Beispiel #1
0
 /**
  * Check if upload exceeds maximum file size
  *
  * @param \phpbb\files\filespec $file Filespec object
  *
  * @return \phpbb\files\filespec Returns same filespec instance
  */
 public function check_upload_size($file)
 {
     // PHP Upload filesize exceeded
     if ($file->get('filename') == 'none') {
         $max_filesize = $this->php_ini->getString('upload_max_filesize');
         $unit = 'MB';
         if (!empty($max_filesize)) {
             $unit = strtolower(substr($max_filesize, -1, 1));
             $max_filesize = (int) $max_filesize;
             $unit = $unit == 'k' ? 'KB' : ($unit == 'g' ? 'GB' : 'MB');
         }
         $file->error[] = empty($max_filesize) ? $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_NA') : $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, $this->language->lang($unit));
     }
     return $file;
 }
Beispiel #2
0
 /**
  * Check for allowed dimension
  *
  * @param filespec $file Instance of filespec class
  *
  * @return bool True if dimensions are valid or no constraints set, false
  *			if not
  */
 public function valid_dimensions(&$file)
 {
     if (!$this->max_width && !$this->max_height && !$this->min_width && !$this->min_height) {
         return true;
     }
     if ($file->get('width') > $this->max_width && $this->max_width || $file->get('height') > $this->max_height && $this->max_height || $file->get('width') < $this->min_width && $this->min_width || $file->get('height') < $this->min_height && $this->min_height) {
         return false;
     }
     return true;
 }