Little Goat Posted May 2, 2006 Share Posted May 2, 2006 I was trying to find a heavy duty counter that not only counts, but also records the refferer, the IP address, and the date or something.I found a few on another site, but I was wondering, how hard would it be to make my own? (so there are no copyright issues, personalized, you know...)could someone point me in the right direction? (notice, I am not asking for a ready made script. )thnx, LG Link to comment Share on other sites More sharing options...
justsomeguy Posted May 2, 2006 Share Posted May 2, 2006 You need to use the $_SERVER array. Figure out where you want to save them, in a file or database or whatever, and use the information in that array. If you want to see everything in the array, use this statement:print_r($_SERVER);http://www.php.net/manual/en/reserved.vari...ariables.server'PHP_SELF' - file name'HTTP_REFERER' - page that linked to this page'HTTP_USER_AGENT' - browser string'REMOTE_ADDR' - user's IP'REMOTE_HOST' - user's host, based on reverse DNS Link to comment Share on other sites More sharing options...
Little Goat Posted May 2, 2006 Author Share Posted May 2, 2006 thanks, justsomeguy.I figured a few things out on my own, (it's funny how sometimes we ask questions and then we find out we could have done it ourselves ) but you gave me a few things I hadn't found yet. thanx again.LG Link to comment Share on other sites More sharing options...
Little Goat Posted May 8, 2006 Author Share Posted May 8, 2006 one more question:How do you tell if the visitor is an SE bot?LG Link to comment Share on other sites More sharing options...
justsomeguy Posted May 9, 2006 Share Posted May 9, 2006 Ah ha! That's the question. I have a web site set up to display SE-friendly keywords and terms if I can detect Googlebot or Yahoo or MSN or whatever, and leave that information off for normal users. Google hasn't delisted the site yet, so it seems to be working. Here's the code that I use (excuse the VBScript): if InStr(1, uagent, "google", VBTextCompare) = 0 and InStr(1, uagent, "bot", VBTextCompare) = 0 and InStr(1, uagent, "yahoo", VBTextCompare) = 0 and ((InStr(1, uagent, "mozilla", VBTextCompare) > 0 or InStr(1, uagent, "msie", VBTextCompare) > 0 or InStr(1, uagent, "opera", VBTextCompare) > 0) and ((InStr(1, uagent, "win", VBTextCompare) > 0 or InStr(1, uagent, "linux", VBTextCompare) > 0 or InStr(1, uagent, "mac", VBTextCompare) > 0 or InStr(1, uagent, "sunos", VBTextCompare) > 0 or InStr(1, uagent, "hp-ux", VBTextCompare) > 0 or InStr(1, uagent, "irix", VBTextCompare) > 0 or InStr(1, uagent, "beos", VBTextCompare) > 0) or (InStr(1, uagent, "gecko", VBTextCompare) > 0 or InStr(1, uagent, "firefox", VBTextCompare) > 0))) then  show_footer = falseend if So let's see.. I check if the user agent string:  -does not contain 'google'  and  -does not contain 'bot'  and  -does not contain 'yahoo'  and   -contains 'mozilla'   or   -contains 'msie'   or   -contains 'opera'   and    -contains 'win'    or    -contains 'linux'    or    -contains 'mac'    or    -contains 'sunos'    or    -contains 'hp-ux'    or    -contains 'irix'    or    -contains 'beos'    or    -contains 'gecko'    or    -contains 'firefox' If that is true, then it does not show the footer (it assumes human user), or else the default action is to show the footer for the search engines. Link to comment Share on other sites More sharing options...
Little Goat Posted May 9, 2006 Author Share Posted May 9, 2006 thnx so much justsomeguy but how would I do that in PHP?LG Link to comment Share on other sites More sharing options...
justsomeguy Posted May 9, 2006 Share Posted May 9, 2006 Well, here's the function to use:http://us2.php.net/manual/en/function.strstr.phpSo I guess it would be something like this: $uagent = strtolower($_SERVER['HTTP_USER_AGENT']);if (strstr($uagent, 'google') === false &&    strstr($uagent, 'bot') === false &&    strstr($uagent, 'yahoo') === false &&    (strstr($uagent, 'mozilla') !== false ||     strstr($uagent, 'msie') !== false ||     strstr($uagent, 'opera') !== false ||     strstr($uagent, 'gecko') !== false ||     strstr($uagent, 'firefox') !== false) &&    (strstr($uagent, 'win') !== false ||     strstr($uagent, 'linux') !== false ||     strstr($uagent, 'mac') !== false ||    strstr($uagent, 'sunos') !== false ||     strstr($uagent, 'hp-ux') !== false ||     strstr($uagent, 'irix') !== false ||     strstr($uagent, 'beos') !== false))   $human = true;else   $human = false; Not exactly the prettiest thing, but it should generally work.. Link to comment Share on other sites More sharing options...
Little Goat Posted May 9, 2006 Author Share Posted May 9, 2006 ok, thanks soo much!actually, I'm trying to build this for SEO.I found an article on another forum, and it said to get a tracker.LG Link to comment Share on other sites More sharing options...
calvin182 Posted May 9, 2006 Share Posted May 9, 2006 what good would knowing if the visitor is a bot do? Link to comment Share on other sites More sharing options...
Little Goat Posted May 9, 2006 Author Share Posted May 9, 2006 I just want to know if the search engines spiders are going through my site.LG Link to comment Share on other sites More sharing options...
calvin182 Posted May 9, 2006 Share Posted May 9, 2006 oh I thought maybe for like forcing more content like keywords or links to boost pagerank or something Link to comment Share on other sites More sharing options...
justsomeguy Posted May 9, 2006 Share Posted May 9, 2006 That's what I use it for, but I generally do the opposite, I try to determine if the user is a human instead of a bot. If I can determine that the user is a human, I hide the marketing stuff, or else I show it. If I can't tell what the user is, I assume it's a bot. Link to comment Share on other sites More sharing options...
calvin182 Posted May 11, 2006 Share Posted May 11, 2006 So when u determine its a bot, what do you have added to the page exactly and does it actually help your page rank? I'd be interested in giving this a try but I don't know what to insert into my page if it were a bot, a table of links at the bottom of every page or would that be a dumb thing to do because of caching? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 11, 2006 Share Posted May 11, 2006 Mostly just text, with various keywords. Not just strings of keywords, but sentences that use the keywords we are trying to rank on. Also, to be clear, I try to determine if it's a human, instead of a bot. I assume it's a bot unless I can determine it's a human, so that if I'm not sure I be safe and send the search text. 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