﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gavin&#039;s Blog &#187; PHPCMS</title>
	<atom:link href="http://laigw.name/tag/phpcms/feed" rel="self" type="application/rss+xml" />
	<link>http://laigw.name</link>
	<description>Keep it simple, stupid. Simplicity is beauty.</description>
	<lastBuildDate>Sun, 29 Jan 2012 07:14:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>国内著名CMS:PHPCMS整站源码分析(四)</title>
		<link>http://laigw.name/post/127.html</link>
		<comments>http://laigw.name/post/127.html#comments</comments>
		<pubDate>Sat, 15 Nov 2008 09:44:38 +0000</pubDate>
		<dc:creator>Gavin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPCMS]]></category>
		<category><![CDATA[源码分析]]></category>

		<guid isPermaLink="false">http://www.laigw.name/?p=127</guid>
		<description><![CDATA[四、phpcms的模版引擎
函数 template函数是在global.func.php 里面定义的。 在前面的phpcms 的首页 index.php 里就见到了。用法： include template() 用法很熟， 呵呵其实和 dz 的模板引擎一样的用法。 但DZ的模板引擎比 PHPCMS 的简单很多，因为没有用到模板的标签技术。 大家有空可以研究下DZ的模板引擎。这里不说。 好分析下上面这个 模板的主要函数吧。他的作用是返回编译好的模板文件路径。也就是把模板 X.html(模板文件) 用正则替换成 x.php(编译后的PHP文件).然后使用 include 函数。懂了吧！ php的模板引擎都一个鸟样。 然后剩下的就是正则的东西了。


&#160;查看代码 PHP1
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
&#60;?php
/**
函数 template函数是在global.func.php 里面定义的。 在前面的phpcms 的首页 index.php 里就见到了。用法： include template() 用法很熟， 呵呵其实和 dz 的模板引擎一样的用法。 但DZ的模板引擎比 PHPCMS 的简单很多，因为没有用到模板的标签技术。 大家有空可以研究下DZ的模板引擎。这里不说。 好分析下上面这个 模板的主要函数吧。他的作用是返回编译好的模板文件路径。也就是把模板 X.html(模板文件) 用正则替换成 x.php(编译后的PHP文件).然后使用 include 函数。懂了吧！ php的模板引擎都一个鸟样。 然后剩下的就是正则的东西了。等下再说。
*/
function template&#40;$module = 'phpcms', [...]]]></description>
		<wfw:commentRss>http://laigw.name/post/127.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>国内著名CMS:PHPCMS整站源码分析(三)</title>
		<link>http://laigw.name/post/124.html</link>
		<comments>http://laigw.name/post/124.html#comments</comments>
		<pubDate>Sat, 15 Nov 2008 09:42:49 +0000</pubDate>
		<dc:creator>Gavin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPCMS]]></category>
		<category><![CDATA[源码分析]]></category>

		<guid isPermaLink="false">http://www.laigw.name/?p=124</guid>
		<description><![CDATA[三、index.php
现在开始讲 index.php 首页文件. 基本来说PHPCMS的加载到显示操作的整个流程都分析完了.大家看一遍后.还要整体的来看来分析.慢慢体会.把些好的思想和思路实现到自己以后的项目里.我相信大家都会变得很强的. 记得: 程序是死的,人是活的.有实现思路一切都好办了


&#160;查看代码 PHP1
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
/**
代码分析版权所有：逆雪寒
*/
require './include/common.inc.php';
/**
看 common.inc.php 核心启动文件我们已经讲解完了。应该都明白了吧
*/
if&#40;$PHPCMS&#91;'ishtml'&#93; == 1 &#38;&#38; file_exists&#40;PHPCMS_ROOT.'/'.$PHPCMS&#91;'index'&#93;.'.'.$PHPCMS&#91;'fileext'&#93;&#41;&#41;
&#123;
header&#40;'location:'.$PHPCMS&#91;'index'&#93;.'.'.$PHPCMS&#91;'fileext'&#93;&#41;;
exit;
&#125;
/**
phpcms 允许在后台生静态和使用静态,这里就是先判断 $PHPCMS['ishtml'](从文本缓存弄过来的。应该知道了吧)是否为1 就是开启了。和这个 静态的html文件是否存在。
*/
$channels = array&#40;&#41;;
$channels&#91;'article'&#93; = $channels&#91;'down'&#93; = $channels&#91;'picture'&#93; = $channels&#91;'info'&#93;= array&#40;&#41;;
foreach&#40;$CHANNEL as $v&#41;
&#123;
$module = $v&#91;'module'&#93;;
if&#40;$v&#91;'islink'&#93; == 0 &#38;&#38; $MODULE&#91;$module&#93;&#91;'iscopy'&#93; == 1&#41; $channels&#91;$module&#93;&#91;$v&#91;'channelid'&#93;&#93; = $v;
&#125;
//获取频道模块的信息。都是从缓存中取的
&#160;
$head&#91;'title'&#93; = $PHPCMS&#91;'seo_title'&#93;;
$head&#91;'keywords'&#93; = $PHPCMS&#91;'seo_keywords'&#93;;
$head&#91;'description'&#93; = $PHPCMS&#91;'seo_description'&#93;;
// 这个是网页的SEO (title,keywords,description)信息。这个写好了。网络蜘蛛会找你哦。
&#160;
include template&#40;'phpcms', 'index'&#41;;
// template() 函数是模板函数。这个就是这章的主题。往下会讲模板引擎的制作,大家都看到include 了吧。它的参数是文件地址。那么就可以想到 template()函数其实就是
&#160;
// 模板编译后的PHP文件地址。
&#160;
phpcache&#40;&#41;;
/**
这个函数厉害了。用来自动生缓存页的（这个是页面缓存和数据库信息的文本缓存不是一会事）,页面缓存，就是把你所看的页自动生成 [...]]]></description>
		<wfw:commentRss>http://laigw.name/post/124.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>国内著名CMS:PHPCMS整站源码分析(二)</title>
		<link>http://laigw.name/post/121.html</link>
		<comments>http://laigw.name/post/121.html#comments</comments>
		<pubDate>Sat, 15 Nov 2008 09:39:51 +0000</pubDate>
		<dc:creator>Gavin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPCMS]]></category>
		<category><![CDATA[源码分析]]></category>

		<guid isPermaLink="false">http://www.laigw.name/?p=121</guid>
		<description><![CDATA[二、db_mysql.class.php
这个讲 phpcms 的数据库类 和 phpcms 的文本缓存的实现。
首先是数据库类,phpcms 的数据库 分mysql 和mssql 版本. MSSQL 版本的我就不说了. 他们主要的sql 语句不同点就在于我们分页常用到的 limit 语句.所以.在 mssql 数据库类驱动里.他做了个挺好的封装.让MYSQL 和MSSQL在SQL语句方面的差异性就很小了.可以说PHPCMS你可以随便转换数据库只要在代码中换下数据库类驱动就行.

db_mysql.class.php:

&#160;查看代码 PHP1
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**
mysql数据库类。写得比较简单。也没什么好说的。大家自己看下理解下。
然后就可以跳过了。
*/
defined&#40;'IN_PHPCMS'&#41; or exit&#40;'Access Denied'&#41;;
/**
这个东西是不是很熟呀。对了。在上一章已经讲过了。也已经在上一章的common.inc.php 启动文件里面定义了 IN_PHPCMS 所以在以下的PHP文件里都检测下是否是人为”跳墙“进来的。是就中断
*/
/**
* Mysql 数据库类，支持Cache功能
*/
class db_mysql
&#123;
/**
* MySQL 连接标识
* @var resource
*/
var $connid;
/**
* 整型变量用来计算被执行的sql语句数量
* @var int
*/
var $querynum = 0;
/**
* 数据库连接，返回数据库连接标识符
* @param string 数据库服务器主机
* @param string 数据库服务器帐号
* @param string 数据库服务器密码
* @param string 数据库名
* @param bool [...]]]></description>
		<wfw:commentRss>http://laigw.name/post/121.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>国内著名CMS:PHPCMS整站源码分析(一)</title>
		<link>http://laigw.name/post/117.html</link>
		<comments>http://laigw.name/post/117.html#comments</comments>
		<pubDate>Sat, 15 Nov 2008 09:35:39 +0000</pubDate>
		<dc:creator>Gavin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPCMS]]></category>
		<category><![CDATA[源码分析]]></category>

		<guid isPermaLink="false">http://www.laigw.name/?p=117</guid>
		<description><![CDATA[本文源自PHPChina上逆雪寒版主的大作，发表在PHPChina的BBS上，由于跟贴很多(也说明其受欢迎程度)，难以跟踪查看。故将之转贴于次，并且跟踪更新，希望阅读效果会好一点。
废话少说，请看：
一、include/common.inc.php，程序启动的核心文件


&#160;查看代码 PHP1
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
&#60;?php
/**
代码讲解分析： 逆雪寒. 2007 - 12 - 20
*/
$mtime = explode&#40;' ', microtime&#40;&#41;&#41;;
$phpcms_starttime = $mtime&#91;1&#93; + $mtime&#91;0&#93;;
/**
计算脚本开始运行的时间。很常见的写法。最后结算还在程序运行的终点位置。讲到了在给各位说。
*/
unset&#40;$LANG, $_REQUEST, $HTTP_ENV_VARS, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_POST_FILES, $HTTP_COOKIE_VARS&#41;;
/**
把 $HTTP_ENV_VARS $HTTP_POST_VARS 全局变量设置为 NULL 因为php4.1.0以上默认以 $_POST 来替代。unset后防止程序运行在低版本会出现安全等问题。比如变量注入
*/
set_magic_quotes_runtime&#40;0&#41;;
//地球人都知道。关了字符窜入库自动转意 比如 my name is on'x 转成 my name is on \'x 为了最大的程序性能所以我们关掉吧~哈哈
define&#40;'IN_PHPCMS', TRUE&#41;;
/**
程序入口标记。为什么需要这个东西呢。就好比你进一个小区，保安大哥哥肯定要你签字或是挂个鸟牌证明你是从正门进来的。
防止你翻墙进入去偷东西搞破坏。这个入口标记也有这个功能。 在这里定义了一个常量 IN_PHPCMS 为 TRUE ，然后我在其他程序文件里面检查这个标记。如果不存在或不为真，
那么就基本可以肯定你这个家伙是个小偷来的。 人可能翻墙进入。但程序怎么翻墙呢。只要在php.ini文件里面激活 allow_url_fopen选项，include() 就可以包含 URL 地址了。你想下如果你有个放密码的PHP文件。如果给人家include 了以后。你怕不怕。
*/
define&#40;'PHPCMS_ROOT', str_replace&#40;&#34;\\&#34;, '/', [...]]]></description>
		<wfw:commentRss>http://laigw.name/post/117.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

