Пример #1
0
 /**
  * Does validation on the current upload.
  *
  * @access protected
  * @param boolean $import
  * @return boolean
  */
 protected function _validates($import = false)
 {
     $current = $this->_data[$this->_current];
     $grouping = self::checkMimeType($current['ext'], $current['type']);
     if ($grouping) {
         $this->_data[$this->_current]['group'] = $grouping;
     } else {
         if (!$import) {
             return false;
         }
     }
     // Only validate uploaded files, not imported
     if (!$import && !isset($current['stream'])) {
         if ($current['error'] > 0 || !is_uploaded_file($current['tmp_name']) || !is_file($current['tmp_name'])) {
             return false;
         }
         // Requires the ClamAV module to be installed
         if ($this->scanFile && $this->_loadExtension('clamav')) {
             cl_setlimits(5, 1000, 200, 0, 10485760);
             if (cl_scanfile($current['tmp_name'])) {
                 return false;
             }
         }
     }
     return true;
 }
Пример #2
0
 /**
  * Does validation on the current upload
  * @access private
  * @return boolean
  */
 private function __validates()
 {
     $validExt = false;
     $validMime = false;
     // Check valid mime type!
     if (!isset($this->__data[$this->__current]['group'])) {
         $this->__data[$this->__current]['group'] = '';
     }
     foreach ($this->__mimeTypes as $grouping => $mimes) {
         if (isset($mimes[$this->__data[$this->__current]['ext']])) {
             $validExt = true;
         }
         $currType = mb_strtolower($this->__data[$this->__current]['type']);
         foreach ($mimes as $mimeExt => $mimeType) {
             if ($currType == $mimeType || is_array($mimeType) && in_array($currType, $mimeType)) {
                 $validMime = true;
                 break;
             }
         }
         if ($validExt === true && $validMime === true) {
             $this->__data[$this->__current]['group'] = $grouping;
         }
     }
     if ($validExt === false || $validMime === false) {
         return false;
     }
     // Correctly uploaded?
     if ($this->__data[$this->__current]['error'] > 0 || !is_uploaded_file($this->__data[$this->__current]['tmp_name']) || !is_file($this->__data[$this->__current]['tmp_name'])) {
         return false;
     }
     // Requires the ClamAV module to be installed
     // http://www.clamav.net/
     if ($this->scanFile === true) {
         if (!extension_loaded('clamav')) {
             @dl('clamav.' . PHP_SHLIB_SUFFIX);
         }
         if (extension_loaded('clamav')) {
             cl_setlimits(5, 1000, 200, 0, 10485760);
             //clam_get_version();
             if ($malware = cl_scanfile($this->__data[$this->__current]['tmp_name'])) {
                 return false;
             }
         }
     }
     return true;
 }