Examples
weppos edited this page Nov 11, 2010
·
1 revision
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.
/**
* @see ApacheLogAnalyzer2Feed
*/
require_once 'ApacheLogAnalyzer2Feed.php';
// create a new instance, parse access.log and write test.xml
$tool = new ApacheLogAnalyzer2Feed('access.log', 'test.xml');
// select entries matching Googlebot useragent
$tool->addFilter('User-Agent', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
// run
$tool->run();
The following sample usage will show you how to query registration logs and convert them into an RSS feed with this class.
/**
* @see ApacheLogAnalyzer2Feed
*/
require_once 'ApacheLogAnalyzer2Feed.php';
// create a new instance, parse access.log and write test.xml
$tool = new ApacheLogAnalyzer2Feed('access.log');
// select entries with Request matching a regular expression pattern
$tool->addFilter('Request', 'regexp:/site/register\-confirm\.php');
// run
$tool->run();
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.
/**
* @see ApacheLogAnalyzer2Feed
*/
require_once 'ApacheLogAnalyzer2Feed.php';
// create a new instance, parse access.log and write test.xml
$tool = new ApacheLogAnalyzer2Feed('access.log', 'test.xml');
// select entries matching Googlebot useragent with a regular expression pattern
$tool->addFilter('User-Agent', 'regexp:Googlebot');
// select entries with Request matching a regular expression pattern
$tool->addFilter('Request', 'regexp:/site/profile\.php');
// run
$tool->run();
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.
/**
* @see ApacheLogAnalyzer2Feed
*/
require_once 'ApacheLogAnalyzer2Feed.php';
// create a new instance, parse access.log and write test.xml
$tool = new ApacheLogAnalyzer2Feed('access.log', 'test.xml');
// select entries matching Googlebot useragent with a regular expression pattern
$tool->addFilter('User-Agent', 'regexp:Googlebot');
// select entries matching Yahoo! useragent with a regular expression pattern
$tool->addFilter('User-Agent', 'regexp:Slurp');
// use OR filter mode
$tool->setFilterCallback(ApacheLogAnalyzer2Feed::FILTER_MODE_OR);
// run
$tool->run();