把动态网页转为静态网页的PHP代码
以下代码保存为html.php:
<
html
><
head
><
title
>
把动态网页转为静态网页
</
title
></
head
><
body
><
form enctype
=
'multipart/form-data'
action dedecms.com
=
"html.php"
method
=
"post"
>
动态网页地址:
<
input type
=
"text"
size
=
"32"
name
=
"url"
value
=
""
/>< 内容来自dedecms
br
/>
生成静态网页:
<
input type
=
"text"
size
=
"12"
name
=
"file"
value
=
""
/><
select name
=
type
><
option value
内容来自dedecms
=
".htm"
>.
htm
</
option
><
option value
=
".html"
selected
>.
html
</
option
></
select
><
input type
=
"hidden"
name 织梦内容管理系统
=
"action"
value
=
"html"
/><
input type
=
submit value
=
'确定'
></
form
><?
php
if(
$_POST
[
'action'
]==
'html'
){ if( copyright dedecms
$_POST
[
'file'
]==
""
|| !
ereg
(
"^[a-zA-Z0-9 ]*$"
,
$_POST
[
'file'
])){ echo
"<font color='red'>错误!文件名只能包含英文和数字!</font>"
; exit; }
copyright dedecms
$content
= @
file_get_contents
(
$_POST
[
'url'
]); if(empty(
$content
)){ echo
"<font color='red'>错误!无法获取该网页内容!</font>"
; exit; } 织梦好,好织梦
$filename
=
"html/"
.
$_POST
[
'file'
].
$_POST
[
'type'
]; if(!
is_dir
(
"html"
))
mkdir
(
"html"
,
织梦内容管理系统
0777
);
$fp
=
fopen
(
$filename
,
"w "
);
$content
=
"<base href=\""
.
$_POST
[
'url'
].
"\">" 内容来自dedecms
.
$content
;
fwrite
(
$fp
,
$content
);
fclose
(
$fp
); echo
"察看静态网页:<a href='"
.
$filename
dedecms.com
.
"' target='_blank'>"
.
$_POST
[
'file'
].
$_POST
[
'type'
].
"</a>"
;}
?>
</body></html>
织梦内容管理系统
织梦内容管理系统
本文来自织梦
dedecms.com
更多精彩:http://www.cnseoo.net www.hbmobiles.cn
copyright dedecms

