Share file sitemap_news của code TGT music 4.5


Bước 1: Tạo file tên sitemap_news.php

Bước 2: Copy code ở dưới đây về dán vào trong file sitemap_news.php

Mã:
<?php
#####################################
# IPOS V1.0 (TGT 4.5) #
# code by ichphienpro #
# email: ichphien_pro@yahoo.com #
#####################################
define('TGT-MUSIC',true);
include("./tgt/tgt_music.php");

$rssVersion = 2.0;
$type = $_GET['type'];
$page = (int)$_GET['p'];

$fullpage = 20000;

if($page > 0 && $page!= "")
$start=($page-1) * $fullpage;
else{
$page = 1;
$start=0;
}

$rStar = $fullpage * ($page -1 );

$arr = $tgtdb->databasetgt(" news_id, news_title ","news"," news_hot = 0 ORDER BY news_id DESC LIMIT ".$rStar .",".$fullpage."");

// tell the browser we want xml output by setting the following header.
header("Content-Type: text/xml; charset=utf-8");
$m_date = date('Y-m-d');
$m_time = date('H:i:s');
$rss .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
$rss .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n";
for($i=0;$i<count($arr);$i++) {
$rss .= "<url>\r\n";
$rss .= "<loc>".SITE_LINK."tin-tuc/".replace($arr[$i][1])."/".en_id($arr[$i][0]).".html</loc>\r\n";
$rss .= "<changefreq>daily</changefreq>\r\n";
$rss .= "<lastmod>".$m_date."T".$m_time."+07:00</lastmod>\r\n";
$rss .= "</url>\r\n\r\n";
}

$rss .= "</urlset>\r\n";

echo $rss;
@copy('./sitemap/filesitemap.xml',"./sitemap/news-".$page.'.xml');
$path = './sitemap/news-'.$page.'.xml';
$file=fopen($path, "w");
$write=fwrite($file,$rss);
fclose($file);

?>

Bước 3: Chạy link và gửi cho google 

http://domain.com/sitemap_news.php

0 Nhận xét