UCHome下伪静态的实现及路径解析
仅适用于程序可以通过独立域名或者二级域名直接访问。
01.
<IfModule mod_rewrite.c>
02.
03.
RewriteEngine On
04.
05.
RewriteBase /UCHome
06.
07.
RewriteRule ^(space|network)\-(.+)\.html$
$1
.php?rewrite=
$2
[L]
08.
09.
RewriteRule ^(space|network)\.html$
$1
.php [L]
10.
11.
RewriteRule ^([0-9]+)$ space.php?uid=
$1
[L]
12.
13.
</IfModule>
01.
if
(
$_SCONFIG
[
'allowrewrite'
] && isset(
$_GET
[
'rewrite'
])) {
02.
$rws
=
explode
(
'-'
,
$_GET
[
'rewrite'
]);
03.
if
(
$rw_uid
=
intval
(
$rws
[0])) {
04.
$_GET
[
'uid'
] =
$rw_uid
;
05.
}
else
{
06.
$_GET
[
'do'
] =
$rws
[0];
07.
}
08.
if
(isset(
$rws
[1])) {
09.
$rw_count
=
count
(
$rws
);
10.
for
(
$rw_i
=1;
$rw_i
<
$rw_count
;
$rw_i
=
$rw_i
+2) {
11.
$_GET
[
$rws
[
$rw_i
]] =
empty
(
$rws
[
$rw_i
+1])?
''
:
$rws
[
$rw_i
+1];
12.
}
13.
}
14.
unset(
$_GET
[
'rewrite'
]);
15.
}
01.
function
ob_out() {
02.
global
$_SGLOBAL
,
$_SCONFIG
,
$_SC
;
03.
04.
$content
= ob_get_contents();
05.
06.
$preg_searchs
=
$preg_replaces
=
$str_searchs
=
$str_replaces
=
array
();
07.
08.
if
(
$_SCONFIG
[
'allowrewrite'
]) {
09.
$preg_searchs
[] =
"/\<a href\=\"space\.php\?(uid|do)+\=([a-z0-9\=\&]+?)\"/ie"
;
10.
$preg_searchs
[] =
"/\<a href\=\"space.php\"/i"
;
11.
$preg_searchs
[] =
"/\<a href\=\"network\.php\?ac\=([a-z0-9\=\&]+?)\"/ie"
;
12.
$preg_searchs
[] =
"/\<a href\=\"network.php\"/i"
;
13.
14.
$preg_replaces
[] =
'rewrite_url(\'space-\',\'\\2\')'
;
15.
$preg_replaces
[] =
'<a href="space.html"'
;
16.
$preg_replaces
[] =
'rewrite_url(\'network-\',\'\\1\')'
;
17.
$preg_replaces
[] =
'<a href="network.html"'
;
18.
}
19.
if
(
$_SCONFIG
[
'linkguide'
]) {
20.
$preg_searchs
[] =
"/\<a href\=\"http\:\/\/(.+?)\"/ie"
;
21.
$preg_replaces
[] =
'iframe_url(\'\\1\')'
;
22.
}
23.
24.
if
(
$_SGLOBAL
[
'inajax'
]) {
25.
$preg_searchs
[] =
"/([\x01-\x09\x0b-\x0c\x0e-\x1f])+/"
;
26.
$preg_replaces
[] =
' '
;
27.
28.
$str_searchs
[] =
']]>'
;
29.
$str_replaces
[] =
']]>'
;
30.
}
31.
32.
if
(
$preg_searchs
) {
33.
$content
= preg_replace(
$preg_searchs
,
$preg_replaces
,
$content
);
34.
}
35.
if
(
$str_searchs
) {
36.
$content
= trim(
str_replace
(
$str_searchs
,
$str_replaces
,
$content
));
37.
}
38.
39.
obclean();
40.
if
(
$_SGLOBAL
[
'inajax'
]) {
41.
xml_out(
$content
);
42.
}
else
{
43.
if
(
$_SCONFIG
[
'headercharset'
]) {
44.
@header(
'Content-Type: text/html; charset='
.
$_SC
[
'charset'
]);
45.
}
46.
echo
$content
;
47.
if
(D_BUG) {
48.
@
include_once
(S_ROOT.
'./source/inc_debug.php'
);
49.
}
50.
}
51.
}
1.
//换行
2.
$template
= preg_replace(
"/ \?\>[\n\r]*\<\? /s"
,
" "
,
$template
);
3.
4.
//附加处理
5.
$template
=
"<?php if(!defined('IN_UCHOME')) exit('Access Denied');?><?php subtplcheck('"
.implode('|
', $_SGLOBAL['
sub_tpls
'])."'
,
'$_SGLOBAL[timestamp]'
,
'$tpl'
);?>
$template
<?php ob_out();?>";