Classic Empire CMS generates sitemap for code sharing
Because I was not satisfied with the sitemap plug-in of Empire CMS, I wrote a sitemap generation tool myself, put the homepage link, column page link and content page link in the sitemap, and then generated XML file and submit it to Baidu Webmaster Tools. The code in this article needs to be generated vividly. I wrote a scheduled task using cron in Linux and generated it once a day at a fixed time. Let’s do this for now~
The code is as follows:
<?php /*引用文件*/ require('e/class/connect.php'); require('e/class/db_sql.php'); require('e/data/dbcache/class.php');</p> <p>/*建立数据库链接 与 实例化类*/ $link = db_connect(); $empire=new mysqlquery(); </p> <p>//header("Content-type:application/xml"); header("Content-type: text/html; charset=utf-8");</p> <p>$operation = $_GET['operation']; $current_url = explode('/',$_SERVER['PHP_SELF']); $current_script_name = end($current_url); </p> <p>if($operation && $operation == "makexml") { $xml = generate_sitemp_xml(); $result = save_xml('sitemap.xml',$xml); if($result) { echo '生成成功,<a href="sitemap.xml">点此查看</a>'; } else { echo '生成失败,<a href="'.$current_script_name.'">在来一次</a>!'; } } else { echo '欢迎使用微笑的鱼Sitemap生成工具,请<a href="'.$current_script_name.'?operation=makexml">点此生成</a>!'; }</p> <p></p> <p> //保存到文件 function save_xml($filename, $text) { if (!$filename || !$text) return false; @chmod($filename,0777); if ($fp = fopen($filename, "w")) { if (@fwrite($fp, $text)) { fclose($fp); return true; } else { fclose($fp); return false; } } return false; } //生成Sitemap XML数据 function generate_sitemp_xml() { global $dbtbpre,$empire; $xml = ''; $xml .= '<?xml version="1.0" encoding="utf-8"?>' .PHP_EOL; $xml .= '<urlset>' .PHP_EOL; $xml .= generate_home_xml();//首页 $xml .= generate_class_xml();//栏目 $query="select * from {$dbtbpre}ecms_news order by id desc limit 100"; $sql=$empire->query($query); while($r=$empire->fetch($sql)) { $titleurl=sys_ReturnBqTitleLink($r); $xml .= ' <url>' .PHP_EOL; $xml .= ' <loc>'.$titleurl.'</loc>' .PHP_EOL; $xml .= ' <lastmod>'.strftime('%Y-%m-%d',$r['newstime']).'</lastmod>' .PHP_EOL; $xml .= ' <changefreq>daily</changefreq>' .PHP_EOL; $xml .= ' <priority>0.8</priority>' .PHP_EOL; $xml .= ' </url>' .PHP_EOL; } $xml .= '</urlset>' .PHP_EOL; return $xml; } //生成栏目链接XML数据 function generate_class_xml() { global $dbtbpre,$empire,$class_r; $xml = ''; $sql=$empire->query("SELECT * FROM {$dbtbpre}enewsclass WHERE islast=1"); while($r=$empire->fetch($sql)) { $infor=$empire->fetch1("SELECT newstime FROM {$dbtbpre}ecms_".$class_r[$r[classid]][tbname]." WHERE classid='$r[classid]' ORDER BY newstime DESC LIMIT 1"); $class_url=sys_ReturnBqClassname($r, 9); $xml .= ' <url>' .PHP_EOL; $xml .= ' <loc>'.$class_url.'</loc>' .PHP_EOL; $xml .= ' <lastmod>'.strftime('%Y-%m-%d',time()).'</lastmod>' .PHP_EOL; $xml .= ' <changefreq>daily</changefreq>' .PHP_EOL; $xml .= ' <priority>0.8</priority>' .PHP_EOL; $xml .= ' </url>' .PHP_EOL; } return $xml; } //生成栏目链接XML数据 function generate_home_xml() { $xml = ''; $xml .= ' <url>' .PHP_EOL; $xml .= ' <loc>https://www.jb51.net</loc>' .PHP_EOL; $xml .= ' <lastmod>'.strftime('%Y-%m-%d',time()).'</lastmod>' .PHP_EOL; $xml .= ' <changefreq>daily</changefreq>' .PHP_EOL; $xml .= ' <priority>0.8</priority>' .PHP_EOL; $xml .= ' </url>' .PHP_EOL; return $xml;</p> <p>}</p> <p>/*关闭数据库连接 与 释放类*/ db_close(); $empire=null; ?
Recommended to study "Empirecms Tutorial"
The above is the detailed content of Classic Empire CMS generates sitemap for code sharing. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The Empire CMS sitemap can be found by accessing the config.inc.php file and checking the dositemap settings. If set to "on", sitemap is enabled. The sitemap path is located in the sitemapurl setting and can be accessed via a browser or downloaded via FTP.

The mobile settings of Empire CMS are located in the "Mobile Template" of the "Template Management" module. The specific steps include: enabling the template, selecting the application channel, editing the template content, and saving the settings.

The ideal location for the Empire CMS template file is /e/template/default/skin/default/. Secondly, it can also be placed in /e/data/skins/ and /e/skin/. You need to pay attention to maintaining the folder structure and setting file permissions. and regular backups.

The Imperial CMS database configuration file is located in the website root directory e/config/db.inc.php. It contains the following configuration information: $dbhost: database server address $dbuser: database user name $dbpass: database password $dbname: database name $dbport :Database port $dbcharset: Database character set

Empire CMS template download location: Official template download: https://www.phome.net/template/ Third-party template website: https://www.dedecms.com/diy/https://www.0978.com.cn /https://www.jiaocheng.com/Installation method: Download template Unzip template Upload template Select template

The automatic publishing interface of Empire CMS is located at /e/api/web/postinfo.php. The usage steps are as follows: visit /e/api/web/postinfo.php address and use HTTP POST to submit the article title, column ID, category ID, author and article The content and other data interfaces will return a response in JSON format, which contains the publishing results and article ID.

Yes, Empire CMS is a free and open source content management system (CMS). It is a lightweight CMS that is feature-rich and easy to use. Empire CMS is licensed under the GNU General Public License (GPL), which means it is free to download, install and use. For commercial use, it offers a paid version that offers additional features and support such as ad management, online payments, and premium technical support.

The imperial cms Baidu active push plug-in is located in the root directory /e/api/baidu/push.php. The specific configuration steps are as follows: 1. Upload the plug-in file to the specified path. 2. Configure the "Baidu Active Push" option in the Imperial CMS background, including push address, API Key and push interval. 3. Get Baidu push information: Push address: https://data.zz.baidu.com/urls?site=YOUR_SITE&token=YOUR_API_KEY, API Key: log in to Baidu search resource platform to obtain. 4. Update the API Key regularly and set a reasonable push interval.
