Changeset 15453
- Timestamp:
- 08/15/11 01:43:59 (10 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
inc/classes/BxDolStorage.php (modified) (3 diffs)
-
inc/classes/BxDolStorageLocal.php (modified) (2 diffs)
-
inc/classes/BxDolStorageS3.php (modified) (2 diffs)
-
inc/images.inc.php (modified) (1 diff)
-
install/sql/v70.sql (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/classes/BxDolStorage.php
r15452 r15453 36 36 define('BX_DOL_STORAGE_INVALID_FILE', 1002); ///< uploaded file is invalid or hack attempts 37 37 define('BX_DOL_STORAGE_ERR_FILE_TOO_BIG', 1003); ///< file is too big 38 define('BX_DOL_STORAGE_ERR_USER_QUOTA_EXCEEDED', 1004); ///< user quota exceeded 39 define('BX_DOL_STORAGE_ERR_OBJECT_QUOTA_EXCEEDED', 1005); ///< storage object quota exceeded 40 define('BX_DOL_STORAGE_ERR_SITE_QUOTA_EXCEEDED', 1006); ///< site quota exceeded 41 define('BX_DOL_STORAGE_ERR_ENGINE_ADD', 1007); ///< some other error during file adding occured, related to particular storage engine 38 define('BX_DOL_STORAGE_ERR_WRONG_EXT', 1004); ///< wrong file extension 39 define('BX_DOL_STORAGE_ERR_USER_QUOTA_EXCEEDED', 1005); ///< user quota exceeded 40 define('BX_DOL_STORAGE_ERR_OBJECT_QUOTA_EXCEEDED', 1006); ///< storage object quota exceeded 41 define('BX_DOL_STORAGE_ERR_SITE_QUOTA_EXCEEDED', 1007); ///< site quota exceeded 42 define('BX_DOL_STORAGE_ERR_ENGINE_ADD', 1008); ///< some other error during file adding occured, related to particular storage engine 42 43 43 44 define('BX_DOL_STORAGE_ERR_FILE_NOT_FOUND', 2001); ///< file not found … … 277 278 278 279 // ------------ internal functions 280 281 protected function storeUploadedFileBegin($aFile, $isPrivate = false, $iProfileId = 0) { 282 283 if (!$aFile['size'] || !$aFile['tmp_name']) { 284 $this->setErrorCode(BX_DOL_STORAGE_ERR_NO_FILE); 285 return false; 286 } 287 288 if (UPLOAD_ERR_OK != $aFile['error']) { 289 $this->setErrorCode((int)$aFile['error']); 290 return false; 291 } 292 293 $sExt = $this->getFileExt($aFile['name']); 294 $sMimeType = $this->getMimeTypeByFileName($aFile['name']); 295 296 if (!$this->isValidExt($sExt)) { 297 $this->setErrorCode(BX_DOL_STORAGE_ERR_WRONG_EXT); 298 return false; 299 } 300 301 if (!$this->onBeforeFileAdd (array( 302 'profile_id' => $iProfileId, 303 'file_name' => $aFile['name'], 304 'mime_type' => $sMimeType, 305 'ext' => $sExt, 306 'size' => $aFile['size'], 307 'private' => $isPrivate ? 1 : 0, 308 ))) { 309 return false; 310 } 311 312 return true; 313 } 279 314 280 315 protected function setErrorCode($i) { … … 313 348 return $sMimeType; 314 349 } 350 351 protected function isValidExt ($sExt) { 352 switch ($this->_aObject['ext_mode']) { 353 case 'allow-deny': 354 if ($this->isAllowedExt($sExt)) 355 return true; 356 return false; 357 case 'deny-allow': 358 if ($this->isDeniedExt($sExt)) 359 return false; 360 return true; 361 default: 362 return false; 363 } 364 } 365 366 protected function isAllowedExt ($sExt) { 367 return $this->isAllowedDeniedExt($sExt, 'ext_allow'); 368 } 369 370 protected function isDeniedExt ($sExt) { 371 return $this->isAllowedDeniedExt($sExt, 'ext_deny'); 372 } 373 374 protected function isAllowedDeniedExt ($sExt, $sExtMode) { 375 if ('' == $this->_aObject[$sExtMode]) 376 return false; 377 if (!is_array($this->_aObject[$sExtMode])) 378 $this->_aObject[$sExtMode] = explode(',', $this->_aObject[$sExtMode]); 379 return in_array ($sExt, $this->_aObject[$sExtMode]); 380 } 381 315 382 } 316 383 -
trunk/inc/classes/BxDolStorageLocal.php
r15452 r15453 35 35 public function storeUploadedFile($aFile, $isPrivate = false, $iProfileId = 0) { 36 36 37 if (!$aFile['size'] || !$aFile['tmp_name']) { 38 $this->setErrorCode(BX_DOL_STORAGE_ERR_NO_FILE); 39 return false; 40 } 41 42 if (UPLOAD_ERR_OK != $aFile['error']) { 43 $this->setErrorCode((int)$aFile['error']); 44 return false; 45 } 37 if (!$this->storeUploadedFileBegin($aFile, $isPrivate, $iProfileId)) 38 return false; 46 39 47 40 $sExt = $this->getFileExt($aFile['name']); 48 41 $sMimeType = $this->getMimeTypeByFileName($aFile['name']); 49 50 if (!$this->onBeforeFileAdd (array(51 'profile_id' => $iProfileId,52 'file_name' => $aFile['name'],53 'mime_type' => $sMimeType,54 'ext' => $sExt,55 'size' => $aFile['size'],56 'private' => $isPrivate ? 1 : 0,57 ))) {58 return false;59 }60 42 61 43 $sLocalId = $this->genRandName(); … … 131 113 return false; 132 114 } 133 134 if (!is_writable($sFileLocation)) {135 $this->setErrorCode(BX_DOL_STORAGE_ERR_FILESYSTEM_PERM);136 return false;137 }138 115 139 116 if (!$this->onBeforeFileDelete ($aFile, $iProfileId)) { -
trunk/inc/classes/BxDolStorageS3.php
r15452 r15453 55 55 public function storeUploadedFile($aFile, $isPrivate = false, $iProfileId = 0) { 56 56 57 if (!$aFile['size'] || !$aFile['tmp_name']) { 58 $this->setErrorCode(BX_DOL_STORAGE_ERR_NO_FILE); 57 if (!$this->storeUploadedFileBegin($aFile, $isPrivate, $iProfileId)) 59 58 return false; 60 }61 62 if (UPLOAD_ERR_OK != $aFile['error']) {63 $this->setErrorCode((int)$aFile['error']);64 return false;65 }66 59 67 60 $sExt = $this->getFileExt($aFile['name']); 68 $sMimeType = $this->getMimeTypeByFileName($aFile['name']); 69 70 if (!$this->onBeforeFileAdd (array( 71 'profile_id' => $iProfileId, 72 'file_name' => $aFile['name'], 73 'mime_type' => $sMimeType, 74 'ext' => $sExt, 75 'size' => $aFile['size'], 76 'private' => $isPrivate ? 1 : 0, 77 ))) { 78 return false; 79 } 61 $sMimeType = $this->getMimeTypeByFileName($aFile['name']); 80 62 81 63 $sLocalId = $this->genRandName(); … … 133 115 ))) { 134 116 $this->_oDb->deleteFile($iId); 135 unlink($sNewFilePath);117 $this->_s3->deleteObject($this->_sBucket, $this->getObjectBaseDir($isPrivate) . $sRemoteNamePath); 136 118 return false; 137 119 } -
trunk/inc/images.inc.php
r15339 r15453 52 52 function produceSecurityImage( $text, $hash ) 53 53 { 54 $use_gd = false;54 global $use_gd; 55 55 global $gdInstalled; 56 56 57 bx_import('BxDolConfig'); 57 58 $sTmpPath = BxDolConfig::getInstance()->get('path_dynamic', 'tmp'); 58 59 -
trunk/install/sql/v70.sql
r15452 r15453 3538 3538 `levels` tinyint(4) NOT NULL, 3539 3539 `table_files` varchar(64) NOT NULL, 3540 `ext_mode` enum('allow-deny','deny-allow') NOT NULL, 3541 `ext_allow` text NOT NULL, 3542 `ext_deny` text NOT NULL, 3540 3543 `quota_size` int(11) NOT NULL, 3541 3544 `current_size` int(11) NOT NULL, … … 3545 3548 `ts` int(11) NOT NULL, 3546 3549 PRIMARY KEY (`id`) 3547 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;3550 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 3548 3551 3549 3552 CREATE TABLE IF NOT EXISTS `sys_storage_user_quotas` (
Note: See TracChangeset
for help on using the changeset viewer.