jwk811 Posted February 16, 2007 Share Posted February 16, 2007 how can you find the refferrer of my site or if it was a direct hit? Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/ Share on other sites More sharing options...
hitman6003 Posted February 16, 2007 Share Posted February 16, 2007 echo $_SERVER['HTTP_REFERER']; Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186012 Share on other sites More sharing options...
Guest Posted February 16, 2007 Share Posted February 16, 2007 Like hitman suggested. But I wouldn't rely on it for anything mission or security-critical, it can be modified. Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186013 Share on other sites More sharing options...
jwk811 Posted February 16, 2007 Author Share Posted February 16, 2007 what about finding the keywords from a search engine? Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186016 Share on other sites More sharing options...
Guest Posted February 16, 2007 Share Posted February 16, 2007 Er. Well. There's no magical variable to give you the keywords. But lets say they were brought to your site from google. Then the referrer url ($_SERVER['HTTP_REFERER']) may look like this: http://www.google.ca/search?q=keyword+keyword&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a Now if you can write some PHP to cut the query string down just to show this q=keyword+keyword Then there you go. The keywords. EDIT: However, this is only assuming that they DID come straight from the search engine. And other search engine's querystrings may be different! Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186019 Share on other sites More sharing options...
jwk811 Posted February 16, 2007 Author Share Posted February 16, 2007 also would any of you know how to get the host name, country, langauge, state, city? my old chat software had this but now its only available for those who upgrade.. and id rather build my own not use any analytics Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186021 Share on other sites More sharing options...
jwk811 Posted February 16, 2007 Author Share Posted February 16, 2007 i see.. how could i take the q variable's contents though? so i can make it separated from the whole address? Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186022 Share on other sites More sharing options...
Guest Posted February 16, 2007 Share Posted February 16, 2007 i see.. how could i take the q variable's contents though? so i can make it separated from the whole address? Hmm, lets see... <?php $url = "http://www.google.ca/search?q=keyword+keyword&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a"; // I basically tell $new_url to equal $url from the first = sign to the first &. Usually // the keywords are the first variables in the query string $new_url = substr( $url, strpos($url, '=')+1, (strpos($url, '&') - strpos($url, 'q=')-2) ); // now: keyword+keyword $keywords_array = explode('+', $new_url); // now: $keywords_array[0] and $keywords_array[1] = 'keyword' ?> Now the two keywords are in $keywords_array. However, I'm not sure if I did this the best way. Give me a minute or two to check it out. But it works, at least for google. EDIT: Changed the code a bit. Ok, there, that should work. But only assuming for google. For yahoo it's ...p=keyword+keyword... Actually. To be compatible with more browsers, maybe: <?php $url = "http://www.google.ca/search?q=keyword+keyword&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a"; $new_url = substr( $url, strpos($url, '=')+1, (strpos($url, '&')-strpos($url, 'q=')-2) ); $keywords_array = explode('+', $new_url); ?> Hmm, that may work for more search engines. Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186024 Share on other sites More sharing options...
Guest Posted February 16, 2007 Share Posted February 16, 2007 Sorry, ended up copying and pasting my second example into the first, couldn't modify after (modify time limit expired). They are both the same. Just one with notes, one without. also would any of you know how to get the host name, country, langauge, state, city? my old chat software had this but now its only available for those who upgrade.. and id rather build my own not use any analytics There's a way, forgot what it was called off the top of my head. Geoprogramming? Something similar, but basically you use the person's IP to locate them (at least down to country or state), not sure about city. But, can't help you there, i haven't a clue how they do it without straight-off just asking the user "where are you?" lol. Doing it automatically has its drawbacks, the IP could be faked. But then again, if you ask them where they are, that's no better. lol. But to pull it off you have to perform some math formula on the IP and it gets you a country code or something. Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186028 Share on other sites More sharing options...
jwk811 Posted February 16, 2007 Author Share Posted February 16, 2007 awesome, thank you very much for your help.. ill play around with that a little in the mornin.. Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186029 Share on other sites More sharing options...
jwk811 Posted February 16, 2007 Author Share Posted February 16, 2007 yup its geolocation http://www.formyip.com/ipcountry.php - that site does it.. just doesnt show you how.. Quote Link to comment https://forums.phpfreaks.com/topic/38719-find-refferer/#findComment-186632 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.