Changeset 16927


Ignore:
Timestamp:
2007/12/19 11:20:08 (16 years ago)
Author:
adachi
Message:

#213 gfDebugLog()修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/beta/data/lib/glib.php

    r15373 r16927  
    1515 *----------------------------------------------------------------------*/ 
    1616function gfDownloadCsv($header, $contents){ 
    17      
     17 
    1818    $fiest_name = date("YmdHis") .".csv"; 
    19      
     19 
    2020    /* HTTP¥Ø¥Ã¥À¤Î½ÐÎÏ */ 
    2121    Header("Content-disposition: attachment; filename=${fiest_name}"); 
    2222    Header("Content-type: application/octet-stream; name=${fiest_name}"); 
    23      
     23 
    2424    $return = $header.$contents; 
    2525    if (mb_detect_encoding($return) == CHAR_CODE){                      //ʸ»ú¥³¡¼¥ÉÊÑ´¹ 
     
    3838 * [Ãí¼á] - 
    3939 *----------------------------------------------------------------------*/ 
    40 function gfSetCsv( $array, $arrayIndex = "" ){   
     40function gfSetCsv( $array, $arrayIndex = "" ){ 
    4141    //°ú¿ô$arrayIndex¤Ï¡¢$array¤¬Ï¢ÁÛÇÛÎó¤Î¤È¤­¤Ëź¤¨»ú¤ò»ØÄꤷ¤Æ¤ä¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë 
    42      
     42 
    4343    $return = ""; 
    4444    for ($i=0; $i<count($array); $i++){ 
    45          
     45 
    4646        for ($j=0; $j<count($array[$i]); $j++ ){ 
    4747            if ( $j > 0 ) $return .= ","; 
    48             $return .= "\"";             
     48            $return .= "\""; 
    4949            if ( $arrayIndex ){ 
    50                 $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$arrayIndex[$j]] )) ."\"";           
     50                $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$arrayIndex[$j]] )) ."\""; 
    5151            } else { 
    5252                $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$j] )) ."\""; 
    5353            } 
    5454        } 
    55         $return .= "\n";             
    56     } 
    57      
     55        $return .= "\n"; 
     56    } 
     57 
    5858    return $return; 
    5959} 
     
    8787 *----------------------------------------------------------------------*/ 
    8888function gfDebugLog($obj, $path = DEBUG_LOG_PATH){ 
    89         gfPrintLog("*** start Debug ***"); 
    90         ob_start(); 
    91         print_r($obj); 
    92         $buffer = ob_get_contents(); 
    93         ob_end_clean(); 
    94         $fp = fopen($path, "a+"); 
    95         fwrite( $fp, $buffer."\n" ); 
    96         fclose( $fp ); 
    97         gfPrintLog("*** end Debug ***"); 
     89        $debugStr = print_r($obj, true); 
     90        gfPrintLog("*** start Debug ***", $path); 
     91        gfPrintLog($debugStr, $path); 
     92        gfPrintLog("*** end Debug ***", $path); 
    9893 
    9994        // ¥í¥°¥Æ¡¼¥·¥ç¥ó 
     
    127122        fclose( $fp ); 
    128123    } 
    129      
     124 
    130125    // ¥í¥°¥Æ¡¼¥·¥ç¥ó 
    131126    gfLogRotation(MAX_LOG_QUANTITY, MAX_LOG_SIZE, $path); 
    132127} 
    133128 
    134 /**          
    135  * ¥í¥°¥í¡¼¥Æ¡¼¥·¥ç¥óµ¡Ç½            
    136  *           
     129/** 
     130 * ¥í¥°¥í¡¼¥Æ¡¼¥·¥ç¥óµ¡Ç½ 
     131 * 
    137132 * @param integer $max_log ºÇÂç¥Õ¥¡¥¤¥ë¿ô 
    138133 * @param integer $max_size ºÇÂ祵¥¤¥º 
    139134 * @param string  $path ¥Õ¥¡¥¤¥ë¥Ñ¥¹ 
    140135 * @return void ¤Ê¤· 
    141  */          
     136 */ 
    142137function gfLogRotation($max_log, $max_size, $path) { 
    143      
     138 
    144139    // ¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ 
    145140    $dirname = dirname($path); 
    146141    // ¥Õ¥¡¥¤¥ë̾¤ò¼èÆÀ 
    147142    $basename = basename($path); 
    148      
     143 
    149144    // ¥Õ¥¡¥¤¥ë¤¬ºÇÂ祵¥¤¥º¤òĶ¤¨¤Æ¤¤¤Ê¤¤¤«¥Á¥§¥Ã¥¯ 
    150145    if(filesize($path) > $max_size) { 
     
    156151                } 
    157152            } 
    158              
     153 
    159154            // ¥Õ¥¡¥¤¥ë¥í¥°¤¬ºÇÂç¸Ä¿ô¤Ê¤é°Ê¾å¤Ê¤é¸Å¤¤¥Õ¥¡¥¤¥ë¤«¤éºï½ü¤¹¤ë 
    160155            $count = count($arrLog); 
     
    163158                for($i = 0; $diff >= $i ; $i++) { 
    164159                    unlink($dirname. "/" .array_pop($arrLog)); 
    165                 }    
    166             } 
    167              
     160                } 
     161            } 
     162 
    168163            // ¥í¥°¥Õ¥¡¥¤¥ë¤Îź¤¨»ú¤ò¤º¤é¤¹ 
    169164            $count = count($arrLog); 
     
    173168            } 
    174169            $ret = copy($path, "$path.1"); 
    175              
     170 
    176171            // ¿·µ¬¥í¥°¥Õ¥¡¥¤¥ë¤òºîÀ® 
    177172            if($ret) { 
    178                 unlink($path);           
     173                unlink($path); 
    179174                touch($path); 
    180175                chmod($path, 0666); 
     
    193188 *----------------------------------------------------------------------*/ 
    194189function gfMakePassword($pwLength) { 
    195      
     190 
    196191    // Íð¿ôɽ¤Î¥·¡¼¥É¤ò·èÄê 
    197192    srand((double)microtime() * 54234853); 
    198      
     193 
    199194    // ¥Ñ¥¹¥ï¡¼¥Éʸ»úÎó¤ÎÇÛÎó¤òºîÀ® 
    200195    $character = "abcdefghkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ2345679"; 
    201196    $pw = preg_split("//", $character, 0, PREG_SPLIT_NO_EMPTY); 
    202      
     197 
    203198    $password = ""; 
    204199    for($i = 0; $i<$pwLength; $i++ ) { 
     
    207202 
    208203    return $password; 
    209 }  
     204} 
    210205 
    211206/*---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.