- 積分
- 287
- 威望
- 287
- 金錢
- 17
|
6#
發表於 2010-3-22 21:04
| 只看該作者
是喔,沒用
我本身的2.6.2就沒這個問題,因為就是在根目錄。
來下載我的sitemaps.php看看。- class sitemap
- {
- var $head = "<\x3Fxml version=\"1.0\" encoding=\"UTF-8\"\x3F>\n<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">\n";
- var $footer = "</urlset>\n";
- var $item;
- function item($item)
- {
- $this->item .= "<url>\n";
- foreach($item as $key => $val){
- $this->item .=" <$key>".htmlentities($val, ENT_QUOTES)."</$key>\n";
- }
- $this->item .= "</url>\n";
- }
- function generate()
- {
- $all = $this->head;
- $all .= $this->item;
- $all .= $this->footer;
- return $all;
- }
- }
- define('IN_ECS', true);
- define('INIT_NO_USERS', true);
- define('INIT_NO_SMARTY', true);
- require(dirname(__FILE__) . '/includes/init.php');
- if (file_exists(ROOT_PATH . DATA_DIR . '/sitemap.dat') && time() - filemtime(ROOT_PATH . DATA_DIR . '/sitemap.dat') < 86400)
- {
- $out = file_get_contents(ROOT_PATH . DATA_DIR . '/sitemap.dat');
- }
- else
- {
- $site_url = rtrim($ecs->url(),'/');
- $sitemap = new sitemap;
- $config = unserialize($_CFG['sitemap']);
- $item = array(
- 'loc' => "$site_url/",
- 'lastmod' => local_date('Y-m-d'),
- 'changefreq' => $config['homepage_changefreq'],
- 'priority' => $config['homepage_priority'],
- );
- $sitemap->item($item);
- /* 商品分类 */
- $sql = "SELECT cat_id FROM " .$ecs->table('category'). " ORDER BY parent_id";
- $res = $db->query($sql);
- while ($row = $db->fetchRow($res))
- {
- $item = array(
- 'loc' => "$site_url" . build_uri('category', array('cid' => $row['cat_id'])),
- 'lastmod' => local_date('Y-m-d'),
- 'changefreq' => $config['category_changefreq'],
- 'priority' => $config['category_priority'],
- );
- $sitemap->item($item);
- }
- /* 文章分类 */
- $sql = "SELECT cat_id FROM " .$ecs->table('article_cat'). " WHERE cat_type=1";
- $res = $db->query($sql);
- while ($row = $db->fetchRow($res))
- {
- $item = array(
- 'loc' => "$site_url/" . build_uri('article_cat', array('acid' => $row['cat_id'])),
- 'lastmod' => local_date('Y-m-d'),
- 'changefreq' => $config['category_changefreq'],
- 'priority' => $config['category_priority'],
- );
- $sitemap->item($item);
- }
- /* 商品 */
- $sql = "SELECT goods_id, last_update FROM " .$ecs->table('goods'). " WHERE is_delete = 0 LIMIT 300";
- $res = $db->query($sql);
- while ($row = $db->fetchRow($res))
- {
- $item = array(
- 'loc' => "$site_url/" . build_uri('goods', array('gid' => $row['goods_id'])),
- 'lastmod' => local_date('Y-m-d', $row['last_update']),
- 'changefreq' => $config['content_changefreq'],
- 'priority' => $config['content_priority'],
- );
- $sitemap->item($item);
- }
- /* 文章 */
- $sql = "SELECT article_id, add_time FROM " .$ecs->table('article'). " WHERE is_open=1";
- $res = $db->query($sql);
- while ($row = $db->fetchRow($res))
- {
- $item = array(
- 'loc' => "$site_url/" . build_uri('article', array('aid' => $row['article_id'])),
- 'lastmod' => local_date('Y-m-d', $row['add_time']),
- 'changefreq' => $config['content_changefreq'],
- 'priority' => $config['content_priority'],
- );
- $sitemap->item($item);
- }
- $out = $sitemap->generate();
- file_put_contents(ROOT_PATH . DATA_DIR . '/sitemap.dat', $out);
- }
- if (function_exists('gzencode'))
- {
- header('Content-type: application/x-gzip');
- $out = gzencode($out, 9);
- }
- else
- {
- header('Content-type: application/xml; charset=utf-8');
- }
- die($out);
- ?>
複製代碼 |
提醒您:
您在" ECSHOP 交流討論區"交流請遵守台灣法律規範," sinps83056"
發表的文章 《》版權歸屬作者所有,如是轉貼版權歸屬原作者所有.本論壇不對其真實性做任何考證.
|