Modificering af simpelt PHP script
Dette script (http://www.psi-tech.com.au/psi_sewatcher.html) skriver i en logfil hver gang der er søgemaskine spider bot aktivitet.Jeg vil gerne have lavet følgende:
1. Ændring af eksisterende script så det også sender en email når GoogleBot indexerer http://www.minside.dk/index.php (bemærk at den f.eks. også kan hedde http://www.minside.dk/index.php?c=2 etc..)
2. Lavet et nyt script som logger ALT (dvs. også alle de alm brugere)
3. De to ovenstående scrips skal desuden generere noget mere output nemlig ip nummer (vigtigt) samt unix timestamp.
BOTS.php:
<?php
/**
* Search Engine Bot detector version 1.0
*
* Copyright (C) 2006 http://www.psi-tech.com.au/
*
*
*
* A PHP script to provide info on which and when spiders crawled your
* website.
*/
/**create a log file named spiders.log when you upload give it wright permissions buy CHMOD
* place your email with your own email address between the red commas(optional)
*/
$email = "";
/**
* Location of the log file (optional)
*/
$log = "./spiders.log";
/**
* Date/Time format
*/
$dateTime = date("r");
// DO NOT MODIFY BELOW THIS //////////////////////////////////////////
$agents[] = 'scooter';
$spiders[] = "Scooter (Altavista's robot www.altavista.com)";
$agents[] = 'googlebot';
$spiders[] = 'Google';
$agents[] = 'slurp';
$spiders[] = "Slurp (Inktomi's robot, HotBot)";
$agents[] = 'webmoose';
$spiders[] = "Webmoose (MSN.com's robot, www.msn.com)";
$agents[] = 'gulliver';
$spiders[] = "Gulliver (Northern Light's robot, www.northernlight.com)";
$agents[] = 'lycos';
$spiders[] = 'Lycos www.lycos.com';
$agents[] = 'wombat';
$spiders[] = "WebWombat's robot, www.webwombat.com.au";
$agents[] = 'infoseek';
$spiders[] = 'Infoseek www.infoseek.com';
$agents[] = 'askjeeves';
$spiders[] = 'Askjeeves www.askjeeves.com';
$agents[] = 'freecrawl';
$spiders[] = "Free Crawl (Euroseek's robot, www.euroseek.com)";
$agents[] = 'robozilla';
$spiders[] = "Robozilla (DMOZ's Directory link checker robot, www.dmoz.com)";
$agents[] = 'zyborg';
$spiders[] = "ZyBorg (WiseNut's robot, www.wisenutbot.com)";
$agents[] = 'Gigabot';
$spiders[] = 'Gigabot, www.gigablast.com';
$agents[] = 'Ask Jeeves/Teoma';
$spiders[] = 'Ask Jeeves/Teoma, www.teoma.com, www.askjeeves.com';
$agents[] = 'grub-client';
$spiders[] = 'Grub (Looksmart Grub client robot, www.grub.org)';
$agents[] = 'linkwalker';
$spiders[] = 'Linkwalker (SevenTwentyFour link checker robot, www.seventwentyfour.com)';
$agents[] = 'ia_archiver';
$spiders[] = "Internet Archive (Alexa & WayBackMachine's robot, www.archive.org, www.alexa.com)";
$agents[] = 'TurnitinBot';
$spiders[] = 'TurnitinBot (Anti-Plagiarism robot, www.turnitin.com)';
$agents[] = 'atSpider';
$spiders[] = 'atSpider (Email Collector/Spam)';
$agents[] = 'autoemailspider';
$spiders[] = 'autoemailspider (Email Collector/Spam)';
$agents[] = 'cherrypicker';
$spiders[] = 'cherrypicker (Email Collector/Spam)';
$agents[] = 'DSurf';
$spiders[] = 'DSurf (Email Collector/Spam)';
$agents[] = 'DTS Agent';
$spiders[] = 'DTS Agent (Email Collector/Spam)';
$agents[] = 'EliteSys Entry';
$spiders[] = 'EliteSys Entry (Email Collector/Spam)';
$agents[] = 'EmailCollector';
$spiders[] = 'EmailCollector (Email Collector/Spam)';
$agents[] = 'EmailSiphon';
$spiders[] = 'EmailSiphon (Email Collector/Spam)';
$agents[] = 'EmailWolf';
$spiders[] = 'EmailWolf (Email Collector/Spam)';
$agents[] = 'Mail Sweeper';
$spiders[] = 'Mail Sweeper (Email Collector/Spam)';
$agents[] = 'msnbot';
$spiders[] = 'MSN Robot (MSN Search, search.msn.com)';
$agents[] = 'whatuseek';
$spiders[] = 'What You Seek';
$agents[] = 'yahoo\! slurp';
$spiders[] = 'Yahoo! Slurp';
$found = false;
for ($spi = 0; $spi < count($spiders); $spi++)
if ($found = eregi($agents[$spi], $_SERVER['HTTP_USER_AGENT']))
break;
if ($found) {
$url = "http://" . $_SERVER['SERVER_NAME']. $_SERVER['PHP_SELF'];
if ($_SERVER['QUERY_STRING'] != "") {
$url .= '?' . $_SERVER['QUERY_STRING'];
}
$line = $dateTime . " " . $spiders[$spi]. " @ " . $url;
if ($log != "") {
if (@file_exists($log)) {
$mode = "a";
} else {
$mode = "w";
}
if ($f = @fopen($log, $mode)) {
@fwrite($f, $line . "\n");
@fclose($f);
}
}
if ($email != "") {
$headers = "From: <$email>\n";
$headers .= "X-Sender: <$email>\n";
$headers .= "X-Mailer: Search Engine Bot detector\n";
$headers .= "X-Priority: 3\n";
$subject = $spiders[$spi]. " crawled your site";
@mail($email, stripslashes($subject), wordwrap(stripslashes($line)), $headers);
}
}
?>
README.txt
psi sewatcher(c) Search Engine Bot detector - Readme
===================================
PHP script to log search engine's spider visits to your homepage.
Version 1.0
-----------
Copyright (C) 2006 http://www.psi-tech.com.au/
REQUIREMENTS:
Any website with PHP4 or later
SUMMARY:
psi sewatcher(c) is an easy way of finding out when and where
search engine spiders are crawling your site.
Currently it supports:
- 30+ bots
- log file reports
- email reports
INSTALLATION:
Edit the "bots.php" file and replace:
$email = "";
with your email address (in case you do not want email reports leave this
field empty ""),
$log = "./spiders.log";
with the name of the log file where all visits are saved (in case you do
not want to log reports leave this field empty ""). Make sure you set write
permissions on this file! On Linux it can be done using CHMOD command, e.g.
"chmod 777 spiders.log"
Include the "bots.php" to each and every PHP file of your website you want
to monitor like this:
<?php
include('bots.php');
?>
