<html><head><title>把动态网页转为静态网页</title></head>
<body>
<form enctype='multipart/form-data' action="html.php" method="post">
动态网页地址:<input type="text" size="32" name="url" value="" /><br />
生成静态网页:<input type="text" size="12" name="file" value="" /><select name=type><option
value=".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($_POST['file']=="" || !ereg("^[a-zA-Z0-9+]*$",$_POST['file'])){
echo "<font color='red'>错误!文件名只能包含英文和数字!</font>";
exit;
}
$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']."\">".$content;
fwrite($fp,$content);
fclose($fp);
echo "察看静态网页:<a href='".$filename."' target='_blank'>".$_POST
['file'].$_POST['type']."</a>";
}
?>
</body>
</html>
ppt.cc/fVjECx ppt.cc/fEnHsx ppt.cc/fRZTnx ppt.cc/fSZ3cx ppt.cc/fLOuCx ppt.cc/fE9Nux ppt.cc/fL5Kyx ppt.cc/fIr1ax ppt.cc/f71Yqx tecmint.com linuxcool.com linux.die.net linux.it.net.cn ostechnix.com unix.com ubuntugeek.com runoob.com man.linuxde.net bit.ly/2EzoUDo bit.ly/2tW6eYT bit.ly/2X6vadl bit.ly/2viLpHU linuxprobe.com linuxtechi.com howtoforge.com linuxstory.org systutorials.com ghacks.net linuxopsys.com v.gd/2P9wTx v.gd/FtfpqE v.gd/eMfHsm v.gd/Ub7mqv v.gd/RReVk0 v.gd/vS3uTI v.gd/4Zxmba
Total Pageviews
Thursday, 8 December 2011
把动态网页转为静态网页的PHP代码
把以下代码保存为html.php:
Labels:
程序和源码
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment