JohnnyDoomo Posted August 25, 2014 Share Posted August 25, 2014 I'm looking to get php to write to file when someone visits one of my sites without javascript. From the research I've done, it seems that an css hidden, iframe within the noscript tag would work, and the php file would then write to a log. I just want a simple tick log that increments by 1, but perhaps also lists the user-agent. My one concern is that I want to include this same code on multiple sites, all of which could be trying to access, and write a tick to the same "no JS log". Is that going to cause problems the way php writes to files? Can someone help me create the code that will write to this log file, that won't cause errors or problems when multiple sites/visitors could be making writes to the log? I'm a php noob, so while I can research how to get php to write to a file and save, most of the tutorials don't mention if it would be a safe method to use, if multiple domains were trying to write to that same file, at the same time, and trying to add their own "tick" to increment the number within the flat file. Extended help that I'm looking for is getting ticks per user-agent/search bot, so bots/web users that visit my pages, that don't run JS, could have ticks by them. eg: Google Bot: 3 Mozilla Firefox 31.0: 15 Any help on this would be appreciated, or any flaws that you see in this type of tracking, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/290650-php-file-to-execute-within-noscript/ Share on other sites More sharing options...
CroNiX Posted August 25, 2014 Share Posted August 25, 2014 (edited) Never tried to do that...but I'd say using a database would be MUCH better for this sort of task, especially if the domains are on different physical servers. I'd also do what google does and use a 1px hidden image, which would request the image from a certain domain. <noscript> <img height="1" width="1" style="border-style:none;" src="http://theSiteThatIsCollectingInfo.com/app.php" alt=""> </noscript> and on that server app.php would just be a simple php script that gets the data from $_SERVER (user agent), stores it in the db if it isn't there, and if it is there increment the total for that UA by 1 Edited August 25, 2014 by CroNiX Quote Link to comment https://forums.phpfreaks.com/topic/290650-php-file-to-execute-within-noscript/#findComment-1488928 Share on other sites More sharing options...
Jacques1 Posted August 25, 2014 Share Posted August 25, 2014 What's the purpose of this log? I mean, what's the information you're trying to get out of it? You won't find a lot of users who have turned off JavaScript altogether, because large parts of the WWW simply require JavaScript. What's much more common is to specifically choose the domains that are allowed to provide JavaScript code (using a browser plug-in like NoScript, for example). So while JavaScript is generally turned on, some scripts on your site may still be blocked. How do you deal with that? For example, if I were to visit your site, all scripts would be disabled by default. However, I might then whitelist your main domain so that I can use the site properly. Does this count as “no JavaScript” or not? Also note that NoScript can block iframes as well. Quote Link to comment https://forums.phpfreaks.com/topic/290650-php-file-to-execute-within-noscript/#findComment-1488930 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.