Changeset 16927
- Timestamp:
- 2007/12/19 11:20:08 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/beta/data/lib/glib.php
r15373 r16927 15 15 *----------------------------------------------------------------------*/ 16 16 function gfDownloadCsv($header, $contents){ 17 17 18 18 $fiest_name = date("YmdHis") .".csv"; 19 19 20 20 /* HTTP¥Ø¥Ã¥À¤Î½ÐÎÏ */ 21 21 Header("Content-disposition: attachment; filename=${fiest_name}"); 22 22 Header("Content-type: application/octet-stream; name=${fiest_name}"); 23 23 24 24 $return = $header.$contents; 25 25 if (mb_detect_encoding($return) == CHAR_CODE){ //ʸ»ú¥³¡¼¥ÉÊÑ´¹ … … 38 38 * [Ãí¼á] - 39 39 *----------------------------------------------------------------------*/ 40 function gfSetCsv( $array, $arrayIndex = "" ){ 40 function gfSetCsv( $array, $arrayIndex = "" ){ 41 41 //°ú¿ô$arrayIndex¤Ï¡¢$array¤¬Ï¢ÁÛÇÛÎó¤Î¤È¤¤Ëź¤¨»ú¤ò»ØÄꤷ¤Æ¤ä¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë 42 42 43 43 $return = ""; 44 44 for ($i=0; $i<count($array); $i++){ 45 45 46 46 for ($j=0; $j<count($array[$i]); $j++ ){ 47 47 if ( $j > 0 ) $return .= ","; 48 $return .= "\""; 48 $return .= "\""; 49 49 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]] )) ."\""; 51 51 } else { 52 52 $return .= mb_ereg_replace("<","¡ã",mb_ereg_replace( "\"","\"\"",$array[$i][$j] )) ."\""; 53 53 } 54 54 } 55 $return .= "\n"; 56 } 57 55 $return .= "\n"; 56 } 57 58 58 return $return; 59 59 } … … 87 87 *----------------------------------------------------------------------*/ 88 88 function 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); 98 93 99 94 // ¥í¥°¥Æ¡¼¥·¥ç¥ó … … 127 122 fclose( $fp ); 128 123 } 129 124 130 125 // ¥í¥°¥Æ¡¼¥·¥ç¥ó 131 126 gfLogRotation(MAX_LOG_QUANTITY, MAX_LOG_SIZE, $path); 132 127 } 133 128 134 /** 135 * ¥í¥°¥í¡¼¥Æ¡¼¥·¥ç¥óµ¡Ç½ 136 * 129 /** 130 * ¥í¥°¥í¡¼¥Æ¡¼¥·¥ç¥óµ¡Ç½ 131 * 137 132 * @param integer $max_log ºÇÂç¥Õ¥¡¥¤¥ë¿ô 138 133 * @param integer $max_size ºÇÂ祵¥¤¥º 139 134 * @param string $path ¥Õ¥¡¥¤¥ë¥Ñ¥¹ 140 135 * @return void ¤Ê¤· 141 */ 136 */ 142 137 function gfLogRotation($max_log, $max_size, $path) { 143 138 144 139 // ¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ 145 140 $dirname = dirname($path); 146 141 // ¥Õ¥¡¥¤¥ë̾¤ò¼èÆÀ 147 142 $basename = basename($path); 148 143 149 144 // ¥Õ¥¡¥¤¥ë¤¬ºÇÂ祵¥¤¥º¤òĶ¤¨¤Æ¤¤¤Ê¤¤¤«¥Á¥§¥Ã¥¯ 150 145 if(filesize($path) > $max_size) { … … 156 151 } 157 152 } 158 153 159 154 // ¥Õ¥¡¥¤¥ë¥í¥°¤¬ºÇÂç¸Ä¿ô¤Ê¤é°Ê¾å¤Ê¤é¸Å¤¤¥Õ¥¡¥¤¥ë¤«¤éºï½ü¤¹¤ë 160 155 $count = count($arrLog); … … 163 158 for($i = 0; $diff >= $i ; $i++) { 164 159 unlink($dirname. "/" .array_pop($arrLog)); 165 } 166 } 167 160 } 161 } 162 168 163 // ¥í¥°¥Õ¥¡¥¤¥ë¤Îź¤¨»ú¤ò¤º¤é¤¹ 169 164 $count = count($arrLog); … … 173 168 } 174 169 $ret = copy($path, "$path.1"); 175 170 176 171 // ¿·µ¬¥í¥°¥Õ¥¡¥¤¥ë¤òºîÀ® 177 172 if($ret) { 178 unlink($path); 173 unlink($path); 179 174 touch($path); 180 175 chmod($path, 0666); … … 193 188 *----------------------------------------------------------------------*/ 194 189 function gfMakePassword($pwLength) { 195 190 196 191 // Íð¿ôɽ¤Î¥·¡¼¥É¤ò·èÄê 197 192 srand((double)microtime() * 54234853); 198 193 199 194 // ¥Ñ¥¹¥ï¡¼¥Éʸ»úÎó¤ÎÇÛÎó¤òºîÀ® 200 195 $character = "abcdefghkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ2345679"; 201 196 $pw = preg_split("//", $character, 0, PREG_SPLIT_NO_EMPTY); 202 197 203 198 $password = ""; 204 199 for($i = 0; $i<$pwLength; $i++ ) { … … 207 202 208 203 return $password; 209 } 204 } 210 205 211 206 /*----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.