|
<?php
$path=$DOCUMENT_ROOT;
$path=str_replace("/","http://",$path);
//指定文件夾
$path=$path."http://web//study//";
//得到所有文件
$s=explode("/n",trim(`dir/b/o:gn $path`));
//得到文件夾下的所有HTML文件名
$num=count($s);
for($i=0;$i<=$num;$i++){
if(strpos($s[$i],".htm")==0){
unset($s[$i]);
}
}
//print_r($s);
//批處理網(wǎng)頁(yè)
foreach($s as $value){
editfile("D://MYOA//webroot//web//study//".$value);
echo $value."已更新!<br>";
}
//editfile("D://MYOA//webroot//web//study//0105_5.htm");
echo "THE END";
//自定義函數(shù):截取標(biāo)簽之間的內(nèi)容
function get_body($start_str,$end_str,$content){
$start_str_num=strlen($start_str);
$end_str_num=strlen($end_str);
$a=strpos($content,$start_str)+$start_str_num;
$b=strpos($content,$end_str)-strpos($content,$start_str)-$start_str_num;
return substr($content,$a,$b);
}
//編輯文件
function editfile($str){
//$str="D://MYOA//webroot//web//study//".$str
//取得HTML內(nèi)容
$file=@fopen($str,"r");
while(!feof($file)){
$result.=fgets($file,9999);
}
fclose($file);
//替換內(nèi)容
$result=str_replace("老王的數(shù)碼配件店:王婆數(shù)碼","嵐視界 ",$result);
$result=str_replace("攝影網(wǎng)校","回到教程首頁(yè)",$result);
$result=str_replace('width="407"','width="770"',$result);
$result=str_replace("http://shop1289309.taobao.com","http://www.lansj.com",$result);
$result=str_replace("老王用的ID有:pccity,joshwang,joshwanggg","",$result);
$result=str_replace("QQ:123709080 MSN:joshwanggg@hotmail.com",'在線咨詢: <a target=blank href=tencent://message/?uin=35501547&Site=嵐視界攝影&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:35501547:10 alt="點(diǎn)擊開(kāi)始咨詢"></a> <a target=blank href=tencent://message/?uin=56025743&Site=嵐視界攝影&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:56025743:10 alt="點(diǎn)擊開(kāi)始咨詢"></a>',$result);
$result=str_replace('<a ,$result);
$result=str_replace('http://www.zonline.com.cn/photo/school/scgs/',"http://www.lansj.com/study/",$result);
$result=str_replace('http://www.yimei.NET/css/',"http://www.lansj.com/study/",$result);
$result=str_replace('http://www.zonline.com.cn/photo/school/img/',"http://www.lansj.com/study/",$result);
$result=str_replace('http://www.yimei.NET/inc/',"http://www.lansj.com/study/",$result);
$result=str_replace('<a <a ,$result);
$result=str_replace('http://www.zonline.com.cn/photo/img/','http://www.lansj.com/study/',$result);
$result=str_replace('<p>如果你對(duì)數(shù)碼器材和配件有什么問(wèn)題可以發(fā)QQ:123709080問(wèn)詢,數(shù)碼相機(jī)及相關(guān)配件專營(yíng):<a href="http;//shop1289309.taobao.com">王婆數(shù)碼</a></p>',"",$result);
$result=str_replace("Untitled Document",substr(str_replace(chr(32),"",str_replace(chr(10),"",str_replace("</p>","",str_replace(chr(13),"",get_body('<p align="center" class="h1"><br>','<p align="left">',$result))))),0,28)." - 嵐視界攝影",$result);
$result=str_replace("攝影天地",substr(str_replace(chr(32),"",str_replace(chr(10),"",str_replace("</p>","",str_replace(chr(13),"",get_body('<span class="text">','</span>',$result))))),0,28)." - 嵐視界攝影",$result);
//echo $result;
//更新HTML
$file=@fopen($str,"w");
fwrite($file,$result);
fclose($file);
}
?>
php技術(shù):PHP 批量更新網(wǎng)頁(yè)內(nèi)容實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。