示例#1
0
 static function publishPost($postid)
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . './inc/sitemap.php';
     $schema = BaidusubmitSitemap::genSchemaByPostId($postid, $xpost);
     if ('publish' != $xpost->post_status || '' != $xpost->post_password) {
         self::deletePost($postid);
         return;
     }
     $xml = $schema->toXml();
     $content = BaidusubmitSitemap::genPostXml($xml);
     //file_put_contents('/home/work/baidusubmit.log',  date('[Y-m-d H:i:s]')."\n".$content, FILE_APPEND);
     $r = BaidusubmitSitemap::sendXml($content, 1);
     //file_put_contents('/home/work/baidusubmit.log', date('[Y-m-d H:i:s]')."\n".$r, FILE_APPEND);
 }
示例#2
0
文件: sitemap.php 项目: yszar/linuxwp
 $endTime = $sitemap->end;
 define('_BAIDU_MAX_POST_COUNT_', 5000);
 $pidlist = BaidusubmitSitemap::getPostIdByTimeRange($startTime, $endTime, _BAIDU_MAX_POST_COUNT_);
 $indexsplitsitemap = false;
 $postCount = count($pidlist);
 if ($postCount >= _BAIDU_MAX_POST_COUNT_) {
     $indexsplitsitemap = true;
 }
 $itemCount = 0;
 $fileSize = 0;
 $index = 0;
 header('Content-Type: text/xml; charset=utf-8');
 echo '<?xml version="1.0" encoding="UTF-8"?><urlset>';
 $sizesplitsitemap = false;
 foreach ($pidlist as $pid) {
     $schema = BaidusubmitSitemap::genSchemaByPostId($pid, $post);
     $output = $schema->toXml() . "\n";
     $fileSizeCheck = $fileSize + strlen($output);
     $itemCount += 1;
     if ($fileSizeCheck >= 1024 * 1024 * 8) {
         $sizesplitsitemap = true;
         break;
     }
     $fileSize = $fileSizeCheck;
     echo $output;
     flush();
 }
 echo '</urlset>';
 //分裂数据
 if ($sizesplitsitemap || $indexsplitsitemap && $thread['lastpost'] < $endTime) {
     //超过sitemap文件限制进行分裂