Jump to content

Load file only under specific IP


HaCos

Recommended Posts

We are looking for a way to load a js file only when specific IP addresses are visiting our site.
We already tried by adding in the footer the following code:

{if ($_SERVER['REMOTE_ADDR'] != 'ip_address') }
    {include file='_partials/jsfileneedtobeload.tpl'}
{/if}

Due to caching of the whole page the above doesnt seem to be working correctly. 
Since its not possible to check current ip on js without using a 3rd party, I think i will need to pass the  $_SERVER['REMOTE_ADDR'] into the js file. Any ideas more than welcome :)

Link to comment
Share on other sites

  • 3 weeks later...
On 12/30/2022 at 6:17 PM, ventura said:

js in smarty something like that

https://notepad.pw/code/y6olBaYpuaB7YbWYHjQp

 

 

 

I worked around with this and it seems to work fine but unfortunatly the file is getting cached and so it's saved the first visit and doesn't check the user ip on every call. Do you have any idea how I may bypass this?

On 12/30/2022 at 5:48 PM, Nickz said:

You are aware that IP ranges are not fixed and therefore change over time?

Of course but there are also static ones.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...