Ticket #591: diff.2.patch
| File diff.2.patch, 2.8 kB (added by brettalton, 7 months ago) |
|---|
-
config/mimes.php
diff -ur system-old/config/mimes.php system/config/mimes.php
old new 143 143 'pl' => array('text/x-perl'), 144 144 'pm' => array('text/x-perl'), 145 145 'png' => array('image/png', 'image/x-png'), 146 'po' => array('text/x-gettext-translation'), 146 147 'pot' => array('application/vnd.ms-powerpoint'), 147 148 'pps' => array('application/vnd.ms-powerpoint'), 148 149 'ppt' => array('application/powerpoint'), -
helpers/file.php
diff -ur system-old/helpers/file.php system/helpers/file.php
old new 174 174 return ($piece - 1); 175 175 } 176 176 177 } // End file 178 No newline at end of file 177 /** 178 * Return file size using metric prefixes (SI), allow rounding 179 * 180 * @param string path to file 181 * @param integer integer to round to 182 * @return string file size with metric prefix 183 */ 184 public static function size($filename, $round = FALSE) 185 { 186 // Check that file exists 187 if ( ! file_exists($filename) OR ! is_file($filename) OR ! is_readable($filename)) 188 return FALSE; 189 190 // Find filesize in bytes 191 $file_size = sprintf("%u", filesize($filename)); // filesize() has troubles between 2GB and 4GB 192 193 // Make sure $file_size was calculated 194 if (empty($file_size) || $file_size === FALSE) 195 return FALSE; 196 197 $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); 198 for ($i=0; $file_size > 1024 && $i < count($sizes) - 1; $i++) 199 $file_size /= 1024; 200 return round($file_size,$round).' '.$sizes[$i]; // ex: 10 kB 201 } 202 203 } // End file -
helpers/security.php
diff -ur system-old/helpers/security.php system/helpers/security.php
old new 44 44 return str_replace(array('<?', '?>'), array('<?', '?>'), $str); 45 45 } 46 46 47 } // End security 48 No newline at end of file 47 /** 48 * Generate a pseudo-random token between 1-40 characters 49 * 50 * @param integar length of token (min 1, max 40) 51 * @param string string to hash 52 * @return string return psuedo-random token 53 */ 54 public static function generate_token($length = FALSE, $key = uniqid(rand(), TRUE)) 55 { 56 // sha1 is a 256-bit hex hash and is 40 characters long, thus it can not be longer than 40 57 // generate a 40 character long hash if length is greater than 40 or less than 0 (fail safe) 58 if ($length == FALSE || $length >= 40 || $length <= 0) 59 { 60 return sha1($key); 61 } 62 else 63 { 64 $start = rand(0,40-$length); // random number between 0 and maximum acceptable number before $start + $length > 40 65 return substr(sha1($key),$start,$length); 66 } 67 } 68 69 } // End security
