Source for file example.php
Documentation is available at example.php
* Sitemap Creator Example
* @link http://sitemapcreator.org/
* @package SitemapCreator
* @link https://gadelkareem.com/
require
'../SitemapCreator.class.php';
if (PHP_SAPI ==
"cli") $lb =
"\n";
//Sitemap Creator creates a URL to sitemap files
//echo $sitemap->getSitemapURL(1) . $lb;
//however you should add your formated URL
$sitemap->setSitemapURL('http://www.dmoz.org/Sitemap_Creator/data/' .
$sitemap->getSitemapDirName() .
'/' );
//Sitemap Creator creates a path to sitemaps in system tmp
//echo $sitemap->getSitemapPath(1) . $lb;
//however you should add your writable directory path
//$sitemap->setDataDir('/server/sitemaps/data');
//choose to gzip compress the sitemaps
//this option is useful if you will use NGINX sendfile {@link http://wiki.nginx.org/HttpCoreModule#sendfile}
//$sitemap->useGzip(true);
if( isset
($_GET['sitemap']) ){
$sitemap->readSitemap($_GET['sitemap']);
//choose sitemaps options
$sitemap->setEntriesPerSitemap(10);
$sitemap->setMinFrequency('yearly');
$sitemap->setMinPriority(0.3);
//all set, let start the crawler
//create $sitemap->Crawler
//set the Cralwer options
//for more options check {@link http://phpcrawl.cuab.de/classreferences/index.html}
$sitemap->Crawler->setPageLimit(10); // Set the page-limit to 50 for testing
//if we are not calculating Frequency based on last-modified header then we can disable
$sitemap->Crawler->enableLastModifiedCount(false);
//start the crawling process
// At the end, after the process is finished, we print a short
// report (see method getProcessReport() for more information)
$report =
$sitemap->crawler_reports;
echo
"Links followed: ".
$report->links_followed.
$lb;
echo
"Documents received: ".
$report->files_received.
$lb;
echo
"Bytes received: ".
$report->bytes_received.
" bytes".
$lb;
echo
"Process runtime: ".
$report->process_runtime.
" sec".
$lb;
$sitemap->CreateSitemaps();
echo
"Sitemap Created at {$sitemap->getSitemapPath('index')} {
$lb}";
echo
"Click <a href='{$_SERVER['PHP_SELF']}?sitemap=index' >here</a> to view your sitemap{$lb}";
$results =
$sitemap->Ping();
foreach( $results as $engine =>
$result)
if( isset
($result['body']) )
echo
"{
$engine} pinged successfully{
$lb}";
echo
"Error pinging {$engine} : {$result['error']}{$lb}";
Documentation generated on Sun, 20 Jan 2013 21:18:49 +0200 by phpDocumentor 1.4.4