HaCos Posted December 30, 2022 Share Posted December 30, 2022 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 More sharing options...
Nickz Posted December 30, 2022 Share Posted December 30, 2022 6 minutes ago, HaCos said: We are looking for a way to load a js file only when specific IP addresses are visiting our site. You are aware that IP ranges are not fixed and therefore change over time? Link to comment Share on other sites More sharing options...
ventura Posted December 30, 2022 Share Posted December 30, 2022 js in smarty something like that https://notepad.pw/code/y6olBaYpuaB7YbWYHjQp 1 Link to comment Share on other sites More sharing options...
HaCos Posted January 21, 2023 Author Share Posted January 21, 2023 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now