《CMS系统:phpcmsv9 自动更新静态页内容页》要点:
本文介绍了CMS系统:phpcmsv9 自动更新静态页内容页,希望对您有用。如果有疑问,可以联系我们。
相关主题:PHPCMS教程
既然只需要更新指定的静态就可以更新全站,所以定时更新这些静态页能省很多编辑的时间.特此我写了个更新指定栏目下文字的程序与大家分享.CMS教程
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
<?php /* * index.php?m=content&c=autohtml&a=show&catid=6&start=0&offset=10&pwd=house * catid 需要更新的栏目ID号,不能有子栏目(必填) * start 从第几条开始(选填) * 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; } } //首页 public function init() { } /** * 生成内容页 */ 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 '安全验证未通过'; exit; } if (!$catid) { echo "catid未设置,请设置get参数 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设置错误,请查看set_catid是否正确'; exit; } //设置模型数据表名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 "暂无数据"; exit; } $tablename = $this->db->table_name . '_data'; $this->url = pc_base::load_app_class('url'); foreach ($data as $r) { if ($r['islink']) continue; //写入文件 $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 "成功"; } } ?> |
把以上内容复制一份添加到自己的PHPCMSV9系统下的\phpcms\modules\content目录下,就可以用index.php?m=content&c=autohtml&a=show&catid=6&start=0&offset=10&pwd=house这样的方式访问,参数请参照说明.这样就可以把这个链接添加到服务器或是监控宝那样定时访问指定页面的定时功能上,这样就可以实现指定栏目下的所有文章定时更新.CMS教程
转载请注明本页网址:
http://www.vephp.com/jiaocheng/5848.html