Example Usage

When did Google visit my website?

The following sample usage will show you how to query all GoogleBot hits on your website and convert them into an RSS feed with this class.

 1 /**
 2  * @see ApacheLogAnalyzer2Feed
 3  */
 4 require_once 'ApacheLogAnalyzer2Feed.php';
 5 
 6 // create a new instance, parse access.log and write test.xml
 7 $tool = new ApacheLogAnalyzer2Feed('access.log', 'test.xml');
 8 // select entries matching Googlebot useragent
 9 $tool->addFilter('User-Agent', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
10 // run
11 $tool->run();

When did an user register into my website?

The following sample usage will show you how to query registration logs and convert them into an RSS feed with this class.

 1 /**
 2  * @see ApacheLogAnalyzer2Feed
 3  */
 4 require_once 'ApacheLogAnalyzer2Feed.php';
 5 
 6 // create a new instance, parse access.log and write test.xml
 7 $tool = new ApacheLogAnalyzer2Feed('access.log');
 8 // select entries with Request matching a regular expression pattern
 9 $tool->addFilter('Request', 'regexp:/site/register\-confirm\.php');
10 // run
11 $tool->run();

When did Google visit my blog profile page?

The following sample usage will show you how to query all GoogleBot hits on your weblog profile page and convert them into an RSS feed with this class.

 1 /**
 2  * @see ApacheLogAnalyzer2Feed
 3  */
 4 require_once 'ApacheLogAnalyzer2Feed.php';
 5 
 6 // create a new instance, parse access.log and write test.xml
 7 $tool = new ApacheLogAnalyzer2Feed('access.log', 'test.xml');
 8 // select entries matching Googlebot useragent with a regular expression pattern
 9 $tool->addFilter('User-Agent', 'regexp:Googlebot');
10 // select entries with Request matching a regular expression pattern
11 $tool->addFilter('Request', 'regexp:/site/profile\.php');
12 // run
13 $tool->run();

When did either Google or Yahoo! visit my website?

The following sample usage will show you how to query all GoogleBot and Yahoo! Slurp hits on your website and convert them into an RSS feed with this class.

 1 /**
 2  * @see ApacheLogAnalyzer2Feed
 3  */
 4 require_once 'ApacheLogAnalyzer2Feed.php';
 5 
 6 // create a new instance, parse access.log and write test.xml
 7 $tool = new ApacheLogAnalyzer2Feed('access.log', 'test.xml');
 8 // select entries matching Googlebot useragent with a regular expression pattern
 9 $tool->addFilter('User-Agent', 'regexp:Googlebot');
10 // select entries matching Yahoo! useragent with a regular expression pattern
11 $tool->addFilter('User-Agent', 'regexp:Slurp');
12 // use OR filter mode
13 $tool->setFilterCallback(ApacheLogAnalyzer2Feed::FILTER_MODE_OR);
14 // run
15 $tool->run();