Changeset 17371


Ignore:
Timestamp:
2008/06/24 18:32:36 (16 years ago)
Author:
uehara
Message:

#310ログローテーション不具合に対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2/data/class/util/GC_Utils.php

    r17177 r17371  
    179179                    // ログローテーションにて作成されたファイルを取得 
    180180                    if(ereg("^". $basename . "\." , $file)) { 
    181                         $arrLog[] = $file; 
     181                        $arrFile[] = $file; 
    182182                    } 
    183183                } 
    184184 
    185                 // ファイルログが最大個数なら以上なら古いファイルから削除する 
    186                 $count = count($arrLog); 
    187                 if($count >= $max_log) { 
    188                     $diff = $count - $max_log; 
    189                     for($i = 0; $diff >= $i ; $i++) { 
    190                         unlink($dirname. "/" .array_pop($arrLog)); 
     185                // ローテーションにて作成されたログファイルが存在しない場合は実行しない 
     186                if(is_array($arrFile)) { 
     187                    // ソートを行う 
     188                    $arrLog = natcasesort($arrFile); 
     189                     
     190                    // ファイルログが最大個数なら以上なら古いファイルから削除する 
     191                    $count = count($arrLog); 
     192                    if($count >= $max_log) { 
     193                        $diff = $count - $max_log; 
     194                        for($i = 0; $diff >= $i ; $i++) { 
     195                            unlink($dirname. "/" .array_pop($arrLog)); 
     196                        } 
    191197                    } 
    192                 } 
    193  
    194                 // ログファイルの添え字をずらす 
    195                 $count = count($arrLog); 
    196                 for($i = $count; 1 <= $i; $i--) { 
    197                     $move_number = $i + 1; 
    198  
    199                     if(file_exists("$path.$move_number")) unlink("$path.$move_number"); 
    200                     copy("$dirname/" . $arrLog[$i - 1], "$path.$move_number"); 
    201  
     198     
     199                    // ログファイルの添え字をずらす 
     200                    $count = count($arrLog); 
     201                    for($i = $count; 1 <= $i; $i--) { 
     202                        $move_number = $i + 1; 
     203                        if(file_exists("$path.$move_number")) unlink("$path.$move_number"); 
     204                        copy("$dirname/" . $arrLog[$i - 1], "$path.$move_number"); 
     205                    } 
    202206                } 
    203207                $ret = copy($path, "$path.1"); 
     
    212216        } 
    213217    } 
    214  
     218     
    215219    /*---------------------------------------------------------------------- 
    216220     * [名称] gfMakePassword 
Note: See TracChangeset for help on using the changeset viewer.