色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

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

<?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://www.jb51.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)頁部分
*/
$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"); //打開文件指針,創(chuàng)建文件
$logHandle = fopen ($out_logFile, "a+"); //打開日志文件
/**
* @檢查目錄是否可寫
*/
if (!is_writable($out_htmlFile))
{
echo "文件:".$out_htmlFile."不可寫,請(qǐng)檢查目錄屬性后重試";
exit();
}
if (!is_writable($out_logFile))
{
echo "文件:".$out_logFile."不可寫,請(qǐng)檢查目錄屬性后重試";
exit();
}
/**
* @寫入文件
*/
if (!fwrite ($handle, $htmlContent))
{
$logMsg = "寫入文件" . $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://www.jb51.NET", dirname(__FILE__)."/yanjing_html/index.html", dirname(__FILE__)."/yanjing_log/log.txt");
echo "成功";
?>

php技術(shù)php2html php生成靜態(tài)頁函數(shù),轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 大理市| 德惠市| 乐都县| 庆安县| 兴山县| 弥勒县| 木兰县| 兴城市| 张北县| 汾西县| 宜宾市| 博野县| 邹城市| 石阡县| 霍林郭勒市| 甘德县| 苏尼特右旗| 泾川县| 营山县| 乃东县| 乌苏市| 称多县| 乌苏市| 蓝田县| 永济市| 霞浦县| 藁城市| 盈江县| 靖江市| 巩留县| 濮阳市| 突泉县| 资兴市| 女性| 宝丰县| 三河市| 通化县| 瑞昌市| 邳州市| 舞钢市| 蒙城县|