@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param $old_image_req |
| 75 | 75 | * @param int $autorize_empty |
| 76 | 76 | * @param int $delete_old_img |
| 77 | - * @return bool|string -> renvoi false si err sinon renvoi le chemin vers l'img |
|
| 77 | + * @return null|boolean -> renvoi false si err sinon renvoi le chemin vers l'img |
|
| 78 | 78 | */ |
| 79 | 79 | public function setEnvoyerImage($name, $old_image_req=null, $autorize_empty=1, $delete_old_img=1) { |
| 80 | 80 | $dbc = \core\App::getDb(); |
@@ -178,9 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | 180 | * fonction qui permet de supprimer une image en fonction d'une requete ou de la variable old_image |
| 181 | - * @param null $chemin_img |
|
| 182 | - * @param null $req_image |
|
| 183 | - * @return bool |
|
| 181 | + * @return boolean|null |
|
| 184 | 182 | */ |
| 185 | 183 | public function setDeleteImage($nom_image=null) { |
| 186 | 184 | //si pas de requete et qu'on a une old_img on la supprime |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace core\images; |
| 4 | 4 | |
| 5 | 5 | use core\App; |
| 6 | - use core\HTML\flashmessage\FlashMessage; |
|
| 7 | 6 | |
| 8 | 7 | class Images { |
| 9 | 8 | //initialisée pour le bon fonctionnement de la class |
@@ -43,13 +43,13 @@ |
||
| 43 | 43 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 44 | 44 | |
| 45 | 45 | public function getOldImage() { |
| 46 | - return $this->old_image; |
|
| 46 | + return $this->old_image; |
|
| 47 | 47 | } |
| 48 | 48 | public function getCheminImage() { |
| 49 | - return $this->chemin_image; |
|
| 49 | + return $this->chemin_image; |
|
| 50 | 50 | } |
| 51 | 51 | public function getErreur() { |
| 52 | - return $this->erreur; |
|
| 52 | + return $this->erreur; |
|
| 53 | 53 | } |
| 54 | 54 | public function getNomImage() { |
| 55 | 55 | return $this->nom_image; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param int $delete_old_img |
| 77 | 77 | * @return bool|string -> renvoi false si err sinon renvoi le chemin vers l'img |
| 78 | 78 | */ |
| 79 | - public function setEnvoyerImage($name, $old_image_req=null, $autorize_empty=1, $delete_old_img=1) { |
|
| 79 | + public function setEnvoyerImage($name, $old_image_req = null, $autorize_empty = 1, $delete_old_img = 1) { |
|
| 80 | 80 | $dbc = \core\App::getDb(); |
| 81 | 81 | |
| 82 | 82 | $this->old_image = null; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param null $req_img |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - public function setResizeImage($width, $height, $prefixe, $delete_old=1, $req_img=null) { |
|
| 149 | + public function setResizeImage($width, $height, $prefixe, $delete_old = 1, $req_img = null) { |
|
| 150 | 150 | if (($req_img == null) && ($this->chemin_image != "")) { |
| 151 | 151 | $this->getImage(); |
| 152 | 152 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param null $req_image |
| 183 | 183 | * @return bool |
| 184 | 184 | */ |
| 185 | - public function setDeleteImage($nom_image=null) { |
|
| 185 | + public function setDeleteImage($nom_image = null) { |
|
| 186 | 186 | //si pas de requete et qu'on a une old_img on la supprime |
| 187 | 187 | if (($this->old_image != "") && ($nom_image == null)) { |
| 188 | 188 | $old_image = explode("/", $this->old_image); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | else if ($nom_image != null) { |
| 197 | 197 | |
| 198 | 198 | if (is_array($nom_image)) { |
| 199 | - for ($i=0 ; $i<count($nom_image) ; $i++) { |
|
| 199 | + for ($i = 0; $i < count($nom_image); $i++) { |
|
| 200 | 200 | $chemin_img = $this->dossier_image."/".$nom_image[$i]; |
| 201 | 201 | |
| 202 | 202 | if (unlink($chemin_img)) { |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | $explode = explode("/", $this->chemin_image); |
| 60 | 60 | $this->image = end($explode); |
| 61 | 61 | return $this->image; |
| 62 | - } |
|
| 63 | - else { |
|
| 62 | + } else { |
|
| 64 | 63 | $this->erreur = "Impossible de trouver votre image, vuellez réessayer dans un instant"; |
| 65 | 64 | return false; |
| 66 | 65 | } |
@@ -90,8 +89,7 @@ discard block |
||
| 90 | 89 | $this->erreur = "Vous devez obligatoirement ajouter une image"; |
| 91 | 90 | return false; |
| 92 | 91 | } |
| 93 | - } |
|
| 94 | - else { |
|
| 92 | + } else { |
|
| 95 | 93 | //test si il y a deja une img |
| 96 | 94 | if ($old_image_req != null) { |
| 97 | 95 | $query = $dbc->query($old_image_req); |
@@ -109,12 +107,10 @@ discard block |
||
| 109 | 107 | if (!in_array(substr($image, -3), $this->autorized_extention)) { |
| 110 | 108 | $this->erreur = "Votre image ne comporte pas l'extension jpg, png, jpeg, gif, JPG, PNG, JPEG, GIF"; |
| 111 | 109 | return false; |
| 112 | - } |
|
| 113 | - else if (($infos_img[0] >= $this->width_max) && ($infos_img[1] >= $this->height_max) && ($_FILES[$name]['size'] >= $this->poid_max)) { |
|
| 110 | + } else if (($infos_img[0] >= $this->width_max) && ($infos_img[1] >= $this->height_max) && ($_FILES[$name]['size'] >= $this->poid_max)) { |
|
| 114 | 111 | $this->erreur = "Problème dans les dimensions ou taille de l'image."; |
| 115 | 112 | return false; |
| 116 | - } |
|
| 117 | - else { |
|
| 113 | + } else { |
|
| 118 | 114 | $uniqid = uniqid(); |
| 119 | 115 | |
| 120 | 116 | if (move_uploaded_file($_FILES[$name]['tmp_name'], $this->dossier_image."/".$uniqid.substr($image, -4))) { |
@@ -129,8 +125,7 @@ discard block |
||
| 129 | 125 | } |
| 130 | 126 | |
| 131 | 127 | return true; |
| 132 | - } |
|
| 133 | - else { |
|
| 128 | + } else { |
|
| 134 | 129 | $this->erreur = "Impossible d'envoyer votre image sur le serveur, veuillez réessayer dans une instant, si l'erreur se reproduit, contactez votre administrateur"; |
| 135 | 130 | } |
| 136 | 131 | } |
@@ -157,8 +152,7 @@ discard block |
||
| 157 | 152 | $image = $this->dossier_image."/".$img_resize; |
| 158 | 153 | |
| 159 | 154 | $this->nom_image = $img_resize; |
| 160 | - } |
|
| 161 | - else { |
|
| 155 | + } else { |
|
| 162 | 156 | |
| 163 | 157 | $this->nom_image = null; |
| 164 | 158 | /*$resize = new resize($urlimg); |
@@ -192,8 +186,7 @@ discard block |
||
| 192 | 186 | unlink($this->dossier_image."/".end($old_image)); |
| 193 | 187 | return true; |
| 194 | 188 | } |
| 195 | - } |
|
| 196 | - else if ($nom_image != null) { |
|
| 189 | + } else if ($nom_image != null) { |
|
| 197 | 190 | |
| 198 | 191 | if (is_array($nom_image)) { |
| 199 | 192 | for ($i=0 ; $i<count($nom_image) ; $i++) { |
@@ -201,27 +194,22 @@ discard block |
||
| 201 | 194 | |
| 202 | 195 | if (unlink($chemin_img)) { |
| 203 | 196 | $success = true; |
| 204 | - } |
|
| 205 | - else { |
|
| 197 | + } else { |
|
| 206 | 198 | if (unlink($this->chemin_image)) { |
| 207 | 199 | $success = true; |
| 208 | - } |
|
| 209 | - else { |
|
| 200 | + } else { |
|
| 210 | 201 | $this->erreur = "Impossible de supprimer cette image, veuillez réesayer dans un instant, sinon contacter l'administrateur de votre site"; |
| 211 | 202 | $success = false; |
| 212 | 203 | } |
| 213 | 204 | } |
| 214 | 205 | } |
| 215 | - } |
|
| 216 | - else { |
|
| 206 | + } else { |
|
| 217 | 207 | if (unlink($this->dossier_image."/".$nom_image)) { |
| 218 | 208 | $success = true; |
| 219 | - } |
|
| 220 | - else { |
|
| 209 | + } else { |
|
| 221 | 210 | if (unlink($this->chemin_image)) { |
| 222 | 211 | $success = true; |
| 223 | - } |
|
| 224 | - else { |
|
| 212 | + } else { |
|
| 225 | 213 | $this->erreur = "Impossible de supprimer cette image, veuillez réesayer dans un instant, sinon contacter l'administrateur de votre site"; |
| 226 | 214 | $success = false; |
| 227 | 215 | } |
@@ -229,8 +217,7 @@ discard block |
||
| 229 | 217 | } |
| 230 | 218 | |
| 231 | 219 | return $success; |
| 232 | - } |
|
| 233 | - else { |
|
| 220 | + } else { |
|
| 234 | 221 | $this->erreur = "Impossible de supprimer cette image"; |
| 235 | 222 | return false; |
| 236 | 223 | } |
@@ -25,6 +25,9 @@ discard block |
||
| 25 | 25 | private $height; |
| 26 | 26 | private $imageResized; |
| 27 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string|null $fileName |
|
| 30 | + */ |
|
| 28 | 31 | function __construct($fileName) |
| 29 | 32 | { |
| 30 | 33 | // *** Open up the file |
@@ -85,6 +88,9 @@ discard block |
||
| 85 | 88 | |
| 86 | 89 | ## -------------------------------------------------------- |
| 87 | 90 | |
| 91 | + /** |
|
| 92 | + * @param string $option |
|
| 93 | + */ |
|
| 88 | 94 | private function getDimensions($newWidth, $newHeight, $option) |
| 89 | 95 | { |
| 90 | 96 | |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | // *** Class variables |
| 23 | 23 | private $image; |
| 24 | - private $width; |
|
| 25 | - private $height; |
|
| 24 | + private $width; |
|
| 25 | + private $height; |
|
| 26 | 26 | private $imageResized; |
| 27 | 27 | |
| 28 | 28 | function __construct($fileName) |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | // *** Open up the file |
| 31 | 31 | $this->image = $this->openImage($fileName); |
| 32 | 32 | |
| 33 | - // *** Get width and height |
|
| 34 | - $this->width = imagesx($this->image); |
|
| 35 | - $this->height = imagesy($this->image); |
|
| 33 | + // *** Get width and height |
|
| 34 | + $this->width = imagesx($this->image); |
|
| 35 | + $this->height = imagesy($this->image); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | ## -------------------------------------------------------- |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | public function saveImage($savePath, $imageQuality="100") |
| 207 | 207 | { |
| 208 | 208 | // *** Get extension |
| 209 | - $extension = strrchr($savePath, '.'); |
|
| 210 | - $extension = strtolower($extension); |
|
| 209 | + $extension = strrchr($savePath, '.'); |
|
| 210 | + $extension = strtolower($extension); |
|
| 211 | 211 | |
| 212 | 212 | switch($extension) |
| 213 | 213 | { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | // *** Get extension |
| 43 | 43 | $extension = strtolower(strrchr($file, '.')); |
| 44 | 44 | |
| 45 | - switch($extension) |
|
| 45 | + switch ($extension) |
|
| 46 | 46 | { |
| 47 | 47 | case '.jpg': |
| 48 | 48 | case '.jpeg': |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | ## -------------------------------------------------------- |
| 65 | 65 | |
| 66 | - public function resizeImage($newWidth, $newHeight, $option="auto") |
|
| 66 | + public function resizeImage($newWidth, $newHeight, $option = "auto") |
|
| 67 | 67 | { |
| 68 | 68 | // *** Get optimal width and height - based on $option |
| 69 | 69 | $optionArray = $this->getDimensions($newWidth, $newHeight, $option); |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | case 'exact': |
| 94 | 94 | $optimalWidth = $newWidth; |
| 95 | - $optimalHeight= $newHeight; |
|
| 95 | + $optimalHeight = $newHeight; |
|
| 96 | 96 | break; |
| 97 | 97 | case 'portrait': |
| 98 | 98 | $optimalWidth = $this->getSizeByFixedHeight($newHeight); |
| 99 | - $optimalHeight= $newHeight; |
|
| 99 | + $optimalHeight = $newHeight; |
|
| 100 | 100 | break; |
| 101 | 101 | case 'landscape': |
| 102 | 102 | $optimalWidth = $newWidth; |
| 103 | - $optimalHeight= $this->getSizeByFixedWidth($newWidth); |
|
| 103 | + $optimalHeight = $this->getSizeByFixedWidth($newWidth); |
|
| 104 | 104 | break; |
| 105 | 105 | case 'auto': |
| 106 | 106 | $optionArray = $this->getSizeByAuto($newWidth, $newHeight); |
@@ -138,27 +138,27 @@ discard block |
||
| 138 | 138 | // *** Image to be resized is wider (landscape) |
| 139 | 139 | { |
| 140 | 140 | $optimalWidth = $newWidth; |
| 141 | - $optimalHeight= $this->getSizeByFixedWidth($newWidth); |
|
| 141 | + $optimalHeight = $this->getSizeByFixedWidth($newWidth); |
|
| 142 | 142 | } |
| 143 | 143 | elseif ($this->height > $this->width) |
| 144 | 144 | // *** Image to be resized is taller (portrait) |
| 145 | 145 | { |
| 146 | 146 | $optimalWidth = $this->getSizeByFixedHeight($newHeight); |
| 147 | - $optimalHeight= $newHeight; |
|
| 147 | + $optimalHeight = $newHeight; |
|
| 148 | 148 | } |
| 149 | 149 | else |
| 150 | 150 | // *** Image to be resizerd is a square |
| 151 | 151 | { |
| 152 | 152 | if ($newHeight < $newWidth) { |
| 153 | 153 | $optimalWidth = $newWidth; |
| 154 | - $optimalHeight= $this->getSizeByFixedWidth($newWidth); |
|
| 154 | + $optimalHeight = $this->getSizeByFixedWidth($newWidth); |
|
| 155 | 155 | } else if ($newHeight > $newWidth) { |
| 156 | 156 | $optimalWidth = $this->getSizeByFixedHeight($newHeight); |
| 157 | - $optimalHeight= $newHeight; |
|
| 157 | + $optimalHeight = $newHeight; |
|
| 158 | 158 | } else { |
| 159 | 159 | // *** Sqaure being resized to a square |
| 160 | 160 | $optimalWidth = $newWidth; |
| 161 | - $optimalHeight= $newHeight; |
|
| 161 | + $optimalHeight = $newHeight; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | |
| 173 | 173 | $heightRatio = $this->height / $newHeight; |
| 174 | - $widthRatio = $this->width / $newWidth; |
|
| 174 | + $widthRatio = $this->width / $newWidth; |
|
| 175 | 175 | |
| 176 | 176 | if ($heightRatio < $widthRatio) { |
| 177 | 177 | $optimalRatio = $heightRatio; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $optimalHeight = $this->height / $optimalRatio; |
| 183 | - $optimalWidth = $this->width / $optimalRatio; |
|
| 183 | + $optimalWidth = $this->width / $optimalRatio; |
|
| 184 | 184 | |
| 185 | 185 | return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight); |
| 186 | 186 | } |
@@ -190,26 +190,26 @@ discard block |
||
| 190 | 190 | private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight) |
| 191 | 191 | { |
| 192 | 192 | // *** Find center - this will be used for the crop |
| 193 | - $cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 ); |
|
| 194 | - $cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 ); |
|
| 193 | + $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); |
|
| 194 | + $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); |
|
| 195 | 195 | |
| 196 | 196 | $crop = $this->imageResized; |
| 197 | 197 | //imagedestroy($this->imageResized); |
| 198 | 198 | |
| 199 | 199 | // *** Now crop from center to exact requested size |
| 200 | - $this->imageResized = imagecreatetruecolor($newWidth , $newHeight); |
|
| 201 | - imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight); |
|
| 200 | + $this->imageResized = imagecreatetruecolor($newWidth, $newHeight); |
|
| 201 | + imagecopyresampled($this->imageResized, $crop, 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight, $newWidth, $newHeight); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | ## -------------------------------------------------------- |
| 205 | 205 | |
| 206 | - public function saveImage($savePath, $imageQuality="100") |
|
| 206 | + public function saveImage($savePath, $imageQuality = "100") |
|
| 207 | 207 | { |
| 208 | 208 | // *** Get extension |
| 209 | 209 | $extension = strrchr($savePath, '.'); |
| 210 | 210 | $extension = strtolower($extension); |
| 211 | 211 | |
| 212 | - switch($extension) |
|
| 212 | + switch ($extension) |
|
| 213 | 213 | { |
| 214 | 214 | case '.jpg': |
| 215 | 215 | case '.jpeg': |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | case '.png': |
| 228 | 228 | // *** Scale quality from 0-100 to 0-9 |
| 229 | - $scaleQuality = round(($imageQuality/100) * 9); |
|
| 229 | + $scaleQuality = round(($imageQuality / 100) * 9); |
|
| 230 | 230 | |
| 231 | 231 | // *** Invert quality setting as 0 is best, not 9 |
| 232 | 232 | $invertScaleQuality = 9 - $scaleQuality; |
@@ -134,19 +134,19 @@ |
||
| 134 | 134 | |
| 135 | 135 | private function getSizeByAuto($newWidth, $newHeight) |
| 136 | 136 | { |
| 137 | - if ($this->height < $this->width) |
|
| 138 | - // *** Image to be resized is wider (landscape) |
|
| 137 | + if ($this->height < $this->width) { |
|
| 138 | + // *** Image to be resized is wider (landscape) |
|
| 139 | 139 | { |
| 140 | 140 | $optimalWidth = $newWidth; |
| 141 | - $optimalHeight= $this->getSizeByFixedWidth($newWidth); |
|
| 142 | 141 | } |
| 143 | - elseif ($this->height > $this->width) |
|
| 144 | - // *** Image to be resized is taller (portrait) |
|
| 142 | + $optimalHeight= $this->getSizeByFixedWidth($newWidth); |
|
| 143 | + } elseif ($this->height > $this->width) { |
|
| 144 | + // *** Image to be resized is taller (portrait) |
|
| 145 | 145 | { |
| 146 | 146 | $optimalWidth = $this->getSizeByFixedHeight($newHeight); |
| 147 | - $optimalHeight= $newHeight; |
|
| 148 | 147 | } |
| 149 | - else |
|
| 148 | + $optimalHeight= $newHeight; |
|
| 149 | + } else |
|
| 150 | 150 | // *** Image to be resizerd is a square |
| 151 | 151 | { |
| 152 | 152 | if ($newHeight < $newWidth) { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * @param $nom_module |
| 136 | - * @return bool |
|
| 136 | + * @return boolean|null |
|
| 137 | 137 | * return true si le module est activer sinon false |
| 138 | 138 | */ |
| 139 | 139 | public static function getModuleActiver($nom_module) { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * @param $nom_module |
| 156 | - * @return bool |
|
| 156 | + * @return boolean|null |
|
| 157 | 157 | * fonction qui permet de savoir si un module est à jour ou non |
| 158 | 158 | * si a jour renvoi true sinon renvoi false |
| 159 | 159 | */ |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | $this->nom_fichier = end($explode); |
| 204 | 204 | |
| 205 | 205 | //on recupere le nom du dossier + extention |
| 206 | - $explode = explode(".", $obj->url_telechargement); |
|
| 206 | + $explode = explode(".", $obj->url_telechargement); |
|
| 207 | 207 | array_pop($explode); |
| 208 | 208 | |
| 209 | 209 | $version_txt = implode(".", $explode)."_version.txt"; |
| 210 | 210 | |
| 211 | - if(file_get_contents($version_txt) == true) { |
|
| 211 | + if (file_get_contents($version_txt) == true) { |
|
| 212 | 212 | |
| 213 | 213 | //online pour bdd |
| 214 | 214 | $version_online_txt = file_get_contents($version_txt); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | |
| 277 | 277 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
| 278 | - private function setListeModuleActiver($id_module, $url, $version, $nom, $icone=null, $url_telechargement=null) { |
|
| 278 | + private function setListeModuleActiver($id_module, $url, $version, $nom, $icone = null, $url_telechargement = null) { |
|
| 279 | 279 | $this->id_module = $id_module; |
| 280 | 280 | $this->url = $url; |
| 281 | 281 | $this->nom = $nom; |
@@ -121,12 +121,10 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | if ($installer == 1) { |
| 123 | 123 | return true; |
| 124 | - } |
|
| 125 | - else { |
|
| 124 | + } else { |
|
| 126 | 125 | return false; |
| 127 | 126 | } |
| 128 | - } |
|
| 129 | - else { |
|
| 127 | + } else { |
|
| 130 | 128 | return false; |
| 131 | 129 | } |
| 132 | 130 | } |
@@ -144,8 +142,7 @@ discard block |
||
| 144 | 142 | foreach ($query as $obj) { |
| 145 | 143 | if ($obj->activer == 1) { |
| 146 | 144 | return true; |
| 147 | - } |
|
| 148 | - else { |
|
| 145 | + } else { |
|
| 149 | 146 | return false; |
| 150 | 147 | } |
| 151 | 148 | } |
@@ -165,8 +162,7 @@ discard block |
||
| 165 | 162 | foreach ($query as $obj) { |
| 166 | 163 | if ($obj->mettre_jour == 1) { |
| 167 | 164 | return false; |
| 168 | - } |
|
| 169 | - else { |
|
| 165 | + } else { |
|
| 170 | 166 | return true; |
| 171 | 167 | } |
| 172 | 168 | } |
@@ -189,8 +185,7 @@ discard block |
||
| 189 | 185 | //si pas de version a checker, cela veut dire qu'on vient d'installer le module |
| 190 | 186 | //du coup on met le next_check aa la semaine pro |
| 191 | 187 | $set_next = true; |
| 192 | - } |
|
| 193 | - else if (($obj->next_check_version <= $today) && ($obj->mettre_jour != 1)) { |
|
| 188 | + } else if (($obj->next_check_version <= $today) && ($obj->mettre_jour != 1)) { |
|
| 194 | 189 | //avant tout on regarde si on doit delete une vieille version |
| 195 | 190 | if ($obj->delete_old_version == 1) { |
| 196 | 191 | $import = new ImportModule(); |
@@ -232,8 +227,7 @@ discard block |
||
| 232 | 227 | $dbc->prepare("UPDATE module SET mettre_jour=:update, online_version=:online_version WHERE ID_module=:id_module", $value); |
| 233 | 228 | |
| 234 | 229 | $set_next = true; |
| 235 | - } |
|
| 236 | - else { |
|
| 230 | + } else { |
|
| 237 | 231 | $set_next = true; |
| 238 | 232 | } |
| 239 | 233 | } |
@@ -266,8 +260,7 @@ discard block |
||
| 266 | 260 | $this->setListeModuleMettreJour($nom_module, $version, $online_version); |
| 267 | 261 | |
| 268 | 262 | return true; |
| 269 | - } |
|
| 270 | - else { |
|
| 263 | + } else { |
|
| 271 | 264 | return false; |
| 272 | 265 | } |
| 273 | 266 | } |
@@ -50,6 +50,7 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @param $url_module |
| 52 | 52 | * fonction qui permets d'importer un module dans notre site internet |
| 53 | + * @param boolean $update |
|
| 53 | 54 | */ |
| 54 | 55 | public function setImportModule($url_module, $update=null) { |
| 55 | 56 | $dbc= App::getDb(); |
@@ -226,7 +227,7 @@ discard block |
||
| 226 | 227 | } |
| 227 | 228 | |
| 228 | 229 | /** |
| 229 | - * @param $url |
|
| 230 | + * @param string $url |
|
| 230 | 231 | * fonction qui permet de supprmer un dossier avec toute son abrorescence en fonction d'une URL |
| 231 | 232 | */ |
| 232 | 233 | private function supprimerDossier($url) { |
@@ -51,15 +51,15 @@ |
||
| 51 | 51 | * @param $url_module |
| 52 | 52 | * fonction qui permets d'importer un module dans notre site internet |
| 53 | 53 | */ |
| 54 | - public function setImportModule($url_module, $update=null) { |
|
| 55 | - $dbc= App::getDb(); |
|
| 54 | + public function setImportModule($url_module, $update = null) { |
|
| 55 | + $dbc = App::getDb(); |
|
| 56 | 56 | |
| 57 | 57 | //avant tout on récupère le nom du fichier pour le mettre dans le dossier temporaire |
| 58 | 58 | $explode = explode("/", $url_module); |
| 59 | 59 | $this->nom_fichier = end($explode); |
| 60 | 60 | |
| 61 | 61 | //on recupere le nom du dossier + extention |
| 62 | - $explode = explode(".", $this->nom_fichier); |
|
| 62 | + $explode = explode(".", $this->nom_fichier); |
|
| 63 | 63 | $this->nom_dossier = $explode[0]; |
| 64 | 64 | $this->extension = $explode[1]; |
| 65 | 65 | |
@@ -20,8 +20,12 @@ discard block |
||
| 20 | 20 | //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
| 21 | 21 | public function __construct() { |
| 22 | 22 | //On test si dossier temporaire + modules a la racines existes bien sinon on les crées |
| 23 | - if (!file_exists(ROOT."temp")) mkdir(ROOT."temp"); |
|
| 24 | - if (!file_exists(ROOT."modules")) mkdir(ROOT."modules"); |
|
| 23 | + if (!file_exists(ROOT."temp")) { |
|
| 24 | + mkdir(ROOT."temp"); |
|
| 25 | + } |
|
| 26 | + if (!file_exists(ROOT."modules")) { |
|
| 27 | + mkdir(ROOT."modules"); |
|
| 28 | + } |
|
| 25 | 29 | } |
| 26 | 30 | //-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
| 27 | 31 | |
@@ -81,19 +85,16 @@ discard block |
||
| 81 | 85 | |
| 82 | 86 | |
| 83 | 87 | FlashMessage::setFlash("Votre module a bien été ajouté au site.", "success"); |
| 84 | - } |
|
| 85 | - else { |
|
| 88 | + } else { |
|
| 86 | 89 | \core\HTML\flashmessage\FlashMessage::setFlash("Erreur lors du téléchargement du module, veuillez réessayer dans un instant."); |
| 87 | 90 | $this->erreur = true; |
| 88 | 91 | } |
| 89 | - } |
|
| 90 | - else { |
|
| 92 | + } else { |
|
| 91 | 93 | \core\HTML\flashmessage\FlashMessage::setFlash("Erreur lors du téléchargement du module, veuillez réessayer dans un instant."); |
| 92 | 94 | $this->setSupprimerArchiveTemp(); |
| 93 | 95 | $this->erreur = true; |
| 94 | 96 | } |
| 95 | - } |
|
| 96 | - else { |
|
| 97 | + } else { |
|
| 97 | 98 | \core\HTML\flashmessage\FlashMessage::setFlash("Erreur lors du téléchargement du module, veuillez réessayer dans un instant."); |
| 98 | 99 | $this->setSupprimerArchiveTemp(); |
| 99 | 100 | $this->erreur = true; |
@@ -101,18 +102,15 @@ discard block |
||
| 101 | 102 | |
| 102 | 103 | $zip->close(); |
| 103 | 104 | $this->setSupprimerArchiveTemp(); |
| 104 | - } |
|
| 105 | - else { |
|
| 105 | + } else { |
|
| 106 | 106 | FlashMessage::setFlash("Le module n'a pas pu être correctement téléchargé, veuillez réesseyer dans un instant"); |
| 107 | 107 | $this->erreur = true; |
| 108 | 108 | } |
| 109 | - } |
|
| 110 | - else { |
|
| 109 | + } else { |
|
| 111 | 110 | FlashMessage::setFlash("Ce module est déjà présent sur ce site, merci de renommer votre module"); |
| 112 | 111 | $this->erreur = true; |
| 113 | 112 | } |
| 114 | - } |
|
| 115 | - else { |
|
| 113 | + } else { |
|
| 116 | 114 | FlashMessage::setFlash("Le format de votre archive doit obligatoirement être un .zip"); |
| 117 | 115 | $this->erreur = true; |
| 118 | 116 | } |
@@ -150,8 +148,7 @@ discard block |
||
| 150 | 148 | |
| 151 | 149 | FlashMessage::setFlash("Votre module a bien été mis à jour", "success"); |
| 152 | 150 | } |
| 153 | - } |
|
| 154 | - else { |
|
| 151 | + } else { |
|
| 155 | 152 | FlashMessage::setFlash("Impossible de télécharger la mise à jour, veuillez réesseyer dans un instant"); |
| 156 | 153 | } |
| 157 | 154 | } |
@@ -163,8 +160,7 @@ discard block |
||
| 163 | 160 | private function setSupprimerArchiveTemp() { |
| 164 | 161 | if (unlink(TEMPROOT.$this->nom_fichier) == true) { |
| 165 | 162 | return true; |
| 166 | - } |
|
| 167 | - else { |
|
| 163 | + } else { |
|
| 168 | 164 | return false; |
| 169 | 165 | } |
| 170 | 166 | } |
@@ -191,8 +187,7 @@ discard block |
||
| 191 | 187 | ); |
| 192 | 188 | |
| 193 | 189 | $dbc->prepare("UPDATE module SET activer=:activer, installer=:installer WHERE ID_module=:id_module", $value); |
| 194 | - } |
|
| 195 | - else { |
|
| 190 | + } else { |
|
| 196 | 191 | $value = array( |
| 197 | 192 | "id_module" => $id_module, |
| 198 | 193 | ); |
@@ -234,7 +229,11 @@ discard block |
||
| 234 | 229 | $objects = scandir($url); |
| 235 | 230 | foreach ($objects as $object) { |
| 236 | 231 | if ($object != "." && $object != "..") { |
| 237 | - if (filetype($url."/".$object) == "dir") $this->supprimerDossier($url."/".$object); else unlink($url."/".$object); |
|
| 232 | + if (filetype($url."/".$object) == "dir") { |
|
| 233 | + $this->supprimerDossier($url."/".$object); |
|
| 234 | + } else { |
|
| 235 | + unlink($url."/".$object); |
|
| 236 | + } |
|
| 238 | 237 | } |
| 239 | 238 | } |
| 240 | 239 | reset($objects); |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use core\App; |
| 6 | 6 | use core\functions\ChaineCaractere; |
| 7 | - use core\HTML\flashmessage\FlashMessage; |
|
| 8 | 7 | |
| 9 | 8 | class RouterModule { |
| 10 | 9 | //varaibles de base de config |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | * @param $url |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - public function getUrl($url){ |
|
| 51 | + public function getUrl($url) { |
|
| 52 | 52 | $explode = explode("/", $url); |
| 53 | 53 | |
| 54 | - for ($i=0 ; $i<count($explode) ; $i++) { |
|
| 54 | + for ($i = 0; $i < count($explode); $i++) { |
|
| 55 | 55 | if (in_array($explode[$i], $this->getAllModules())) { |
| 56 | 56 | $this->module = $explode[$i]; |
| 57 | 57 | $debut_url = $explode[$i]; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $query = $dbc->query("SELECT * FROM module"); |
| 87 | 87 | |
| 88 | - foreach($query as $obj) { |
|
| 88 | + foreach ($query as $obj) { |
|
| 89 | 89 | $test_module = ChaineCaractere::FindInString($url, $obj->url); |
| 90 | 90 | $test_module1 = ChaineCaractere::FindInString($url, str_replace("/", "", $obj->url)); |
| 91 | 91 | $module_activer = \core\modules\GestionModule::getModuleActiver($obj->nom_module); |
@@ -55,12 +55,10 @@ discard block |
||
| 55 | 55 | if (in_array($explode[$i], $this->getAllModules())) { |
| 56 | 56 | $this->module = $explode[$i]; |
| 57 | 57 | $debut_url = $explode[$i]; |
| 58 | - } |
|
| 59 | - else if ($i == 1) { |
|
| 58 | + } else if ($i == 1) { |
|
| 60 | 59 | $centre_url = $explode[$i]; |
| 61 | 60 | $this->page = $explode[$i]; |
| 62 | - } |
|
| 63 | - else { |
|
| 61 | + } else { |
|
| 64 | 62 | $this->parametre = $explode[$i]; |
| 65 | 63 | } |
| 66 | 64 | } |
@@ -93,16 +91,14 @@ discard block |
||
| 93 | 91 | if ((($test_module == true) || ($test_module1 == true)) && ($module_activer == true)) { |
| 94 | 92 | $error = false; |
| 95 | 93 | break; |
| 96 | - } |
|
| 97 | - else { |
|
| 94 | + } else { |
|
| 98 | 95 | $error = true; |
| 99 | 96 | } |
| 100 | 97 | } |
| 101 | 98 | |
| 102 | 99 | if ($error == true) { |
| 103 | 100 | return false; |
| 104 | - } |
|
| 105 | - else { |
|
| 101 | + } else { |
|
| 106 | 102 | return true; |
| 107 | 103 | } |
| 108 | 104 | } |
@@ -7,6 +7,9 @@ |
||
| 7 | 7 | |
| 8 | 8 | class RedirectError { |
| 9 | 9 | |
| 10 | + /** |
|
| 11 | + * @param integer $type |
|
| 12 | + */ |
|
| 10 | 13 | public static function Redirect($type) { |
| 11 | 14 | if ($type == 404) { |
| 12 | 15 | header("HTTP/1.0 404 Not Found"); |
@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace core; |
| 3 | 3 | |
| 4 | - use core\functions\ChaineCaractere; |
|
| 5 | - use core\HTML\flashmessage\FlashMessage; |
|
| 6 | 4 | use core\modules\RouterModule; |
| 7 | 5 | |
| 8 | 6 | class RedirectError { |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - $find = 'controller/'; |
|
| 35 | + $find = 'controller/'; |
|
| 36 | 36 | $pos = strpos($url, $find); |
| 37 | 37 | |
| 38 | 38 | if ($pos !== false) { |
@@ -26,8 +26,7 @@ discard block |
||
| 26 | 26 | public static function testRedirect404($query, $url) { |
| 27 | 27 | if (is_array($query)) { |
| 28 | 28 | $count_query = count($query); |
| 29 | - } |
|
| 30 | - else { |
|
| 29 | + } else { |
|
| 31 | 30 | $count_query = 0; |
| 32 | 31 | } |
| 33 | 32 | |
@@ -37,15 +36,13 @@ discard block |
||
| 37 | 36 | |
| 38 | 37 | if ($pos !== false) { |
| 39 | 38 | $controller = true; |
| 40 | - } |
|
| 41 | - else { |
|
| 39 | + } else { |
|
| 42 | 40 | $controller = false; |
| 43 | 41 | } |
| 44 | 42 | |
| 45 | 43 | if (($count_query > 0) || ((!is_array($query)) && ($query > 0)) || ($controller == true)) { |
| 46 | 44 | return true; |
| 47 | - } |
|
| 48 | - else { |
|
| 45 | + } else { |
|
| 49 | 46 | $router = new RouterModule(); |
| 50 | 47 | |
| 51 | 48 | if ($router->getRouteModuleExist($url) == false) { |
@@ -243,6 +243,10 @@ |
||
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | + /** |
|
| 247 | + * @param integer $errorCode |
|
| 248 | + * @param string $path |
|
| 249 | + */ |
|
| 246 | 250 | function appendErrorNode(&$oErrorsNode, $errorCode, $name, $type, $path) |
| 247 | 251 | { |
| 248 | 252 | $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
@@ -32,224 +32,224 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class CKFinder_Connector_CommandHandler_CopyFiles extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Command name |
|
| 37 | - * |
|
| 38 | - * @access private |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - var $command = "CopyFiles"; |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * handle request and build XML |
|
| 46 | - * @access protected |
|
| 47 | - * |
|
| 48 | - */ |
|
| 49 | - function buildXml() |
|
| 50 | - { |
|
| 51 | - if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 52 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - $clientPath = $this->_currentFolder->getClientPath(); |
|
| 56 | - $sServerDir = $this->_currentFolder->getServerPath(); |
|
| 57 | - $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
|
| 58 | - $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 59 | - $_aclConfig = $_config->getAccessControlConfig(); |
|
| 60 | - $aclMasks = array(); |
|
| 61 | - $_resourceTypeConfig = array(); |
|
| 62 | - |
|
| 63 | - if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 64 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // Create the "Errors" node. |
|
| 68 | - $oErrorsNode = new CKFinder_Connector_Utils_XmlNode("Errors"); |
|
| 69 | - $errorCode = CKFINDER_CONNECTOR_ERROR_NONE; |
|
| 70 | - $copied = 0; |
|
| 71 | - $copiedAll = 0; |
|
| 72 | - if (!empty($_POST['copied'])) { |
|
| 73 | - $copiedAll = intval($_POST['copied']); |
|
| 74 | - } |
|
| 75 | - $checkedPaths = array(); |
|
| 76 | - |
|
| 77 | - $oCopyFilesNode = new Ckfinder_Connector_Utils_XmlNode("CopyFiles"); |
|
| 78 | - |
|
| 79 | - if (!empty($_POST['files']) && is_array($_POST['files'])) { |
|
| 80 | - foreach ($_POST['files'] as $index => $arr) { |
|
| 81 | - if (empty($arr['name'])) { |
|
| 82 | - continue; |
|
| 83 | - } |
|
| 84 | - if (!isset($arr['name'], $arr['type'], $arr['folder'])) { |
|
| 85 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - // file name |
|
| 89 | - $name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']); |
|
| 90 | - // resource type |
|
| 91 | - $type = $arr['type']; |
|
| 92 | - // client path |
|
| 93 | - $path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']); |
|
| 94 | - // options |
|
| 95 | - $options = (!empty($arr['options'])) ? $arr['options'] : ''; |
|
| 96 | - |
|
| 97 | - $destinationFilePath = $sServerDir.$name; |
|
| 98 | - |
|
| 99 | - // check #1 (path) |
|
| 100 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) { |
|
| 101 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - // get resource type config for current file |
|
| 105 | - if (!isset($_resourceTypeConfig[$type])) { |
|
| 106 | - $_resourceTypeConfig[$type] = $_config->getResourceTypeConfig($type); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // check #2 (resource type) |
|
| 110 | - if (is_null($_resourceTypeConfig[$type])) { |
|
| 111 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - // check #3 (extension) |
|
| 115 | - if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) { |
|
| 116 | - $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 117 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 118 | - continue; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // check #4 (extension) - when moving to another resource type, double check extension |
|
| 122 | - if ($currentResourceTypeConfig->getName() != $type) { |
|
| 123 | - if (!$currentResourceTypeConfig->checkExtension($name, false)) { |
|
| 124 | - $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 125 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 126 | - continue; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // check #5 (hidden folders) |
|
| 131 | - // cache results |
|
| 132 | - if (empty($checkedPaths[$path])) { |
|
| 133 | - $checkedPaths[$path] = true; |
|
| 134 | - |
|
| 135 | - if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) { |
|
| 136 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - $sourceFilePath = $_resourceTypeConfig[$type]->getDirectory().$path.$name; |
|
| 141 | - |
|
| 142 | - // check #6 (hidden file name) |
|
| 143 | - if ($currentResourceTypeConfig->checkIsHiddenFile($name)) { |
|
| 144 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // check #7 (Access Control, need file view permission to source files) |
|
| 148 | - if (!isset($aclMasks[$type."@".$path])) { |
|
| 149 | - $aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - $isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 153 | - if (!$isAuthorized) { |
|
| 154 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - // check #8 (invalid file name) |
|
| 158 | - if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) { |
|
| 159 | - $errorCode = CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND; |
|
| 160 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 161 | - continue; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // check #9 (max size) |
|
| 165 | - if ($currentResourceTypeConfig->getName() != $type) { |
|
| 166 | - $maxSize = $currentResourceTypeConfig->getMaxSize(); |
|
| 167 | - $fileSize = filesize($sourceFilePath); |
|
| 168 | - if ($maxSize && $fileSize>$maxSize) { |
|
| 169 | - $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
|
| 170 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 171 | - continue; |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - //$overwrite |
|
| 176 | - // finally, no errors so far, we may attempt to copy a file |
|
| 177 | - // protection against copying files to itself |
|
| 178 | - if ($sourceFilePath == $destinationFilePath) { |
|
| 179 | - $errorCode = CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL; |
|
| 180 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 181 | - continue; |
|
| 182 | - } |
|
| 183 | - // check if file exists if we don't force overwriting |
|
| 184 | - else if (file_exists($destinationFilePath) && strpos($options, "overwrite") === false) { |
|
| 185 | - if (strpos($options, "autorename") !== false) { |
|
| 186 | - $iCounter = 1; |
|
| 187 | - while (true) |
|
| 188 | - { |
|
| 189 | - $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) . |
|
| 190 | - "(" . $iCounter . ")" . "." . |
|
| 191 | - CKFinder_Connector_Utils_FileSystem::getExtension($name); |
|
| 192 | - |
|
| 193 | - $destinationFilePath = $sServerDir.$fileName; |
|
| 194 | - if (!file_exists($destinationFilePath)) { |
|
| 195 | - break; |
|
| 196 | - } |
|
| 197 | - else { |
|
| 198 | - $iCounter++; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - if (!@copy($sourceFilePath, $destinationFilePath)) { |
|
| 202 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 203 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 204 | - continue; |
|
| 205 | - } |
|
| 206 | - else { |
|
| 207 | - $copied++; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - else { |
|
| 211 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
|
| 212 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 213 | - continue; |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - // copy() overwrites without warning |
|
| 217 | - else { |
|
| 218 | - if (!@copy($sourceFilePath, $destinationFilePath)) { |
|
| 219 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 220 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 221 | - continue; |
|
| 222 | - } |
|
| 223 | - else { |
|
| 224 | - $copied++; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - $this->_connectorNode->addChild($oCopyFilesNode); |
|
| 231 | - if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 232 | - $this->_connectorNode->addChild($oErrorsNode); |
|
| 233 | - } |
|
| 234 | - $oCopyFilesNode->addAttribute("copied", $copied); |
|
| 235 | - $oCopyFilesNode->addAttribute("copiedTotal", $copiedAll + $copied); |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Note: actually we could have more than one error. |
|
| 239 | - * This is just a flag for CKFinder interface telling it to check all errors. |
|
| 240 | - */ |
|
| 241 | - if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 242 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_COPY_FAILED); |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - function appendErrorNode(&$oErrorsNode, $errorCode, $name, $type, $path) |
|
| 247 | - { |
|
| 248 | - $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
|
| 249 | - $oErrorNode->addAttribute("code", $errorCode); |
|
| 250 | - $oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 251 | - $oErrorNode->addAttribute("type", $type); |
|
| 252 | - $oErrorNode->addAttribute("folder", $path); |
|
| 253 | - $oErrorsNode->addChild($oErrorNode); |
|
| 254 | - } |
|
| 35 | + /** |
|
| 36 | + * Command name |
|
| 37 | + * |
|
| 38 | + * @access private |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + var $command = "CopyFiles"; |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * handle request and build XML |
|
| 46 | + * @access protected |
|
| 47 | + * |
|
| 48 | + */ |
|
| 49 | + function buildXml() |
|
| 50 | + { |
|
| 51 | + if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 52 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + $clientPath = $this->_currentFolder->getClientPath(); |
|
| 56 | + $sServerDir = $this->_currentFolder->getServerPath(); |
|
| 57 | + $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
|
| 58 | + $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 59 | + $_aclConfig = $_config->getAccessControlConfig(); |
|
| 60 | + $aclMasks = array(); |
|
| 61 | + $_resourceTypeConfig = array(); |
|
| 62 | + |
|
| 63 | + if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 64 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // Create the "Errors" node. |
|
| 68 | + $oErrorsNode = new CKFinder_Connector_Utils_XmlNode("Errors"); |
|
| 69 | + $errorCode = CKFINDER_CONNECTOR_ERROR_NONE; |
|
| 70 | + $copied = 0; |
|
| 71 | + $copiedAll = 0; |
|
| 72 | + if (!empty($_POST['copied'])) { |
|
| 73 | + $copiedAll = intval($_POST['copied']); |
|
| 74 | + } |
|
| 75 | + $checkedPaths = array(); |
|
| 76 | + |
|
| 77 | + $oCopyFilesNode = new Ckfinder_Connector_Utils_XmlNode("CopyFiles"); |
|
| 78 | + |
|
| 79 | + if (!empty($_POST['files']) && is_array($_POST['files'])) { |
|
| 80 | + foreach ($_POST['files'] as $index => $arr) { |
|
| 81 | + if (empty($arr['name'])) { |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 84 | + if (!isset($arr['name'], $arr['type'], $arr['folder'])) { |
|
| 85 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + // file name |
|
| 89 | + $name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']); |
|
| 90 | + // resource type |
|
| 91 | + $type = $arr['type']; |
|
| 92 | + // client path |
|
| 93 | + $path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']); |
|
| 94 | + // options |
|
| 95 | + $options = (!empty($arr['options'])) ? $arr['options'] : ''; |
|
| 96 | + |
|
| 97 | + $destinationFilePath = $sServerDir.$name; |
|
| 98 | + |
|
| 99 | + // check #1 (path) |
|
| 100 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) { |
|
| 101 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + // get resource type config for current file |
|
| 105 | + if (!isset($_resourceTypeConfig[$type])) { |
|
| 106 | + $_resourceTypeConfig[$type] = $_config->getResourceTypeConfig($type); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // check #2 (resource type) |
|
| 110 | + if (is_null($_resourceTypeConfig[$type])) { |
|
| 111 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + // check #3 (extension) |
|
| 115 | + if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) { |
|
| 116 | + $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 117 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // check #4 (extension) - when moving to another resource type, double check extension |
|
| 122 | + if ($currentResourceTypeConfig->getName() != $type) { |
|
| 123 | + if (!$currentResourceTypeConfig->checkExtension($name, false)) { |
|
| 124 | + $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 125 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 126 | + continue; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // check #5 (hidden folders) |
|
| 131 | + // cache results |
|
| 132 | + if (empty($checkedPaths[$path])) { |
|
| 133 | + $checkedPaths[$path] = true; |
|
| 134 | + |
|
| 135 | + if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) { |
|
| 136 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + $sourceFilePath = $_resourceTypeConfig[$type]->getDirectory().$path.$name; |
|
| 141 | + |
|
| 142 | + // check #6 (hidden file name) |
|
| 143 | + if ($currentResourceTypeConfig->checkIsHiddenFile($name)) { |
|
| 144 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // check #7 (Access Control, need file view permission to source files) |
|
| 148 | + if (!isset($aclMasks[$type."@".$path])) { |
|
| 149 | + $aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + $isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 153 | + if (!$isAuthorized) { |
|
| 154 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + // check #8 (invalid file name) |
|
| 158 | + if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) { |
|
| 159 | + $errorCode = CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND; |
|
| 160 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // check #9 (max size) |
|
| 165 | + if ($currentResourceTypeConfig->getName() != $type) { |
|
| 166 | + $maxSize = $currentResourceTypeConfig->getMaxSize(); |
|
| 167 | + $fileSize = filesize($sourceFilePath); |
|
| 168 | + if ($maxSize && $fileSize>$maxSize) { |
|
| 169 | + $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
|
| 170 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + //$overwrite |
|
| 176 | + // finally, no errors so far, we may attempt to copy a file |
|
| 177 | + // protection against copying files to itself |
|
| 178 | + if ($sourceFilePath == $destinationFilePath) { |
|
| 179 | + $errorCode = CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL; |
|
| 180 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 181 | + continue; |
|
| 182 | + } |
|
| 183 | + // check if file exists if we don't force overwriting |
|
| 184 | + else if (file_exists($destinationFilePath) && strpos($options, "overwrite") === false) { |
|
| 185 | + if (strpos($options, "autorename") !== false) { |
|
| 186 | + $iCounter = 1; |
|
| 187 | + while (true) |
|
| 188 | + { |
|
| 189 | + $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) . |
|
| 190 | + "(" . $iCounter . ")" . "." . |
|
| 191 | + CKFinder_Connector_Utils_FileSystem::getExtension($name); |
|
| 192 | + |
|
| 193 | + $destinationFilePath = $sServerDir.$fileName; |
|
| 194 | + if (!file_exists($destinationFilePath)) { |
|
| 195 | + break; |
|
| 196 | + } |
|
| 197 | + else { |
|
| 198 | + $iCounter++; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + if (!@copy($sourceFilePath, $destinationFilePath)) { |
|
| 202 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 203 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 204 | + continue; |
|
| 205 | + } |
|
| 206 | + else { |
|
| 207 | + $copied++; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + else { |
|
| 211 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
|
| 212 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 213 | + continue; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + // copy() overwrites without warning |
|
| 217 | + else { |
|
| 218 | + if (!@copy($sourceFilePath, $destinationFilePath)) { |
|
| 219 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 220 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 221 | + continue; |
|
| 222 | + } |
|
| 223 | + else { |
|
| 224 | + $copied++; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + $this->_connectorNode->addChild($oCopyFilesNode); |
|
| 231 | + if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 232 | + $this->_connectorNode->addChild($oErrorsNode); |
|
| 233 | + } |
|
| 234 | + $oCopyFilesNode->addAttribute("copied", $copied); |
|
| 235 | + $oCopyFilesNode->addAttribute("copiedTotal", $copiedAll + $copied); |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Note: actually we could have more than one error. |
|
| 239 | + * This is just a flag for CKFinder interface telling it to check all errors. |
|
| 240 | + */ |
|
| 241 | + if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 242 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_COPY_FAILED); |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + function appendErrorNode(&$oErrorsNode, $errorCode, $name, $type, $path) |
|
| 247 | + { |
|
| 248 | + $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
|
| 249 | + $oErrorNode->addAttribute("code", $errorCode); |
|
| 250 | + $oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 251 | + $oErrorNode->addAttribute("type", $type); |
|
| 252 | + $oErrorNode->addAttribute("folder", $path); |
|
| 253 | + $oErrorsNode->addChild($oErrorNode); |
|
| 254 | + } |
|
| 255 | 255 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Include base XML command handler |
| 23 | 23 | */ |
| 24 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php"; |
|
| 24 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php"; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Handle CopyFiles command |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $clientPath = $this->_currentFolder->getClientPath(); |
| 56 | 56 | $sServerDir = $this->_currentFolder->getServerPath(); |
| 57 | 57 | $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
| 58 | - $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 58 | + $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 59 | 59 | $_aclConfig = $_config->getAccessControlConfig(); |
| 60 | 60 | $aclMasks = array(); |
| 61 | 61 | $_resourceTypeConfig = array(); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | if ($currentResourceTypeConfig->getName() != $type) { |
| 166 | 166 | $maxSize = $currentResourceTypeConfig->getMaxSize(); |
| 167 | 167 | $fileSize = filesize($sourceFilePath); |
| 168 | - if ($maxSize && $fileSize>$maxSize) { |
|
| 168 | + if ($maxSize && $fileSize > $maxSize) { |
|
| 169 | 169 | $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
| 170 | 170 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 171 | 171 | continue; |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | $iCounter = 1; |
| 187 | 187 | while (true) |
| 188 | 188 | { |
| 189 | - $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) . |
|
| 190 | - "(" . $iCounter . ")" . "." . |
|
| 189 | + $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name). |
|
| 190 | + "(".$iCounter.")".".". |
|
| 191 | 191 | CKFinder_Connector_Utils_FileSystem::getExtension($name); |
| 192 | 192 | |
| 193 | 193 | $destinationFilePath = $sServerDir.$fileName; |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * modifying or distribute this file or part of its contents. The contents of |
| 11 | 11 | * this file is part of the Source Code of CKFinder. |
| 12 | 12 | */ |
| 13 | -if (!defined('IN_CKFINDER')) exit; |
|
| 13 | +if (!defined('IN_CKFINDER')) { |
|
| 14 | + exit; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * @package CKFinder |
@@ -193,8 +195,7 @@ discard block |
||
| 193 | 195 | $destinationFilePath = $sServerDir.$fileName; |
| 194 | 196 | if (!file_exists($destinationFilePath)) { |
| 195 | 197 | break; |
| 196 | - } |
|
| 197 | - else { |
|
| 198 | + } else { |
|
| 198 | 199 | $iCounter++; |
| 199 | 200 | } |
| 200 | 201 | } |
@@ -202,12 +203,10 @@ discard block |
||
| 202 | 203 | $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
| 203 | 204 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 204 | 205 | continue; |
| 205 | - } |
|
| 206 | - else { |
|
| 206 | + } else { |
|
| 207 | 207 | $copied++; |
| 208 | 208 | } |
| 209 | - } |
|
| 210 | - else { |
|
| 209 | + } else { |
|
| 211 | 210 | $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
| 212 | 211 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 213 | 212 | continue; |
@@ -219,8 +218,7 @@ discard block |
||
| 219 | 218 | $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
| 220 | 219 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 221 | 220 | continue; |
| 222 | - } |
|
| 223 | - else { |
|
| 221 | + } else { |
|
| 224 | 222 | $copied++; |
| 225 | 223 | } |
| 226 | 224 | } |
@@ -259,6 +259,10 @@ |
||
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | + /** |
|
| 263 | + * @param integer $errorCode |
|
| 264 | + * @param string $path |
|
| 265 | + */ |
|
| 262 | 266 | function appendErrorNode(&$oErrorsNode, $errorCode, $name, $type, $path) |
| 263 | 267 | { |
| 264 | 268 | $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
@@ -32,240 +32,240 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class CKFinder_Connector_CommandHandler_MoveFiles extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Command name |
|
| 37 | - * |
|
| 38 | - * @access private |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - var $command = "MoveFiles"; |
|
| 35 | + /** |
|
| 36 | + * Command name |
|
| 37 | + * |
|
| 38 | + * @access private |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + var $command = "MoveFiles"; |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * handle request and build XML |
|
| 46 | - * @access protected |
|
| 47 | - * |
|
| 48 | - */ |
|
| 49 | - function buildXml() |
|
| 50 | - { |
|
| 51 | - if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 52 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * handle request and build XML |
|
| 46 | + * @access protected |
|
| 47 | + * |
|
| 48 | + */ |
|
| 49 | + function buildXml() |
|
| 50 | + { |
|
| 51 | + if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') { |
|
| 52 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $clientPath = $this->_currentFolder->getClientPath(); |
|
| 56 | - $sServerDir = $this->_currentFolder->getServerPath(); |
|
| 57 | - $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
|
| 58 | - $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 59 | - $_aclConfig = $_config->getAccessControlConfig(); |
|
| 60 | - $aclMasks = array(); |
|
| 61 | - $_resourceTypeConfig = array(); |
|
| 55 | + $clientPath = $this->_currentFolder->getClientPath(); |
|
| 56 | + $sServerDir = $this->_currentFolder->getServerPath(); |
|
| 57 | + $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
|
| 58 | + $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 59 | + $_aclConfig = $_config->getAccessControlConfig(); |
|
| 60 | + $aclMasks = array(); |
|
| 61 | + $_resourceTypeConfig = array(); |
|
| 62 | 62 | |
| 63 | - if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 64 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 65 | - } |
|
| 63 | + if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) { |
|
| 64 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - // Create the "Errors" node. |
|
| 68 | - $oErrorsNode = new CKFinder_Connector_Utils_XmlNode("Errors"); |
|
| 69 | - $errorCode = CKFINDER_CONNECTOR_ERROR_NONE; |
|
| 70 | - $moved = 0; |
|
| 71 | - $movedAll = 0; |
|
| 72 | - if (!empty($_POST['moved'])) { |
|
| 73 | - $movedAll = intval($_POST['moved']); |
|
| 74 | - } |
|
| 75 | - $checkedPaths = array(); |
|
| 67 | + // Create the "Errors" node. |
|
| 68 | + $oErrorsNode = new CKFinder_Connector_Utils_XmlNode("Errors"); |
|
| 69 | + $errorCode = CKFINDER_CONNECTOR_ERROR_NONE; |
|
| 70 | + $moved = 0; |
|
| 71 | + $movedAll = 0; |
|
| 72 | + if (!empty($_POST['moved'])) { |
|
| 73 | + $movedAll = intval($_POST['moved']); |
|
| 74 | + } |
|
| 75 | + $checkedPaths = array(); |
|
| 76 | 76 | |
| 77 | - $oMoveFilesNode = new Ckfinder_Connector_Utils_XmlNode("MoveFiles"); |
|
| 77 | + $oMoveFilesNode = new Ckfinder_Connector_Utils_XmlNode("MoveFiles"); |
|
| 78 | 78 | |
| 79 | - if (!empty($_POST['files']) && is_array($_POST['files'])) { |
|
| 80 | - foreach ($_POST['files'] as $index => $arr) { |
|
| 81 | - if (empty($arr['name'])) { |
|
| 82 | - continue; |
|
| 83 | - } |
|
| 84 | - if (!isset($arr['name'], $arr['type'], $arr['folder'])) { |
|
| 85 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 86 | - } |
|
| 79 | + if (!empty($_POST['files']) && is_array($_POST['files'])) { |
|
| 80 | + foreach ($_POST['files'] as $index => $arr) { |
|
| 81 | + if (empty($arr['name'])) { |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 84 | + if (!isset($arr['name'], $arr['type'], $arr['folder'])) { |
|
| 85 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // file name |
|
| 89 | - $name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']); |
|
| 90 | - // resource type |
|
| 91 | - $type = $arr['type']; |
|
| 92 | - // client path |
|
| 93 | - $path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']); |
|
| 94 | - // options |
|
| 95 | - $options = (!empty($arr['options'])) ? $arr['options'] : ''; |
|
| 88 | + // file name |
|
| 89 | + $name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']); |
|
| 90 | + // resource type |
|
| 91 | + $type = $arr['type']; |
|
| 92 | + // client path |
|
| 93 | + $path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']); |
|
| 94 | + // options |
|
| 95 | + $options = (!empty($arr['options'])) ? $arr['options'] : ''; |
|
| 96 | 96 | |
| 97 | - $destinationFilePath = $sServerDir.$name; |
|
| 97 | + $destinationFilePath = $sServerDir.$name; |
|
| 98 | 98 | |
| 99 | - // check #1 (path) |
|
| 100 | - if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) { |
|
| 101 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 102 | - } |
|
| 99 | + // check #1 (path) |
|
| 100 | + if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) { |
|
| 101 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - // get resource type config for current file |
|
| 105 | - if (!isset($_resourceTypeConfig[$type])) { |
|
| 106 | - $_resourceTypeConfig[$type] = $_config->getResourceTypeConfig($type); |
|
| 107 | - } |
|
| 104 | + // get resource type config for current file |
|
| 105 | + if (!isset($_resourceTypeConfig[$type])) { |
|
| 106 | + $_resourceTypeConfig[$type] = $_config->getResourceTypeConfig($type); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - // check #2 (resource type) |
|
| 110 | - if (is_null($_resourceTypeConfig[$type])) { |
|
| 111 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 112 | - } |
|
| 109 | + // check #2 (resource type) |
|
| 110 | + if (is_null($_resourceTypeConfig[$type])) { |
|
| 111 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - // check #3 (extension) |
|
| 115 | - if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) { |
|
| 116 | - $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 117 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 118 | - continue; |
|
| 119 | - } |
|
| 114 | + // check #3 (extension) |
|
| 115 | + if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) { |
|
| 116 | + $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 117 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - // check #4 (extension) - when moving to another resource type, double check extension |
|
| 122 | - if ($currentResourceTypeConfig->getName() != $type) { |
|
| 123 | - if (!$currentResourceTypeConfig->checkExtension($name, false)) { |
|
| 124 | - $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 125 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 126 | - continue; |
|
| 127 | - } |
|
| 128 | - } |
|
| 121 | + // check #4 (extension) - when moving to another resource type, double check extension |
|
| 122 | + if ($currentResourceTypeConfig->getName() != $type) { |
|
| 123 | + if (!$currentResourceTypeConfig->checkExtension($name, false)) { |
|
| 124 | + $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION; |
|
| 125 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 126 | + continue; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - // check #5 (hidden folders) |
|
| 131 | - // cache results |
|
| 132 | - if (empty($checkedPaths[$path])) { |
|
| 133 | - $checkedPaths[$path] = true; |
|
| 130 | + // check #5 (hidden folders) |
|
| 131 | + // cache results |
|
| 132 | + if (empty($checkedPaths[$path])) { |
|
| 133 | + $checkedPaths[$path] = true; |
|
| 134 | 134 | |
| 135 | - if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) { |
|
| 136 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 137 | - } |
|
| 138 | - } |
|
| 135 | + if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) { |
|
| 136 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - $sourceFilePath = $_resourceTypeConfig[$type]->getDirectory().$path.$name; |
|
| 140 | + $sourceFilePath = $_resourceTypeConfig[$type]->getDirectory().$path.$name; |
|
| 141 | 141 | |
| 142 | - // check #6 (hidden file name) |
|
| 143 | - if ($currentResourceTypeConfig->checkIsHiddenFile($name)) { |
|
| 144 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 145 | - } |
|
| 142 | + // check #6 (hidden file name) |
|
| 143 | + if ($currentResourceTypeConfig->checkIsHiddenFile($name)) { |
|
| 144 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - // check #7 (Access Control, need file view permission to source files) |
|
| 148 | - if (!isset($aclMasks[$type."@".$path])) { |
|
| 149 | - $aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path); |
|
| 150 | - } |
|
| 147 | + // check #7 (Access Control, need file view permission to source files) |
|
| 148 | + if (!isset($aclMasks[$type."@".$path])) { |
|
| 149 | + $aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - $isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 153 | - if (!$isAuthorized) { |
|
| 154 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 155 | - } |
|
| 152 | + $isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW); |
|
| 153 | + if (!$isAuthorized) { |
|
| 154 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - // check #8 (invalid file name) |
|
| 158 | - if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) { |
|
| 159 | - $errorCode = CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND; |
|
| 160 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 161 | - continue; |
|
| 162 | - } |
|
| 157 | + // check #8 (invalid file name) |
|
| 158 | + if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) { |
|
| 159 | + $errorCode = CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND; |
|
| 160 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - // check #9 (max size) |
|
| 165 | - if ($currentResourceTypeConfig->getName() != $type) { |
|
| 166 | - $maxSize = $currentResourceTypeConfig->getMaxSize(); |
|
| 167 | - $fileSize = filesize($sourceFilePath); |
|
| 168 | - if ($maxSize && $fileSize>$maxSize) { |
|
| 169 | - $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
|
| 170 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 171 | - continue; |
|
| 172 | - } |
|
| 173 | - } |
|
| 164 | + // check #9 (max size) |
|
| 165 | + if ($currentResourceTypeConfig->getName() != $type) { |
|
| 166 | + $maxSize = $currentResourceTypeConfig->getMaxSize(); |
|
| 167 | + $fileSize = filesize($sourceFilePath); |
|
| 168 | + if ($maxSize && $fileSize>$maxSize) { |
|
| 169 | + $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
|
| 170 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - //$overwrite |
|
| 176 | - // finally, no errors so far, we may attempt to copy a file |
|
| 177 | - // protection against copying files to itself |
|
| 178 | - if ($sourceFilePath == $destinationFilePath) { |
|
| 179 | - $errorCode = CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL; |
|
| 180 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 181 | - continue; |
|
| 182 | - } |
|
| 183 | - // check if file exists if we don't force overwriting |
|
| 184 | - else if (file_exists($destinationFilePath)) { |
|
| 185 | - if (strpos($options, "overwrite") !== false) { |
|
| 186 | - if (!@unlink($destinationFilePath)) { |
|
| 187 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 188 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 189 | - continue; |
|
| 190 | - } |
|
| 191 | - else { |
|
| 192 | - if (!@rename($sourceFilePath, $destinationFilePath)) { |
|
| 193 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 194 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 195 | - continue; |
|
| 196 | - } |
|
| 197 | - else { |
|
| 198 | - $moved++; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - else if (strpos($options, "autorename") !== false) { |
|
| 203 | - $iCounter = 1; |
|
| 204 | - while (true) |
|
| 205 | - { |
|
| 206 | - $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) . |
|
| 207 | - "(" . $iCounter . ")" . "." . |
|
| 208 | - CKFinder_Connector_Utils_FileSystem::getExtension($name); |
|
| 175 | + //$overwrite |
|
| 176 | + // finally, no errors so far, we may attempt to copy a file |
|
| 177 | + // protection against copying files to itself |
|
| 178 | + if ($sourceFilePath == $destinationFilePath) { |
|
| 179 | + $errorCode = CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL; |
|
| 180 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 181 | + continue; |
|
| 182 | + } |
|
| 183 | + // check if file exists if we don't force overwriting |
|
| 184 | + else if (file_exists($destinationFilePath)) { |
|
| 185 | + if (strpos($options, "overwrite") !== false) { |
|
| 186 | + if (!@unlink($destinationFilePath)) { |
|
| 187 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 188 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 189 | + continue; |
|
| 190 | + } |
|
| 191 | + else { |
|
| 192 | + if (!@rename($sourceFilePath, $destinationFilePath)) { |
|
| 193 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 194 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 195 | + continue; |
|
| 196 | + } |
|
| 197 | + else { |
|
| 198 | + $moved++; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + else if (strpos($options, "autorename") !== false) { |
|
| 203 | + $iCounter = 1; |
|
| 204 | + while (true) |
|
| 205 | + { |
|
| 206 | + $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) . |
|
| 207 | + "(" . $iCounter . ")" . "." . |
|
| 208 | + CKFinder_Connector_Utils_FileSystem::getExtension($name); |
|
| 209 | 209 | |
| 210 | - $destinationFilePath = $sServerDir.$fileName; |
|
| 211 | - if (!file_exists($destinationFilePath)) { |
|
| 212 | - break; |
|
| 213 | - } |
|
| 214 | - else { |
|
| 215 | - $iCounter++; |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - if (!@rename($sourceFilePath, $destinationFilePath)) { |
|
| 219 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 220 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 221 | - continue; |
|
| 222 | - } |
|
| 223 | - else { |
|
| 224 | - $moved++; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - else { |
|
| 228 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
|
| 229 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 230 | - continue; |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - else { |
|
| 234 | - if (!@rename($sourceFilePath, $destinationFilePath)) { |
|
| 235 | - $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 236 | - $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 237 | - continue; |
|
| 238 | - } |
|
| 239 | - else { |
|
| 240 | - $moved++; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - } |
|
| 210 | + $destinationFilePath = $sServerDir.$fileName; |
|
| 211 | + if (!file_exists($destinationFilePath)) { |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | + else { |
|
| 215 | + $iCounter++; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + if (!@rename($sourceFilePath, $destinationFilePath)) { |
|
| 219 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 220 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 221 | + continue; |
|
| 222 | + } |
|
| 223 | + else { |
|
| 224 | + $moved++; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + else { |
|
| 228 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
|
| 229 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 230 | + continue; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + else { |
|
| 234 | + if (!@rename($sourceFilePath, $destinationFilePath)) { |
|
| 235 | + $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
|
| 236 | + $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
|
| 237 | + continue; |
|
| 238 | + } |
|
| 239 | + else { |
|
| 240 | + $moved++; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - $this->_connectorNode->addChild($oMoveFilesNode); |
|
| 247 | - if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 248 | - $this->_connectorNode->addChild($oErrorsNode); |
|
| 249 | - } |
|
| 250 | - $oMoveFilesNode->addAttribute("moved", $moved); |
|
| 251 | - $oMoveFilesNode->addAttribute("movedTotal", $movedAll + $moved); |
|
| 246 | + $this->_connectorNode->addChild($oMoveFilesNode); |
|
| 247 | + if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 248 | + $this->_connectorNode->addChild($oErrorsNode); |
|
| 249 | + } |
|
| 250 | + $oMoveFilesNode->addAttribute("moved", $moved); |
|
| 251 | + $oMoveFilesNode->addAttribute("movedTotal", $movedAll + $moved); |
|
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Note: actually we could have more than one error. |
|
| 255 | - * This is just a flag for CKFinder interface telling it to check all errors. |
|
| 256 | - */ |
|
| 257 | - if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 258 | - $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_MOVE_FAILED); |
|
| 259 | - } |
|
| 260 | - } |
|
| 253 | + /** |
|
| 254 | + * Note: actually we could have more than one error. |
|
| 255 | + * This is just a flag for CKFinder interface telling it to check all errors. |
|
| 256 | + */ |
|
| 257 | + if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) { |
|
| 258 | + $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_MOVE_FAILED); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - function appendErrorNode(&$oErrorsNode, $errorCode, $name, $type, $path) |
|
| 263 | - { |
|
| 264 | - $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
|
| 265 | - $oErrorNode->addAttribute("code", $errorCode); |
|
| 266 | - $oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 267 | - $oErrorNode->addAttribute("type", $type); |
|
| 268 | - $oErrorNode->addAttribute("folder", $path); |
|
| 269 | - $oErrorsNode->addChild($oErrorNode); |
|
| 270 | - } |
|
| 262 | + function appendErrorNode(&$oErrorsNode, $errorCode, $name, $type, $path) |
|
| 263 | + { |
|
| 264 | + $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error"); |
|
| 265 | + $oErrorNode->addAttribute("code", $errorCode); |
|
| 266 | + $oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name)); |
|
| 267 | + $oErrorNode->addAttribute("type", $type); |
|
| 268 | + $oErrorNode->addAttribute("folder", $path); |
|
| 269 | + $oErrorsNode->addChild($oErrorNode); |
|
| 270 | + } |
|
| 271 | 271 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Include base XML command handler |
| 23 | 23 | */ |
| 24 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php"; |
|
| 24 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php"; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Handle MoveFiles command |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $clientPath = $this->_currentFolder->getClientPath(); |
| 56 | 56 | $sServerDir = $this->_currentFolder->getServerPath(); |
| 57 | 57 | $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig(); |
| 58 | - $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 58 | + $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 59 | 59 | $_aclConfig = $_config->getAccessControlConfig(); |
| 60 | 60 | $aclMasks = array(); |
| 61 | 61 | $_resourceTypeConfig = array(); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | if ($currentResourceTypeConfig->getName() != $type) { |
| 166 | 166 | $maxSize = $currentResourceTypeConfig->getMaxSize(); |
| 167 | 167 | $fileSize = filesize($sourceFilePath); |
| 168 | - if ($maxSize && $fileSize>$maxSize) { |
|
| 168 | + if ($maxSize && $fileSize > $maxSize) { |
|
| 169 | 169 | $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; |
| 170 | 170 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 171 | 171 | continue; |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | $iCounter = 1; |
| 204 | 204 | while (true) |
| 205 | 205 | { |
| 206 | - $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) . |
|
| 207 | - "(" . $iCounter . ")" . "." . |
|
| 206 | + $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name). |
|
| 207 | + "(".$iCounter.")".".". |
|
| 208 | 208 | CKFinder_Connector_Utils_FileSystem::getExtension($name); |
| 209 | 209 | |
| 210 | 210 | $destinationFilePath = $sServerDir.$fileName; |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * modifying or distribute this file or part of its contents. The contents of |
| 11 | 11 | * this file is part of the Source Code of CKFinder. |
| 12 | 12 | */ |
| 13 | -if (!defined('IN_CKFINDER')) exit; |
|
| 13 | +if (!defined('IN_CKFINDER')) { |
|
| 14 | + exit; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * @package CKFinder |
@@ -187,19 +189,16 @@ discard block |
||
| 187 | 189 | $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
| 188 | 190 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 189 | 191 | continue; |
| 190 | - } |
|
| 191 | - else { |
|
| 192 | + } else { |
|
| 192 | 193 | if (!@rename($sourceFilePath, $destinationFilePath)) { |
| 193 | 194 | $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
| 194 | 195 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 195 | 196 | continue; |
| 196 | - } |
|
| 197 | - else { |
|
| 197 | + } else { |
|
| 198 | 198 | $moved++; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | - } |
|
| 202 | - else if (strpos($options, "autorename") !== false) { |
|
| 201 | + } else if (strpos($options, "autorename") !== false) { |
|
| 203 | 202 | $iCounter = 1; |
| 204 | 203 | while (true) |
| 205 | 204 | { |
@@ -210,8 +209,7 @@ discard block |
||
| 210 | 209 | $destinationFilePath = $sServerDir.$fileName; |
| 211 | 210 | if (!file_exists($destinationFilePath)) { |
| 212 | 211 | break; |
| 213 | - } |
|
| 214 | - else { |
|
| 212 | + } else { |
|
| 215 | 213 | $iCounter++; |
| 216 | 214 | } |
| 217 | 215 | } |
@@ -219,24 +217,20 @@ discard block |
||
| 219 | 217 | $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
| 220 | 218 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 221 | 219 | continue; |
| 222 | - } |
|
| 223 | - else { |
|
| 220 | + } else { |
|
| 224 | 221 | $moved++; |
| 225 | 222 | } |
| 226 | - } |
|
| 227 | - else { |
|
| 223 | + } else { |
|
| 228 | 224 | $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; |
| 229 | 225 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 230 | 226 | continue; |
| 231 | 227 | } |
| 232 | - } |
|
| 233 | - else { |
|
| 228 | + } else { |
|
| 234 | 229 | if (!@rename($sourceFilePath, $destinationFilePath)) { |
| 235 | 230 | $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; |
| 236 | 231 | $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path); |
| 237 | 232 | continue; |
| 238 | - } |
|
| 239 | - else { |
|
| 233 | + } else { |
|
| 240 | 234 | $moved++; |
| 241 | 235 | } |
| 242 | 236 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * Get "forceAscii" value |
| 233 | 233 | * |
| 234 | 234 | * @access public |
| 235 | - * @return array |
|
| 235 | + * @return boolean |
|
| 236 | 236 | */ |
| 237 | 237 | function forceAscii() |
| 238 | 238 | { |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * Get regular expression to hide folders |
| 244 | 244 | * |
| 245 | 245 | * @access public |
| 246 | - * @return array |
|
| 246 | + * @return string |
|
| 247 | 247 | */ |
| 248 | 248 | function getHideFoldersRegex() |
| 249 | 249 | { |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * Get regular expression to hide files |
| 270 | 270 | * |
| 271 | 271 | * @access public |
| 272 | - * @return array |
|
| 272 | + * @return string |
|
| 273 | 273 | */ |
| 274 | 274 | function getHideFilesRegex() |
| 275 | 275 | { |
@@ -46,491 +46,491 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class CKFinder_Connector_Core_Config |
| 48 | 48 | { |
| 49 | - /** |
|
| 50 | - * Is CKFinder enabled |
|
| 51 | - * |
|
| 52 | - * @var boolean |
|
| 53 | - * @access private |
|
| 54 | - */ |
|
| 55 | - var $_isEnabled = false; |
|
| 56 | - /** |
|
| 49 | + /** |
|
| 50 | + * Is CKFinder enabled |
|
| 51 | + * |
|
| 52 | + * @var boolean |
|
| 53 | + * @access private |
|
| 54 | + */ |
|
| 55 | + var $_isEnabled = false; |
|
| 56 | + /** |
|
| 57 | 57 | * License Name |
| 58 | 58 | * |
| 59 | 59 | * @var string |
| 60 | 60 | * @access private |
| 61 | 61 | */ |
| 62 | - var $_licenseName = ""; |
|
| 63 | - /** |
|
| 64 | - * License Key |
|
| 65 | - * |
|
| 66 | - * @var string |
|
| 67 | - * @access private |
|
| 68 | - */ |
|
| 69 | - var $_licenseKey = ""; |
|
| 70 | - /** |
|
| 71 | - * Role session variable name |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - * @access private |
|
| 75 | - */ |
|
| 76 | - var $_roleSessionVar = "CKFinder_UserRole"; |
|
| 77 | - /** |
|
| 78 | - * Access Control Configuration |
|
| 79 | - * |
|
| 80 | - * @var CKFinder_Connector_Core_AccessControlConfig |
|
| 81 | - * @access private |
|
| 82 | - */ |
|
| 83 | - var $_accessControlConfigCache; |
|
| 84 | - /** |
|
| 85 | - * ResourceType config cache |
|
| 86 | - * |
|
| 87 | - * @var array |
|
| 88 | - * @access private |
|
| 89 | - */ |
|
| 90 | - var $_resourceTypeConfigCache = array(); |
|
| 91 | - /** |
|
| 92 | - * Thumbnails config cache |
|
| 93 | - * |
|
| 94 | - * @var CKFinder_Connector_Core_ThumbnailsConfig |
|
| 95 | - * @access private |
|
| 96 | - */ |
|
| 97 | - var $_thumbnailsConfigCache; |
|
| 98 | - /** |
|
| 99 | - * Images config cache |
|
| 100 | - * |
|
| 101 | - * @var CKFinder_Connector_Core_ImagesConfig |
|
| 102 | - * @access private |
|
| 103 | - */ |
|
| 104 | - var $_imagesConfigCache; |
|
| 105 | - /** |
|
| 106 | - * Array with default resource types names |
|
| 107 | - * |
|
| 108 | - * @access private |
|
| 109 | - * @var array |
|
| 110 | - */ |
|
| 111 | - var $_defaultResourceTypes = array(); |
|
| 112 | - /** |
|
| 113 | - * Filesystem encoding |
|
| 114 | - * |
|
| 115 | - * @var string |
|
| 116 | - * @access private |
|
| 117 | - */ |
|
| 118 | - var $_filesystemEncoding; |
|
| 119 | - /** |
|
| 120 | - * Check double extension |
|
| 121 | - * |
|
| 122 | - * @var boolean |
|
| 123 | - * @access private |
|
| 124 | - */ |
|
| 125 | - var $_checkDoubleExtension = true; |
|
| 126 | - /** |
|
| 127 | - * If set to true, validate image size |
|
| 128 | - * |
|
| 129 | - * @var boolean |
|
| 130 | - * @access private |
|
| 131 | - */ |
|
| 132 | - var $_secureImageUploads = true; |
|
| 133 | - /** |
|
| 134 | - * Check file size after scaling images (applies to images only) |
|
| 135 | - * |
|
| 136 | - * @var boolean |
|
| 137 | - */ |
|
| 138 | - var $_checkSizeAfterScaling = true; |
|
| 139 | - /** |
|
| 140 | - * For security, HTML is allowed in the first Kb of data for files having the following extensions only |
|
| 141 | - * |
|
| 142 | - * @var array |
|
| 143 | - * @access private |
|
| 144 | - */ |
|
| 145 | - var $_htmlExtensions = array('html', 'htm', 'xml', 'xsd', 'txt', 'js'); |
|
| 146 | - /** |
|
| 147 | - * Chmod files after upload to the following permission |
|
| 148 | - * |
|
| 149 | - * @var integer |
|
| 150 | - * @access private |
|
| 151 | - */ |
|
| 152 | - var $_chmodFiles = 0777; |
|
| 153 | - /** |
|
| 154 | - * Chmod directories after creation |
|
| 155 | - * |
|
| 156 | - * @var integer |
|
| 157 | - * @access private |
|
| 158 | - */ |
|
| 159 | - var $_chmodFolders = 0755; |
|
| 160 | - /** |
|
| 161 | - * Hide folders |
|
| 162 | - * |
|
| 163 | - * @var array |
|
| 164 | - * @access private |
|
| 165 | - */ |
|
| 166 | - var $_hideFolders = array(".svn", "CVS"); |
|
| 167 | - /** |
|
| 168 | - * Hide files |
|
| 169 | - * |
|
| 170 | - * @var integer |
|
| 171 | - * @access private |
|
| 172 | - */ |
|
| 173 | - var $_hideFiles = array(".*"); |
|
| 174 | - /** |
|
| 175 | - * If set to true, force ASCII names |
|
| 176 | - * |
|
| 177 | - * @var boolean |
|
| 178 | - * @access private |
|
| 179 | - */ |
|
| 180 | - var $_forceAscii = false; |
|
| 181 | - |
|
| 182 | - function CKFinder_Connector_Core_Config() |
|
| 183 | - { |
|
| 184 | - $this->loadValues(); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 62 | + var $_licenseName = ""; |
|
| 63 | + /** |
|
| 64 | + * License Key |
|
| 65 | + * |
|
| 66 | + * @var string |
|
| 67 | + * @access private |
|
| 68 | + */ |
|
| 69 | + var $_licenseKey = ""; |
|
| 70 | + /** |
|
| 71 | + * Role session variable name |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + * @access private |
|
| 75 | + */ |
|
| 76 | + var $_roleSessionVar = "CKFinder_UserRole"; |
|
| 77 | + /** |
|
| 78 | + * Access Control Configuration |
|
| 79 | + * |
|
| 80 | + * @var CKFinder_Connector_Core_AccessControlConfig |
|
| 81 | + * @access private |
|
| 82 | + */ |
|
| 83 | + var $_accessControlConfigCache; |
|
| 84 | + /** |
|
| 85 | + * ResourceType config cache |
|
| 86 | + * |
|
| 87 | + * @var array |
|
| 88 | + * @access private |
|
| 89 | + */ |
|
| 90 | + var $_resourceTypeConfigCache = array(); |
|
| 91 | + /** |
|
| 92 | + * Thumbnails config cache |
|
| 93 | + * |
|
| 94 | + * @var CKFinder_Connector_Core_ThumbnailsConfig |
|
| 95 | + * @access private |
|
| 96 | + */ |
|
| 97 | + var $_thumbnailsConfigCache; |
|
| 98 | + /** |
|
| 99 | + * Images config cache |
|
| 100 | + * |
|
| 101 | + * @var CKFinder_Connector_Core_ImagesConfig |
|
| 102 | + * @access private |
|
| 103 | + */ |
|
| 104 | + var $_imagesConfigCache; |
|
| 105 | + /** |
|
| 106 | + * Array with default resource types names |
|
| 107 | + * |
|
| 108 | + * @access private |
|
| 109 | + * @var array |
|
| 110 | + */ |
|
| 111 | + var $_defaultResourceTypes = array(); |
|
| 112 | + /** |
|
| 113 | + * Filesystem encoding |
|
| 114 | + * |
|
| 115 | + * @var string |
|
| 116 | + * @access private |
|
| 117 | + */ |
|
| 118 | + var $_filesystemEncoding; |
|
| 119 | + /** |
|
| 120 | + * Check double extension |
|
| 121 | + * |
|
| 122 | + * @var boolean |
|
| 123 | + * @access private |
|
| 124 | + */ |
|
| 125 | + var $_checkDoubleExtension = true; |
|
| 126 | + /** |
|
| 127 | + * If set to true, validate image size |
|
| 128 | + * |
|
| 129 | + * @var boolean |
|
| 130 | + * @access private |
|
| 131 | + */ |
|
| 132 | + var $_secureImageUploads = true; |
|
| 133 | + /** |
|
| 134 | + * Check file size after scaling images (applies to images only) |
|
| 135 | + * |
|
| 136 | + * @var boolean |
|
| 137 | + */ |
|
| 138 | + var $_checkSizeAfterScaling = true; |
|
| 139 | + /** |
|
| 140 | + * For security, HTML is allowed in the first Kb of data for files having the following extensions only |
|
| 141 | + * |
|
| 142 | + * @var array |
|
| 143 | + * @access private |
|
| 144 | + */ |
|
| 145 | + var $_htmlExtensions = array('html', 'htm', 'xml', 'xsd', 'txt', 'js'); |
|
| 146 | + /** |
|
| 147 | + * Chmod files after upload to the following permission |
|
| 148 | + * |
|
| 149 | + * @var integer |
|
| 150 | + * @access private |
|
| 151 | + */ |
|
| 152 | + var $_chmodFiles = 0777; |
|
| 153 | + /** |
|
| 154 | + * Chmod directories after creation |
|
| 155 | + * |
|
| 156 | + * @var integer |
|
| 157 | + * @access private |
|
| 158 | + */ |
|
| 159 | + var $_chmodFolders = 0755; |
|
| 160 | + /** |
|
| 161 | + * Hide folders |
|
| 162 | + * |
|
| 163 | + * @var array |
|
| 164 | + * @access private |
|
| 165 | + */ |
|
| 166 | + var $_hideFolders = array(".svn", "CVS"); |
|
| 167 | + /** |
|
| 168 | + * Hide files |
|
| 169 | + * |
|
| 170 | + * @var integer |
|
| 171 | + * @access private |
|
| 172 | + */ |
|
| 173 | + var $_hideFiles = array(".*"); |
|
| 174 | + /** |
|
| 175 | + * If set to true, force ASCII names |
|
| 176 | + * |
|
| 177 | + * @var boolean |
|
| 178 | + * @access private |
|
| 179 | + */ |
|
| 180 | + var $_forceAscii = false; |
|
| 181 | + |
|
| 182 | + function CKFinder_Connector_Core_Config() |
|
| 183 | + { |
|
| 184 | + $this->loadValues(); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | 188 | * Get file system encoding, returns null if encoding is not set |
| 189 | 189 | * |
| 190 | 190 | * @access public |
| 191 | 191 | * @return string |
| 192 | 192 | */ |
| 193 | - function getFilesystemEncoding() |
|
| 194 | - { |
|
| 195 | - return $this->_filesystemEncoding; |
|
| 196 | - } |
|
| 193 | + function getFilesystemEncoding() |
|
| 194 | + { |
|
| 195 | + return $this->_filesystemEncoding; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 198 | + /** |
|
| 199 | 199 | * Get "secureImageUploads" value |
| 200 | 200 | * |
| 201 | 201 | * @access public |
| 202 | 202 | * @return boolean |
| 203 | 203 | */ |
| 204 | - function getSecureImageUploads() |
|
| 205 | - { |
|
| 206 | - return $this->_secureImageUploads; |
|
| 207 | - } |
|
| 204 | + function getSecureImageUploads() |
|
| 205 | + { |
|
| 206 | + return $this->_secureImageUploads; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - /** |
|
| 209 | + /** |
|
| 210 | 210 | * Get "checkSizeAfterScaling" value |
| 211 | 211 | * |
| 212 | 212 | * @access public |
| 213 | 213 | * @return boolean |
| 214 | 214 | */ |
| 215 | - function checkSizeAfterScaling() |
|
| 216 | - { |
|
| 217 | - return $this->_checkSizeAfterScaling; |
|
| 218 | - } |
|
| 215 | + function checkSizeAfterScaling() |
|
| 216 | + { |
|
| 217 | + return $this->_checkSizeAfterScaling; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - /** |
|
| 220 | + /** |
|
| 221 | 221 | * Get "htmlExtensions" value |
| 222 | 222 | * |
| 223 | 223 | * @access public |
| 224 | 224 | * @return array |
| 225 | 225 | */ |
| 226 | - function getHtmlExtensions() |
|
| 227 | - { |
|
| 228 | - return $this->_htmlExtensions; |
|
| 229 | - } |
|
| 226 | + function getHtmlExtensions() |
|
| 227 | + { |
|
| 228 | + return $this->_htmlExtensions; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - /** |
|
| 231 | + /** |
|
| 232 | 232 | * Get "forceAscii" value |
| 233 | 233 | * |
| 234 | 234 | * @access public |
| 235 | 235 | * @return array |
| 236 | 236 | */ |
| 237 | - function forceAscii() |
|
| 238 | - { |
|
| 239 | - return $this->_forceAscii; |
|
| 240 | - } |
|
| 237 | + function forceAscii() |
|
| 238 | + { |
|
| 239 | + return $this->_forceAscii; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - /** |
|
| 242 | + /** |
|
| 243 | 243 | * Get regular expression to hide folders |
| 244 | 244 | * |
| 245 | 245 | * @access public |
| 246 | 246 | * @return array |
| 247 | 247 | */ |
| 248 | - function getHideFoldersRegex() |
|
| 249 | - { |
|
| 250 | - static $folderRegex; |
|
| 251 | - |
|
| 252 | - if (!isset($folderRegex)) { |
|
| 253 | - if (is_array($this->_hideFolders) && $this->_hideFolders) { |
|
| 254 | - $folderRegex = join("|", $this->_hideFolders); |
|
| 255 | - $folderRegex = strtr($folderRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__")); |
|
| 256 | - $folderRegex = preg_quote($folderRegex, "/"); |
|
| 257 | - $folderRegex = strtr($folderRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
|
| 258 | - $folderRegex = "/^(?:" . $folderRegex . ")$/uim"; |
|
| 259 | - } |
|
| 260 | - else { |
|
| 261 | - $folderRegex = ""; |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - return $folderRegex; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - /** |
|
| 248 | + function getHideFoldersRegex() |
|
| 249 | + { |
|
| 250 | + static $folderRegex; |
|
| 251 | + |
|
| 252 | + if (!isset($folderRegex)) { |
|
| 253 | + if (is_array($this->_hideFolders) && $this->_hideFolders) { |
|
| 254 | + $folderRegex = join("|", $this->_hideFolders); |
|
| 255 | + $folderRegex = strtr($folderRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__")); |
|
| 256 | + $folderRegex = preg_quote($folderRegex, "/"); |
|
| 257 | + $folderRegex = strtr($folderRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
|
| 258 | + $folderRegex = "/^(?:" . $folderRegex . ")$/uim"; |
|
| 259 | + } |
|
| 260 | + else { |
|
| 261 | + $folderRegex = ""; |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + return $folderRegex; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | 269 | * Get regular expression to hide files |
| 270 | 270 | * |
| 271 | 271 | * @access public |
| 272 | 272 | * @return array |
| 273 | 273 | */ |
| 274 | - function getHideFilesRegex() |
|
| 275 | - { |
|
| 276 | - static $fileRegex; |
|
| 277 | - |
|
| 278 | - if (!isset($fileRegex)) { |
|
| 279 | - if (is_array($this->_hideFiles) && $this->_hideFiles) { |
|
| 280 | - $fileRegex = join("|", $this->_hideFiles); |
|
| 281 | - $fileRegex = strtr($fileRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__")); |
|
| 282 | - $fileRegex = preg_quote($fileRegex, "/"); |
|
| 283 | - $fileRegex = strtr($fileRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
|
| 284 | - $fileRegex = "/^(?:" . $fileRegex . ")$/uim"; |
|
| 285 | - } |
|
| 286 | - else { |
|
| 287 | - $fileRegex = ""; |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return $fileRegex; |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - /** |
|
| 274 | + function getHideFilesRegex() |
|
| 275 | + { |
|
| 276 | + static $fileRegex; |
|
| 277 | + |
|
| 278 | + if (!isset($fileRegex)) { |
|
| 279 | + if (is_array($this->_hideFiles) && $this->_hideFiles) { |
|
| 280 | + $fileRegex = join("|", $this->_hideFiles); |
|
| 281 | + $fileRegex = strtr($fileRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__")); |
|
| 282 | + $fileRegex = preg_quote($fileRegex, "/"); |
|
| 283 | + $fileRegex = strtr($fileRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
|
| 284 | + $fileRegex = "/^(?:" . $fileRegex . ")$/uim"; |
|
| 285 | + } |
|
| 286 | + else { |
|
| 287 | + $fileRegex = ""; |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return $fileRegex; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | 295 | * Get "Check double extension" value |
| 296 | 296 | * |
| 297 | 297 | * @access public |
| 298 | 298 | * @return boolean |
| 299 | 299 | */ |
| 300 | - function getCheckDoubleExtension() |
|
| 301 | - { |
|
| 302 | - return $this->_checkDoubleExtension; |
|
| 303 | - } |
|
| 300 | + function getCheckDoubleExtension() |
|
| 301 | + { |
|
| 302 | + return $this->_checkDoubleExtension; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - /** |
|
| 305 | + /** |
|
| 306 | 306 | * Get default resource types |
| 307 | 307 | * |
| 308 | 308 | * @access public |
| 309 | 309 | * @return array() |
| 310 | 310 | */ |
| 311 | - function getDefaultResourceTypes() |
|
| 312 | - { |
|
| 313 | - return $this->_defaultResourceTypes; |
|
| 314 | - } |
|
| 311 | + function getDefaultResourceTypes() |
|
| 312 | + { |
|
| 313 | + return $this->_defaultResourceTypes; |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - /** |
|
| 316 | + /** |
|
| 317 | 317 | * Is CKFinder enabled |
| 318 | 318 | * |
| 319 | 319 | * @access public |
| 320 | 320 | * @return boolean |
| 321 | 321 | */ |
| 322 | - function getIsEnabled() |
|
| 323 | - { |
|
| 324 | - return $this->_isEnabled; |
|
| 325 | - } |
|
| 322 | + function getIsEnabled() |
|
| 323 | + { |
|
| 324 | + return $this->_isEnabled; |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - /** |
|
| 327 | + /** |
|
| 328 | 328 | * Get license key |
| 329 | 329 | * |
| 330 | 330 | * @access public |
| 331 | 331 | * @return string |
| 332 | 332 | */ |
| 333 | - function getLicenseKey() |
|
| 334 | - { |
|
| 335 | - return $this->_licenseKey; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * Get license name |
|
| 340 | - * |
|
| 341 | - * @access public |
|
| 342 | - * @return string |
|
| 343 | - */ |
|
| 344 | - function getLicenseName() |
|
| 345 | - { |
|
| 346 | - return $this->_licenseName; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * Get chmod settings for uploaded files |
|
| 351 | - * |
|
| 352 | - * @access public |
|
| 353 | - * @return integer |
|
| 354 | - */ |
|
| 355 | - function getChmodFiles() |
|
| 356 | - { |
|
| 357 | - return $this->_chmodFiles; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Get chmod settings for created directories |
|
| 362 | - * |
|
| 363 | - * @access public |
|
| 364 | - * @return integer |
|
| 365 | - */ |
|
| 366 | - function getChmodFolders() |
|
| 367 | - { |
|
| 368 | - return $this->_chmodFolders; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 333 | + function getLicenseKey() |
|
| 334 | + { |
|
| 335 | + return $this->_licenseKey; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * Get license name |
|
| 340 | + * |
|
| 341 | + * @access public |
|
| 342 | + * @return string |
|
| 343 | + */ |
|
| 344 | + function getLicenseName() |
|
| 345 | + { |
|
| 346 | + return $this->_licenseName; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * Get chmod settings for uploaded files |
|
| 351 | + * |
|
| 352 | + * @access public |
|
| 353 | + * @return integer |
|
| 354 | + */ |
|
| 355 | + function getChmodFiles() |
|
| 356 | + { |
|
| 357 | + return $this->_chmodFiles; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Get chmod settings for created directories |
|
| 362 | + * |
|
| 363 | + * @access public |
|
| 364 | + * @return integer |
|
| 365 | + */ |
|
| 366 | + function getChmodFolders() |
|
| 367 | + { |
|
| 368 | + return $this->_chmodFolders; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | 372 | * Get role sesion variable name |
| 373 | 373 | * |
| 374 | 374 | * @access public |
| 375 | 375 | * @return string |
| 376 | 376 | */ |
| 377 | - function getRoleSessionVar() |
|
| 378 | - { |
|
| 379 | - return $this->_roleSessionVar; |
|
| 380 | - } |
|
| 377 | + function getRoleSessionVar() |
|
| 378 | + { |
|
| 379 | + return $this->_roleSessionVar; |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - /** |
|
| 382 | + /** |
|
| 383 | 383 | * Get resourceTypeName config |
| 384 | 384 | * |
| 385 | 385 | * @param string $resourceTypeName |
| 386 | 386 | * @return CKFinder_Connector_Core_ResourceTypeConfig|null |
| 387 | 387 | * @access public |
| 388 | 388 | */ |
| 389 | - function &getResourceTypeConfig($resourceTypeName) |
|
| 390 | - { |
|
| 391 | - $_null = null; |
|
| 392 | - |
|
| 393 | - if (isset($this->_resourceTypeConfigCache[$resourceTypeName])) { |
|
| 394 | - return $this->_resourceTypeConfigCache[$resourceTypeName]; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) { |
|
| 398 | - return $_null; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - reset($GLOBALS['config']['ResourceType']); |
|
| 402 | - while (list($_key,$_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) { |
|
| 403 | - if ($_resourceTypeNode['name'] === $resourceTypeName) { |
|
| 404 | - $this->_resourceTypeConfigCache[$resourceTypeName] = new CKFinder_Connector_Core_ResourceTypeConfig($_resourceTypeNode); |
|
| 405 | - |
|
| 406 | - return $this->_resourceTypeConfigCache[$resourceTypeName]; |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - return $_null; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * Get thumbnails config |
|
| 415 | - * |
|
| 416 | - * @access public |
|
| 417 | - * @return CKFinder_Connector_Core_ThumbnailsConfig |
|
| 418 | - */ |
|
| 419 | - function &getThumbnailsConfig() |
|
| 420 | - { |
|
| 421 | - if (!isset($this->_thumbnailsConfigCache)) { |
|
| 422 | - $this->_thumbnailsConfigCache = new CKFinder_Connector_Core_ThumbnailsConfig(isset($GLOBALS['config']['Thumbnails']) ? $GLOBALS['config']['Thumbnails'] : array()); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - return $this->_thumbnailsConfigCache; |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - /** |
|
| 429 | - * Get images config |
|
| 430 | - * |
|
| 431 | - * @access public |
|
| 432 | - * @return CKFinder_Connector_Core_ImagesConfig |
|
| 433 | - */ |
|
| 434 | - function &getImagesConfig() |
|
| 435 | - { |
|
| 436 | - if (!isset($this->_imagesConfigCache)) { |
|
| 437 | - $this->_imagesConfigCache = new CKFinder_Connector_Core_ImagesConfig(isset($GLOBALS['config']['Images']) ? $GLOBALS['config']['Images'] : array()); |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - return $this->_imagesConfigCache; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * Get access control config |
|
| 445 | - * |
|
| 446 | - * @access public |
|
| 447 | - * @return CKFinder_Connector_Core_AccessControlConfig |
|
| 448 | - */ |
|
| 449 | - function &getAccessControlConfig() |
|
| 450 | - { |
|
| 451 | - if (!isset($this->_accessControlConfigCache)) { |
|
| 452 | - $this->_accessControlConfigCache = new CKFinder_Connector_Core_AccessControlConfig(isset($GLOBALS['config']['AccessControl']) ? $GLOBALS['config']['AccessControl'] : array()); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - return $this->_accessControlConfigCache; |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * Load values from config |
|
| 460 | - * |
|
| 461 | - * @access private |
|
| 462 | - */ |
|
| 463 | - function loadValues() |
|
| 464 | - { |
|
| 465 | - if (function_exists('CheckAuthentication')) { |
|
| 466 | - $this->_isEnabled = CheckAuthentication(); |
|
| 467 | - } |
|
| 468 | - if (isset($GLOBALS['config']['LicenseName'])) { |
|
| 469 | - $this->_licenseName = (string)$GLOBALS['config']['LicenseName']; |
|
| 470 | - } |
|
| 471 | - if (isset($GLOBALS['config']['LicenseKey'])) { |
|
| 472 | - $this->_licenseKey = (string)$GLOBALS['config']['LicenseKey']; |
|
| 473 | - } |
|
| 474 | - if (isset($GLOBALS['config']['FilesystemEncoding'])) { |
|
| 475 | - $this->_filesystemEncoding = (string)$GLOBALS['config']['FilesystemEncoding']; |
|
| 476 | - } |
|
| 477 | - if (isset($GLOBALS['config']['RoleSessionVar'])) { |
|
| 478 | - $this->_roleSessionVar = (string)$GLOBALS['config']['RoleSessionVar']; |
|
| 479 | - } |
|
| 480 | - if (isset($GLOBALS['config']['CheckDoubleExtension'])) { |
|
| 481 | - $this->_checkDoubleExtension = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckDoubleExtension']); |
|
| 482 | - } |
|
| 483 | - if (isset($GLOBALS['config']['SecureImageUploads'])) { |
|
| 484 | - $this->_secureImageUploads = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['SecureImageUploads']); |
|
| 485 | - } |
|
| 486 | - if (isset($GLOBALS['config']['CheckSizeAfterScaling'])) { |
|
| 487 | - $this->_checkSizeAfterScaling = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckSizeAfterScaling']); |
|
| 488 | - } |
|
| 489 | - if (isset($GLOBALS['config']['ForceAscii'])) { |
|
| 490 | - $this->_forceAscii = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['ForceAscii']); |
|
| 491 | - } |
|
| 492 | - if (isset($GLOBALS['config']['HtmlExtensions'])) { |
|
| 493 | - $this->_htmlExtensions = (array)$GLOBALS['config']['HtmlExtensions']; |
|
| 494 | - } |
|
| 495 | - if (isset($GLOBALS['config']['HideFolders'])) { |
|
| 496 | - $this->_hideFolders = (array)$GLOBALS['config']['HideFolders']; |
|
| 497 | - } |
|
| 498 | - if (isset($GLOBALS['config']['HideFiles'])) { |
|
| 499 | - $this->_hideFiles = (array)$GLOBALS['config']['HideFiles']; |
|
| 500 | - } |
|
| 501 | - if (isset($GLOBALS['config']['ChmodFiles'])) { |
|
| 502 | - $this->_chmodFiles = $GLOBALS['config']['ChmodFiles']; |
|
| 503 | - } |
|
| 504 | - if (isset($GLOBALS['config']['ChmodFolders'])) { |
|
| 505 | - $this->_chmodFolders = $GLOBALS['config']['ChmodFolders']; |
|
| 506 | - } |
|
| 507 | - if (isset($GLOBALS['config']['DefaultResourceTypes'])) { |
|
| 508 | - $_defaultResourceTypes = (string)$GLOBALS['config']['DefaultResourceTypes']; |
|
| 509 | - if (strlen($_defaultResourceTypes)) { |
|
| 510 | - $this->_defaultResourceTypes = explode(",", $_defaultResourceTypes); |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - /** |
|
| 516 | - * Get all resource type names defined in config |
|
| 517 | - * |
|
| 518 | - * @return array |
|
| 519 | - * @access public |
|
| 520 | - */ |
|
| 521 | - function getResourceTypeNames() |
|
| 522 | - { |
|
| 523 | - if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) { |
|
| 524 | - return array(); |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - $_names = array(); |
|
| 528 | - foreach ($GLOBALS['config']['ResourceType'] as $key => $_resourceType) { |
|
| 529 | - if (isset($_resourceType['name'])) { |
|
| 530 | - $_names[] = (string)$_resourceType['name']; |
|
| 531 | - } |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - return $_names; |
|
| 535 | - } |
|
| 389 | + function &getResourceTypeConfig($resourceTypeName) |
|
| 390 | + { |
|
| 391 | + $_null = null; |
|
| 392 | + |
|
| 393 | + if (isset($this->_resourceTypeConfigCache[$resourceTypeName])) { |
|
| 394 | + return $this->_resourceTypeConfigCache[$resourceTypeName]; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) { |
|
| 398 | + return $_null; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + reset($GLOBALS['config']['ResourceType']); |
|
| 402 | + while (list($_key,$_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) { |
|
| 403 | + if ($_resourceTypeNode['name'] === $resourceTypeName) { |
|
| 404 | + $this->_resourceTypeConfigCache[$resourceTypeName] = new CKFinder_Connector_Core_ResourceTypeConfig($_resourceTypeNode); |
|
| 405 | + |
|
| 406 | + return $this->_resourceTypeConfigCache[$resourceTypeName]; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + return $_null; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * Get thumbnails config |
|
| 415 | + * |
|
| 416 | + * @access public |
|
| 417 | + * @return CKFinder_Connector_Core_ThumbnailsConfig |
|
| 418 | + */ |
|
| 419 | + function &getThumbnailsConfig() |
|
| 420 | + { |
|
| 421 | + if (!isset($this->_thumbnailsConfigCache)) { |
|
| 422 | + $this->_thumbnailsConfigCache = new CKFinder_Connector_Core_ThumbnailsConfig(isset($GLOBALS['config']['Thumbnails']) ? $GLOBALS['config']['Thumbnails'] : array()); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + return $this->_thumbnailsConfigCache; |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * Get images config |
|
| 430 | + * |
|
| 431 | + * @access public |
|
| 432 | + * @return CKFinder_Connector_Core_ImagesConfig |
|
| 433 | + */ |
|
| 434 | + function &getImagesConfig() |
|
| 435 | + { |
|
| 436 | + if (!isset($this->_imagesConfigCache)) { |
|
| 437 | + $this->_imagesConfigCache = new CKFinder_Connector_Core_ImagesConfig(isset($GLOBALS['config']['Images']) ? $GLOBALS['config']['Images'] : array()); |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + return $this->_imagesConfigCache; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * Get access control config |
|
| 445 | + * |
|
| 446 | + * @access public |
|
| 447 | + * @return CKFinder_Connector_Core_AccessControlConfig |
|
| 448 | + */ |
|
| 449 | + function &getAccessControlConfig() |
|
| 450 | + { |
|
| 451 | + if (!isset($this->_accessControlConfigCache)) { |
|
| 452 | + $this->_accessControlConfigCache = new CKFinder_Connector_Core_AccessControlConfig(isset($GLOBALS['config']['AccessControl']) ? $GLOBALS['config']['AccessControl'] : array()); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + return $this->_accessControlConfigCache; |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * Load values from config |
|
| 460 | + * |
|
| 461 | + * @access private |
|
| 462 | + */ |
|
| 463 | + function loadValues() |
|
| 464 | + { |
|
| 465 | + if (function_exists('CheckAuthentication')) { |
|
| 466 | + $this->_isEnabled = CheckAuthentication(); |
|
| 467 | + } |
|
| 468 | + if (isset($GLOBALS['config']['LicenseName'])) { |
|
| 469 | + $this->_licenseName = (string)$GLOBALS['config']['LicenseName']; |
|
| 470 | + } |
|
| 471 | + if (isset($GLOBALS['config']['LicenseKey'])) { |
|
| 472 | + $this->_licenseKey = (string)$GLOBALS['config']['LicenseKey']; |
|
| 473 | + } |
|
| 474 | + if (isset($GLOBALS['config']['FilesystemEncoding'])) { |
|
| 475 | + $this->_filesystemEncoding = (string)$GLOBALS['config']['FilesystemEncoding']; |
|
| 476 | + } |
|
| 477 | + if (isset($GLOBALS['config']['RoleSessionVar'])) { |
|
| 478 | + $this->_roleSessionVar = (string)$GLOBALS['config']['RoleSessionVar']; |
|
| 479 | + } |
|
| 480 | + if (isset($GLOBALS['config']['CheckDoubleExtension'])) { |
|
| 481 | + $this->_checkDoubleExtension = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckDoubleExtension']); |
|
| 482 | + } |
|
| 483 | + if (isset($GLOBALS['config']['SecureImageUploads'])) { |
|
| 484 | + $this->_secureImageUploads = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['SecureImageUploads']); |
|
| 485 | + } |
|
| 486 | + if (isset($GLOBALS['config']['CheckSizeAfterScaling'])) { |
|
| 487 | + $this->_checkSizeAfterScaling = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckSizeAfterScaling']); |
|
| 488 | + } |
|
| 489 | + if (isset($GLOBALS['config']['ForceAscii'])) { |
|
| 490 | + $this->_forceAscii = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['ForceAscii']); |
|
| 491 | + } |
|
| 492 | + if (isset($GLOBALS['config']['HtmlExtensions'])) { |
|
| 493 | + $this->_htmlExtensions = (array)$GLOBALS['config']['HtmlExtensions']; |
|
| 494 | + } |
|
| 495 | + if (isset($GLOBALS['config']['HideFolders'])) { |
|
| 496 | + $this->_hideFolders = (array)$GLOBALS['config']['HideFolders']; |
|
| 497 | + } |
|
| 498 | + if (isset($GLOBALS['config']['HideFiles'])) { |
|
| 499 | + $this->_hideFiles = (array)$GLOBALS['config']['HideFiles']; |
|
| 500 | + } |
|
| 501 | + if (isset($GLOBALS['config']['ChmodFiles'])) { |
|
| 502 | + $this->_chmodFiles = $GLOBALS['config']['ChmodFiles']; |
|
| 503 | + } |
|
| 504 | + if (isset($GLOBALS['config']['ChmodFolders'])) { |
|
| 505 | + $this->_chmodFolders = $GLOBALS['config']['ChmodFolders']; |
|
| 506 | + } |
|
| 507 | + if (isset($GLOBALS['config']['DefaultResourceTypes'])) { |
|
| 508 | + $_defaultResourceTypes = (string)$GLOBALS['config']['DefaultResourceTypes']; |
|
| 509 | + if (strlen($_defaultResourceTypes)) { |
|
| 510 | + $this->_defaultResourceTypes = explode(",", $_defaultResourceTypes); |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + /** |
|
| 516 | + * Get all resource type names defined in config |
|
| 517 | + * |
|
| 518 | + * @return array |
|
| 519 | + * @access public |
|
| 520 | + */ |
|
| 521 | + function getResourceTypeNames() |
|
| 522 | + { |
|
| 523 | + if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) { |
|
| 524 | + return array(); |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + $_names = array(); |
|
| 528 | + foreach ($GLOBALS['config']['ResourceType'] as $key => $_resourceType) { |
|
| 529 | + if (isset($_resourceType['name'])) { |
|
| 530 | + $_names[] = (string)$_resourceType['name']; |
|
| 531 | + } |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + return $_names; |
|
| 535 | + } |
|
| 536 | 536 | } |
@@ -21,19 +21,19 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Include access control config class |
| 23 | 23 | */ |
| 24 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/Core/AccessControlConfig.php"; |
|
| 24 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/Core/AccessControlConfig.php"; |
|
| 25 | 25 | /** |
| 26 | 26 | * Include resource type config class |
| 27 | 27 | */ |
| 28 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/Core/ResourceTypeConfig.php"; |
|
| 28 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/Core/ResourceTypeConfig.php"; |
|
| 29 | 29 | /** |
| 30 | 30 | * Include thumbnails config class |
| 31 | 31 | */ |
| 32 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/Core/ThumbnailsConfig.php"; |
|
| 32 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/Core/ThumbnailsConfig.php"; |
|
| 33 | 33 | /** |
| 34 | 34 | * Include thumbnails config class |
| 35 | 35 | */ |
| 36 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/Core/ImagesConfig.php"; |
|
| 36 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/Core/ImagesConfig.php"; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Main config parser |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | $folderRegex = strtr($folderRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__")); |
| 256 | 256 | $folderRegex = preg_quote($folderRegex, "/"); |
| 257 | 257 | $folderRegex = strtr($folderRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
| 258 | - $folderRegex = "/^(?:" . $folderRegex . ")$/uim"; |
|
| 258 | + $folderRegex = "/^(?:".$folderRegex.")$/uim"; |
|
| 259 | 259 | } |
| 260 | 260 | else { |
| 261 | 261 | $folderRegex = ""; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $fileRegex = strtr($fileRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__")); |
| 282 | 282 | $fileRegex = preg_quote($fileRegex, "/"); |
| 283 | 283 | $fileRegex = strtr($fileRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
| 284 | - $fileRegex = "/^(?:" . $fileRegex . ")$/uim"; |
|
| 284 | + $fileRegex = "/^(?:".$fileRegex.")$/uim"; |
|
| 285 | 285 | } |
| 286 | 286 | else { |
| 287 | 287 | $fileRegex = ""; |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | reset($GLOBALS['config']['ResourceType']); |
| 402 | - while (list($_key,$_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) { |
|
| 402 | + while (list($_key, $_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) { |
|
| 403 | 403 | if ($_resourceTypeNode['name'] === $resourceTypeName) { |
| 404 | 404 | $this->_resourceTypeConfigCache[$resourceTypeName] = new CKFinder_Connector_Core_ResourceTypeConfig($_resourceTypeNode); |
| 405 | 405 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * modifying or distribute this file or part of its contents. The contents of |
| 11 | 11 | * this file is part of the Source Code of CKFinder. |
| 12 | 12 | */ |
| 13 | -if (!defined('IN_CKFINDER')) exit; |
|
| 13 | +if (!defined('IN_CKFINDER')) { |
|
| 14 | + exit; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * @package CKFinder |
@@ -256,8 +258,7 @@ discard block |
||
| 256 | 258 | $folderRegex = preg_quote($folderRegex, "/"); |
| 257 | 259 | $folderRegex = strtr($folderRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
| 258 | 260 | $folderRegex = "/^(?:" . $folderRegex . ")$/uim"; |
| 259 | - } |
|
| 260 | - else { |
|
| 261 | + } else { |
|
| 261 | 262 | $folderRegex = ""; |
| 262 | 263 | } |
| 263 | 264 | } |
@@ -282,8 +283,7 @@ discard block |
||
| 282 | 283 | $fileRegex = preg_quote($fileRegex, "/"); |
| 283 | 284 | $fileRegex = strtr($fileRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|")); |
| 284 | 285 | $fileRegex = "/^(?:" . $fileRegex . ")$/uim"; |
| 285 | - } |
|
| 286 | - else { |
|
| 286 | + } else { |
|
| 287 | 287 | $fileRegex = ""; |
| 288 | 288 | } |
| 289 | 289 | } |