-
Notifications
You must be signed in to change notification settings - Fork 176
Description
This update provide sitemap sort property and send sitemap to Google and Bing crawlers
Demo : http://www.aklisahane.com/sitemap.xml
Just Change your library file in this file in attachment : sitemap_lib.php.txt and rename to sitemap_lib.php.
sitemap_lib.php.txt
Usage :
`<?php
require_once("www_includes/func/sql.php"); // call database connection file
require_once("www_includes/func/func_inc.php"); // call your functions file
require_once 'sitemap_lib.php'; // call sitemap_lib.php file
$handle = fopen("../sitemap.xml", "w"); fclose($handle); // delete current sitemap file
$sitemap = new Sitemap('http://www.yoursite.com');
$sitemap->setPath('../');
$sitemap->setFilename('sitemap');
$query = mysqli_query($bag, 'Select * from blog_posts order by post_id desc ');
while ($post = mysql_fetch_array($query)) {
$sitemap->addItem('/blog/'.$post['id'].'-'.sefyap($post['adi']).'/' , '0.4', 'daily', $post["tarih"]);
}
$sitemap->setDomain('http://aklisahane.com/');
$sitemap->createSitemapIndex('http://www.yoursite.com/', 'Today');
$sitemaps = array("http://yourwebsite.com/sitemap.xml");
//This codes for sent sitemap file to Google And Bing Crawler Services
function Submit($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $httpCode;
}
function SubmitSiteMap($url) {
$returnCode = Submit($url);
if ($returnCode != 200) {
echo "Error $returnCode: $url
";
} else {
echo "Submitted $returnCode: $url
";
}
}
foreach ($sitemaps as $sitemapUrl) {
$sitemapUrl = htmlentities($sitemapUrl);
//Google
$url = "http://www.google.com/webmasters/sitemaps/ping?sitemap=".$sitemapUrl;
SubmitSiteMap($url);
//Bing / MSN
$url = "http://www.bing.com/webmaster/ping.aspx?siteMap=".$sitemapUrl;
SubmitSiteMap($url);
// Live
$url = "http://www.bing.com/webmaster/ping.aspx?siteMap=".$sitemapUrl;
SubmitSiteMap($url);
// moreover
$url = "http://api.moreover.com/ping?sitemap=".$sitemapUrl;
SubmitSiteMap($url);
}
?>`