最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php2html php生成靜態(tài)頁(yè)函數(shù)

 更新時(shí)間:2008年12月08日 00:34:50   作者:  
生成靜態(tài)函數(shù) 這里要用到的路徑為服務(wù)器絕對(duì)路徑; 若給定的路徑目錄不存在則自動(dòng)創(chuàng)建
<?php
/**
------------------------
Function: php2html($in_Url, $out_htmlFile, $out_logFile)
------------------------
@ Description: 生成靜態(tài)函數(shù)
@ Copyright: Copyright (c) 2006 - 2011
@ Create: 2006-08-01
@ Modify: 2006-10-27
@ 提示:這里要用到的路徑為服務(wù)器絕對(duì)路徑; 若給定的路徑目錄不存在則自動(dòng)創(chuàng)建
=======================================================================================
@ Example:php2html("http://m.fzitv.net", "/www/html/index.html", "/www/log/log.txt");
*/
// {{{ contents
function php2html($in_Url, $out_htmlFile, $out_logFile)
{
$htmlContent = file_get_contents($in_Url); //將文件讀入 $htmlContent 變量
/**
* @檢查要生成的文件是否存在
*/
if (is_file($out_htmlFile))
{
@unlink($out_htmlFile);//若文件已存在,則刪除
}
/**
* @ 創(chuàng)建目錄 網(wǎng)頁(yè)部分
*/
$dir_array = explode("/", dirname($out_htmlFile));
chdir("/"); //改變目錄到根
for($i=1;$i<count($dir_array);$i++)
{
if(is_dir($dir_array[$i]))
{
chdir($dir_array[$i]);
}
else
{
mkdir($dir_array[$i]);
chdir($dir_array[$i]);
}
}
/**
* @ 創(chuàng)建目錄 日志部分
*/
$dir_array = explode("/", dirname($out_logFile));
chdir("/"); //改變目錄到根
for($i=1;$i<count($dir_array);$i++)
{
if(is_dir($dir_array[$i]))
{
chdir($dir_array[$i]);
}
else
{
mkdir($dir_array[$i], 0777);
chdir($dir_array[$i]);
}
}
$handle = fopen($out_htmlFile, "w"); //打開(kāi)文件指針,創(chuàng)建文件
$logHandle = fopen ($out_logFile, "a+"); //打開(kāi)日志文件
/**
* @檢查目錄是否可寫(xiě)
*/
if (!is_writable($out_htmlFile))
{
echo "文件:".$out_htmlFile."不可寫(xiě),請(qǐng)檢查目錄屬性后重試";
exit();
}
if (!is_writable($out_logFile))
{
echo "文件:".$out_logFile."不可寫(xiě),請(qǐng)檢查目錄屬性后重試";
exit();
}
/**
* @寫(xiě)入文件
*/
if (!fwrite ($handle, $htmlContent))
{
$logMsg = "寫(xiě)入文件" . $out_htmlFile . "失敗";
}
else
{
$logMsg = "創(chuàng)建文件" . $out_htmlFile . "成功";
}
/**
* @記錄日志
*/
$logMsg .= "(".date("Y-m-d H:i:s") .")\r\n";
fwrite ($logHandle, $logMsg);
fclose($logHandle); //關(guān)閉日志指針
fclose ($handle); //關(guān)閉指針
}
// }}}
php2html("http://m.fzitv.net", dirname(__FILE__)."/yanjing_html/index.html", dirname(__FILE__)."/yanjing_log/log.txt");
echo "成功";
?>

相關(guān)文章

最新評(píng)論

长春市| 沁阳市| 德格县| 昭平县| 监利县| 山丹县| 葫芦岛市| 新泰市| 罗定市| 大邑县| 大化| 江川县| 江阴市| 公主岭市| 竹溪县| 通州市| 日照市| 图们市| 黑龙江省| 吐鲁番市| 吴旗县| 炉霍县| 华池县| 冕宁县| 英山县| 兴城市| 昌江| 凤凰县| 逊克县| 伽师县| 贵南县| 晴隆县| 株洲县| 镇巴县| 溧阳市| 南岸区| 禹州市| 台中市| 无棣县| 吉隆县| 夏津县|