此代码来自noah,本人只是做了修改!修正了原代码的一点点问题!
这是sitemap的索引页 演示:http://www.dakm.net/sitemap.php
再进去是url页:
http://www.dakm.net/sitemap.php?classid=125
代码中的:$siteurl="http://www.dakm.net";//修改为您的站点名字; 代码保存为sitemap.php,然后到各大搜索引擎递交sitemap.php; gb2312的,需要utf8的自己另存转一下就OK了。
--------------------------------------------------------------------------------
<?php require("e/class/connect.php"); include("e/class/db_sql.php"); include("e/class/config.php"); include("e/data/dbcache/class.php"); $link=db_connect(); $empire=new mysqlquery(); $siteurl="http://www.dakm.net";//修改为您的站点名字; $classid = (int)$_GET['classid']; if(empty($classid)) { echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n"; $sql=$empire->query("SELECT classid FROM {$dbtbpre}enewsclass WHERE islast=1"); while($r=$empire->fetch($sql)) { echo " <sitemap> <loc>$siteurl/sitemap.php?classid=$r[classid]</loc>\r\n"; $csql=$empire->fetch1("SELECT newstime FROM {$dbtbpre}ecms_".$class_r[$r[classid]][tbname]." WHERE classid=$r[classid] ORDER BY newstime DESC LIMIT 1"); echo " <lastmod>".date('Y-m-d',$csql[newstime])."</lastmod> </sitemap>\r\n"; } echo "</sitemapindex>"; } else { echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n <url> <loc>http://www.dakm.net</loc> <priority>1.00</priority> <changefreq>daily</changefreq> </url> <url> <loc>http://life.dakm.net</loc> <priority>0.90</priority> <changefreq>daily</changefreq> </url> <url> <loc>http://news.dakm.net</loc> <priority>0.90</priority> <changefreq>daily</changefreq> </url> <url> <loc>http://info.dakm.net</loc> <priority>0.90</priority> <changefreq>daily</changefreq> </url> <url> <loc>http://hot.dakm.net</loc> <priority>0.90</priority> <changefreq>daily</changefreq> </url> \r\n"; $sql=$empire->query("SELECT * FROM {$dbtbpre}ecms_".$class_r[$classid][tbname]." WHERE classid=$classid AND checked=1"); while($r=$empire->fetch($sql)) { $titleurl=sys_ReturnBqTitleLink($r); echo " <url> <loc>$titleurl</loc> <priority>0.80</priority> <lastmod>".date('Y-m-d',$r[newstime])."</lastmod> </url>\r\n"; } echo "</urlset>"; } db_close(); $empire=null; ?>
以前全部为一样的权重,现在增加区别权重的。修改了一下!!!
有些部份修改为自己喔···!!
上传以下附件: [下载 *.rar](文件大小:0.80 KB,下载次数:211)
|