@@ -24,7 +24,7 @@ |
||
| 24 | 24 | |
| 25 | 25 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 26 | 26 | public static function getValues() { |
| 27 | - return ["bataille" => self::$values]; |
|
| 27 | + return ["bataille" => self::$values]; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | //initilisation of all classes of battle |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 17 | 17 | public function getBatiments(){ |
| 18 | - return $this->batiments; |
|
| 18 | + return $this->batiments; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | return $this->ressource_construire; |
| 47 | 47 | } |
| 48 | 48 | public function getInfoBatiment(){ |
| 49 | - return $this->info_batiment; |
|
| 49 | + return $this->info_batiment; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function getNomBatimentConstruction() { |
@@ -87,25 +87,25 @@ |
||
| 87 | 87 | |
| 88 | 88 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 89 | 89 | public function getNomBatiment(){ |
| 90 | - return $this->nom_batiment; |
|
| 90 | + return $this->nom_batiment; |
|
| 91 | 91 | } |
| 92 | 92 | public function getNomBatimentSql(){ |
| 93 | - return $this->nom_batiment_sql; |
|
| 93 | + return $this->nom_batiment_sql; |
|
| 94 | 94 | } |
| 95 | 95 | public function getNiveauBatiment(){ |
| 96 | - return $this->niveau_batiment; |
|
| 96 | + return $this->niveau_batiment; |
|
| 97 | 97 | } |
| 98 | 98 | public function getTempsConstruction(){ |
| 99 | - return $this->temps_construction; |
|
| 99 | + return $this->temps_construction; |
|
| 100 | 100 | } |
| 101 | 101 | public function getRessourceConstruire(){ |
| 102 | - return $this->ressource_construire; |
|
| 102 | + return $this->ressource_construire; |
|
| 103 | 103 | } |
| 104 | 104 | public function getNomBatimentConstruire(){ |
| 105 | - return $this->nom_batiment_construire; |
|
| 105 | + return $this->nom_batiment_construire; |
|
| 106 | 106 | } |
| 107 | 107 | public function getNiveauBatimentConstruire(){ |
| 108 | - return $this->niveau_batiment_construire; |
|
| 108 | + return $this->niveau_batiment_construire; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | return $this->message; |
| 77 | 77 | } |
| 78 | 78 | public function getDateMessage(){ |
| 79 | - return $this->date_message; |
|
| 79 | + return $this->date_message; |
|
| 80 | 80 | } |
| 81 | 81 | public function getUrl(){ |
| 82 | - return $this->url; |
|
| 82 | + return $this->url; |
|
| 83 | 83 | } |
| 84 | 84 | public function getIdExpediteur() { |
| 85 | 85 | return $this->id_expediteur; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return $this->pseudo_receveur; |
| 95 | 95 | } |
| 96 | 96 | public function getValues(){ |
| 97 | - return ["messagerie" => $this->values]; |
|
| 97 | + return ["messagerie" => $this->values]; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -21,16 +21,16 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | function CheckAuthentication() |
| 23 | 23 | { |
| 24 | - // WARNING : DO NOT simply return "true". By doing so, you are allowing |
|
| 25 | - // "anyone" to upload and list the files in your server. You must implement |
|
| 26 | - // some kind of session validation here. Even something very simple as... |
|
| 24 | + // WARNING : DO NOT simply return "true". By doing so, you are allowing |
|
| 25 | + // "anyone" to upload and list the files in your server. You must implement |
|
| 26 | + // some kind of session validation here. Even something very simple as... |
|
| 27 | 27 | |
| 28 | - return true; |
|
| 28 | + return true; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the |
|
| 32 | - // user logs in your system. To be able to use session variables don't |
|
| 33 | - // forget to add session_start() at the top of this file. |
|
| 31 | + // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the |
|
| 32 | + // user logs in your system. To be able to use session variables don't |
|
| 33 | + // forget to add session_start() at the top of this file. |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | } |
@@ -96,23 +96,23 @@ discard block |
||
| 96 | 96 | directory, no matter the resource type. |
| 97 | 97 | */ |
| 98 | 98 | $config['Thumbnails'] = Array( |
| 99 | - 'url' => $baseUrl . '_thumbs', |
|
| 100 | - 'directory' => $baseDir . '_thumbs', |
|
| 101 | - 'enabled' => true, |
|
| 102 | - 'directAccess' => false, |
|
| 103 | - 'maxWidth' => 100, |
|
| 104 | - 'maxHeight' => 100, |
|
| 105 | - 'bmpSupported' => false, |
|
| 106 | - 'quality' => 80); |
|
| 99 | + 'url' => $baseUrl . '_thumbs', |
|
| 100 | + 'directory' => $baseDir . '_thumbs', |
|
| 101 | + 'enabled' => true, |
|
| 102 | + 'directAccess' => false, |
|
| 103 | + 'maxWidth' => 100, |
|
| 104 | + 'maxHeight' => 100, |
|
| 105 | + 'bmpSupported' => false, |
|
| 106 | + 'quality' => 80); |
|
| 107 | 107 | |
| 108 | 108 | /* |
| 109 | 109 | Set the maximum size of uploaded images. If an uploaded image is larger, it |
| 110 | 110 | gets scaled down proportionally. Set to 0 to disable this feature. |
| 111 | 111 | */ |
| 112 | 112 | $config['Images'] = Array( |
| 113 | - 'maxWidth' => 700, |
|
| 114 | - 'maxHeight' => 1200, |
|
| 115 | - 'quality' => 80); |
|
| 113 | + 'maxWidth' => 700, |
|
| 114 | + 'maxHeight' => 1200, |
|
| 115 | + 'quality' => 80); |
|
| 116 | 116 | |
| 117 | 117 | /* |
| 118 | 118 | RoleSessionVar : the session variable name that CKFinder must use to retrieve |
@@ -138,19 +138,19 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | |
| 140 | 140 | $config['AccessControl'][] = Array( |
| 141 | - 'role' => '*', |
|
| 142 | - 'resourceType' => '*', |
|
| 143 | - 'folder' => '/', |
|
| 141 | + 'role' => '*', |
|
| 142 | + 'resourceType' => '*', |
|
| 143 | + 'folder' => '/', |
|
| 144 | 144 | |
| 145 | - 'folderView' => true, |
|
| 146 | - 'folderCreate' => true, |
|
| 147 | - 'folderRename' => true, |
|
| 148 | - 'folderDelete' => true, |
|
| 145 | + 'folderView' => true, |
|
| 146 | + 'folderCreate' => true, |
|
| 147 | + 'folderRename' => true, |
|
| 148 | + 'folderDelete' => true, |
|
| 149 | 149 | |
| 150 | - 'fileView' => true, |
|
| 151 | - 'fileUpload' => true, |
|
| 152 | - 'fileRename' => true, |
|
| 153 | - 'fileDelete' => true); |
|
| 150 | + 'fileView' => true, |
|
| 151 | + 'fileUpload' => true, |
|
| 152 | + 'fileRename' => true, |
|
| 153 | + 'fileDelete' => true); |
|
| 154 | 154 | |
| 155 | 155 | /* |
| 156 | 156 | For example, if you want to restrict the upload, rename or delete of files in |
@@ -193,36 +193,36 @@ discard block |
||
| 193 | 193 | $config['DefaultResourceTypes'] = ''; |
| 194 | 194 | |
| 195 | 195 | $config['ResourceType'][] = Array( |
| 196 | - 'name' => 'Files', // Single quotes not allowed |
|
| 197 | - 'url' => $baseUrl . '/file/', |
|
| 198 | - 'directory' => $baseDir . '/file/', |
|
| 199 | - 'maxSize' => 0, |
|
| 200 | - 'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip,ai,psd', |
|
| 201 | - 'deniedExtensions' => ''); |
|
| 196 | + 'name' => 'Files', // Single quotes not allowed |
|
| 197 | + 'url' => $baseUrl . '/file/', |
|
| 198 | + 'directory' => $baseDir . '/file/', |
|
| 199 | + 'maxSize' => 0, |
|
| 200 | + 'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip,ai,psd', |
|
| 201 | + 'deniedExtensions' => ''); |
|
| 202 | 202 | |
| 203 | 203 | $config['ResourceType'][] = Array( |
| 204 | - 'name' => 'Images', |
|
| 205 | - 'url' => $baseUrl . '/image/', |
|
| 206 | - 'directory' => $baseDir . '/image/', |
|
| 207 | - 'maxSize' => "16M", |
|
| 208 | - 'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,', |
|
| 209 | - 'deniedExtensions' => ''); |
|
| 204 | + 'name' => 'Images', |
|
| 205 | + 'url' => $baseUrl . '/image/', |
|
| 206 | + 'directory' => $baseDir . '/image/', |
|
| 207 | + 'maxSize' => "16M", |
|
| 208 | + 'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,', |
|
| 209 | + 'deniedExtensions' => ''); |
|
| 210 | 210 | |
| 211 | 211 | $config['ResourceType'][] = Array( |
| 212 | - 'name' => 'Flash', |
|
| 213 | - 'url' => $baseUrl . '/flash/', |
|
| 214 | - 'directory' => $baseDir . '/flash/', |
|
| 215 | - 'maxSize' => 0, |
|
| 216 | - 'allowedExtensions' => 'swf,flv', |
|
| 217 | - 'deniedExtensions' => ''); |
|
| 212 | + 'name' => 'Flash', |
|
| 213 | + 'url' => $baseUrl . '/flash/', |
|
| 214 | + 'directory' => $baseDir . '/flash/', |
|
| 215 | + 'maxSize' => 0, |
|
| 216 | + 'allowedExtensions' => 'swf,flv', |
|
| 217 | + 'deniedExtensions' => ''); |
|
| 218 | 218 | |
| 219 | 219 | $config['ResourceType'][] = Array( |
| 220 | - 'name' => 'Media', |
|
| 221 | - 'url' => $baseUrl . '/media/', |
|
| 222 | - 'directory' => $baseDir . '/media/', |
|
| 223 | - 'maxSize' => 0, |
|
| 224 | - 'allowedExtensions' => 'mp3,mp4,swf,flv,avi', |
|
| 225 | - 'deniedExtensions' => ''); |
|
| 220 | + 'name' => 'Media', |
|
| 221 | + 'url' => $baseUrl . '/media/', |
|
| 222 | + 'directory' => $baseDir . '/media/', |
|
| 223 | + 'maxSize' => 0, |
|
| 224 | + 'allowedExtensions' => 'mp3,mp4,swf,flv,avi', |
|
| 225 | + 'deniedExtensions' => ''); |
|
| 226 | 226 | |
| 227 | 227 | /* |
| 228 | 228 | Due to security issues with Apache modules, it is recommended to leave the |
@@ -15,174 +15,174 @@ |
||
| 15 | 15 | |
| 16 | 16 | class Watermark |
| 17 | 17 | { |
| 18 | - function onAfterFileUpload($currentFolder, $uploadedFile, $sFilePath) |
|
| 19 | - { |
|
| 20 | - global $config; |
|
| 21 | - $watermarkSettings = $config['Plugin_Watermark']; |
|
| 18 | + function onAfterFileUpload($currentFolder, $uploadedFile, $sFilePath) |
|
| 19 | + { |
|
| 20 | + global $config; |
|
| 21 | + $watermarkSettings = $config['Plugin_Watermark']; |
|
| 22 | 22 | |
| 23 | - $this->createWatermark($sFilePath, $watermarkSettings['source'], $watermarkSettings['marginRight'], |
|
| 24 | - $watermarkSettings['marginBottom'], $watermarkSettings['quality'], $watermarkSettings['transparency']); |
|
| 23 | + $this->createWatermark($sFilePath, $watermarkSettings['source'], $watermarkSettings['marginRight'], |
|
| 24 | + $watermarkSettings['marginBottom'], $watermarkSettings['quality'], $watermarkSettings['transparency']); |
|
| 25 | 25 | |
| 26 | - return true; |
|
| 27 | - } |
|
| 26 | + return true; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - function createWatermark($sourceFile, $watermarkFile, $marginLeft = 5, $marginBottom = 5, $quality = 90, $transparency = 100) |
|
| 30 | - { |
|
| 31 | - if (!file_exists($watermarkFile)) { |
|
| 32 | - $watermarkFile = dirname(__FILE__) . "/" . $watermarkFile; |
|
| 33 | - } |
|
| 34 | - if (!file_exists($watermarkFile)) { |
|
| 35 | - return false; |
|
| 36 | - } |
|
| 29 | + function createWatermark($sourceFile, $watermarkFile, $marginLeft = 5, $marginBottom = 5, $quality = 90, $transparency = 100) |
|
| 30 | + { |
|
| 31 | + if (!file_exists($watermarkFile)) { |
|
| 32 | + $watermarkFile = dirname(__FILE__) . "/" . $watermarkFile; |
|
| 33 | + } |
|
| 34 | + if (!file_exists($watermarkFile)) { |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $watermarkImageAttr = @getimagesize($watermarkFile); |
|
| 39 | - $sourceImageAttr = @getimagesize($sourceFile); |
|
| 40 | - if ($sourceImageAttr === false || $watermarkImageAttr === false) { |
|
| 41 | - return false; |
|
| 42 | - } |
|
| 38 | + $watermarkImageAttr = @getimagesize($watermarkFile); |
|
| 39 | + $sourceImageAttr = @getimagesize($sourceFile); |
|
| 40 | + if ($sourceImageAttr === false || $watermarkImageAttr === false) { |
|
| 41 | + return false; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - switch ($watermarkImageAttr['mime']) |
|
| 45 | - { |
|
| 46 | - case 'image/gif': |
|
| 47 | - { |
|
| 48 | - if (@imagetypes() & IMG_GIF) { |
|
| 49 | - $oWatermarkImage = @imagecreatefromgif($watermarkFile); |
|
| 50 | - } else { |
|
| 51 | - $ermsg = 'GIF images are not supported'; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - break; |
|
| 55 | - case 'image/jpeg': |
|
| 56 | - { |
|
| 57 | - if (@imagetypes() & IMG_JPG) { |
|
| 58 | - $oWatermarkImage = @imagecreatefromjpeg($watermarkFile) ; |
|
| 59 | - } else { |
|
| 60 | - $ermsg = 'JPEG images are not supported'; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - break; |
|
| 64 | - case 'image/png': |
|
| 65 | - { |
|
| 66 | - if (@imagetypes() & IMG_PNG) { |
|
| 67 | - $oWatermarkImage = @imagecreatefrompng($watermarkFile) ; |
|
| 68 | - } else { |
|
| 69 | - $ermsg = 'PNG images are not supported'; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - break; |
|
| 73 | - case 'image/wbmp': |
|
| 74 | - { |
|
| 75 | - if (@imagetypes() & IMG_WBMP) { |
|
| 76 | - $oWatermarkImage = @imagecreatefromwbmp($watermarkFile); |
|
| 77 | - } else { |
|
| 78 | - $ermsg = 'WBMP images are not supported'; |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - break; |
|
| 82 | - default: |
|
| 83 | - $ermsg = $watermarkImageAttr['mime'].' images are not supported'; |
|
| 84 | - break; |
|
| 85 | - } |
|
| 44 | + switch ($watermarkImageAttr['mime']) |
|
| 45 | + { |
|
| 46 | + case 'image/gif': |
|
| 47 | + { |
|
| 48 | + if (@imagetypes() & IMG_GIF) { |
|
| 49 | + $oWatermarkImage = @imagecreatefromgif($watermarkFile); |
|
| 50 | + } else { |
|
| 51 | + $ermsg = 'GIF images are not supported'; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + break; |
|
| 55 | + case 'image/jpeg': |
|
| 56 | + { |
|
| 57 | + if (@imagetypes() & IMG_JPG) { |
|
| 58 | + $oWatermarkImage = @imagecreatefromjpeg($watermarkFile) ; |
|
| 59 | + } else { |
|
| 60 | + $ermsg = 'JPEG images are not supported'; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + break; |
|
| 64 | + case 'image/png': |
|
| 65 | + { |
|
| 66 | + if (@imagetypes() & IMG_PNG) { |
|
| 67 | + $oWatermarkImage = @imagecreatefrompng($watermarkFile) ; |
|
| 68 | + } else { |
|
| 69 | + $ermsg = 'PNG images are not supported'; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + break; |
|
| 73 | + case 'image/wbmp': |
|
| 74 | + { |
|
| 75 | + if (@imagetypes() & IMG_WBMP) { |
|
| 76 | + $oWatermarkImage = @imagecreatefromwbmp($watermarkFile); |
|
| 77 | + } else { |
|
| 78 | + $ermsg = 'WBMP images are not supported'; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + break; |
|
| 82 | + default: |
|
| 83 | + $ermsg = $watermarkImageAttr['mime'].' images are not supported'; |
|
| 84 | + break; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - switch ($sourceImageAttr['mime']) |
|
| 88 | - { |
|
| 89 | - case 'image/gif': |
|
| 90 | - { |
|
| 91 | - if (@imagetypes() & IMG_GIF) { |
|
| 92 | - $oImage = @imagecreatefromgif($sourceFile); |
|
| 93 | - } else { |
|
| 94 | - $ermsg = 'GIF images are not supported'; |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - break; |
|
| 98 | - case 'image/jpeg': |
|
| 99 | - { |
|
| 100 | - if (@imagetypes() & IMG_JPG) { |
|
| 101 | - $oImage = @imagecreatefromjpeg($sourceFile) ; |
|
| 102 | - } else { |
|
| 103 | - $ermsg = 'JPEG images are not supported'; |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - break; |
|
| 107 | - case 'image/png': |
|
| 108 | - { |
|
| 109 | - if (@imagetypes() & IMG_PNG) { |
|
| 110 | - $oImage = @imagecreatefrompng($sourceFile) ; |
|
| 111 | - } else { |
|
| 112 | - $ermsg = 'PNG images are not supported'; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - break; |
|
| 116 | - case 'image/wbmp': |
|
| 117 | - { |
|
| 118 | - if (@imagetypes() & IMG_WBMP) { |
|
| 119 | - $oImage = @imagecreatefromwbmp($sourceFile); |
|
| 120 | - } else { |
|
| 121 | - $ermsg = 'WBMP images are not supported'; |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - break; |
|
| 125 | - default: |
|
| 126 | - $ermsg = $sourceImageAttr['mime'].' images are not supported'; |
|
| 127 | - break; |
|
| 128 | - } |
|
| 87 | + switch ($sourceImageAttr['mime']) |
|
| 88 | + { |
|
| 89 | + case 'image/gif': |
|
| 90 | + { |
|
| 91 | + if (@imagetypes() & IMG_GIF) { |
|
| 92 | + $oImage = @imagecreatefromgif($sourceFile); |
|
| 93 | + } else { |
|
| 94 | + $ermsg = 'GIF images are not supported'; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + break; |
|
| 98 | + case 'image/jpeg': |
|
| 99 | + { |
|
| 100 | + if (@imagetypes() & IMG_JPG) { |
|
| 101 | + $oImage = @imagecreatefromjpeg($sourceFile) ; |
|
| 102 | + } else { |
|
| 103 | + $ermsg = 'JPEG images are not supported'; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + break; |
|
| 107 | + case 'image/png': |
|
| 108 | + { |
|
| 109 | + if (@imagetypes() & IMG_PNG) { |
|
| 110 | + $oImage = @imagecreatefrompng($sourceFile) ; |
|
| 111 | + } else { |
|
| 112 | + $ermsg = 'PNG images are not supported'; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + break; |
|
| 116 | + case 'image/wbmp': |
|
| 117 | + { |
|
| 118 | + if (@imagetypes() & IMG_WBMP) { |
|
| 119 | + $oImage = @imagecreatefromwbmp($sourceFile); |
|
| 120 | + } else { |
|
| 121 | + $ermsg = 'WBMP images are not supported'; |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + break; |
|
| 125 | + default: |
|
| 126 | + $ermsg = $sourceImageAttr['mime'].' images are not supported'; |
|
| 127 | + break; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - if (isset($ermsg) || false === $oImage || false === $oWatermarkImage) { |
|
| 131 | - return false; |
|
| 132 | - } |
|
| 130 | + if (isset($ermsg) || false === $oImage || false === $oWatermarkImage) { |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - $watermark_width = $watermarkImageAttr[0]; |
|
| 135 | - $watermark_height = $watermarkImageAttr[1]; |
|
| 136 | - $dest_x = $sourceImageAttr[0] - $watermark_width - $marginLeft; |
|
| 137 | - $dest_y = $sourceImageAttr[1] - $watermark_height - $marginBottom; |
|
| 134 | + $watermark_width = $watermarkImageAttr[0]; |
|
| 135 | + $watermark_height = $watermarkImageAttr[1]; |
|
| 136 | + $dest_x = $sourceImageAttr[0] - $watermark_width - $marginLeft; |
|
| 137 | + $dest_y = $sourceImageAttr[1] - $watermark_height - $marginBottom; |
|
| 138 | 138 | |
| 139 | - if ( $sourceImageAttr['mime'] == 'image/png') |
|
| 140 | - { |
|
| 141 | - if(function_exists('imagesavealpha') && function_exists('imagecolorallocatealpha') ) |
|
| 142 | - { |
|
| 143 | - $bg = imagecolorallocatealpha($oImage, 255, 255, 255, 127); // (PHP 4 >= 4.3.2, PHP 5) |
|
| 144 | - imagefill($oImage, 0, 0 , $bg); |
|
| 145 | - imagealphablending($oImage, false); |
|
| 146 | - imagesavealpha($oImage, true); // (PHP 4 >= 4.3.2, PHP 5) |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - if ($watermarkImageAttr['mime'] == 'image/png') { |
|
| 150 | - imagecopy($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); |
|
| 151 | - } |
|
| 152 | - else { |
|
| 153 | - imagecopymerge($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency); |
|
| 154 | - } |
|
| 139 | + if ( $sourceImageAttr['mime'] == 'image/png') |
|
| 140 | + { |
|
| 141 | + if(function_exists('imagesavealpha') && function_exists('imagecolorallocatealpha') ) |
|
| 142 | + { |
|
| 143 | + $bg = imagecolorallocatealpha($oImage, 255, 255, 255, 127); // (PHP 4 >= 4.3.2, PHP 5) |
|
| 144 | + imagefill($oImage, 0, 0 , $bg); |
|
| 145 | + imagealphablending($oImage, false); |
|
| 146 | + imagesavealpha($oImage, true); // (PHP 4 >= 4.3.2, PHP 5) |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + if ($watermarkImageAttr['mime'] == 'image/png') { |
|
| 150 | + imagecopy($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); |
|
| 151 | + } |
|
| 152 | + else { |
|
| 153 | + imagecopymerge($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - switch ($sourceImageAttr['mime']) |
|
| 157 | - { |
|
| 158 | - case 'image/gif': |
|
| 159 | - imagegif($oImage, $sourceFile); |
|
| 160 | - break; |
|
| 161 | - case 'image/jpeg': |
|
| 162 | - imagejpeg($oImage, $sourceFile, $quality); |
|
| 163 | - break; |
|
| 164 | - case 'image/png': |
|
| 165 | - imagepng($oImage, $sourceFile); |
|
| 166 | - break; |
|
| 167 | - case 'image/wbmp': |
|
| 168 | - imagewbmp($oImage, $sourceFile); |
|
| 169 | - break; |
|
| 170 | - } |
|
| 156 | + switch ($sourceImageAttr['mime']) |
|
| 157 | + { |
|
| 158 | + case 'image/gif': |
|
| 159 | + imagegif($oImage, $sourceFile); |
|
| 160 | + break; |
|
| 161 | + case 'image/jpeg': |
|
| 162 | + imagejpeg($oImage, $sourceFile, $quality); |
|
| 163 | + break; |
|
| 164 | + case 'image/png': |
|
| 165 | + imagepng($oImage, $sourceFile); |
|
| 166 | + break; |
|
| 167 | + case 'image/wbmp': |
|
| 168 | + imagewbmp($oImage, $sourceFile); |
|
| 169 | + break; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - imageDestroy($oImage); |
|
| 173 | - imageDestroy($oWatermarkImage); |
|
| 174 | - } |
|
| 172 | + imageDestroy($oImage); |
|
| 173 | + imageDestroy($oWatermarkImage); |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $watermark = new Watermark(); |
| 178 | 178 | $config['Hooks']['AfterFileUpload'][] = array($watermark, 'onAfterFileUpload'); |
| 179 | 179 | if (empty($config['Plugin_Watermark'])) |
| 180 | 180 | { |
| 181 | - $config['Plugin_Watermark'] = array( |
|
| 182 | - "source" => "logo.gif", |
|
| 183 | - "marginRight" => 5, |
|
| 184 | - "marginBottom" => 5, |
|
| 185 | - "quality" => 90, |
|
| 186 | - "transparency" => 80, |
|
| 187 | - ); |
|
| 181 | + $config['Plugin_Watermark'] = array( |
|
| 182 | + "source" => "logo.gif", |
|
| 183 | + "marginRight" => 5, |
|
| 184 | + "marginBottom" => 5, |
|
| 185 | + "quality" => 90, |
|
| 186 | + "transparency" => 80, |
|
| 187 | + ); |
|
| 188 | 188 | } |
@@ -21,79 +21,79 @@ |
||
| 21 | 21 | |
| 22 | 22 | class CKFinder_Connector_CommandHandler_FileEditor extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * handle request and build XML |
|
| 26 | - * @access protected |
|
| 27 | - */ |
|
| 28 | - function buildXml() |
|
| 29 | - { |
|
| 30 | - if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 31 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * handle request and build XML |
|
| 26 | + * @access protected |
|
| 27 | + */ |
|
| 28 | + function buildXml() |
|
| 29 | + { |
|
| 30 | + if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 31 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - $this->checkConnector(); |
|
| 35 | - $this->checkRequest(); |
|
| 34 | + $this->checkConnector(); |
|
| 35 | + $this->checkRequest(); |
|
| 36 | 36 | |
| 37 | - // Saving empty file is equal to deleting a file, that's why FILE_DELETE permissions are required |
|
| 38 | - if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 39 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 40 | - } |
|
| 37 | + // Saving empty file is equal to deleting a file, that's why FILE_DELETE permissions are required |
|
| 38 | + if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 39 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - if (!isset($_POST["fileName"])) { |
|
| 43 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME); |
|
| 44 | - } |
|
| 45 | - if (!isset($_POST["content"])) { |
|
| 46 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 47 | - } |
|
| 42 | + if (!isset($_POST["fileName"])) { |
|
| 43 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME); |
|
| 44 | + } |
|
| 45 | + if (!isset($_POST["content"])) { |
|
| 46 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]); |
|
| 50 | - $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 49 | + $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]); |
|
| 50 | + $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 51 | 51 | |
| 52 | - if (!$resourceTypeInfo->checkExtension($fileName)) { |
|
| 53 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 54 | - } |
|
| 52 | + if (!$resourceTypeInfo->checkExtension($fileName)) { |
|
| 53 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) { |
|
| 57 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 58 | - } |
|
| 56 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) { |
|
| 57 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName); |
|
| 60 | + $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName); |
|
| 61 | 61 | |
| 62 | - if (!file_exists($filePath) || !is_file($filePath)) { |
|
| 63 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 64 | - } |
|
| 62 | + if (!file_exists($filePath) || !is_file($filePath)) { |
|
| 63 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - if (!is_writable(dirname($filePath))) { |
|
| 67 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 68 | - } |
|
| 66 | + if (!is_writable(dirname($filePath))) { |
|
| 67 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - $fp = @fopen($filePath, 'wb'); |
|
| 71 | - if ($fp === false || !flock($fp, LOCK_EX)) { |
|
| 72 | - $result = false; |
|
| 73 | - } |
|
| 74 | - else { |
|
| 75 | - $result = fwrite($fp, $_POST["content"]); |
|
| 76 | - flock($fp, LOCK_UN); |
|
| 77 | - fclose($fp); |
|
| 78 | - } |
|
| 79 | - if ($result === false) { |
|
| 80 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 81 | - } |
|
| 82 | - } |
|
| 70 | + $fp = @fopen($filePath, 'wb'); |
|
| 71 | + if ($fp === false || !flock($fp, LOCK_EX)) { |
|
| 72 | + $result = false; |
|
| 73 | + } |
|
| 74 | + else { |
|
| 75 | + $result = fwrite($fp, $_POST["content"]); |
|
| 76 | + flock($fp, LOCK_UN); |
|
| 77 | + fclose($fp); |
|
| 78 | + } |
|
| 79 | + if ($result === false) { |
|
| 80 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @access public |
|
| 86 | - */ |
|
| 87 | - function onBeforeExecuteCommand( &$command ) |
|
| 88 | - { |
|
| 89 | - if ( $command == 'SaveFile' ) |
|
| 90 | - { |
|
| 91 | - $this->sendResponse(); |
|
| 92 | - return false; |
|
| 93 | - } |
|
| 84 | + /** |
|
| 85 | + * @access public |
|
| 86 | + */ |
|
| 87 | + function onBeforeExecuteCommand( &$command ) |
|
| 88 | + { |
|
| 89 | + if ( $command == 'SaveFile' ) |
|
| 90 | + { |
|
| 91 | + $this->sendResponse(); |
|
| 92 | + return false; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - return true ; |
|
| 96 | - } |
|
| 95 | + return true ; |
|
| 96 | + } |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $CommandHandler_FileEditor = new CKFinder_Connector_CommandHandler_FileEditor(); |
@@ -30,65 +30,65 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | protected function buildXml() |
| 32 | 32 | { |
| 33 | - if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 34 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 35 | - } |
|
| 33 | + if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 34 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - if (!extension_loaded('zip')) { |
|
| 38 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_COMMAND); |
|
| 39 | - } |
|
| 37 | + if (!extension_loaded('zip')) { |
|
| 38 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_COMMAND); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $this->checkConnector(); |
|
| 42 | - $this->checkRequest(); |
|
| 41 | + $this->checkConnector(); |
|
| 42 | + $this->checkRequest(); |
|
| 43 | 43 | |
| 44 | - if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) { |
|
| 45 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 46 | - } |
|
| 44 | + if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) { |
|
| 45 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - if (!isset($_POST["fileName"])) { |
|
| 49 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME); |
|
| 50 | - } |
|
| 48 | + if (!isset($_POST["fileName"])) { |
|
| 49 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]); |
|
| 53 | - $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 52 | + $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]); |
|
| 53 | + $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 54 | 54 | |
| 55 | - if (!$resourceTypeInfo->checkExtension($fileName)) { |
|
| 56 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 57 | - } |
|
| 55 | + if (!$resourceTypeInfo->checkExtension($fileName)) { |
|
| 56 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) { |
|
| 60 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 61 | - } |
|
| 59 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) { |
|
| 60 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName); |
|
| 63 | + $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName); |
|
| 64 | 64 | |
| 65 | - if (!file_exists($filePath) || !is_file($filePath)) { |
|
| 66 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 67 | - } |
|
| 65 | + if (!file_exists($filePath) || !is_file($filePath)) { |
|
| 66 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - if (!is_writable(dirname($filePath))) { |
|
| 70 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 71 | - } |
|
| 69 | + if (!is_writable(dirname($filePath))) { |
|
| 70 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if ( strtolower(pathinfo($fileName, PATHINFO_EXTENSION)) !== 'zip'){ |
|
| 74 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 75 | - } |
|
| 73 | + if ( strtolower(pathinfo($fileName, PATHINFO_EXTENSION)) !== 'zip'){ |
|
| 74 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $zip = new ZipArchive(); |
|
| 78 | - $result = $zip->open($filePath); |
|
| 79 | - if ($result !== TRUE) { |
|
| 80 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN); |
|
| 81 | - } |
|
| 82 | - $this->zip = $zip; |
|
| 83 | - $this->filePath = $filePath; |
|
| 84 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 77 | + $zip = new ZipArchive(); |
|
| 78 | + $result = $zip->open($filePath); |
|
| 79 | + if ($result !== TRUE) { |
|
| 80 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN); |
|
| 81 | + } |
|
| 82 | + $this->zip = $zip; |
|
| 83 | + $this->filePath = $filePath; |
|
| 84 | + $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 85 | 85 | |
| 86 | - // list of unzipped nodes |
|
| 87 | - $this->unzippedNodes = new CKFinder_Connector_Utils_XmlNode("UnzippedFiles"); |
|
| 86 | + // list of unzipped nodes |
|
| 87 | + $this->unzippedNodes = new CKFinder_Connector_Utils_XmlNode("UnzippedFiles"); |
|
| 88 | 88 | |
| 89 | - // list of files which could not be unzipped |
|
| 90 | - $this->skippedFilesNode = new CKFinder_Connector_Utils_XmlNode("Errors"); |
|
| 91 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_NONE; |
|
| 89 | + // list of files which could not be unzipped |
|
| 90 | + $this->skippedFilesNode = new CKFinder_Connector_Utils_XmlNode("Errors"); |
|
| 91 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_NONE; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -100,89 +100,89 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function checkOneFile($filePathInfo, $originalFileName ) |
| 102 | 102 | { |
| 103 | - $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 104 | - |
|
| 105 | - // checked if it is a folder |
|
| 106 | - $fileStat = $this->zip->statName($originalFileName); |
|
| 107 | - if ( empty($filePathInfo['extension']) && empty($fileStat['size']) ){ |
|
| 108 | - $sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(rtrim($fileStat['name'],'/')); |
|
| 109 | - if ($this->_config->forceAscii()) { |
|
| 110 | - $sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sNewFolderName); |
|
| 111 | - } |
|
| 112 | - if (!CKFinder_Connector_Utils_FileSystem::checkFolderPath($sNewFolderName) || $resourceTypeInfo->checkIsHiddenFolder($sNewFolderName)) { |
|
| 113 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_NAME; |
|
| 114 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 115 | - return false; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - if (!is_writeable($this->_currentFolder->getServerPath())) { |
|
| 119 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 120 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 121 | - return false; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $originalFileName; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($filePathInfo['basename']); |
|
| 128 | - $sFileName = CKFinder_Connector_Utils_FileSystem::secureFileName($fileName); |
|
| 129 | - |
|
| 130 | - // max file size |
|
| 131 | - $maxSize = $resourceTypeInfo->getMaxSize(); |
|
| 132 | - if ( $maxSize && $fileStat['size'] > $maxSize ) |
|
| 133 | - { |
|
| 134 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
|
| 135 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 136 | - return false; |
|
| 137 | - } |
|
| 138 | - // extension |
|
| 139 | - if ( !$resourceTypeInfo->checkExtension($sFileName) ) |
|
| 140 | - { |
|
| 141 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 142 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 143 | - return false; |
|
| 144 | - } |
|
| 145 | - // hidden file |
|
| 146 | - if ( !CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $resourceTypeInfo->checkIsHiddenFile($sFileName) ){ |
|
| 147 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST; |
|
| 148 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 149 | - return false; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // unpack file to tmp dir for detecting html and valid image |
|
| 153 | - $dir = CKFinder_Connector_Utils_FileSystem::getTmpDir().'/'; |
|
| 154 | - if ( file_exists($dir.$sFileName) && !CKFinder_Connector_Utils_FileSystem::unlink($dir.$sFileName) ){ |
|
| 155 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST; |
|
| 156 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 157 | - return false; |
|
| 158 | - } |
|
| 159 | - if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $dir.$sFileName) ) |
|
| 160 | - { |
|
| 161 | - // html extensions |
|
| 162 | - $htmlExtensions = $this->_config->getHtmlExtensions(); |
|
| 163 | - $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension( $dir.$sFileName ); |
|
| 164 | - if ( $htmlExtensions |
|
| 165 | - && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive( $sExtension, $htmlExtensions ) |
|
| 166 | - && CKFinder_Connector_Utils_FileSystem::detectHtml($dir.$sFileName) === true ) |
|
| 167 | - { |
|
| 168 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID; |
|
| 169 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - // proper image |
|
| 174 | - $secureImageUploads = $this->_config->getSecureImageUploads(); |
|
| 175 | - if ( $secureImageUploads |
|
| 176 | - && ( $isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($dir.$sFileName, $sExtension) ) === false ) |
|
| 177 | - { |
|
| 178 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID; |
|
| 179 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 180 | - return false; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $sDirName = ($filePathInfo['dirname'] != '.')? $filePathInfo['dirname'].'/' : ''; |
|
| 184 | - |
|
| 185 | - return $sDirName.$sFileName; |
|
| 103 | + $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 104 | + |
|
| 105 | + // checked if it is a folder |
|
| 106 | + $fileStat = $this->zip->statName($originalFileName); |
|
| 107 | + if ( empty($filePathInfo['extension']) && empty($fileStat['size']) ){ |
|
| 108 | + $sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(rtrim($fileStat['name'],'/')); |
|
| 109 | + if ($this->_config->forceAscii()) { |
|
| 110 | + $sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sNewFolderName); |
|
| 111 | + } |
|
| 112 | + if (!CKFinder_Connector_Utils_FileSystem::checkFolderPath($sNewFolderName) || $resourceTypeInfo->checkIsHiddenFolder($sNewFolderName)) { |
|
| 113 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_NAME; |
|
| 114 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 115 | + return false; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + if (!is_writeable($this->_currentFolder->getServerPath())) { |
|
| 119 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 120 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 121 | + return false; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $originalFileName; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($filePathInfo['basename']); |
|
| 128 | + $sFileName = CKFinder_Connector_Utils_FileSystem::secureFileName($fileName); |
|
| 129 | + |
|
| 130 | + // max file size |
|
| 131 | + $maxSize = $resourceTypeInfo->getMaxSize(); |
|
| 132 | + if ( $maxSize && $fileStat['size'] > $maxSize ) |
|
| 133 | + { |
|
| 134 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
|
| 135 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 136 | + return false; |
|
| 137 | + } |
|
| 138 | + // extension |
|
| 139 | + if ( !$resourceTypeInfo->checkExtension($sFileName) ) |
|
| 140 | + { |
|
| 141 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 142 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 145 | + // hidden file |
|
| 146 | + if ( !CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $resourceTypeInfo->checkIsHiddenFile($sFileName) ){ |
|
| 147 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST; |
|
| 148 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 149 | + return false; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // unpack file to tmp dir for detecting html and valid image |
|
| 153 | + $dir = CKFinder_Connector_Utils_FileSystem::getTmpDir().'/'; |
|
| 154 | + if ( file_exists($dir.$sFileName) && !CKFinder_Connector_Utils_FileSystem::unlink($dir.$sFileName) ){ |
|
| 155 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST; |
|
| 156 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 157 | + return false; |
|
| 158 | + } |
|
| 159 | + if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $dir.$sFileName) ) |
|
| 160 | + { |
|
| 161 | + // html extensions |
|
| 162 | + $htmlExtensions = $this->_config->getHtmlExtensions(); |
|
| 163 | + $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension( $dir.$sFileName ); |
|
| 164 | + if ( $htmlExtensions |
|
| 165 | + && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive( $sExtension, $htmlExtensions ) |
|
| 166 | + && CKFinder_Connector_Utils_FileSystem::detectHtml($dir.$sFileName) === true ) |
|
| 167 | + { |
|
| 168 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID; |
|
| 169 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + // proper image |
|
| 174 | + $secureImageUploads = $this->_config->getSecureImageUploads(); |
|
| 175 | + if ( $secureImageUploads |
|
| 176 | + && ( $isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($dir.$sFileName, $sExtension) ) === false ) |
|
| 177 | + { |
|
| 178 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID; |
|
| 179 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 180 | + return false; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $sDirName = ($filePathInfo['dirname'] != '.')? $filePathInfo['dirname'].'/' : ''; |
|
| 184 | + |
|
| 185 | + return $sDirName.$sFileName; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -195,16 +195,16 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | protected function appendErrorNode($oErrorsNode, $errorCode=0, $name, $type=null, $path=null) |
| 197 | 197 | { |
| 198 | - $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
|
| 199 | - $oErrorNode->addAttribute("code", $errorCode); |
|
| 200 | - $oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 201 | - if ( $type ){ |
|
| 202 | - $oErrorNode->addAttribute("type", $type); |
|
| 203 | - } |
|
| 204 | - if ( $path ){ |
|
| 205 | - $oErrorNode->addAttribute("folder", $path); |
|
| 206 | - } |
|
| 207 | - $oErrorsNode->addChild($oErrorNode); |
|
| 198 | + $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
|
| 199 | + $oErrorNode->addAttribute("code", $errorCode); |
|
| 200 | + $oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 201 | + if ( $type ){ |
|
| 202 | + $oErrorNode->addAttribute("type", $type); |
|
| 203 | + } |
|
| 204 | + if ( $path ){ |
|
| 205 | + $oErrorNode->addAttribute("folder", $path); |
|
| 206 | + } |
|
| 207 | + $oErrorsNode->addChild($oErrorNode); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | protected function appendUnzippedNode($oUnzippedNodes, $name, $action='ok') |
| 217 | 217 | { |
| 218 | - $oUnzippedNode = new CKFinder_Connector_Utils_XmlNode("File"); |
|
| 219 | - $oUnzippedNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 220 | - $oUnzippedNode->addAttribute("action", $action ); |
|
| 221 | - $oUnzippedNodes->addChild($oUnzippedNode); |
|
| 218 | + $oUnzippedNode = new CKFinder_Connector_Utils_XmlNode("File"); |
|
| 219 | + $oUnzippedNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 220 | + $oUnzippedNode->addAttribute("action", $action ); |
|
| 221 | + $oUnzippedNodes->addChild($oUnzippedNode); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -232,72 +232,72 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | protected function extractTo($extractPath, $extractClientPath, $filePathInfo, $sFileName, $originalFileName) |
| 234 | 234 | { |
| 235 | - $sfilePathInfo = pathinfo($extractPath.$sFileName); |
|
| 236 | - $extractClientPathDir = $filePathInfo['dirname']; |
|
| 237 | - if ( $filePathInfo['dirname'] == '.' ){ |
|
| 238 | - $extractClientPathDir = ''; |
|
| 239 | - } |
|
| 240 | - $folderPath = CKFinder_Connector_Utils_FileSystem::combinePaths($extractClientPath,$extractClientPathDir); |
|
| 241 | - |
|
| 242 | - $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 243 | - $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$folderPath); |
|
| 244 | - $canCreateFolder = (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ); |
|
| 245 | - // create sub-directory of zip archive |
|
| 246 | - if ( empty($sfilePathInfo['extension']) ) |
|
| 247 | - { |
|
| 248 | - $fileStat = $this->zip->statName($originalFileName); |
|
| 249 | - $isDir = false; |
|
| 250 | - if ( $fileStat && empty($fileStat['size']) ){ |
|
| 251 | - $isDir = true; |
|
| 252 | - } |
|
| 253 | - if( !empty($sfilePathInfo['dirname']) && !empty($sfilePathInfo['basename']) && !file_exists($sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename']) ) |
|
| 254 | - { |
|
| 255 | - if ( !$canCreateFolder ){ |
|
| 256 | - return; |
|
| 257 | - } |
|
| 258 | - if ( $isDir ) { |
|
| 259 | - CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename'] ); |
|
| 260 | - return; |
|
| 261 | - } else { |
|
| 262 | - CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname']); |
|
| 263 | - } |
|
| 264 | - } else { |
|
| 265 | - return; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - // extract file |
|
| 270 | - if ( !file_exists($sfilePathInfo['dirname']) ){ |
|
| 271 | - if ( !$canCreateFolder ){ |
|
| 272 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED; |
|
| 273 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName ); |
|
| 274 | - return; |
|
| 275 | - } |
|
| 276 | - CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($sfilePathInfo['dirname']); |
|
| 277 | - } |
|
| 278 | - $isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ); |
|
| 279 | - if ( !$isAuthorized ){ |
|
| 280 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED; |
|
| 281 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 282 | - return; |
|
| 283 | - } |
|
| 284 | - if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $extractPath.$sFileName) ) |
|
| 285 | - { |
|
| 286 | - $this->appendUnzippedNode($this->unzippedNodes,$originalFileName); |
|
| 287 | - // chmod extracted file |
|
| 288 | - if ( is_file($extractPath.$sFileName) && ( $perms = $this->_config->getChmodFiles()) ) |
|
| 289 | - { |
|
| 290 | - $oldumask = umask(0); |
|
| 291 | - chmod( $extractPath.$sFileName, $perms ); |
|
| 292 | - umask( $oldumask ); |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - // file extraction failed, add to skipped |
|
| 296 | - else |
|
| 297 | - { |
|
| 298 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED; |
|
| 299 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 300 | - } |
|
| 235 | + $sfilePathInfo = pathinfo($extractPath.$sFileName); |
|
| 236 | + $extractClientPathDir = $filePathInfo['dirname']; |
|
| 237 | + if ( $filePathInfo['dirname'] == '.' ){ |
|
| 238 | + $extractClientPathDir = ''; |
|
| 239 | + } |
|
| 240 | + $folderPath = CKFinder_Connector_Utils_FileSystem::combinePaths($extractClientPath,$extractClientPathDir); |
|
| 241 | + |
|
| 242 | + $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 243 | + $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$folderPath); |
|
| 244 | + $canCreateFolder = (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ); |
|
| 245 | + // create sub-directory of zip archive |
|
| 246 | + if ( empty($sfilePathInfo['extension']) ) |
|
| 247 | + { |
|
| 248 | + $fileStat = $this->zip->statName($originalFileName); |
|
| 249 | + $isDir = false; |
|
| 250 | + if ( $fileStat && empty($fileStat['size']) ){ |
|
| 251 | + $isDir = true; |
|
| 252 | + } |
|
| 253 | + if( !empty($sfilePathInfo['dirname']) && !empty($sfilePathInfo['basename']) && !file_exists($sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename']) ) |
|
| 254 | + { |
|
| 255 | + if ( !$canCreateFolder ){ |
|
| 256 | + return; |
|
| 257 | + } |
|
| 258 | + if ( $isDir ) { |
|
| 259 | + CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename'] ); |
|
| 260 | + return; |
|
| 261 | + } else { |
|
| 262 | + CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname']); |
|
| 263 | + } |
|
| 264 | + } else { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + // extract file |
|
| 270 | + if ( !file_exists($sfilePathInfo['dirname']) ){ |
|
| 271 | + if ( !$canCreateFolder ){ |
|
| 272 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED; |
|
| 273 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName ); |
|
| 274 | + return; |
|
| 275 | + } |
|
| 276 | + CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($sfilePathInfo['dirname']); |
|
| 277 | + } |
|
| 278 | + $isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ); |
|
| 279 | + if ( !$isAuthorized ){ |
|
| 280 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED; |
|
| 281 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 282 | + return; |
|
| 283 | + } |
|
| 284 | + if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $extractPath.$sFileName) ) |
|
| 285 | + { |
|
| 286 | + $this->appendUnzippedNode($this->unzippedNodes,$originalFileName); |
|
| 287 | + // chmod extracted file |
|
| 288 | + if ( is_file($extractPath.$sFileName) && ( $perms = $this->_config->getChmodFiles()) ) |
|
| 289 | + { |
|
| 290 | + $oldumask = umask(0); |
|
| 291 | + chmod( $extractPath.$sFileName, $perms ); |
|
| 292 | + umask( $oldumask ); |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + // file extraction failed, add to skipped |
|
| 296 | + else |
|
| 297 | + { |
|
| 298 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED; |
|
| 299 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName); |
|
| 300 | + } |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | } // end of CKFinder_Connector_CommandHandler_Unzip class |
@@ -309,111 +309,111 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | protected function buildXml() |
| 311 | 311 | { |
| 312 | - parent::buildXml(); |
|
| 312 | + parent::buildXml(); |
|
| 313 | 313 | |
| 314 | 314 | $checkedFiles = array(); |
| 315 | 315 | if ( !empty($_POST['files']) && is_array($_POST['files']) ){ |
| 316 | - foreach ( $_POST['files'] as $file){ |
|
| 317 | - $checkedFiles[$file['name']] = $file; |
|
| 318 | - } |
|
| 316 | + foreach ( $_POST['files'] as $file){ |
|
| 317 | + $checkedFiles[$file['name']] = $file; |
|
| 318 | + } |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | for ($i = 0; $i < $this->zip->numFiles; $i++) |
| 322 | - { |
|
| 323 | - $fileName = $this->zip->getNameIndex($i); |
|
| 324 | - if ( !empty($checkedFiles[$fileName]) && $checkedFiles[$fileName]['options'] == 'ok' ) |
|
| 325 | - { |
|
| 326 | - // file was sucessfully unzipped before |
|
| 327 | - $this->appendUnzippedNode($this->unzippedNodes,$fileName); |
|
| 328 | - continue; |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - $filePathInfo = pathinfo($fileName); |
|
| 332 | - $fileType = 'File'; |
|
| 333 | - $fileStat = $this->zip->statName($i); |
|
| 334 | - if ( empty($filePathInfo['extension']) && empty($fileStat['size']) ){ |
|
| 335 | - $fileType = 'Folder'; |
|
| 336 | - // check if we can create subfolder |
|
| 337 | - if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) ){ |
|
| 338 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED; |
|
| 339 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 340 | - continue; |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - $extractPath = $this->_currentFolder->getServerPath(); |
|
| 344 | - $extractClientPath = $this->_currentFolder->getClientPath(); |
|
| 345 | - |
|
| 346 | - $sFileName = $this->checkOneFile( $filePathInfo, $fileName ); |
|
| 347 | - // security test failed, add to skipped |
|
| 348 | - if ( false !== $sFileName ) |
|
| 349 | - { |
|
| 350 | - if ( file_exists($extractPath.$sFileName) ) |
|
| 351 | - { |
|
| 352 | - if ( !is_dir($extractPath.$sFileName) ) |
|
| 353 | - { |
|
| 354 | - // file was checked before |
|
| 355 | - if ( !empty($checkedFiles[$fileName]['options']) ) |
|
| 356 | - { |
|
| 357 | - if ( $checkedFiles[$fileName]['options'] == 'autorename') |
|
| 358 | - { |
|
| 359 | - $sFileName = CKFinder_Connector_Utils_FileSystem::autoRename($extractPath,$sFileName); |
|
| 360 | - $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 361 | - } |
|
| 362 | - elseif ( $checkedFiles[$fileName]['options'] == 'overwrite') |
|
| 363 | - { |
|
| 364 | - if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FILE_DELETE ) ){ |
|
| 365 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED; |
|
| 366 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 367 | - continue; |
|
| 368 | - } |
|
| 369 | - if (!CKFinder_Connector_Utils_FileSystem::unlink($extractPath.$sFileName)) |
|
| 370 | - { |
|
| 371 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 372 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 373 | - } |
|
| 374 | - else |
|
| 375 | - { |
|
| 376 | - $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - else |
|
| 380 | - { |
|
| 381 | - // add to skipped files |
|
| 382 | - $this->appendUnzippedNode($this->unzippedNodes,$fileName,'skip'); |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - else |
|
| 386 | - { |
|
| 387 | - $this->errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
|
| 388 | - $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - // file doesn't exist yet |
|
| 393 | - else |
|
| 394 | - { |
|
| 395 | - $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - $this->zip->close(); |
|
| 400 | - |
|
| 401 | - $this->_connectorNode->addChild($this->unzippedNodes); |
|
| 402 | - |
|
| 403 | - if ($this->errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 404 | - $this->_connectorNode->addChild($this->skippedFilesNode); |
|
| 405 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ZIP_FAILED); |
|
| 406 | - } |
|
| 322 | + { |
|
| 323 | + $fileName = $this->zip->getNameIndex($i); |
|
| 324 | + if ( !empty($checkedFiles[$fileName]) && $checkedFiles[$fileName]['options'] == 'ok' ) |
|
| 325 | + { |
|
| 326 | + // file was sucessfully unzipped before |
|
| 327 | + $this->appendUnzippedNode($this->unzippedNodes,$fileName); |
|
| 328 | + continue; |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + $filePathInfo = pathinfo($fileName); |
|
| 332 | + $fileType = 'File'; |
|
| 333 | + $fileStat = $this->zip->statName($i); |
|
| 334 | + if ( empty($filePathInfo['extension']) && empty($fileStat['size']) ){ |
|
| 335 | + $fileType = 'Folder'; |
|
| 336 | + // check if we can create subfolder |
|
| 337 | + if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) ){ |
|
| 338 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED; |
|
| 339 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 340 | + continue; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + $extractPath = $this->_currentFolder->getServerPath(); |
|
| 344 | + $extractClientPath = $this->_currentFolder->getClientPath(); |
|
| 345 | + |
|
| 346 | + $sFileName = $this->checkOneFile( $filePathInfo, $fileName ); |
|
| 347 | + // security test failed, add to skipped |
|
| 348 | + if ( false !== $sFileName ) |
|
| 349 | + { |
|
| 350 | + if ( file_exists($extractPath.$sFileName) ) |
|
| 351 | + { |
|
| 352 | + if ( !is_dir($extractPath.$sFileName) ) |
|
| 353 | + { |
|
| 354 | + // file was checked before |
|
| 355 | + if ( !empty($checkedFiles[$fileName]['options']) ) |
|
| 356 | + { |
|
| 357 | + if ( $checkedFiles[$fileName]['options'] == 'autorename') |
|
| 358 | + { |
|
| 359 | + $sFileName = CKFinder_Connector_Utils_FileSystem::autoRename($extractPath,$sFileName); |
|
| 360 | + $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 361 | + } |
|
| 362 | + elseif ( $checkedFiles[$fileName]['options'] == 'overwrite') |
|
| 363 | + { |
|
| 364 | + if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FILE_DELETE ) ){ |
|
| 365 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED; |
|
| 366 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 367 | + continue; |
|
| 368 | + } |
|
| 369 | + if (!CKFinder_Connector_Utils_FileSystem::unlink($extractPath.$sFileName)) |
|
| 370 | + { |
|
| 371 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 372 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 373 | + } |
|
| 374 | + else |
|
| 375 | + { |
|
| 376 | + $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + else |
|
| 380 | + { |
|
| 381 | + // add to skipped files |
|
| 382 | + $this->appendUnzippedNode($this->unzippedNodes,$fileName,'skip'); |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + else |
|
| 386 | + { |
|
| 387 | + $this->errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
|
| 388 | + $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType); |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + // file doesn't exist yet |
|
| 393 | + else |
|
| 394 | + { |
|
| 395 | + $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + $this->zip->close(); |
|
| 400 | + |
|
| 401 | + $this->_connectorNode->addChild($this->unzippedNodes); |
|
| 402 | + |
|
| 403 | + if ($this->errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 404 | + $this->_connectorNode->addChild($this->skippedFilesNode); |
|
| 405 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ZIP_FAILED); |
|
| 406 | + } |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | public function onBeforeExecuteCommand( &$command ) |
| 410 | 410 | { |
| 411 | - if ( $command == 'ExtractHere' ) |
|
| 412 | - { |
|
| 413 | - $this->sendResponse(); |
|
| 414 | - return false; |
|
| 415 | - } |
|
| 416 | - return true ; |
|
| 411 | + if ( $command == 'ExtractHere' ) |
|
| 412 | + { |
|
| 413 | + $this->sendResponse(); |
|
| 414 | + return false; |
|
| 415 | + } |
|
| 416 | + return true ; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | } // end of CKFinder_Connector_CommandHandler_UnzipHere class |
@@ -425,82 +425,82 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | protected function buildXml() |
| 427 | 427 | { |
| 428 | - parent::buildXml(); |
|
| 429 | - |
|
| 430 | - $extractDir = ( !empty($_POST['extractDir']) ) ? ltrim($_POST['extractDir'],'/') : ''; |
|
| 431 | - $extractDir = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($extractDir); |
|
| 432 | - if ( preg_match(CKFINDER_REGEX_INVALID_PATH, $extractDir) ){ |
|
| 433 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 434 | - } |
|
| 435 | - $extractPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $extractDir.'/'); |
|
| 436 | - $extractClientPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getClientPath(),$extractDir); |
|
| 437 | - // acl for upload dir |
|
| 438 | - $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 439 | - $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$extractDir); |
|
| 440 | - |
|
| 441 | - if ( !(($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) ){ |
|
| 442 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 443 | - } |
|
| 444 | - if ( empty( $_POST['force']) && file_exists($extractPath) && is_dir($extractPath) && !CKFinder_Connector_Utils_FileSystem::isEmptyDir($extractPath) ) |
|
| 445 | - { |
|
| 446 | - $dirExists = new CKFinder_Connector_Utils_XmlNode("FolderExists"); |
|
| 447 | - $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Folder"); |
|
| 448 | - $oErrorNode->addAttribute("name", $extractDir); |
|
| 449 | - $dirExists->addChild($oErrorNode); |
|
| 450 | - $this->_connectorNode->addChild($dirExists); |
|
| 451 | - return; |
|
| 452 | - } |
|
| 453 | - elseif ( !empty( $_POST['force']) && $_POST['force'] =='overwrite' ) |
|
| 454 | - { |
|
| 455 | - if ( !(($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE ) ){ |
|
| 456 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 457 | - } |
|
| 458 | - if ( $extractDir && file_exists($extractPath) && is_dir($extractPath) ) |
|
| 459 | - { |
|
| 460 | - if ( !(($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE | CKFINDER_CONNECTOR_ACL_FOLDER_DELETE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE | CKFINDER_CONNECTOR_ACL_FOLDER_DELETE ) ){ |
|
| 461 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 462 | - } |
|
| 463 | - if (!CKFinder_Connector_Utils_FileSystem::unlink($extractPath)) |
|
| 464 | - { |
|
| 465 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - else if ( !empty( $_POST['force']) && $_POST['force'] !== 'merge' ) |
|
| 470 | - { |
|
| 471 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - for ($i = 0; $i < $this->zip->numFiles; $i++) |
|
| 475 | - { |
|
| 476 | - $fileName = $this->zip->getNameIndex($i); |
|
| 477 | - $filePathInfo = pathinfo($fileName); |
|
| 478 | - |
|
| 479 | - $sFileName = $this->checkOneFile( $filePathInfo, $fileName ); |
|
| 480 | - // security test failed, add to skipped |
|
| 481 | - if ( $sFileName ) |
|
| 482 | - { |
|
| 483 | - $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 484 | - } |
|
| 485 | - } |
|
| 486 | - $this->zip->close(); |
|
| 487 | - |
|
| 488 | - |
|
| 489 | - $this->_connectorNode->addChild($this->unzippedNodes); |
|
| 490 | - |
|
| 491 | - if ($this->errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 492 | - $this->_connectorNode->addChild($this->skippedFilesNode); |
|
| 493 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ZIP_FAILED); |
|
| 494 | - } |
|
| 428 | + parent::buildXml(); |
|
| 429 | + |
|
| 430 | + $extractDir = ( !empty($_POST['extractDir']) ) ? ltrim($_POST['extractDir'],'/') : ''; |
|
| 431 | + $extractDir = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($extractDir); |
|
| 432 | + if ( preg_match(CKFINDER_REGEX_INVALID_PATH, $extractDir) ){ |
|
| 433 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 434 | + } |
|
| 435 | + $extractPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $extractDir.'/'); |
|
| 436 | + $extractClientPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getClientPath(),$extractDir); |
|
| 437 | + // acl for upload dir |
|
| 438 | + $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 439 | + $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$extractDir); |
|
| 440 | + |
|
| 441 | + if ( !(($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) ){ |
|
| 442 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 443 | + } |
|
| 444 | + if ( empty( $_POST['force']) && file_exists($extractPath) && is_dir($extractPath) && !CKFinder_Connector_Utils_FileSystem::isEmptyDir($extractPath) ) |
|
| 445 | + { |
|
| 446 | + $dirExists = new CKFinder_Connector_Utils_XmlNode("FolderExists"); |
|
| 447 | + $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Folder"); |
|
| 448 | + $oErrorNode->addAttribute("name", $extractDir); |
|
| 449 | + $dirExists->addChild($oErrorNode); |
|
| 450 | + $this->_connectorNode->addChild($dirExists); |
|
| 451 | + return; |
|
| 452 | + } |
|
| 453 | + elseif ( !empty( $_POST['force']) && $_POST['force'] =='overwrite' ) |
|
| 454 | + { |
|
| 455 | + if ( !(($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE ) ){ |
|
| 456 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 457 | + } |
|
| 458 | + if ( $extractDir && file_exists($extractPath) && is_dir($extractPath) ) |
|
| 459 | + { |
|
| 460 | + if ( !(($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE | CKFINDER_CONNECTOR_ACL_FOLDER_DELETE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE | CKFINDER_CONNECTOR_ACL_FOLDER_DELETE ) ){ |
|
| 461 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 462 | + } |
|
| 463 | + if (!CKFinder_Connector_Utils_FileSystem::unlink($extractPath)) |
|
| 464 | + { |
|
| 465 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + else if ( !empty( $_POST['force']) && $_POST['force'] !== 'merge' ) |
|
| 470 | + { |
|
| 471 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + for ($i = 0; $i < $this->zip->numFiles; $i++) |
|
| 475 | + { |
|
| 476 | + $fileName = $this->zip->getNameIndex($i); |
|
| 477 | + $filePathInfo = pathinfo($fileName); |
|
| 478 | + |
|
| 479 | + $sFileName = $this->checkOneFile( $filePathInfo, $fileName ); |
|
| 480 | + // security test failed, add to skipped |
|
| 481 | + if ( $sFileName ) |
|
| 482 | + { |
|
| 483 | + $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName); |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + $this->zip->close(); |
|
| 487 | + |
|
| 488 | + |
|
| 489 | + $this->_connectorNode->addChild($this->unzippedNodes); |
|
| 490 | + |
|
| 491 | + if ($this->errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 492 | + $this->_connectorNode->addChild($this->skippedFilesNode); |
|
| 493 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ZIP_FAILED); |
|
| 494 | + } |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | public function onBeforeExecuteCommand( &$command ) |
| 498 | 498 | { |
| 499 | - if ( $command == 'ExtractTo'){ |
|
| 500 | - $this->sendResponse(); |
|
| 501 | - return false; |
|
| 502 | - } |
|
| 503 | - return true ; |
|
| 499 | + if ( $command == 'ExtractTo'){ |
|
| 500 | + $this->sendResponse(); |
|
| 501 | + return false; |
|
| 502 | + } |
|
| 503 | + return true ; |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | } // end of CKFinder_Connector_CommandHandler_UnzipTo class |
@@ -517,14 +517,14 @@ discard block |
||
| 517 | 517 | * @return array |
| 518 | 518 | */ |
| 519 | 519 | protected function getConfig(){ |
| 520 | - $config = array(); |
|
| 520 | + $config = array(); |
|
| 521 | 521 | |
| 522 | - $config['zipMaxSize'] = 'default'; |
|
| 523 | - if (isset($GLOBALS['config']['ZipMaxSize']) && (string)$GLOBALS['config']['ZipMaxSize']!='default' ){ |
|
| 524 | - $config['zipMaxSize'] = CKFinder_Connector_Utils_Misc::returnBytes((string)$GLOBALS['config']['ZipMaxSize']); |
|
| 525 | - } |
|
| 522 | + $config['zipMaxSize'] = 'default'; |
|
| 523 | + if (isset($GLOBALS['config']['ZipMaxSize']) && (string)$GLOBALS['config']['ZipMaxSize']!='default' ){ |
|
| 524 | + $config['zipMaxSize'] = CKFinder_Connector_Utils_Misc::returnBytes((string)$GLOBALS['config']['ZipMaxSize']); |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - return $config; |
|
| 527 | + return $config; |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | /** |
@@ -536,44 +536,44 @@ discard block |
||
| 536 | 536 | */ |
| 537 | 537 | protected function checkOneFile($file) |
| 538 | 538 | { |
| 539 | - $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 540 | - $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 541 | - $directory = str_replace('\\','/', $resourceTypeInfo->getDirectory()); |
|
| 542 | - $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($file->getFilename()); |
|
| 543 | - |
|
| 544 | - if ($this->_config->forceAscii()) { |
|
| 545 | - $fileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($fileName); |
|
| 546 | - } |
|
| 547 | - $pathName = str_replace('\\','/', pathinfo($file->getPathname(), PATHINFO_DIRNAME) ); |
|
| 548 | - $pathName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($pathName); |
|
| 549 | - |
|
| 550 | - // acl |
|
| 551 | - $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(), str_ireplace($directory,'',$pathName)); |
|
| 552 | - $isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 553 | - if ( !$isAuthorized ){ |
|
| 554 | - return false; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - // if it is a folder fileName represents the dir |
|
| 558 | - if ( $file->isDir() && ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($fileName) || $resourceTypeInfo->checkIsHiddenPath($fileName) ) ){ |
|
| 559 | - return false; |
|
| 560 | - } |
|
| 561 | - // folder name |
|
| 562 | - if ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($pathName) ){ |
|
| 563 | - return false; |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - // is hidden |
|
| 567 | - if ( $resourceTypeInfo->checkIsHiddenPath($pathName) || $resourceTypeInfo->checkIsHiddenFile($fileName) ){ |
|
| 568 | - return false; |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - // extension |
|
| 572 | - if ( !$resourceTypeInfo->checkExtension($fileName) || !CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) ){ |
|
| 573 | - return false; |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - return true; |
|
| 539 | + $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 540 | + $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 541 | + $directory = str_replace('\\','/', $resourceTypeInfo->getDirectory()); |
|
| 542 | + $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($file->getFilename()); |
|
| 543 | + |
|
| 544 | + if ($this->_config->forceAscii()) { |
|
| 545 | + $fileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($fileName); |
|
| 546 | + } |
|
| 547 | + $pathName = str_replace('\\','/', pathinfo($file->getPathname(), PATHINFO_DIRNAME) ); |
|
| 548 | + $pathName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($pathName); |
|
| 549 | + |
|
| 550 | + // acl |
|
| 551 | + $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(), str_ireplace($directory,'',$pathName)); |
|
| 552 | + $isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 553 | + if ( !$isAuthorized ){ |
|
| 554 | + return false; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + // if it is a folder fileName represents the dir |
|
| 558 | + if ( $file->isDir() && ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($fileName) || $resourceTypeInfo->checkIsHiddenPath($fileName) ) ){ |
|
| 559 | + return false; |
|
| 560 | + } |
|
| 561 | + // folder name |
|
| 562 | + if ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($pathName) ){ |
|
| 563 | + return false; |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + // is hidden |
|
| 567 | + if ( $resourceTypeInfo->checkIsHiddenPath($pathName) || $resourceTypeInfo->checkIsHiddenFile($fileName) ){ |
|
| 568 | + return false; |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + // extension |
|
| 572 | + if ( !$resourceTypeInfo->checkExtension($fileName) || !CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) ){ |
|
| 573 | + return false; |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + return true; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /** |
@@ -585,36 +585,36 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | protected function getFilesRecursively( $directory, $zipMaxSize ) |
| 587 | 587 | { |
| 588 | - $allFiles = array(); |
|
| 589 | - $_zipFilesSize = 0; |
|
| 590 | - $serverPath = str_replace('\\','/',$directory); |
|
| 591 | - |
|
| 592 | - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST) as $file ) { |
|
| 593 | - if ( !$this->checkOneFile($file) ){ |
|
| 594 | - continue; |
|
| 595 | - } |
|
| 596 | - if ( !empty($zipMaxSize) ){ |
|
| 597 | - clearstatcache(); |
|
| 598 | - $_zipFilesSize += $file->getSize(); |
|
| 599 | - if ( $_zipFilesSize > $zipMaxSize ) { |
|
| 600 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CREATED_FILE_TOO_BIG); |
|
| 601 | - } |
|
| 602 | - } |
|
| 603 | - $pathName = str_replace('\\','/',$file->getPathname()); |
|
| 604 | - if ( $file->isDir() ){ |
|
| 605 | - // skip dot folders on unix systems ( do not try to use isDot() as $file is not a DirectoryIterator obj ) |
|
| 606 | - if ( in_array($file->getFilename(),array('..','.')) ){ |
|
| 607 | - continue; |
|
| 608 | - } |
|
| 609 | - if ($pathName != rtrim($serverPath,'/')){ |
|
| 610 | - $allFiles[ ltrim(str_ireplace(rtrim($serverPath,'/'),'',$pathName),'/') ] = ''; |
|
| 611 | - } |
|
| 612 | - } else { |
|
| 613 | - $allFiles[$pathName] = str_ireplace($serverPath,'',$pathName); |
|
| 614 | - } |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - return $allFiles; |
|
| 588 | + $allFiles = array(); |
|
| 589 | + $_zipFilesSize = 0; |
|
| 590 | + $serverPath = str_replace('\\','/',$directory); |
|
| 591 | + |
|
| 592 | + foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST) as $file ) { |
|
| 593 | + if ( !$this->checkOneFile($file) ){ |
|
| 594 | + continue; |
|
| 595 | + } |
|
| 596 | + if ( !empty($zipMaxSize) ){ |
|
| 597 | + clearstatcache(); |
|
| 598 | + $_zipFilesSize += $file->getSize(); |
|
| 599 | + if ( $_zipFilesSize > $zipMaxSize ) { |
|
| 600 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CREATED_FILE_TOO_BIG); |
|
| 601 | + } |
|
| 602 | + } |
|
| 603 | + $pathName = str_replace('\\','/',$file->getPathname()); |
|
| 604 | + if ( $file->isDir() ){ |
|
| 605 | + // skip dot folders on unix systems ( do not try to use isDot() as $file is not a DirectoryIterator obj ) |
|
| 606 | + if ( in_array($file->getFilename(),array('..','.')) ){ |
|
| 607 | + continue; |
|
| 608 | + } |
|
| 609 | + if ($pathName != rtrim($serverPath,'/')){ |
|
| 610 | + $allFiles[ ltrim(str_ireplace(rtrim($serverPath,'/'),'',$pathName),'/') ] = ''; |
|
| 611 | + } |
|
| 612 | + } else { |
|
| 613 | + $allFiles[$pathName] = str_ireplace($serverPath,'',$pathName); |
|
| 614 | + } |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + return $allFiles; |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
@@ -622,229 +622,229 @@ discard block |
||
| 622 | 622 | */ |
| 623 | 623 | public function buildXml() |
| 624 | 624 | { |
| 625 | - if (!extension_loaded('zip')) { |
|
| 626 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_COMMAND); |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - $this->checkConnector(); |
|
| 630 | - $this->checkRequest(); |
|
| 631 | - |
|
| 632 | - if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) { |
|
| 633 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 637 | - $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
|
| 638 | - $_sServerDir = $this->_currentFolder->getServerPath(); |
|
| 639 | - |
|
| 640 | - $files = array(); |
|
| 641 | - |
|
| 642 | - $_zipFilesSize = 0; |
|
| 643 | - $config = $this->getConfig(); |
|
| 644 | - $zipMaxSize = $config['zipMaxSize']; |
|
| 645 | - if ( !empty($zipMaxSize) && $zipMaxSize == 'default' ){ |
|
| 646 | - $zipMaxSize = $currentResourceTypeConfig->getMaxSize(); |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - $_isBasket = ( isset($_POST['basket']) && $_POST['basket'] == 'true' )? true : false; |
|
| 650 | - |
|
| 651 | - if ( !empty($_POST['files'])) |
|
| 652 | - { |
|
| 653 | - |
|
| 654 | - $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 655 | - $aclMasks = array(); |
|
| 656 | - $_resourceTypeConfig = array(); |
|
| 657 | - |
|
| 658 | - foreach ( $_POST['files'] as $arr ){ |
|
| 659 | - if ( empty($arr['name']) || empty($arr['type']) || empty($arr['folder']) ) { |
|
| 660 | - continue; |
|
| 661 | - } |
|
| 662 | - // file name |
|
| 663 | - $name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']); |
|
| 664 | - // resource type |
|
| 665 | - $type = $arr['type']; |
|
| 666 | - // client path |
|
| 667 | - $path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']); |
|
| 668 | - |
|
| 669 | - // check #1 (path) |
|
| 670 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) { |
|
| 671 | - continue; |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - // get resource type config for current file |
|
| 675 | - if (!isset($_resourceTypeConfig[$type])) { |
|
| 676 | - $_resourceTypeConfig[$type] = $this->_config->getResourceTypeConfig($type); |
|
| 677 | - } |
|
| 678 | - |
|
| 679 | - // check #2 (resource type) |
|
| 680 | - if (is_null($_resourceTypeConfig[$type])) { |
|
| 681 | - continue; |
|
| 682 | - } |
|
| 683 | - |
|
| 684 | - // check #3 (extension) |
|
| 685 | - if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) { |
|
| 686 | - continue; |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - // check #4 (extension) - when moving to another resource type, double check extension |
|
| 690 | - if ($currentResourceTypeConfig->getName() != $type && !$currentResourceTypeConfig->checkExtension($name, false)) { |
|
| 691 | - continue; |
|
| 692 | - } |
|
| 693 | - |
|
| 694 | - // check #5 (hidden folders) |
|
| 695 | - // cache results |
|
| 696 | - if (empty($checkedPaths[$path])) { |
|
| 697 | - $checkedPaths[$path] = true; |
|
| 698 | - |
|
| 699 | - if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) { |
|
| 700 | - continue; |
|
| 701 | - } |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - // check #6 (hidden file name) |
|
| 705 | - if ($currentResourceTypeConfig->checkIsHiddenFile($name)) { |
|
| 706 | - continue; |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - // check #7 (Access Control, need file view permission to source files) |
|
| 710 | - if (!isset($aclMasks[$type."@".$path])) { |
|
| 711 | - $aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path); |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - $isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 715 | - if (!$isAuthorized) { |
|
| 716 | - continue; |
|
| 717 | - } |
|
| 718 | - |
|
| 719 | - $sourceFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($_resourceTypeConfig[$type]->getDirectory().$path,$name); |
|
| 720 | - // check #8 (invalid file name) |
|
| 721 | - if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) { |
|
| 722 | - continue; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - // check #9 - max file size |
|
| 726 | - if ( !empty($zipMaxSize) ){ |
|
| 727 | - clearstatcache(); |
|
| 728 | - $_zipFilesSize += filesize($sourceFilePath); |
|
| 729 | - if ( $_zipFilesSize > $zipMaxSize ) { |
|
| 730 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CREATED_FILE_TOO_BIG); |
|
| 731 | - } |
|
| 732 | - } |
|
| 733 | - |
|
| 734 | - $zipPathPart = ( $_isBasket ) ? CKFinder_Connector_Utils_FileSystem::combinePaths($type,$path) : ''; |
|
| 735 | - |
|
| 736 | - $files[$sourceFilePath] = $zipPathPart.pathinfo($sourceFilePath,PATHINFO_BASENAME); |
|
| 737 | - } |
|
| 738 | - } |
|
| 739 | - else |
|
| 740 | - { |
|
| 741 | - if (!is_dir($_sServerDir)) { |
|
| 742 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND); |
|
| 743 | - } |
|
| 744 | - $files = $this->getFilesRecursively($_sServerDir,$zipMaxSize); |
|
| 745 | - } |
|
| 746 | - if ( sizeof($files)<1) { |
|
| 747 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 748 | - } |
|
| 749 | - // default destination dir - temp |
|
| 750 | - $dest_dir = CKFinder_Connector_Utils_FileSystem::getTmpDir(); |
|
| 751 | - $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 752 | - |
|
| 753 | - // default file name - hash |
|
| 754 | - $zip_filename = substr(md5(serialize($files)), 0, 16).$resourceTypeInfo->getHash().'.zip'; |
|
| 755 | - |
|
| 756 | - // compress files - do not download them |
|
| 757 | - // change destination and name |
|
| 758 | - if ( isset($_POST['download']) && $_POST['download'] == 'false'){ |
|
| 759 | - $dest_dir = $_sServerDir; |
|
| 760 | - if ( isset($_POST['zipName']) && !empty($_POST['zipName'])){ |
|
| 761 | - $zip_filename = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST['zipName']); |
|
| 762 | - if (!$resourceTypeInfo->checkExtension($zip_filename)) { |
|
| 763 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 764 | - } |
|
| 765 | - } |
|
| 766 | - } |
|
| 767 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($zip_filename) || $resourceTypeInfo->checkIsHiddenFile($zip_filename)) { |
|
| 768 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME); |
|
| 769 | - } |
|
| 770 | - if ($this->_config->forceAscii()) { |
|
| 771 | - $zip_filename = CKFinder_Connector_Utils_FileSystem::convertToAscii($zip_filename); |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - $zipFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir, $zip_filename); |
|
| 775 | - |
|
| 776 | - if (!is_writable(dirname($zipFilePath))) { |
|
| 777 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - // usually we would need to create zip? |
|
| 781 | - $createZip = true; |
|
| 782 | - |
|
| 783 | - // only if file already exists and we want download it |
|
| 784 | - // do not create new one - because hash of previously created is the same - existing archive is ok |
|
| 785 | - if ( file_exists($zipFilePath) && isset($_POST['download']) && $_POST['download'] == 'true' ){ |
|
| 786 | - $createZip = false; |
|
| 787 | - } |
|
| 788 | - // if we only want to create archive |
|
| 789 | - else |
|
| 790 | - { |
|
| 791 | - if ( file_exists($zipFilePath) && ( !isset($_POST['fileExistsAction']) || !in_array($_POST['fileExistsAction'], array('autorename','overwrite')) ) ){ |
|
| 792 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST); |
|
| 793 | - } |
|
| 794 | - |
|
| 795 | - if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FILE_UPLOAD )) { |
|
| 796 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 797 | - } |
|
| 798 | - // check how to deal with existing file |
|
| 799 | - if ( isset($_POST['fileExistsAction']) && $_POST['fileExistsAction'] == 'autorename' ) |
|
| 800 | - { |
|
| 801 | - if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_RENAME )) { |
|
| 802 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 803 | - } |
|
| 804 | - $zip_filename = CKFinder_Connector_Utils_FileSystem::autoRename($dest_dir, $zip_filename); |
|
| 805 | - $zipFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir, $zip_filename); |
|
| 806 | - } |
|
| 807 | - elseif ( isset($_POST['fileExistsAction']) && $_POST['fileExistsAction'] == 'overwrite' ) |
|
| 808 | - { |
|
| 809 | - if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 810 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 811 | - } |
|
| 812 | - if (!CKFinder_Connector_Utils_FileSystem::unlink($zipFilePath)){ |
|
| 813 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 814 | - } |
|
| 815 | - } |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - if ( $createZip ){ |
|
| 819 | - $zip = new ZipArchive(); |
|
| 820 | - $result = $zip->open( $zipFilePath, ZIPARCHIVE::CREATE); |
|
| 821 | - if ( $result !== TRUE ) { |
|
| 822 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN); |
|
| 823 | - } |
|
| 824 | - foreach ( $files as $pathname => $filename ){ |
|
| 825 | - if ( !empty($filename) ){ |
|
| 826 | - if ( file_exists($pathname) && is_readable($pathname) ){ |
|
| 827 | - $zip->addFile( $pathname, $filename ); |
|
| 828 | - } |
|
| 829 | - } else { |
|
| 830 | - $zip->addEmptyDir( $pathname ); |
|
| 831 | - } |
|
| 832 | - } |
|
| 833 | - $zip->close(); |
|
| 834 | - } |
|
| 835 | - |
|
| 836 | - $file = new CKFinder_Connector_Utils_XmlNode("ZipFile"); |
|
| 837 | - $file->addAttribute("name", $zip_filename); |
|
| 838 | - $this->_connectorNode->addChild($file); |
|
| 625 | + if (!extension_loaded('zip')) { |
|
| 626 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_COMMAND); |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + $this->checkConnector(); |
|
| 630 | + $this->checkRequest(); |
|
| 631 | + |
|
| 632 | + if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) { |
|
| 633 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 637 | + $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
|
| 638 | + $_sServerDir = $this->_currentFolder->getServerPath(); |
|
| 639 | + |
|
| 640 | + $files = array(); |
|
| 641 | + |
|
| 642 | + $_zipFilesSize = 0; |
|
| 643 | + $config = $this->getConfig(); |
|
| 644 | + $zipMaxSize = $config['zipMaxSize']; |
|
| 645 | + if ( !empty($zipMaxSize) && $zipMaxSize == 'default' ){ |
|
| 646 | + $zipMaxSize = $currentResourceTypeConfig->getMaxSize(); |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | + $_isBasket = ( isset($_POST['basket']) && $_POST['basket'] == 'true' )? true : false; |
|
| 650 | + |
|
| 651 | + if ( !empty($_POST['files'])) |
|
| 652 | + { |
|
| 653 | + |
|
| 654 | + $_aclConfig = $this->_config->getAccessControlConfig(); |
|
| 655 | + $aclMasks = array(); |
|
| 656 | + $_resourceTypeConfig = array(); |
|
| 657 | + |
|
| 658 | + foreach ( $_POST['files'] as $arr ){ |
|
| 659 | + if ( empty($arr['name']) || empty($arr['type']) || empty($arr['folder']) ) { |
|
| 660 | + continue; |
|
| 661 | + } |
|
| 662 | + // file name |
|
| 663 | + $name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']); |
|
| 664 | + // resource type |
|
| 665 | + $type = $arr['type']; |
|
| 666 | + // client path |
|
| 667 | + $path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']); |
|
| 668 | + |
|
| 669 | + // check #1 (path) |
|
| 670 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) { |
|
| 671 | + continue; |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + // get resource type config for current file |
|
| 675 | + if (!isset($_resourceTypeConfig[$type])) { |
|
| 676 | + $_resourceTypeConfig[$type] = $this->_config->getResourceTypeConfig($type); |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + // check #2 (resource type) |
|
| 680 | + if (is_null($_resourceTypeConfig[$type])) { |
|
| 681 | + continue; |
|
| 682 | + } |
|
| 683 | + |
|
| 684 | + // check #3 (extension) |
|
| 685 | + if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) { |
|
| 686 | + continue; |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + // check #4 (extension) - when moving to another resource type, double check extension |
|
| 690 | + if ($currentResourceTypeConfig->getName() != $type && !$currentResourceTypeConfig->checkExtension($name, false)) { |
|
| 691 | + continue; |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + // check #5 (hidden folders) |
|
| 695 | + // cache results |
|
| 696 | + if (empty($checkedPaths[$path])) { |
|
| 697 | + $checkedPaths[$path] = true; |
|
| 698 | + |
|
| 699 | + if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) { |
|
| 700 | + continue; |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + // check #6 (hidden file name) |
|
| 705 | + if ($currentResourceTypeConfig->checkIsHiddenFile($name)) { |
|
| 706 | + continue; |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + // check #7 (Access Control, need file view permission to source files) |
|
| 710 | + if (!isset($aclMasks[$type."@".$path])) { |
|
| 711 | + $aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path); |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + $isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 715 | + if (!$isAuthorized) { |
|
| 716 | + continue; |
|
| 717 | + } |
|
| 718 | + |
|
| 719 | + $sourceFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($_resourceTypeConfig[$type]->getDirectory().$path,$name); |
|
| 720 | + // check #8 (invalid file name) |
|
| 721 | + if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) { |
|
| 722 | + continue; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + // check #9 - max file size |
|
| 726 | + if ( !empty($zipMaxSize) ){ |
|
| 727 | + clearstatcache(); |
|
| 728 | + $_zipFilesSize += filesize($sourceFilePath); |
|
| 729 | + if ( $_zipFilesSize > $zipMaxSize ) { |
|
| 730 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CREATED_FILE_TOO_BIG); |
|
| 731 | + } |
|
| 732 | + } |
|
| 733 | + |
|
| 734 | + $zipPathPart = ( $_isBasket ) ? CKFinder_Connector_Utils_FileSystem::combinePaths($type,$path) : ''; |
|
| 735 | + |
|
| 736 | + $files[$sourceFilePath] = $zipPathPart.pathinfo($sourceFilePath,PATHINFO_BASENAME); |
|
| 737 | + } |
|
| 738 | + } |
|
| 739 | + else |
|
| 740 | + { |
|
| 741 | + if (!is_dir($_sServerDir)) { |
|
| 742 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND); |
|
| 743 | + } |
|
| 744 | + $files = $this->getFilesRecursively($_sServerDir,$zipMaxSize); |
|
| 745 | + } |
|
| 746 | + if ( sizeof($files)<1) { |
|
| 747 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 748 | + } |
|
| 749 | + // default destination dir - temp |
|
| 750 | + $dest_dir = CKFinder_Connector_Utils_FileSystem::getTmpDir(); |
|
| 751 | + $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 752 | + |
|
| 753 | + // default file name - hash |
|
| 754 | + $zip_filename = substr(md5(serialize($files)), 0, 16).$resourceTypeInfo->getHash().'.zip'; |
|
| 755 | + |
|
| 756 | + // compress files - do not download them |
|
| 757 | + // change destination and name |
|
| 758 | + if ( isset($_POST['download']) && $_POST['download'] == 'false'){ |
|
| 759 | + $dest_dir = $_sServerDir; |
|
| 760 | + if ( isset($_POST['zipName']) && !empty($_POST['zipName'])){ |
|
| 761 | + $zip_filename = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST['zipName']); |
|
| 762 | + if (!$resourceTypeInfo->checkExtension($zip_filename)) { |
|
| 763 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 764 | + } |
|
| 765 | + } |
|
| 766 | + } |
|
| 767 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($zip_filename) || $resourceTypeInfo->checkIsHiddenFile($zip_filename)) { |
|
| 768 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME); |
|
| 769 | + } |
|
| 770 | + if ($this->_config->forceAscii()) { |
|
| 771 | + $zip_filename = CKFinder_Connector_Utils_FileSystem::convertToAscii($zip_filename); |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + $zipFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir, $zip_filename); |
|
| 775 | + |
|
| 776 | + if (!is_writable(dirname($zipFilePath))) { |
|
| 777 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + // usually we would need to create zip? |
|
| 781 | + $createZip = true; |
|
| 782 | + |
|
| 783 | + // only if file already exists and we want download it |
|
| 784 | + // do not create new one - because hash of previously created is the same - existing archive is ok |
|
| 785 | + if ( file_exists($zipFilePath) && isset($_POST['download']) && $_POST['download'] == 'true' ){ |
|
| 786 | + $createZip = false; |
|
| 787 | + } |
|
| 788 | + // if we only want to create archive |
|
| 789 | + else |
|
| 790 | + { |
|
| 791 | + if ( file_exists($zipFilePath) && ( !isset($_POST['fileExistsAction']) || !in_array($_POST['fileExistsAction'], array('autorename','overwrite')) ) ){ |
|
| 792 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST); |
|
| 793 | + } |
|
| 794 | + |
|
| 795 | + if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FILE_UPLOAD )) { |
|
| 796 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 797 | + } |
|
| 798 | + // check how to deal with existing file |
|
| 799 | + if ( isset($_POST['fileExistsAction']) && $_POST['fileExistsAction'] == 'autorename' ) |
|
| 800 | + { |
|
| 801 | + if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_RENAME )) { |
|
| 802 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 803 | + } |
|
| 804 | + $zip_filename = CKFinder_Connector_Utils_FileSystem::autoRename($dest_dir, $zip_filename); |
|
| 805 | + $zipFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir, $zip_filename); |
|
| 806 | + } |
|
| 807 | + elseif ( isset($_POST['fileExistsAction']) && $_POST['fileExistsAction'] == 'overwrite' ) |
|
| 808 | + { |
|
| 809 | + if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 810 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 811 | + } |
|
| 812 | + if (!CKFinder_Connector_Utils_FileSystem::unlink($zipFilePath)){ |
|
| 813 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 814 | + } |
|
| 815 | + } |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + if ( $createZip ){ |
|
| 819 | + $zip = new ZipArchive(); |
|
| 820 | + $result = $zip->open( $zipFilePath, ZIPARCHIVE::CREATE); |
|
| 821 | + if ( $result !== TRUE ) { |
|
| 822 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN); |
|
| 823 | + } |
|
| 824 | + foreach ( $files as $pathname => $filename ){ |
|
| 825 | + if ( !empty($filename) ){ |
|
| 826 | + if ( file_exists($pathname) && is_readable($pathname) ){ |
|
| 827 | + $zip->addFile( $pathname, $filename ); |
|
| 828 | + } |
|
| 829 | + } else { |
|
| 830 | + $zip->addEmptyDir( $pathname ); |
|
| 831 | + } |
|
| 832 | + } |
|
| 833 | + $zip->close(); |
|
| 834 | + } |
|
| 835 | + |
|
| 836 | + $file = new CKFinder_Connector_Utils_XmlNode("ZipFile"); |
|
| 837 | + $file->addAttribute("name", $zip_filename); |
|
| 838 | + $this->_connectorNode->addChild($file); |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | public function onBeforeExecuteCommand( &$command ) |
| 842 | 842 | { |
| 843 | - if ( $command == 'CreateZip'){ |
|
| 844 | - $this->sendResponse(); |
|
| 845 | - return false; |
|
| 846 | - } |
|
| 847 | - return true ; |
|
| 843 | + if ( $command == 'CreateZip'){ |
|
| 844 | + $this->sendResponse(); |
|
| 845 | + return false; |
|
| 846 | + } |
|
| 847 | + return true ; |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | } // end of CKFinder_Connector_CommandHandler_DownloadZip class |
@@ -856,77 +856,77 @@ discard block |
||
| 856 | 856 | */ |
| 857 | 857 | protected function sendZipFile() |
| 858 | 858 | { |
| 859 | - if (!function_exists('ob_list_handlers') || ob_list_handlers()) { |
|
| 860 | - @ob_end_clean(); |
|
| 861 | - } |
|
| 862 | - header("Content-Encoding: none"); |
|
| 863 | - |
|
| 864 | - $this->checkConnector(); |
|
| 865 | - $this->checkRequest(); |
|
| 866 | - |
|
| 867 | - // empty wystarczy |
|
| 868 | - if ( empty($_GET['FileName']) ){ |
|
| 869 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 870 | - } |
|
| 871 | - |
|
| 872 | - $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 873 | - $hash = $resourceTypeInfo->getHash(); |
|
| 874 | - if ( $hash !== $_GET['hash'] || $hash !== substr($_GET['FileName'],16,16) ){ |
|
| 875 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 876 | - } |
|
| 877 | - |
|
| 878 | - if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) { |
|
| 879 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['FileName'])); |
|
| 883 | - |
|
| 884 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) { |
|
| 885 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 886 | - } |
|
| 887 | - |
|
| 888 | - if ( strtolower(pathinfo($fileName, PATHINFO_EXTENSION)) !== 'zip'){ |
|
| 889 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 890 | - } |
|
| 891 | - |
|
| 892 | - $dest_dir = CKFinder_Connector_Utils_FileSystem::getTmpDir(); |
|
| 893 | - $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir,$fileName); |
|
| 894 | - if ( !file_exists($filePath) || !is_file($filePath)) { |
|
| 895 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 896 | - } |
|
| 897 | - if (!is_readable($filePath)) { |
|
| 898 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - $zipFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['ZipName'])); |
|
| 902 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($zipFileName)) { |
|
| 903 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 904 | - } |
|
| 905 | - $fileFilename = pathinfo($zipFileName,PATHINFO_BASENAME ); |
|
| 906 | - |
|
| 907 | - header("Content-Encoding: none"); |
|
| 908 | - header("Cache-Control: cache, must-revalidate"); |
|
| 909 | - header("Pragma: public"); |
|
| 910 | - header("Expires: 0"); |
|
| 911 | - $user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 912 | - $encodedName = str_replace("\"", "\\\"", $fileFilename); |
|
| 913 | - if (strpos($user_agent, "MSIE") !== false) { |
|
| 914 | - $encodedName = str_replace(array("+", "%2E"), array(" ", "."), urlencode($encodedName)); |
|
| 915 | - } |
|
| 916 | - header("Content-type: application/octet-stream; name=\"" . $fileFilename . "\""); |
|
| 917 | - header("Content-Disposition: attachment; filename=\"" . $encodedName. "\""); |
|
| 918 | - header("Content-Length: " . filesize($filePath)); |
|
| 919 | - CKFinder_Connector_Utils_FileSystem::sendFile($filePath); |
|
| 920 | - exit; |
|
| 859 | + if (!function_exists('ob_list_handlers') || ob_list_handlers()) { |
|
| 860 | + @ob_end_clean(); |
|
| 861 | + } |
|
| 862 | + header("Content-Encoding: none"); |
|
| 863 | + |
|
| 864 | + $this->checkConnector(); |
|
| 865 | + $this->checkRequest(); |
|
| 866 | + |
|
| 867 | + // empty wystarczy |
|
| 868 | + if ( empty($_GET['FileName']) ){ |
|
| 869 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 870 | + } |
|
| 871 | + |
|
| 872 | + $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); |
|
| 873 | + $hash = $resourceTypeInfo->getHash(); |
|
| 874 | + if ( $hash !== $_GET['hash'] || $hash !== substr($_GET['FileName'],16,16) ){ |
|
| 875 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 876 | + } |
|
| 877 | + |
|
| 878 | + if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) { |
|
| 879 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['FileName'])); |
|
| 883 | + |
|
| 884 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) { |
|
| 885 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 886 | + } |
|
| 887 | + |
|
| 888 | + if ( strtolower(pathinfo($fileName, PATHINFO_EXTENSION)) !== 'zip'){ |
|
| 889 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION); |
|
| 890 | + } |
|
| 891 | + |
|
| 892 | + $dest_dir = CKFinder_Connector_Utils_FileSystem::getTmpDir(); |
|
| 893 | + $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir,$fileName); |
|
| 894 | + if ( !file_exists($filePath) || !is_file($filePath)) { |
|
| 895 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); |
|
| 896 | + } |
|
| 897 | + if (!is_readable($filePath)) { |
|
| 898 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + $zipFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['ZipName'])); |
|
| 902 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($zipFileName)) { |
|
| 903 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 904 | + } |
|
| 905 | + $fileFilename = pathinfo($zipFileName,PATHINFO_BASENAME ); |
|
| 906 | + |
|
| 907 | + header("Content-Encoding: none"); |
|
| 908 | + header("Cache-Control: cache, must-revalidate"); |
|
| 909 | + header("Pragma: public"); |
|
| 910 | + header("Expires: 0"); |
|
| 911 | + $user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 912 | + $encodedName = str_replace("\"", "\\\"", $fileFilename); |
|
| 913 | + if (strpos($user_agent, "MSIE") !== false) { |
|
| 914 | + $encodedName = str_replace(array("+", "%2E"), array(" ", "."), urlencode($encodedName)); |
|
| 915 | + } |
|
| 916 | + header("Content-type: application/octet-stream; name=\"" . $fileFilename . "\""); |
|
| 917 | + header("Content-Disposition: attachment; filename=\"" . $encodedName. "\""); |
|
| 918 | + header("Content-Length: " . filesize($filePath)); |
|
| 919 | + CKFinder_Connector_Utils_FileSystem::sendFile($filePath); |
|
| 920 | + exit; |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | public function onBeforeExecuteCommand( &$command ) |
| 924 | 924 | { |
| 925 | - if ( $command == 'DownloadZip'){ |
|
| 926 | - $this->sendZipFile(); |
|
| 927 | - return false; |
|
| 928 | - } |
|
| 929 | - return true ; |
|
| 925 | + if ( $command == 'DownloadZip'){ |
|
| 926 | + $this->sendZipFile(); |
|
| 927 | + return false; |
|
| 928 | + } |
|
| 929 | + return true ; |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | } // end of CKFinder_Connector_CommandHandler_DownloadZip |