<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[沧海一粟]]></title> 
<link>http://www.dzhope.com/index.php</link> 
<description><![CDATA[Web系统架构与服务器运维,php开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[沧海一粟]]></copyright>
<item>
<link>http://www.dzhope.com/post//</link>
<title><![CDATA[php2html php生成静态页函数 ]]></title> 
<author>jed &lt;jed521@163.com&gt;</author>
<category><![CDATA[代码编程]]></category>
<pubDate>Sat, 23 Dec 2006 09:27:52 +0000</pubDate> 
<guid>http://www.dzhope.com/post//</guid> 
<description>
<![CDATA[ 
	<div class="code"><br/>&lt;?php<br/>/**<br/> ------------------------<br/> &nbsp; Function: php2html($in_Url, $out_htmlFile, $out_logFile) <br/> ------------------------<br/> @ Description: 生成静态函数<br/> @ Author 眼睛5462 &nbsp; &nbsp;<br/> @ QQ: 332458700 &#91;E-mail:yanjing5462@my55.com.cn&#93;<br/> @ Copyright: Copyright (c) 2006 - 2011 MY55.com.cn<br/> @ Create: 2006-08-01<br/> @ Modify: 2006-10-27<br/> @ 提示:这里要用到的路径为服务器绝对路径; 若给定的路径目录不存在则自动创建<br/> =======================================================================================<br/> @ Example：php2html(&quot;http://www.baidu.com&quot;, &quot;/www/html/index.html&quot;, &quot;/www/log/log.txt&quot;);<br/> */<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br/>// &#123;&#123;&#123; &nbsp; &nbsp; contents<br/><br/> &nbsp; &nbsp;function php2html($in_Url, $out_htmlFile, $out_logFile)<br/> &nbsp; &nbsp;&#123; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp;$htmlContent = file_get_contents($in_Url); //将文件读入 $htmlContent 变量<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;/**<br/> &nbsp; &nbsp; &nbsp; &nbsp; * @检查要生成的文件是否存在<br/> &nbsp; &nbsp; &nbsp; &nbsp; */<br/> &nbsp; &nbsp; &nbsp; &nbsp;if (is_file($out_htmlFile))<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@unlink($out_htmlFile);//若文件已存在，则删除<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp;/**<br/> &nbsp; &nbsp; &nbsp; &nbsp; * @ 创建目录 网页部分<br/> &nbsp; &nbsp; &nbsp; &nbsp; */<br/> &nbsp; &nbsp; &nbsp; &nbsp;$dir_array = explode(&quot;/&quot;, dirname($out_htmlFile));<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;chdir(&quot;/&quot;); //改变目录到根<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;for($i=1;$i&lt;count($dir_array);$i++)<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(is_dir($dir_array&#91;$i&#93;))<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;chdir($dir_array&#91;$i&#93;); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mkdir($dir_array&#91;$i&#93;);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;chdir($dir_array&#91;$i&#93;);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;/**<br/> &nbsp; &nbsp; &nbsp; &nbsp; * @ 创建目录 日志部分<br/> &nbsp; &nbsp; &nbsp; &nbsp; */<br/> &nbsp; &nbsp; &nbsp; &nbsp;$dir_array = explode(&quot;/&quot;, dirname($out_logFile));<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;chdir(&quot;/&quot;); //改变目录到根<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;for($i=1;$i&lt;count($dir_array);$i++)<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(is_dir($dir_array&#91;$i&#93;))<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;chdir($dir_array&#91;$i&#93;); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mkdir($dir_array&#91;$i&#93;, 0777);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;chdir($dir_array&#91;$i&#93;);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;$handle = fopen($out_htmlFile, &quot;w&quot;); //打开文件指针，创建文件<br/> &nbsp; &nbsp; &nbsp; &nbsp;$logHandle &nbsp; &nbsp;= fopen ($out_logFile, &quot;a+&quot;); //打开日志文件<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;/**<br/> &nbsp; &nbsp; &nbsp; &nbsp; * @检查目录是否可写<br/> &nbsp; &nbsp; &nbsp; &nbsp; */<br/> &nbsp; &nbsp; &nbsp; &nbsp;if (!is_writable($out_htmlFile))<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo &quot;文件：&quot;.$out_htmlFile.&quot;不可写，请检查目录属性后重试&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit();<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp;if (!is_writable($out_logFile))<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo &quot;文件：&quot;.$out_logFile.&quot;不可写，请检查目录属性后重试&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit();<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;/**<br/> &nbsp; &nbsp; &nbsp; &nbsp; * @写入文件<br/> &nbsp; &nbsp; &nbsp; &nbsp; */<br/> &nbsp; &nbsp; &nbsp; &nbsp;if (!fwrite ($handle, $htmlContent))<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$logMsg = &quot;写入文件&quot; . $out_htmlFile . &quot;失败&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125; <br/> &nbsp; &nbsp; &nbsp; &nbsp;else <br/> &nbsp; &nbsp; &nbsp; &nbsp;&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$logMsg = &quot;创建文件&quot; . $out_htmlFile . &quot;成功&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;/**<br/> &nbsp; &nbsp; &nbsp; &nbsp; * @记录日志<br/> &nbsp; &nbsp; &nbsp; &nbsp; */<br/> &nbsp; &nbsp; &nbsp; &nbsp;$logMsg &nbsp; &nbsp;.= &quot;(&quot;.date(&quot;Y-m-d H:i:s&quot;) .&quot;)&#92;r&#92;n&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp;fwrite ($logHandle, $logMsg);<br/> &nbsp; &nbsp; &nbsp; &nbsp;fclose($logHandle); //关闭日志指针<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;fclose ($handle); //关闭指针<br/> &nbsp; &nbsp;&#125;<br/><br/>// &#125;&#125;&#125; <br/><br/>php2html(&quot;http://www.baidu.com&quot;, dirname(__FILE__).&quot;/yanjing_html/index.html&quot;, dirname(__FILE__).&quot;/yanjing_log/log.txt&quot;);<br/>echo &quot;成功&quot;;<br/>?&gt; <br/><br/></div><br/><br/>Tags - <a href="http://www.dzhope.com/tags/%25E7%2594%259F%25E6%2588%2590%25E9%259D%2599%25E6%2580%2581/" rel="tag">生成静态</a>
]]>
</description>
</item><item>
<link>http://www.dzhope.com/post//#blogcomment</link>
<title><![CDATA[[评论] php2html php生成静态页函数 ]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.dzhope.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>