Пример #1
0
<?php

include $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'lib_db.php';
$sm = new Sitemap();
$sm->createSitemap();
class Sitemap
{
    private $SITE_NAME = '';
    private $CHANGE_FREQ = 'weekly';
    private $VM_PRODUCT_SUFFIX = "-detail";
    private $SITEMAP_FILE_NAME = "sitemap.xml";
    private $PRIORITY = '1';
    private $db;
    private $table_prefix = '';
    public function __construct()
    {
        $this->SITE_NAME = "http://" . $_SERVER['SERVER_NAME'];
        $this->db = new Dbprocess();
        $this->db->connectToDb();
        $this->table_prefix = $this->db->getTablePrefix();
    }
    public function createSitemap()
    {
        $where = "published = 1 and menutype = 'mainmenu' and access IN (1)";
        $result = $this->db->select($this->table_prefix . "menu", "*", "{$where}", 'std');
        $dom = new DOMDocument('1.0');
        $dom->formatOutput = true;
        $root = $dom->createElement('urlset');
        $root = $dom->appendChild($root);
        $ns = $dom->createAttributeNS("http://www.sitemaps.org/schemas/sitemap/0.9", "xmlns");
        foreach ($result["value"] as $row) {
Пример #2
0
        $content = '';
        foreach($urlList as $url)
        {
            $content .= '<url>
                    <loc>'.$url.'</loc>
                        <lastmod>'.XDateTime::now()->toShortString().'</lastmod>
                            <changefreq>daily</changefreq>
                               <priority>0.4</priority>
                                  </url>';
        }
        return $content;
    }/*}}}*/

    private function getZixunUrl()
    {/*{{{*/
        $urlList = array();
        $zixunData = array(1,2,3,4,5,6,7,8,9,10,11,1110,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,55,56,57,61);
        foreach($zixunData as $data)
        {
            $urlList[] = 'http://zixun.haodf.com/index/'.$data.'.htm';
        }
        return $urlList;
    }/*}}}*/
    
}


$sitemap = new Sitemap();
$sitemap->createSitemap();
?>