ocpaul20 Posted January 18, 2008 Share Posted January 18, 2008 I want to modify the header string my browser sends, (or my php program run from my local PC ) so that I can detect that it is me visiting my website. My IP gets changed everytime I logon to my ISP so I cannot check the IP address to detect if it is me. Can anyone give me a hint or pointers how I can do this please? I can write the php to look at the USER AGENT string that arrives at the website, but I have no idea about the modifying the headers part. Thanks for any help. Paul Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/ Share on other sites More sharing options...
KrisNz Posted January 18, 2008 Share Posted January 18, 2008 Theres a modify headers add-on for firefox, I haven't tried it. https://addons.mozilla.org/en-US/firefox/addon/967 Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442393 Share on other sites More sharing options...
ocpaul20 Posted January 18, 2008 Author Share Posted January 18, 2008 ok, I'll have a look thanks. However, it must be possible to do this using PHP because the search robot programs have a particular signature - thats how you know it is Googlebot visiting your website etc 'cos it says so in the log file. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442403 Share on other sites More sharing options...
trq Posted January 18, 2008 Share Posted January 18, 2008 You can modify the headers sent by php by using the header function. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442421 Share on other sites More sharing options...
ocpaul20 Posted January 18, 2008 Author Share Posted January 18, 2008 I was hoping for a snippit of code to show me how to alter a header string - I have found the header function in the manual before, is not very forthcoming on this kind of example. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442470 Share on other sites More sharing options...
trq Posted January 18, 2008 Share Posted January 18, 2008 It has nothing at all to do with your original question either. Maybe you need to explain better exactly what it is your trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442510 Share on other sites More sharing options...
ocpaul20 Posted January 18, 2008 Author Share Posted January 18, 2008 it does have everything to do with what I originally asked - or maybe I am assuming wrongly that I should use the header function to change the value of a header string? What I am trying to do is to write a PHP program which will run on my website ONLY if the request comes from me - my php program running on my PC. So, for example, maybe I want to run a utility program, and I dont want others to be able to run it. I realise I can do this in a different way, but I have other ideas for this as well if I can get it going. I have tried to alter the user-agent string (because technically a php program running on my PC is NOT firefox browser) and I have written 2 mickey mouse programs as follows: prog1 header("User-Agent: aaaaaaa"); header("Content-type: text/html"); header('Location: prog2.php'); exit; prog2 echo getallheaders(); exit; and I would expect to see a user-agent of 'aaaaa' rather than 'Mozilla/5.0 ' but this still does not show 'aaaaa'. What I am looking for is a string I can test for in prog2, that I can know the request came from me. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442519 Share on other sites More sharing options...
trq Posted January 18, 2008 Share Posted January 18, 2008 If you want a php program to act as a browser you will need to use either curl (easiest) or sockets. Both have a meens for sending headers. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442524 Share on other sites More sharing options...
ocpaul20 Posted January 18, 2008 Author Share Posted January 18, 2008 Ok, thanks, I'll have a look at that. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442548 Share on other sites More sharing options...
ocpaul20 Posted January 18, 2008 Author Share Posted January 18, 2008 Curl was what I needed - thanks. Quote Link to comment https://forums.phpfreaks.com/topic/86585-solved-modify-header-string-your-browser-sends/#findComment-442567 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.