function index() { $sitemap = new google_sitemap(); //Create a new Sitemap Object $item = new google_sitemap_item(base_url(), date("Y-m-d"), 'weekly', '0.8'); //Create a new Item $sitemap->add_item($item); //Append the item to the sitemap object $sitemap->build("./sitemap.xml"); //Build it... //Let's compress it to gz $data = implode("", file("./sitemap.xml")); $gzdata = gzencode($data, 9); $fp = fopen("./sitemap.xml.gz", "w"); fwrite($fp, $gzdata); fclose($fp); //Let's Ping google //$this->_pingGoogleSitemaps(base_url()."/sitemap.xml.gz"); }
/*------------------------------------------------------ */ assign_query_info(); $config = unserialize($_CFG['sitemap']); $smarty->assign('config', $config); $smarty->assign('ur_here', $_LANG['sitemap']); $smarty->assign('arr_changefreq', array(1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1)); $smarty->display('sitemap.htm'); } else { /*------------------------------------------------------ */ //-- 生成站点地图 /*------------------------------------------------------ */ include_once 'includes/cls_phpzip.php'; include_once 'includes/cls_google_sitemap.php'; $domain = $ecs->url(); $today = local_date('Y-m-d'); $sm = new google_sitemap(); $smi = new google_sitemap_item($domain, $today, $_POST['homepage_changefreq'], $_POST['homepage_priority']); $sm->add_item($smi); $config = array('homepage_changefreq' => $_POST['homepage_changefreq'], 'homepage_priority' => $_POST['homepage_priority'], 'category_changefreq' => $_POST['category_changefreq'], 'category_priority' => $_POST['category_priority'], 'content_changefreq' => $_POST['content_changefreq'], 'content_priority' => $_POST['content_priority']); $config = serialize($config); $db->query("UPDATE " . $ecs->table('shop_config') . " SET VALUE='{$config}' WHERE code='sitemap'"); /* 商品分类 */ $sql = "SELECT cat_id,cat_name FROM " . $ecs->table('category') . " ORDER BY parent_id"; $res = $db->query($sql); while ($row = $db->fetchRow($res)) { $smi = new google_sitemap_item($domain . build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']), $today, $_POST['category_changefreq'], $_POST['category_priority']); $sm->add_item($smi); } /* 文章分类 */ $sql = "SELECT cat_id,cat_name FROM " . $ecs->table('article_cat') . " WHERE cat_type=1"; $res = $db->query($sql);
//访问权限检查 if (!$objWebInit->checkPopedomG($_SESSION['user_id'], 'seo')) { check::AlertExit('对不起,您没有权限访问此页', -1); } if ($_SERVER["REQUEST_METHOD"] == "POST") { $sm_file = '../../sitemap.xml'; if (is_writable($sm_file)) { @set_time_limit(0); //$domain = $arrGWeb['host']; $domain = $_SERVER['HTTP_HOST']; if ($_POST['today']) { $today = date('c'); } else { $today = ''; } $sm = new google_sitemap(); $smi = new google_sitemap_item($domain, $today, $_POST['homepage_changefreq'], $_POST['homepage_priority']); $sm->add_item($smi); foreach ($arrGMeta as $k => $v) { if (!empty($v['cache']) && $v['cache'] == 1) { switch ($k) { case 'suppliers': //厂商报价 //栏目首页 $smi = new google_sitemap_item($domain . '/' . $k . '/', $today, $_POST['category_changefreq'], $_POST['category_priority']); $sm->add_item($smi); //栏目列表 $strSQL = "SELECT user_id FROM " . $arrGPdoDB['db_tablepre'] . "suppliers where pass=1 GROUP BY user_id ORDER BY submit_date desc"; $rs = $objWebInit->db->prepare($strSQL); $rs->execute(); $arrData = $rs->fetchAll(PDO::FETCH_COLUMN);
<?php require_once 'include/common.inc.php'; require_once 'include/sitemap.class.php'; $site_map_container = new google_sitemap(); $siteurl = $tempinfo->get_template_vars('siteurl'); $productlist = $productdata->GetProductList(0); $articlelist = $articledata->GetArticleList(0); $productcategory = $categorydata->GetCategoryList(0, "product"); $articlecategory = $categorydata->GetCategoryList(0, "article"); //列出产品 for ($i = 0; $i < count($productlist); $i++) { $value = $productlist[$i]; $locobj = array("type" => "product", "name" => "{$value->filename}", "siteurl" => "{$siteurl}"); $loc = formaturl($locobj); $site_map_item = new google_sitemap_item($loc, date("c"), 'monthly', "0.5"); $site_map_container->add_item($site_map_item); } //列出文章 for ($i = 0; $i < count($articlelist); $i++) { $value = $articlelist[$i]; $locobj = array("type" => "article", "name" => "{$value->filename}", "siteurl" => "{$siteurl}"); $loc = formaturl($locobj); $site_map_item = new google_sitemap_item($loc, date("c"), 'monthly', "0.5"); $site_map_container->add_item($site_map_item); } //列出产品分类 for ($i = 0; $i < count($productcategory); $i++) { $value = $productcategory[$i]; $locobj = array("type" => "category", "name" => "{$value->filename}", "siteurl" => "{$siteurl}"); $loc = formaturl($locobj);