feat: 上线生成排查 noindex sitemap

master
LiaoYijun 2 weeks ago
parent 28702d6f2b
commit 7f80865939

@ -15,8 +15,7 @@ class Sitemap extends CI_Controller {
} }
public function index() { public function index() {
$this->permission->is_admin(); $this->download_sitemap();
$this->create($this->config->item('site_url'));
} }
public function save($site_code) { public function save($site_code) {
@ -31,10 +30,30 @@ class Sitemap extends CI_Controller {
} }
} }
public function test() { public function download_sitemap() {
// 测试自动部署是否成功
$data['index_list'] = $this->Information_model->get_index_list(); @set_time_limit(0);
echo json_decode($data['index_list']); ini_set('max_execution_time', '0');
ini_set ('memory_limit', '512M');
$this->permission->is_admin();
$site_url = $this->config->item('site_url');
$site_code = $this->config->item('site_code');
$index_list = $this->Information_model->get_index_list($site_code);
$sitemap_string = '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> ';
foreach ($index_list as $item) {
if ($item->im_value == 'noindex,nofollow' || $item->im_value == 'noindex,nofollow') {
continue;
} else {
$sitemap_string.='<url><loc>' . $site_url . $item->ic_url . '</loc><lastmod>' . date('c', strtotime($item->ic_datetime)) . '</lastmod></url>';
}
}
$sitemap_string.='</urlset> ';
$this->load->helper('download');
force_download('sitemap.xml', $sitemap_string);
} }
public function create($site_url, $site_sitemap = false) { public function create($site_url, $site_sitemap = false) {

@ -343,14 +343,16 @@ class Information_model extends CI_Model
return $this->GetList(); return $this->GetList();
} }
// 获取所有标识 index 的页面 // 获取某个站点所有的页面,用于生成 Sitemap
function get_index_list() { function get_index_list($site_code) {
$index_query = $this->HT->query(" $index_query = $this->HT->query("
select ic_url, ic_datetime, im_value from infoContents ic select ic_url, ic_datetime, im_value from infoContents ic
inner join infoStructures is1 ON ic.ic_id = is1.is_ic_id inner join infoStructures is1 ON ic.ic_id = is1.is_ic_id
left join infoMetas im on ic.ic_id = im.im_ic_id AND im.im_key = 'meta_index_set' left join infoMetas im on ic.ic_id = im.im_ic_id AND im.im_key = 'meta_index_set'
where ic_status = 1 and is1.is_sitecode = ?", where ic_status = 1 and ic_url is not null and ic_url <> '' and is1.is_sitecode = ?",
array($this->config->item('site_code'))); array($site_code));
return $index_query->result();
} }
function GetList($filed = "", $site_code = "") function GetList($filed = "", $site_code = "")

Loading…
Cancel
Save