国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

phpcmsv9 自動(dòng)更新靜態(tài)頁(yè)內(nèi)容頁(yè)

2024-04-25 20:35:03
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

我們的網(wǎng)站使用的是PHPCMSV9系統(tǒng)開(kāi)發(fā)的,網(wǎng)站越來(lái)越大,新聞頁(yè)右側(cè)推薦內(nèi)容經(jīng)常更新不及時(shí),影響網(wǎng)站的流量。所以在服務(wù)器上開(kāi)啟了ssi功能,也就是常說(shuō)的文件包含功能。這樣就可以在所有的頁(yè)面上添加一個(gè)公用的靜態(tài)頁(yè)面,每次更新右側(cè)內(nèi)容時(shí)只需要更新這一塊的靜態(tài)就可以了,相比之前更新全站才能全右側(cè)信息顯示最新新聞,這樣的效率能夠提高千萬(wàn)倍。至于怎么給PHPCMSV9添加ssi功能我會(huì)另寫(xiě)文章記錄全過(guò)程。

既然只需要更新指定的靜態(tài)就可以更新全站,所以定時(shí)更新這些靜態(tài)頁(yè)能省很多編輯的時(shí)間。特此我寫(xiě)了個(gè)更新指定欄目下文字的程序與大家分享。

<?php

/*

* http://www.bcty365.com/index.php?m=content&c=autohtml&a=show&catid=6&start=0&offset=10&pwd=house

* catid 需要更新的欄目ID號(hào),不能有子欄目(必填)

* start 從第幾條開(kāi)始(選填)

* offset 更新多少條(選填)

* pwd 安全密碼

*/

defined('IN_PHPCMS') or exit('No permission resources.');

//模型緩存路徑

define('CACHE_MODEL_PATH', CACHE_PATH . 'caches_model' . DIRECTORY_SEPARATOR . 'caches_data' . DIRECTORY_SEPARATOR);

pc_base::load_app_func('util', 'content');

class autohtml {

private $db, $categorys;

function __construct() {

$this->db = pc_base::load_model('content_model');
$this->siteid = get_siteid();

$this->categorys = getcache('category_content_' . $this->siteid, 'commons');

foreach ($_GET as $k => $v) {

$_POST[$k] = $v;

}

}

//首頁(yè)

public function init() {

}

/**

* 生成內(nèi)容頁(yè)

*/

public function show() {

$catid = safe_replace($_GET['catid']);

$start = safe_replace($_GET['start']);

$offset = safe_replace($_GET['offset']);

$pwd = safe_replace($_GET['pwd']);

if ($pwd != house) {

echo '安全驗(yàn)證未通過(guò)';

exit;

}

if (!$catid) {

echo "catid未設(shè)置,請(qǐng)?jiān)O(shè)置get參數(shù) set_catid";

exit;

}

if (!$start)

$start = 0;

if (!$offset)

$offset = 10;

$this->html = pc_base::load_app_class('html');

$modelid = $this->categorys[$catid]['modelid'];

if (!$modelid) {

echo 'modelid設(shè)置錯(cuò)誤,請(qǐng)查看set_catid是否正確';

exit;

}

//設(shè)置模型數(shù)據(jù)表名www.bcty365.com
$this->db->set_model($modelid);

$table_name = $this->db->table_name;

$where = " WHERE status=99 AND catid='$catid'";
$order = 'ASC';

$rs = $this->db->query("SELECT * FROM `$table_name` $where ORDER BY `id` $order LIMIT $start,$offset");

$data = $this->db->fetch_array($rs);

if (!$data) {

echo "暫無(wú)數(shù)據(jù)";

exit;

}

$tablename = $this->db->table_name . '_data';

$this->url = pc_base::load_app_class('url');

foreach ($data as $r) {

if ($r['islink'])

continue;

//寫(xiě)入文件

$this->db->table_name = $tablename;

$r2 = $this->db->get_one(array('id' => $r['id']));

if ($r2)

$r = array_merge($r, $r2);

if ($r['upgrade']) {

$urls[1] = $r['url'];

} else {

$urls = $this->url->show($r['id'], '', $r['catid'], $r['inputtime']);

}

$this->html->show($urls[1], $r, 0, 'edit', $r['upgrade']);

}

echo "成功";

}

}

?>

把以上內(nèi)容復(fù)制一份添加到自己的PHPCMSV9系統(tǒng)下的/phpcms/modules/content目錄下,就可以用http://www.bcty365.com/index.php?m=content&c=autohtml&a=show&catid=6&start=0&offset=10&pwd=house這樣的方式訪(fǎng)問(wèn),參數(shù)請(qǐng)參照說(shuō)明。這樣就可以把這個(gè)鏈接添加到服務(wù)器或是監(jiān)控寶那樣定時(shí)訪(fǎng)問(wèn)指定頁(yè)面的定時(shí)功能上,這樣就可以實(shí)現(xiàn)指定欄目下的所有文章定時(shí)更新。

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 衡山县| 临夏市| 洪洞县| 会昌县| 湄潭县| 怀来县| 荆州市| 三原县| 吉林市| 石屏县| 鸡泽县| 来凤县| 安宁市| 青河县| 遵化市| 资溪县| 陵川县| 台南县| 祁门县| 渑池县| 四平市| 天柱县| 凤城市| 出国| 凤凰县| 明溪县| 资中县| 通州市| 丘北县| 深泽县| 德兴市| 昌图县| 五峰| 田阳县| 壶关县| 宝兴县| 霍林郭勒市| 宁海县| 泸定县| 措勤县| 灵璧县|