Beispiel #1
0
 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");
 }
Beispiel #2
0
    $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);
    while ($row = $db->fetchRow($res)) {
        $smi = new google_sitemap_item($domain . build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']), $today, $_POST['category_changefreq'], $_POST['category_priority']);
Beispiel #3
0
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);
    $site_map_item = new google_sitemap_item($loc, date("c"), 'weekly', "0.8");