这篇文章介绍了
php 批量替换程序的具体实现代码,有需要的朋友可以参考一下
代码如下
:
代码如下
:
<?php
/***************************************************************************
batch-replace, v1.1
***************************************************************************
file: batch-replace_utf8.php
functionality: 本程序可以扫描指定目录的所有文件,进行内容替换。可用于被批量挂马的删
除以及批量更新页面某些内容。
本程序适用于对
UTF-8 的页面进行修改。
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
set_time_limit(3600);
if
(
$_POST
['Submit']=='开始执行操作'){
$dir
=
$_POST
['searchpath'];
$shortname
=
$_POST
['shortname'];
$isall
=
$_POST
['isall'];
$isreg
=
$_POST
['isreg'];
if
(!get_magic_quotes_gpc()) {
$sstr
=
$_POST
['sstr'];
$rpstr
=
$_POST
['rpstr'];
}
else
{
$sstr
=
stripslashes
(
$_POST
['sstr']);
$rpstr
=
stripslashes
(
$_POST
['rpstr']);
}
//分析 shortname
$arrext
=
explode
("|",
$shortname
);
if
(!
is_dir
(
$dir
))
return
;
if
(
$sstr
== '')
return
;
//把末尾的/去掉
if
(
substr
(
$dir
,-1)=='/')
$dir
=
substr
(
$dir
,0,
strrpos
(
$dir
,"/"));
//罗列所有目录