Copy CodeThe code is as follows:
$path = $DOCUMENT _root;
$path =str_replace ("/", "\ \", $path);
Specify folder
$path = $path. " \\web\\study\\ ";
Get all the files
$s =explode ("\ n", Trim (' dir/b/o:gn $path '));
Get all the HTML file names under the folder
$num =count ($s);
for ($i =0; $i <= $num; $i + +) {
if (Strpos ($s [$i], ". htm") ==0) {
Unset ($s [$i]);
}
}
Print_r ($s);
Batch processing Web pages
foreach ($s as $value) {
Editfile ("d:\\myoa\\webroot\\web\\study\\". $value);
echo $value. " has been updated!
";
}
Editfile ("d:\\myoa\\webroot\\web\\study\\0105_5.htm");
echo "The END";
Custom Function: Intercepts the contents between tags
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);
}
Edit File
function Editfile ($STR) {
$str = "d:\\myoa\\webroot\\web\\study\\". $str
Get HTML content
$file = @fopen ($str, "R");
while (!feof ($file)) {
$result. =fgets ($file, 9999);
}
Fclose ($file);
Replace content
$result =str_replace ("Lao Wang's Digital accessories shop: Wang Po Digital", "LAN Vision", $result);
$result =str_replace ("Photography net", "Back to Tutorial Home", $result);
$result =str_replace (' width= ' 407 "', ' width=" 770 "', $result);
$result =str_replace ("http://shop1289309.taobao.com", "http://www.lansj.com", $result);
$result =str_replace ("Lao Wang with the ID: pccity,joshwang,joshwanggg", "", $result);
$result =str_replace ("qq:123709080 msn:joshwanggg@hotmail.com", ' Online Enquiry: ', $result);
$result =str_replace (' http://www.zonline.com.cn
', ' ", $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 (' Oak Photography Club ', ' LAN Vision Photography Forum ', $result);
$result =str_replace (' http://www.zonline.com.cn/photo/img/', ' http://www.lansj.com/study/', $result);
$result =str_replace ('
If you have any questions about digital devices and accessories, you can send qq:123709080 inquiries, digital cameras and related accessories franchise: Wang Po Digital
', ' ", $result);
$result =str_replace ("Untitled Document", substr (Str_replace (CHR), "", Str_replace (CHR), "", Str_replace ("
"," ", Str_replace (CHR)," ", Get_body ('
','
($result))))), 0,28). "-Lan Vision Photography", $result);
$result =str_replace ("The World of Photography", substr (Str_replace (CHR), "", Str_replace (CHR), "", Str_replace ("
"," ", Str_replace (CHR)," ", Get_body (' ','($result))))), 0,28). "-Lan Vision Photography", $result);
echo $result;
Update HTML
$file = @fopen ($str, "w");
Fwrite ($file, $result);
Fclose ($file);
}
?>
http://www.bkjia.com/PHPjc/321027.html www.bkjia.com true http://www.bkjia.com/PHPjc/321027.html techarticle Copy the code as follows: PHP $path = $DOCUMENT _root; $path =str_replace ("/", "\ \", $path);//Specify folder $path = $path. " \\web\\study\\ "; Get all Files $s =explode ("\ n", trim (' ...