Changeset 605

Show
Ignore:
Timestamp:
09/28/2007 12:43:50 PM (14 months ago)
Author:
Shadowhand
Message:

bah

Location:
trunk
Files:
1 removed
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/welcome.php

    r566 r605  
    55        function index() 
    66        { 
     7                print_r(date::hours(1, TRUE)); die; 
     8                 
     9                 
    710                foreach(get_class_methods(__CLASS__) as $method) 
    811                { 
  • trunk/system/helpers/text.php

    r597 r605  
    176176        } 
    177177 
    178 } // End text class 
     178} // End text Class 
  • trunk/system/i18n/en/upload.php

    r592 r605  
    33$lang = array 
    44( 
    5         'upload_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 folder does 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.', 
    1717        'error_on_file' => 'Error uploading %s:' 
    1818); 
  • trunk/system/libraries/Input.php

    r558 r605  
    433433         * @return      string 
    434434         */ 
    435         public function xss_clean($str, $charset = 'ISO-8859-1') 
     435        public function xss_clean($str, $charset = 'UTF-8') 
    436436        { 
    437437                /* 
     
    621621                } 
    622622 
    623  
    624623                Log::add('debug', 'XSS Filtering completed'); 
    625624                return $str; 
  • trunk/system/libraries/Upload.php

    r599 r605  
    3434class Upload_Core { 
    3535 
    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_'; 
    5959 
    6060        /** 
     
    8484        public function initialize($config = array()) 
    8585        { 
    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                ); 
    112112 
    113113                foreach ($defaults as $key => $msg) 
     
    133133 
    134134        // -------------------------------------------------------------------- 
    135          
     135 
    136136        /** 
    137137         * Perform a multple file upload 
     
    141141         * @return bool 
    142142         */ 
    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 
    155152                $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)) 
    159156                        { 
    160157                                $return = FALSE; 
    161158                        } 
    162159                } 
     160 
    163161                return $return; 
    164                  
    165         } 
    166          
     162        } 
     163 
    167164        /** 
    168165         * Perform the file upload 
     
    229226                // Is the file size within the allowed maximum? 
    230227                if ( ! $this->is_allowed_filesize()) 
    231                 {        
     228                { 
    232229                        $this->set_error('invalid_filesize', $nice_name, $this->max_size.'KBytes'); 
    233230                        return FALSE; 
     
    630627        public function validate_upload_path() 
    631628        { 
    632                 if ($this->upload_path == '') 
    633                 { 
    634                         $this->set_error('no_filepath'); 
    635                         return FALSE; 
    636                 } 
    637  
    638629                if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE) 
    639630                { 
     
    641632                } 
    642633 
    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'); 
    647637                } 
    648638 
    649639                if ( ! is_writable($this->upload_path)) 
    650640                { 
    651                         $this->set_error('not_writable'); 
    652                         return FALSE; 
     641                        throw new Kohana_Exception('upload.not_writable', $this->upload_path); 
    653642                } 
    654643