Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2005-08-29 16:03:13

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: HowTo: Remove hits from your current IP from the logs

Ok, sorry – I wasn’t even looking at what I actually typed out. Try this:

<pre> $ignore = array( ‘googlebot.com’, ‘inktomisearch.com’, ‘ask.com’ );

if (in_array($ip, $ignore)) return;
</pre>

Offline

#26 2005-08-29 16:09:32

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: HowTo: Remove hits from your current IP from the logs

Thanks, no more notices or warnings. Now I’ll have to wait a while to see if it works. I will let you know!

Offline

#27 2005-08-29 17:12:18

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: HowTo: Remove hits from your current IP from the logs

Unfortunately, after I made the last change, several hits from inktomisearch.com and ask.com were logged…

Last edited by doggiez (2005-08-29 17:14:24)

Offline

#28 2005-08-29 18:34:51

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: HowTo: Remove hits from your current IP from the logs

Oops.

<pre><code>$ignore = array( ‘googlebot.com’, ‘inktomisearch.com’, ‘ask.com’
);

foreach ($ignore as $ip)
{ if (stristr($ip, $out[‘ip’])) { return; }
}</code></pre>

Try again? :)

Offline

#29 2005-08-29 19:09:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: HowTo: Remove hits from your current IP from the logs

Changes made. I’ll let you know later. And thanks!

Offline

#30 2005-08-29 21:17:59

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: HowTo: Remove hits from your current IP from the logs

Mary, you did not secretly write code that attracts those ip’s, did you? After my change I now have three pages with 95% googlebot.com…

Offline

#31 2005-08-29 21:22:55

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: HowTo: Remove hits from your current IP from the logs

Where are you putting it? I think this file (log.php) has changed since Sencer posted this so that may make a difference.

Offline

#32 2005-08-29 21:26:11

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: HowTo: Remove hits from your current IP from the logs

mary, $ip is always the same value as $out['ip'], so your example will now only record a hit if it is on the list, rather than the opposite. The code I posted above works… did you try it out?

Offline

#33 2005-08-29 21:29:58

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: HowTo: Remove hits from your current IP from the logs

Not in the reposted code.

What you posted is just what Sencer posted, and then it has to be that exact string.

Last edited by Mary (2005-08-29 21:33:42)

Offline

#34 2005-08-29 21:31:16

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: HowTo: Remove hits from your current IP from the logs

I’ve put it where Andrew originally said to put it.
This is the function as it is now:

<pre>
// ——————————————————————————————- function logit($r=’‘) { global $siteurl, $prefs; $mydomain = str_replace(‘www.’,’‘,preg_quote($siteurl,”/”)); $out[‘uri’] = $_SERVER[‘REQUEST_URI’]; $out[‘ref’] = clean_url(str_replace(“http://”,”“,serverset(‘HTTP_REFERER’))); $host = $ip = $_SERVER[‘REMOTE_ADDR’];

if (!empty($prefs[‘use_dns’])) { // A crude rDNS cache if ($h = safe_field(‘host’, ‘txp_log’, “ip=’”.doSlash($ip).”’ limit 1”)) { $host = $h; } else { // Double-check the rDNS $host = gethostbyaddr($_SERVER['REMOTE_ADDR']); if ($host != $ip and gethostbyname($host) != $ip) $host = $ip; } } $out[‘ip’] = $ip; $out[‘host’] = $host; $out[‘status’] = 200; // FIXME $out[‘method’] = $_SERVER[‘REQUEST_METHOD’]; if (preg_match(“/^[^\.]*\.?$mydomain/i”, $out[‘ref’])) $out[‘ref’] = “”;

$ignore = array( ‘googlebot.com’, ‘inktomisearch.com’, ‘ask.com’ );

foreach ($ignore as $ip) { if (stristr($ip, $out[‘ip’])) { return; } } if ($r==‘refer’) { if (trim($out[‘ref’]) != “”) { insert_logit($out); } } else insert_logit($out); }

// ——————————————————————————————-</pre>

Offline

#35 2005-08-29 21:38:21

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: HowTo: Remove hits from your current IP from the logs

I’ll just wait until you two agree about it, okay? ;)

Offline

#36 2005-08-29 21:40:13

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: HowTo: Remove hits from your current IP from the logs

Oh wait I see what’s going on here. $ip is getting overwritten. let me regroup. Gah… I’m not getting much correct today.

Offline

Board footer

Powered by FluxBB