Changeset 605
- Timestamp:
- 09/28/2007 12:43:50 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 1 removed
- 5 modified
-
application/controllers/welcome.php (modified) (1 diff)
-
system/helpers/text.php (modified) (1 diff)
-
system/i18n/en/upload.php (modified) (1 diff)
-
system/libraries/Input.php (modified) (2 diffs)
-
system/libraries/Upload.php (modified) (7 diffs)
-
todd_haz_no_hack (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/application/controllers/welcome.php
r566 r605 5 5 function index() 6 6 { 7 print_r(date::hours(1, TRUE)); die; 8 9 7 10 foreach(get_class_methods(__CLASS__) as $method) 8 11 { -
trunk/system/helpers/text.php
r597 r605 176 176 } 177 177 178 } // End text class178 } // End text Class -
trunk/system/i18n/en/upload.php
r592 r605 3 3 $lang = array 4 4 ( 5 'u pload_userfile_not_set' => 'Unable to find a post variable called %s.',6 ' upload_file_exceeds_limit' => 'The uploaded file exceeds the maximum allowed size in your PHP configuration file',7 ' upload_file_partial' => 'The file was only partially uploaded',8 ' upload_no_file_selected' => 'You did not select a file to upload',9 ' upload_invalid_filetype' => 'The file type you are attempting to upload is not allowed.',10 ' upload_invalid_filesize' => 'The file you are attempting to upload is larger than the permitted size (%s)',11 ' upload_invalid_dimensions' => 'The image you are attempting to upload exceedes the maximum height or width (%s)',12 ' upload_destination_error' => 'A problem was encountered while attempting to move the uploaded file to the final destination.',13 ' upload_no_filepath' => 'The upload path does not appear to be valid.',14 ' upload_no_file_types' => 'You have not specified any allowed file types.',15 ' upload_bad_filename' => 'The file name you submitted already exists on the server.',16 ' upload_not_writable' => 'The upload destination folderdoes not appear to be writable.',5 'userfile_not_set' => 'Unable to find a post variable called %s.', 6 'file_exceeds_limit' => 'The uploaded file exceeds the maximum allowed size in your PHP configuration file', 7 'file_partial' => 'The file was only partially uploaded', 8 'no_file_selected' => 'You did not select a file to upload', 9 'invalid_filetype' => 'The file type you are attempting to upload is not allowed.', 10 'invalid_filesize' => 'The file you are attempting to upload is larger than the permitted size (%s)', 11 'invalid_dimensions' => 'The image you are attempting to upload exceedes the maximum height or width (%s)', 12 'destination_error' => 'A problem was encountered while attempting to move the uploaded file to the final destination.', 13 'no_filepath' => 'The upload path does not appear to be valid.', 14 'no_file_types' => 'You have not specified any allowed file types.', 15 'bad_filename' => 'The file name you submitted already exists on the server.', 16 'not_writable' => 'The upload destination folder, %s, does not appear to be writable.', 17 17 'error_on_file' => 'Error uploading %s:' 18 18 ); -
trunk/system/libraries/Input.php
r558 r605 433 433 * @return string 434 434 */ 435 public function xss_clean($str, $charset = ' ISO-8859-1')435 public function xss_clean($str, $charset = 'UTF-8') 436 436 { 437 437 /* … … 621 621 } 622 622 623 624 623 Log::add('debug', 'XSS Filtering completed'); 625 624 return $str; -
trunk/system/libraries/Upload.php
r599 r605 34 34 class Upload_Core { 35 35 36 protected $max_size = 0;37 protected $max_width = 0;38 protected $max_height = 0;39 protected $allowed_types = "";40 protected $file_temp = "";41 protected $file_name = "";42 protected $orig_name = "";43 protected $file_type = "";44 protected $file_size = "";45 protected $file_ext = "";46 protected $upload_path = "";47 protected $overwrite = FALSE;48 protected $encrypt_name = FALSE;49 protected $is_image = FALSE;50 protected $image_width = '';51 protected $image_height = '';52 protected $image_type = '';53 protected $image_size_str = '';54 protected $error_msg = array();55 protected $mimes = array();56 protected $remove_spaces = TRUE;57 protected $xss_clean = FALSE;58 protected $temp_prefix = "temp_file_";36 protected $max_size = 0; 37 protected $max_width = 0; 38 protected $max_height = 0; 39 protected $allowed_types = ''; 40 protected $file_temp = ''; 41 protected $file_name = ''; 42 protected $orig_name = ''; 43 protected $file_type = ''; 44 protected $file_size = ''; 45 protected $file_ext = ''; 46 protected $upload_path = ''; 47 protected $overwrite = FALSE; 48 protected $encrypt_name = FALSE; 49 protected $is_image = FALSE; 50 protected $image_width = ''; 51 protected $image_height = ''; 52 protected $image_type = ''; 53 protected $image_size_str = ''; 54 protected $error_msg = array(); 55 protected $mimes = array(); 56 protected $remove_spaces = TRUE; 57 protected $xss_clean = FALSE; 58 protected $temp_prefix = 'tmp_upload_'; 59 59 60 60 /** … … 84 84 public function initialize($config = array()) 85 85 { 86 $defaults = array (87 'max_size' => 0,88 'max_width' => 0,89 'max_height'=> 0,90 'allowed_types' => "",91 'file_temp' => "",92 'file_name' => "",93 'orig_name' => "",94 'file_type' => "",95 'file_size' => "",96 'file_ext' => "",97 'upload_path' => "",98 'overwrite' => FALSE,99 'encrypt_name'=> FALSE,100 'is_image'=> FALSE,101 'image_width' => '',102 'image_height' => '',103 'image_type' => '',104 'image_size_str'=> '',105 'error_msg' => array(),106 'mimes'=> array(),107 'remove_spaces' => TRUE,108 'xss_clean' => FALSE,109 'temp_prefix' => "temp_file_"110 );111 86 $defaults = array 87 ( 88 'max_size' => 0, 89 'max_width' => 0, 90 'max_height' => 0, 91 'allowed_types' => '', 92 'file_temp' => '', 93 'file_name' => '', 94 'orig_name' => '', 95 'file_type' => '', 96 'file_size' => '', 97 'file_ext' => '', 98 'upload_path' => '', 99 'overwrite' => FALSE, 100 'encrypt_name' => FALSE, 101 'is_image' => FALSE, 102 'image_width' => '', 103 'image_height' => '', 104 'image_type' => '', 105 'image_size_str' => '', 106 'error_msg' => array(), 107 'mimes' => array(), 108 'remove_spaces' => TRUE, 109 'xss_clean' => FALSE, 110 'temp_prefix' => 'tmp_upload_' 111 ); 112 112 113 113 foreach ($defaults as $key => $msg) … … 133 133 134 134 // -------------------------------------------------------------------- 135 135 136 136 /** 137 137 * Perform a multple file upload … … 141 141 * @return bool 142 142 */ 143 144 145 public function do_mupload($field_set) { 146 if( ! is_array($field_set)) 147 { 148 $this->set_error('field_set_not_array'); 149 return FALSE; 150 } 151 if(empty($field_set)) 152 { 153 $this->set_error('field_set_empty'); 154 } 143 144 145 public function do_mupload($field_set) 146 { 147 if ( ! is_array($field_set) OR empty($field_set)) 148 { 149 throw new Kohana_Exception('field_set_empty'); 150 } 151 155 152 $return = TRUE; 156 foreach($field_set as $nice_name => $userfile) 157 { 158 if( ! $this->do_upload($userfile, $nice_name)) 153 foreach($field_set as $nice_name => $userfile) 154 { 155 if( ! $this->do_upload($userfile, $nice_name)) 159 156 { 160 157 $return = FALSE; 161 158 } 162 159 } 160 163 161 return $return; 164 165 } 166 162 } 163 167 164 /** 168 165 * Perform the file upload … … 229 226 // Is the file size within the allowed maximum? 230 227 if ( ! $this->is_allowed_filesize()) 231 { 228 { 232 229 $this->set_error('invalid_filesize', $nice_name, $this->max_size.'KBytes'); 233 230 return FALSE; … … 630 627 public function validate_upload_path() 631 628 { 632 if ($this->upload_path == '')633 {634 $this->set_error('no_filepath');635 return FALSE;636 }637 638 629 if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE) 639 630 { … … 641 632 } 642 633 643 if ( ! @is_dir($this->upload_path)) 644 { 645 $this->set_error('no_filepath'); 646 return FALSE; 634 if ($this->upload_path == '' OR ! @is_dir($this->upload_path)) 635 { 636 throw new Kohana_Exception('upload.no_filepath'); 647 637 } 648 638 649 639 if ( ! is_writable($this->upload_path)) 650 640 { 651 $this->set_error('not_writable'); 652 return FALSE; 641 throw new Kohana_Exception('upload.not_writable', $this->upload_path); 653 642 } 654 643
