老虎美食博客

和老虎一起美食一下吧!

« 凉拌黄瓜的做法银耳莲子红枣羹的做法 »

Sitemap plugin for PHPDug

This is my first PHP page. It is a plugin of PHPDug which can generate google sitemap. I hope it is useful for you.

You can download from here sitemap.php.zip directly or visit my blog http://www.linglihu.com/post/SitemapPluginForPHPDug.html.

这是我的第一个PHP的"程序" , PHPDug的Sitemap插件,希望对你有用. 你可以从这里下载sitemap.php.zip.

<?php
//Code by zitiger at http://www.linglihu.com
require_once('includes/config.php');
require_once('includes/functions/func.global.php');
db_connect(
$config);

header"Content-type: application/xml; charset=\"utf-8\"", true );
header'Pragma: no-cache' );
        
generate_header();

$query = "SELECT story_id,story_time FROM ".$config['db']['pre']."stories";
$query_result = @mysql_query ($query) OR error(mysql_error(), __LINE__, __FILE__, 0, '', '');

while ($info = @mysql_fetch_array($query_result))
{
    
$result="\n";
    
$result .= "\t<url>\n\t\t<loc>".$config['site_url'].'story.php?id='.$info['story_id']."</loc>\n";

    
// lastmod  
    $result .= "\t\t<lastmod>".$info['story_time']."</lastmod>\n";

    
// changefreq  
    $result .= "\t\t<changefreq>weekly</changefreq>\n";

    
// priority
    $result .= "\t\t<priority>0.8</priority>\n";

    
$result .= "\t</url>";
    
print $result;
}

generate_footer();

function generate_header()
{
    
$header = "<\x3Fxml version=\"1.0\" encoding=\"utf-8\"\x3F>\n<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">";
    print $header;
}

function generate_footer()
{
 
$footer = "\n</urlset>";
 
print $footer;
}
?>

  • quote 1.Aaron
  • http://www.aoddesign.com/
  • Great plugin, works well too, but Google Webmaster Tools shows an 'invalid date' error about this line: &quot;&lt;lastmod&gt;1215368939&lt;/lastmod&gt;&quot;. The date output is a 10 digit number, and should be like &quot;&lt;lastmod&gt;2005-01-01&lt;/lastmod&gt;&quot;.
  • 2008-7-28 19:24:35 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80605 Code detection by Codefense

Copyright 2007 老虎美食博客. Some Rights Reserved.