@@ -33,6 +33,9 @@ discard block |
||
| 33 | 33 | return $bloc_editable; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | + /** |
|
| 37 | + * @param integer $parent |
|
| 38 | + */ |
|
| 36 | 39 | private function getOrdrePage($parent) { |
| 37 | 40 | if (($parent != "") || ($parent != 0)) { |
| 38 | 41 | $dbc = \core\App::getDb(); |
@@ -66,13 +69,13 @@ discard block |
||
| 66 | 69 | } |
| 67 | 70 | |
| 68 | 71 | /** |
| 69 | - * @param $nom_table |
|
| 70 | - * @param $nom_id_table |
|
| 71 | - * @param $champ |
|
| 72 | + * @param string $nom_table |
|
| 73 | + * @param string $nom_id_table |
|
| 74 | + * @param string $champ |
|
| 72 | 75 | * @param $value |
| 73 | - * @param $limit_char |
|
| 74 | - * @param $err_char |
|
| 75 | - * @param $err_egalite |
|
| 76 | + * @param integer $limit_char |
|
| 77 | + * @param string $err_char |
|
| 78 | + * @param string $err_egalite |
|
| 76 | 79 | * @param null $value_id_table |
| 77 | 80 | * @return string |
| 78 | 81 | * fonction qui permet de vérifier qu'il n'y ait pas d'erreur dans le champ spécifié ni de doublons |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | private function getParentId($parent) { |
| 53 | 53 | $dbc = \core\App::getDb(); |
| 54 | 54 | |
| 55 | - if ($parent == "") return 0; |
|
| 55 | + if ($parent == "") { |
|
| 56 | + return 0; |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | $query = $dbc->select("ID_page")->from("page")->where("titre", " LIKE ", '"%'.$parent.'%"', "", true)->get(); |
| 58 | 60 | |
@@ -83,8 +85,7 @@ discard block |
||
| 83 | 85 | if (strlen(utf8_decode($value)) > $limit_char) { |
| 84 | 86 | $this->erreur = true; |
| 85 | 87 | return "<li>$err_char</li>"; |
| 86 | - } |
|
| 87 | - else if ($dbc->rechercherEgalite($nom_table, $champ, $value, $nom_id_table, $value_id_table) == true) { |
|
| 88 | + } else if ($dbc->rechercherEgalite($nom_table, $champ, $value, $nom_id_table, $value_id_table) == true) { |
|
| 88 | 89 | $this->erreur = true; |
| 89 | 90 | return "<li>$err_egalite</li>"; |
| 90 | 91 | } |
@@ -167,13 +168,11 @@ discard block |
||
| 167 | 168 | if ($parent == "") { |
| 168 | 169 | $this->setAjoutLienNavigation("ID_page", $this->id_page, 1); |
| 169 | 170 | } |
| 170 | - } |
|
| 171 | - else { |
|
| 171 | + } else { |
|
| 172 | 172 | FlashMessage::setFlash("Impossible de créer cette page, veuillez réeseyer dans un moment. Si le problème persiste contactez votre administrateur."); |
| 173 | 173 | $this->erreur = true; |
| 174 | 174 | } |
| 175 | - } |
|
| 176 | - else { |
|
| 175 | + } else { |
|
| 177 | 176 | $this->setErreurContenus($balise_title, $url, $meta_description, $titre_page, $parent, $err_balise_title, $err_url, $err_meta_description, $err_titre_page); |
| 178 | 177 | $this->erreur = true; |
| 179 | 178 | } |
@@ -219,8 +218,7 @@ discard block |
||
| 219 | 218 | if ($parent == "") { |
| 220 | 219 | $this->setAjoutLienNavigation("ID_page", $this->id_page, 1); |
| 221 | 220 | } |
| 222 | - } |
|
| 223 | - else { |
|
| 221 | + } else { |
|
| 224 | 222 | $this->setErreurContenus($balise_title, $url, $titre_page, $parent, $err_balise_title, $err_url, $err_titre_page); |
| 225 | 223 | $this->erreur = true; |
| 226 | 224 | } |
@@ -284,8 +282,7 @@ discard block |
||
| 284 | 282 | ->set(); |
| 285 | 283 | |
| 286 | 284 | $this->setModifierLienNavigation("ID_page", $id_page, $this->getParentId($parent), $affiche); |
| 287 | - } |
|
| 288 | - else { |
|
| 285 | + } else { |
|
| 289 | 286 | $this->setErreurContenus($balise_title, $url, $meta_description, $titre_page, $parent, $err_balise_title, $err_url, $err_meta_description, $err_titre_page); |
| 290 | 287 | } |
| 291 | 288 | } |
@@ -334,8 +331,7 @@ discard block |
||
| 334 | 331 | FlashMessage::setFlash("Impossible de supprimer cette page, veuillez contacter votre administrateur pour corriger ce problème"); |
| 335 | 332 | $this->erreur = true; |
| 336 | 333 | } |
| 337 | - } |
|
| 338 | - else { |
|
| 334 | + } else { |
|
| 339 | 335 | FlashMessage::setFlash("Impossible de supprimer cette page, veuillez contacter votre administrateur pour corriger ce problème"); |
| 340 | 336 | $this->erreur = true; |
| 341 | 337 | } |
@@ -361,8 +357,7 @@ discard block |
||
| 361 | 357 | if ($parent != "") { |
| 362 | 358 | $nav = new Navigation(); |
| 363 | 359 | $nav->setSupprimerLien($id, $id_page); |
| 364 | - } |
|
| 365 | - else if (($affiche == 1) && ($parent == "")) { |
|
| 360 | + } else if (($affiche == 1) && ($parent == "")) { |
|
| 366 | 361 | $this->setAjoutLienNavigation($id, $id_page, $affiche); |
| 367 | 362 | } |
| 368 | 363 | } |
@@ -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 | } |
@@ -24,7 +24,6 @@ |
||
| 24 | 24 | * Run user defined hooks |
| 25 | 25 | * |
| 26 | 26 | * @param string $event |
| 27 | - * @param object $errorHandler |
|
| 28 | 27 | * @param array $args |
| 29 | 28 | * @return boolean (true to continue processing, false otherwise) |
| 30 | 29 | */ |
@@ -20,154 +20,154 @@ |
||
| 20 | 20 | class CKFinder_Connector_Core_Hooks |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Run user defined hooks |
|
| 25 | - * |
|
| 26 | - * @param string $event |
|
| 27 | - * @param object $errorHandler |
|
| 28 | - * @param array $args |
|
| 29 | - * @return boolean (true to continue processing, false otherwise) |
|
| 30 | - */ |
|
| 31 | - function run($event, $args = array()) |
|
| 32 | - { |
|
| 33 | - $config = $GLOBALS['config']; |
|
| 34 | - if (!isset($config['Hooks'])) { |
|
| 35 | - return true; |
|
| 36 | - } |
|
| 37 | - $hooks =& $config['Hooks']; |
|
| 23 | + /** |
|
| 24 | + * Run user defined hooks |
|
| 25 | + * |
|
| 26 | + * @param string $event |
|
| 27 | + * @param object $errorHandler |
|
| 28 | + * @param array $args |
|
| 29 | + * @return boolean (true to continue processing, false otherwise) |
|
| 30 | + */ |
|
| 31 | + function run($event, $args = array()) |
|
| 32 | + { |
|
| 33 | + $config = $GLOBALS['config']; |
|
| 34 | + if (!isset($config['Hooks'])) { |
|
| 35 | + return true; |
|
| 36 | + } |
|
| 37 | + $hooks =& $config['Hooks']; |
|
| 38 | 38 | |
| 39 | - if (!is_array($hooks) || !array_key_exists($event, $hooks) || !is_array($hooks[$event])) { |
|
| 40 | - return true; |
|
| 41 | - } |
|
| 39 | + if (!is_array($hooks) || !array_key_exists($event, $hooks) || !is_array($hooks[$event])) { |
|
| 40 | + return true; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $errorHandler = $GLOBALS['connector']->getErrorHandler(); |
|
| 43 | + $errorHandler = $GLOBALS['connector']->getErrorHandler(); |
|
| 44 | 44 | |
| 45 | - foreach ($hooks[$event] as $i => $hook) { |
|
| 45 | + foreach ($hooks[$event] as $i => $hook) { |
|
| 46 | 46 | |
| 47 | - $object = NULL; |
|
| 48 | - $method = NULL; |
|
| 49 | - $function = NULL; |
|
| 50 | - $data = NULL; |
|
| 51 | - $passData = false; |
|
| 47 | + $object = NULL; |
|
| 48 | + $method = NULL; |
|
| 49 | + $function = NULL; |
|
| 50 | + $data = NULL; |
|
| 51 | + $passData = false; |
|
| 52 | 52 | |
| 53 | - /* $hook can be: a function, an object, an array of $functiontion and $data, |
|
| 53 | + /* $hook can be: a function, an object, an array of $functiontion and $data, |
|
| 54 | 54 | * an array of just a function, an array of object and method, or an |
| 55 | 55 | * array of object, method, and data. |
| 56 | 56 | */ |
| 57 | - //function |
|
| 58 | - if (is_string($hook)) { |
|
| 59 | - $function = $hook; |
|
| 60 | - } |
|
| 61 | - //object |
|
| 62 | - else if (is_object($hook)) { |
|
| 63 | - $object = $hooks[$event][$i]; |
|
| 64 | - $method = "on" . $event; |
|
| 65 | - } |
|
| 66 | - //array of... |
|
| 67 | - else if (is_array($hook)) { |
|
| 68 | - $count = count($hook); |
|
| 69 | - if ($count) { |
|
| 70 | - //...object |
|
| 71 | - if (is_object($hook[0])) { |
|
| 72 | - $object = $hooks[$event][$i][0]; |
|
| 73 | - if ($count < 2) { |
|
| 74 | - $method = "on" . $event; |
|
| 75 | - } else { |
|
| 76 | - //...object and method |
|
| 77 | - $method = $hook[1]; |
|
| 78 | - if (count($hook) > 2) { |
|
| 79 | - //...object, method and data |
|
| 80 | - $passData = true; |
|
| 81 | - $data = $hook[2]; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - //...function |
|
| 86 | - else if (is_string($hook[0])) { |
|
| 87 | - $function = $hook[0]; |
|
| 88 | - if ($count > 1) { |
|
| 89 | - //...function with data |
|
| 90 | - $passData = true; |
|
| 91 | - $data = $hook[1]; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 57 | + //function |
|
| 58 | + if (is_string($hook)) { |
|
| 59 | + $function = $hook; |
|
| 60 | + } |
|
| 61 | + //object |
|
| 62 | + else if (is_object($hook)) { |
|
| 63 | + $object = $hooks[$event][$i]; |
|
| 64 | + $method = "on" . $event; |
|
| 65 | + } |
|
| 66 | + //array of... |
|
| 67 | + else if (is_array($hook)) { |
|
| 68 | + $count = count($hook); |
|
| 69 | + if ($count) { |
|
| 70 | + //...object |
|
| 71 | + if (is_object($hook[0])) { |
|
| 72 | + $object = $hooks[$event][$i][0]; |
|
| 73 | + if ($count < 2) { |
|
| 74 | + $method = "on" . $event; |
|
| 75 | + } else { |
|
| 76 | + //...object and method |
|
| 77 | + $method = $hook[1]; |
|
| 78 | + if (count($hook) > 2) { |
|
| 79 | + //...object, method and data |
|
| 80 | + $passData = true; |
|
| 81 | + $data = $hook[2]; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + //...function |
|
| 86 | + else if (is_string($hook[0])) { |
|
| 87 | + $function = $hook[0]; |
|
| 88 | + if ($count > 1) { |
|
| 89 | + //...function with data |
|
| 90 | + $passData = true; |
|
| 91 | + $data = $hook[1]; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /* If defined, add data to the arguments array */ |
|
| 98 | - if ($passData) { |
|
| 99 | - $args = array_merge(array($data), $args); |
|
| 100 | - } |
|
| 97 | + /* If defined, add data to the arguments array */ |
|
| 98 | + if ($passData) { |
|
| 99 | + $args = array_merge(array($data), $args); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - if (isset($object)) { |
|
| 103 | - $callback = array($object, $method); |
|
| 104 | - } |
|
| 105 | - else if (false !== ($pos = strpos($function, '::'))) { |
|
| 106 | - $callback = array(substr($function, 0, $pos), substr($function, $pos + 2)); |
|
| 107 | - } |
|
| 108 | - else { |
|
| 109 | - $callback = $function; |
|
| 110 | - } |
|
| 102 | + if (isset($object)) { |
|
| 103 | + $callback = array($object, $method); |
|
| 104 | + } |
|
| 105 | + else if (false !== ($pos = strpos($function, '::'))) { |
|
| 106 | + $callback = array(substr($function, 0, $pos), substr($function, $pos + 2)); |
|
| 107 | + } |
|
| 108 | + else { |
|
| 109 | + $callback = $function; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - if (is_callable($callback)) { |
|
| 113 | - $ret = call_user_func_array($callback, $args); |
|
| 114 | - } |
|
| 115 | - else { |
|
| 116 | - $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback); |
|
| 117 | - $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, |
|
| 118 | - "CKFinder failed to call a hook: " . $functionName); |
|
| 119 | - return false; |
|
| 120 | - } |
|
| 112 | + if (is_callable($callback)) { |
|
| 113 | + $ret = call_user_func_array($callback, $args); |
|
| 114 | + } |
|
| 115 | + else { |
|
| 116 | + $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback); |
|
| 117 | + $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, |
|
| 118 | + "CKFinder failed to call a hook: " . $functionName); |
|
| 119 | + return false; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - //String return is a custom error |
|
| 123 | - if (is_string($ret)) { |
|
| 124 | - $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, $ret); |
|
| 125 | - return false; |
|
| 126 | - } |
|
| 127 | - //hook returned an error code, user error codes start from 50000 |
|
| 128 | - //error codes are important because this way it is possible to create multilanguage extensions |
|
| 122 | + //String return is a custom error |
|
| 123 | + if (is_string($ret)) { |
|
| 124 | + $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, $ret); |
|
| 125 | + return false; |
|
| 126 | + } |
|
| 127 | + //hook returned an error code, user error codes start from 50000 |
|
| 128 | + //error codes are important because this way it is possible to create multilanguage extensions |
|
| 129 | 129 | |
| 130 | - //recomendation: create a function that calculates the error codes starting number |
|
| 131 | - //for an extension, a pool of 100 error codes for each extension should be safe enough |
|
| 132 | - else if (is_int($ret)) { |
|
| 133 | - $errorHandler->throwError($ret); |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - //no value returned |
|
| 137 | - else if( $ret === null ) { |
|
| 138 | - $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback); |
|
| 139 | - $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, |
|
| 140 | - "CKFinder extension returned an invalid value (null)." . |
|
| 141 | - "Hook " . $functionName . " should return a value."); |
|
| 142 | - return false; |
|
| 143 | - } |
|
| 144 | - else if (!$ret) { |
|
| 145 | - return false; |
|
| 146 | - } |
|
| 147 | - } |
|
| 130 | + //recomendation: create a function that calculates the error codes starting number |
|
| 131 | + //for an extension, a pool of 100 error codes for each extension should be safe enough |
|
| 132 | + else if (is_int($ret)) { |
|
| 133 | + $errorHandler->throwError($ret); |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + //no value returned |
|
| 137 | + else if( $ret === null ) { |
|
| 138 | + $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback); |
|
| 139 | + $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, |
|
| 140 | + "CKFinder extension returned an invalid value (null)." . |
|
| 141 | + "Hook " . $functionName . " should return a value."); |
|
| 142 | + return false; |
|
| 143 | + } |
|
| 144 | + else if (!$ret) { |
|
| 145 | + return false; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return true; |
|
| 150 | - } |
|
| 149 | + return true; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Print user friendly name of a callback |
|
| 154 | - * |
|
| 155 | - * @param mixed $callback |
|
| 156 | - * @return string |
|
| 157 | - */ |
|
| 158 | - function _printCallback($callback) |
|
| 159 | - { |
|
| 160 | - if (is_array($callback)) { |
|
| 161 | - if (is_object($callback[0])) { |
|
| 162 | - $className = get_class($callback[0]); |
|
| 163 | - } else { |
|
| 164 | - $className = strval($callback[0]); |
|
| 165 | - } |
|
| 166 | - $functionName = $className . '::' . strval($callback[1]); |
|
| 167 | - } |
|
| 168 | - else { |
|
| 169 | - $functionName = strval($callback); |
|
| 170 | - } |
|
| 171 | - return $functionName; |
|
| 172 | - } |
|
| 152 | + /** |
|
| 153 | + * Print user friendly name of a callback |
|
| 154 | + * |
|
| 155 | + * @param mixed $callback |
|
| 156 | + * @return string |
|
| 157 | + */ |
|
| 158 | + function _printCallback($callback) |
|
| 159 | + { |
|
| 160 | + if (is_array($callback)) { |
|
| 161 | + if (is_object($callback[0])) { |
|
| 162 | + $className = get_class($callback[0]); |
|
| 163 | + } else { |
|
| 164 | + $className = strval($callback[0]); |
|
| 165 | + } |
|
| 166 | + $functionName = $className . '::' . strval($callback[1]); |
|
| 167 | + } |
|
| 168 | + else { |
|
| 169 | + $functionName = strval($callback); |
|
| 170 | + } |
|
| 171 | + return $functionName; |
|
| 172 | + } |
|
| 173 | 173 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | if (!isset($config['Hooks'])) { |
| 35 | 35 | return true; |
| 36 | 36 | } |
| 37 | - $hooks =& $config['Hooks']; |
|
| 37 | + $hooks = & $config['Hooks']; |
|
| 38 | 38 | |
| 39 | 39 | if (!is_array($hooks) || !array_key_exists($event, $hooks) || !is_array($hooks[$event])) { |
| 40 | 40 | return true; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | //object |
| 62 | 62 | else if (is_object($hook)) { |
| 63 | 63 | $object = $hooks[$event][$i]; |
| 64 | - $method = "on" . $event; |
|
| 64 | + $method = "on".$event; |
|
| 65 | 65 | } |
| 66 | 66 | //array of... |
| 67 | 67 | else if (is_array($hook)) { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if (is_object($hook[0])) { |
| 72 | 72 | $object = $hooks[$event][$i][0]; |
| 73 | 73 | if ($count < 2) { |
| 74 | - $method = "on" . $event; |
|
| 74 | + $method = "on".$event; |
|
| 75 | 75 | } else { |
| 76 | 76 | //...object and method |
| 77 | 77 | $method = $hook[1]; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | else { |
| 116 | 116 | $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback); |
| 117 | 117 | $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, |
| 118 | - "CKFinder failed to call a hook: " . $functionName); |
|
| 118 | + "CKFinder failed to call a hook: ".$functionName); |
|
| 119 | 119 | return false; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | return false; |
| 135 | 135 | } |
| 136 | 136 | //no value returned |
| 137 | - else if( $ret === null ) { |
|
| 137 | + else if ($ret === null) { |
|
| 138 | 138 | $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback); |
| 139 | 139 | $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, |
| 140 | - "CKFinder extension returned an invalid value (null)." . |
|
| 141 | - "Hook " . $functionName . " should return a value."); |
|
| 140 | + "CKFinder extension returned an invalid value (null).". |
|
| 141 | + "Hook ".$functionName." should return a value."); |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | else if (!$ret) { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | } else { |
| 164 | 164 | $className = strval($callback[0]); |
| 165 | 165 | } |
| 166 | - $functionName = $className . '::' . strval($callback[1]); |
|
| 166 | + $functionName = $className.'::'.strval($callback[1]); |
|
| 167 | 167 | } |
| 168 | 168 | else { |
| 169 | 169 | $functionName = strval($callback); |
@@ -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 |
@@ -101,18 +103,15 @@ discard block |
||
| 101 | 103 | |
| 102 | 104 | if (isset($object)) { |
| 103 | 105 | $callback = array($object, $method); |
| 104 | - } |
|
| 105 | - else if (false !== ($pos = strpos($function, '::'))) { |
|
| 106 | + } else if (false !== ($pos = strpos($function, '::'))) { |
|
| 106 | 107 | $callback = array(substr($function, 0, $pos), substr($function, $pos + 2)); |
| 107 | - } |
|
| 108 | - else { |
|
| 108 | + } else { |
|
| 109 | 109 | $callback = $function; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if (is_callable($callback)) { |
| 113 | 113 | $ret = call_user_func_array($callback, $args); |
| 114 | - } |
|
| 115 | - else { |
|
| 114 | + } else { |
|
| 116 | 115 | $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback); |
| 117 | 116 | $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, |
| 118 | 117 | "CKFinder failed to call a hook: " . $functionName); |
@@ -140,8 +139,7 @@ discard block |
||
| 140 | 139 | "CKFinder extension returned an invalid value (null)." . |
| 141 | 140 | "Hook " . $functionName . " should return a value."); |
| 142 | 141 | return false; |
| 143 | - } |
|
| 144 | - else if (!$ret) { |
|
| 142 | + } else if (!$ret) { |
|
| 145 | 143 | return false; |
| 146 | 144 | } |
| 147 | 145 | } |
@@ -164,8 +162,7 @@ discard block |
||
| 164 | 162 | $className = strval($callback[0]); |
| 165 | 163 | } |
| 166 | 164 | $functionName = $className . '::' . strval($callback[1]); |
| 167 | - } |
|
| 168 | - else { |
|
| 165 | + } else { |
|
| 169 | 166 | $functionName = strval($callback); |
| 170 | 167 | } |
| 171 | 168 | return $functionName; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * Set value |
| 52 | 52 | * |
| 53 | 53 | * @param string $key |
| 54 | - * @param mixed $obj |
|
| 54 | + * @param string $obj |
|
| 55 | 55 | * @access public |
| 56 | 56 | */ |
| 57 | 57 | function set($key, $obj) |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * Get value |
| 64 | 64 | * |
| 65 | 65 | * @param string $key |
| 66 | - * @return mixed |
|
| 66 | + * @return string |
|
| 67 | 67 | * @access public |
| 68 | 68 | */ |
| 69 | 69 | function get($key) |
@@ -27,49 +27,49 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class CKFinder_Connector_Core_Registry |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * Arrat that stores all values |
|
| 32 | - * |
|
| 33 | - * @var array |
|
| 34 | - * @access private |
|
| 35 | - */ |
|
| 36 | - var $_store = array(); |
|
| 30 | + /** |
|
| 31 | + * Arrat that stores all values |
|
| 32 | + * |
|
| 33 | + * @var array |
|
| 34 | + * @access private |
|
| 35 | + */ |
|
| 36 | + var $_store = array(); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Chacke if value has been set |
|
| 40 | - * |
|
| 41 | - * @param string $key |
|
| 42 | - * @return boolean |
|
| 43 | - * @access private |
|
| 44 | - */ |
|
| 45 | - function isValid($key) |
|
| 46 | - { |
|
| 47 | - return array_key_exists($key, $this->_store); |
|
| 48 | - } |
|
| 38 | + /** |
|
| 39 | + * Chacke if value has been set |
|
| 40 | + * |
|
| 41 | + * @param string $key |
|
| 42 | + * @return boolean |
|
| 43 | + * @access private |
|
| 44 | + */ |
|
| 45 | + function isValid($key) |
|
| 46 | + { |
|
| 47 | + return array_key_exists($key, $this->_store); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Set value |
|
| 52 | - * |
|
| 53 | - * @param string $key |
|
| 54 | - * @param mixed $obj |
|
| 55 | - * @access public |
|
| 56 | - */ |
|
| 57 | - function set($key, $obj) |
|
| 58 | - { |
|
| 59 | - $this->_store[$key] = $obj; |
|
| 60 | - } |
|
| 50 | + /** |
|
| 51 | + * Set value |
|
| 52 | + * |
|
| 53 | + * @param string $key |
|
| 54 | + * @param mixed $obj |
|
| 55 | + * @access public |
|
| 56 | + */ |
|
| 57 | + function set($key, $obj) |
|
| 58 | + { |
|
| 59 | + $this->_store[$key] = $obj; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Get value |
|
| 64 | - * |
|
| 65 | - * @param string $key |
|
| 66 | - * @return mixed |
|
| 67 | - * @access public |
|
| 68 | - */ |
|
| 69 | - function get($key) |
|
| 70 | - { |
|
| 71 | - if ($this->isValid($key)) { |
|
| 72 | - return $this->_store[$key]; |
|
| 73 | - } |
|
| 74 | - } |
|
| 62 | + /** |
|
| 63 | + * Get value |
|
| 64 | + * |
|
| 65 | + * @param string $key |
|
| 66 | + * @return mixed |
|
| 67 | + * @access public |
|
| 68 | + */ |
|
| 69 | + function get($key) |
|
| 70 | + { |
|
| 71 | + if ($this->isValid($key)) { |
|
| 72 | + return $this->_store[$key]; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -10,7 +10,9 @@ |
||
| 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 |
@@ -221,7 +221,6 @@ discard block |
||
| 221 | 221 | * If allowed extensions are defined, return false if extension isn't on allowed list. |
| 222 | 222 | * |
| 223 | 223 | * @access public |
| 224 | - * @param string $extension extension |
|
| 225 | 224 | * @param boolean $renameIfRequired whether try to rename file or not |
| 226 | 225 | * @return boolean |
| 227 | 226 | */ |
@@ -314,8 +313,8 @@ discard block |
||
| 314 | 313 | * Check given path |
| 315 | 314 | * Return true if path contains folder name that matches hidden folder names list |
| 316 | 315 | * |
| 317 | - * @param string $folderName |
|
| 318 | 316 | * @access public |
| 317 | + * @param string $path |
|
| 319 | 318 | * @return boolean |
| 320 | 319 | */ |
| 321 | 320 | function checkIsHiddenPath($path) |
@@ -27,325 +27,325 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class CKFinder_Connector_Core_ResourceTypeConfig |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * Resource name |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - * @access private |
|
| 35 | - */ |
|
| 36 | - var $_name = ""; |
|
| 37 | - /** |
|
| 38 | - * Resource url |
|
| 39 | - * |
|
| 40 | - * @var string |
|
| 41 | - * @access private |
|
| 42 | - */ |
|
| 43 | - var $_url = ""; |
|
| 44 | - /** |
|
| 45 | - * Directory path on a server |
|
| 46 | - * |
|
| 47 | - * @var string |
|
| 48 | - * @access private |
|
| 49 | - */ |
|
| 50 | - var $_directory = ""; |
|
| 51 | - /** |
|
| 52 | - * Max size |
|
| 53 | - * |
|
| 54 | - * @var unknown_type |
|
| 55 | - * @access private |
|
| 56 | - */ |
|
| 57 | - var $_maxSize = 0; |
|
| 58 | - /** |
|
| 59 | - * Array with allowed extensions |
|
| 60 | - * |
|
| 61 | - * @var array[]string |
|
| 62 | - * @access private |
|
| 63 | - */ |
|
| 64 | - var $_allowedExtensions = array(); |
|
| 65 | - /** |
|
| 66 | - * Array with denied extensions |
|
| 67 | - * |
|
| 68 | - * @var array[]string |
|
| 69 | - * @access private |
|
| 70 | - */ |
|
| 71 | - var $_deniedExtensions = array(); |
|
| 72 | - /** |
|
| 73 | - * used for CKFinder_Connector_Core_Config object caching |
|
| 74 | - * |
|
| 75 | - * @var CKFinder_Connector_Core_Config |
|
| 76 | - * @access private |
|
| 77 | - */ |
|
| 78 | - var $_config; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Get ResourceType configuration |
|
| 82 | - * |
|
| 83 | - * @param string $resourceTypeNode |
|
| 84 | - * @return array |
|
| 85 | - * |
|
| 86 | - */ |
|
| 87 | - function CKFinder_Connector_Core_ResourceTypeConfig($resourceTypeNode) |
|
| 88 | - { |
|
| 89 | - if (isset($resourceTypeNode["name"])) { |
|
| 90 | - $this->_name = $resourceTypeNode["name"]; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if (isset($resourceTypeNode["url"])) { |
|
| 94 | - $this->_url = $resourceTypeNode["url"]; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if (!strlen($this->_url)) { |
|
| 98 | - $this->_url = "/"; |
|
| 99 | - } |
|
| 100 | - else if(substr($this->_url,-1,1) != "/") { |
|
| 101 | - $this->_url .= "/"; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - if (isset($resourceTypeNode["maxSize"])) { |
|
| 105 | - $this->_maxSize = CKFinder_Connector_Utils_Misc::returnBytes((string)$resourceTypeNode["maxSize"]); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - if (isset($resourceTypeNode["directory"])) { |
|
| 109 | - $this->_directory = $resourceTypeNode["directory"]; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - if (!strlen($this->_directory)) { |
|
| 113 | - $this->_directory = resolveUrl($this->_url); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if (isset($resourceTypeNode["allowedExtensions"])) { |
|
| 117 | - if (is_array($resourceTypeNode["allowedExtensions"])) { |
|
| 118 | - foreach ($resourceTypeNode["allowedExtensions"] as $e) { |
|
| 119 | - $this->_allowedExtensions[] = strtolower(trim((string)$e)); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - else { |
|
| 123 | - $resourceTypeNode["allowedExtensions"] = trim((string)$resourceTypeNode["allowedExtensions"]); |
|
| 124 | - if (strlen($resourceTypeNode["allowedExtensions"])) { |
|
| 125 | - $extensions = explode(",", $resourceTypeNode["allowedExtensions"]); |
|
| 126 | - foreach ($extensions as $e) { |
|
| 127 | - $this->_allowedExtensions[] = strtolower(trim($e)); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if (isset($resourceTypeNode["deniedExtensions"])) { |
|
| 134 | - if (is_array($resourceTypeNode["deniedExtensions"])) { |
|
| 135 | - |
|
| 136 | - foreach ($resourceTypeNode["deniedExtensions"] as $extension) { |
|
| 137 | - $this->_deniedExtensions[] = strtolower(trim((string)$e)); |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - else { |
|
| 141 | - $resourceTypeNode["deniedExtensions"] = trim((string)$resourceTypeNode["deniedExtensions"]); |
|
| 142 | - if (strlen($resourceTypeNode["deniedExtensions"])) { |
|
| 143 | - $extensions = explode(",", $resourceTypeNode["deniedExtensions"]); |
|
| 144 | - foreach ($extensions as $e) { |
|
| 145 | - $this->_deniedExtensions[] = strtolower(trim($e)); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Get name |
|
| 154 | - * |
|
| 155 | - * @access public |
|
| 156 | - * @return string |
|
| 157 | - */ |
|
| 158 | - function getName() |
|
| 159 | - { |
|
| 160 | - return $this->_name; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Get url |
|
| 165 | - * |
|
| 166 | - * @access public |
|
| 167 | - * @return string |
|
| 168 | - */ |
|
| 169 | - function getUrl() |
|
| 170 | - { |
|
| 171 | - return $this->_url; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Get directory |
|
| 176 | - * |
|
| 177 | - * @access public |
|
| 178 | - * @return string |
|
| 179 | - */ |
|
| 180 | - function getDirectory() |
|
| 181 | - { |
|
| 182 | - return $this->_directory; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Get max size |
|
| 187 | - * |
|
| 188 | - * @access public |
|
| 189 | - * @return int |
|
| 190 | - */ |
|
| 191 | - function getMaxSize() |
|
| 192 | - { |
|
| 193 | - return $this->_maxSize; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Get allowed extensions |
|
| 198 | - * |
|
| 199 | - * @access public |
|
| 200 | - * @return array[]string |
|
| 201 | - */ |
|
| 202 | - function getAllowedExtensions() |
|
| 203 | - { |
|
| 204 | - return $this->_allowedExtensions; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Get denied extensions |
|
| 209 | - * |
|
| 210 | - * @access public |
|
| 211 | - * @return array[]string |
|
| 212 | - */ |
|
| 213 | - function getDeniedExtensions() |
|
| 214 | - { |
|
| 215 | - return $this->_deniedExtensions; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Check extension, return true if file name is valid. |
|
| 220 | - * Return false if extension is on denied list. |
|
| 221 | - * If allowed extensions are defined, return false if extension isn't on allowed list. |
|
| 222 | - * |
|
| 223 | - * @access public |
|
| 224 | - * @param string $extension extension |
|
| 225 | - * @param boolean $renameIfRequired whether try to rename file or not |
|
| 226 | - * @return boolean |
|
| 227 | - */ |
|
| 228 | - function checkExtension(&$fileName, $renameIfRequired = true) |
|
| 229 | - { |
|
| 230 | - if (strpos($fileName, '.') === false) { |
|
| 231 | - return true; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - if (is_null($this->_config)) { |
|
| 235 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - $toCheck = array(); |
|
| 239 | - |
|
| 240 | - if ($this->_config->getCheckDoubleExtension()) { |
|
| 241 | - $pieces = explode('.', $fileName); |
|
| 242 | - |
|
| 243 | - // First, check the last extension (ex. in file.php.jpg, the "jpg"). |
|
| 244 | - if ( !$this->checkSingleExtension( $pieces[sizeof($pieces)-1] ) ) { |
|
| 245 | - return false; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - if ($renameIfRequired) { |
|
| 249 | - // Check the other extensions, rebuilding the file name. If an extension is |
|
| 250 | - // not allowed, replace the dot with an underscore. |
|
| 251 | - $fileName = $pieces[0] ; |
|
| 252 | - for ($i=1; $i<sizeof($pieces)-1; $i++) { |
|
| 253 | - $fileName .= $this->checkSingleExtension( $pieces[$i] ) ? '.' : '_' ; |
|
| 254 | - $fileName .= $pieces[$i]; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - // Add the last extension to the final name. |
|
| 258 | - $fileName .= '.' . $pieces[sizeof($pieces)-1] ; |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - else { |
|
| 262 | - // Check only the last extension (ex. in file.php.jpg, only "jpg"). |
|
| 263 | - return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) ); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - return true; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Check given folder name |
|
| 271 | - * Return true if folder name matches hidden folder names list |
|
| 272 | - * |
|
| 273 | - * @param string $folderName |
|
| 274 | - * @access public |
|
| 275 | - * @return boolean |
|
| 276 | - */ |
|
| 277 | - function checkIsHiddenFolder($folderName) |
|
| 278 | - { |
|
| 279 | - if (is_null($this->_config)) { |
|
| 280 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - $regex = $this->_config->getHideFoldersRegex(); |
|
| 284 | - if ($regex) { |
|
| 285 | - return preg_match($regex, $folderName); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - return false; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Check given file name |
|
| 293 | - * Return true if file name matches hidden file names list |
|
| 294 | - * |
|
| 295 | - * @param string $fileName |
|
| 296 | - * @access public |
|
| 297 | - * @return boolean |
|
| 298 | - */ |
|
| 299 | - function checkIsHiddenFile($fileName) |
|
| 300 | - { |
|
| 301 | - if (is_null($this->_config)) { |
|
| 302 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - $regex = $this->_config->getHideFilesRegex(); |
|
| 306 | - if ($regex) { |
|
| 307 | - return preg_match($regex, $fileName); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - return false; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * Check given path |
|
| 315 | - * Return true if path contains folder name that matches hidden folder names list |
|
| 316 | - * |
|
| 317 | - * @param string $folderName |
|
| 318 | - * @access public |
|
| 319 | - * @return boolean |
|
| 320 | - */ |
|
| 321 | - function checkIsHiddenPath($path) |
|
| 322 | - { |
|
| 323 | - $_clientPathParts = explode("/", trim($path, "/")); |
|
| 324 | - if ($_clientPathParts) { |
|
| 325 | - foreach ($_clientPathParts as $_part) { |
|
| 326 | - if ($this->checkIsHiddenFolder($_part)) { |
|
| 327 | - return true; |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - return false; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - function checkSingleExtension($extension) |
|
| 336 | - { |
|
| 337 | - $extension = strtolower(ltrim($extension,'.')); |
|
| 338 | - |
|
| 339 | - if (sizeof($this->_deniedExtensions)) { |
|
| 340 | - if (in_array($extension, $this->_deniedExtensions)) { |
|
| 341 | - return false; |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - if (sizeof($this->_allowedExtensions)) { |
|
| 346 | - return in_array($extension, $this->_allowedExtensions); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - return true; |
|
| 350 | - } |
|
| 30 | + /** |
|
| 31 | + * Resource name |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + * @access private |
|
| 35 | + */ |
|
| 36 | + var $_name = ""; |
|
| 37 | + /** |
|
| 38 | + * Resource url |
|
| 39 | + * |
|
| 40 | + * @var string |
|
| 41 | + * @access private |
|
| 42 | + */ |
|
| 43 | + var $_url = ""; |
|
| 44 | + /** |
|
| 45 | + * Directory path on a server |
|
| 46 | + * |
|
| 47 | + * @var string |
|
| 48 | + * @access private |
|
| 49 | + */ |
|
| 50 | + var $_directory = ""; |
|
| 51 | + /** |
|
| 52 | + * Max size |
|
| 53 | + * |
|
| 54 | + * @var unknown_type |
|
| 55 | + * @access private |
|
| 56 | + */ |
|
| 57 | + var $_maxSize = 0; |
|
| 58 | + /** |
|
| 59 | + * Array with allowed extensions |
|
| 60 | + * |
|
| 61 | + * @var array[]string |
|
| 62 | + * @access private |
|
| 63 | + */ |
|
| 64 | + var $_allowedExtensions = array(); |
|
| 65 | + /** |
|
| 66 | + * Array with denied extensions |
|
| 67 | + * |
|
| 68 | + * @var array[]string |
|
| 69 | + * @access private |
|
| 70 | + */ |
|
| 71 | + var $_deniedExtensions = array(); |
|
| 72 | + /** |
|
| 73 | + * used for CKFinder_Connector_Core_Config object caching |
|
| 74 | + * |
|
| 75 | + * @var CKFinder_Connector_Core_Config |
|
| 76 | + * @access private |
|
| 77 | + */ |
|
| 78 | + var $_config; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Get ResourceType configuration |
|
| 82 | + * |
|
| 83 | + * @param string $resourceTypeNode |
|
| 84 | + * @return array |
|
| 85 | + * |
|
| 86 | + */ |
|
| 87 | + function CKFinder_Connector_Core_ResourceTypeConfig($resourceTypeNode) |
|
| 88 | + { |
|
| 89 | + if (isset($resourceTypeNode["name"])) { |
|
| 90 | + $this->_name = $resourceTypeNode["name"]; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if (isset($resourceTypeNode["url"])) { |
|
| 94 | + $this->_url = $resourceTypeNode["url"]; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if (!strlen($this->_url)) { |
|
| 98 | + $this->_url = "/"; |
|
| 99 | + } |
|
| 100 | + else if(substr($this->_url,-1,1) != "/") { |
|
| 101 | + $this->_url .= "/"; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + if (isset($resourceTypeNode["maxSize"])) { |
|
| 105 | + $this->_maxSize = CKFinder_Connector_Utils_Misc::returnBytes((string)$resourceTypeNode["maxSize"]); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + if (isset($resourceTypeNode["directory"])) { |
|
| 109 | + $this->_directory = $resourceTypeNode["directory"]; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + if (!strlen($this->_directory)) { |
|
| 113 | + $this->_directory = resolveUrl($this->_url); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if (isset($resourceTypeNode["allowedExtensions"])) { |
|
| 117 | + if (is_array($resourceTypeNode["allowedExtensions"])) { |
|
| 118 | + foreach ($resourceTypeNode["allowedExtensions"] as $e) { |
|
| 119 | + $this->_allowedExtensions[] = strtolower(trim((string)$e)); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + else { |
|
| 123 | + $resourceTypeNode["allowedExtensions"] = trim((string)$resourceTypeNode["allowedExtensions"]); |
|
| 124 | + if (strlen($resourceTypeNode["allowedExtensions"])) { |
|
| 125 | + $extensions = explode(",", $resourceTypeNode["allowedExtensions"]); |
|
| 126 | + foreach ($extensions as $e) { |
|
| 127 | + $this->_allowedExtensions[] = strtolower(trim($e)); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if (isset($resourceTypeNode["deniedExtensions"])) { |
|
| 134 | + if (is_array($resourceTypeNode["deniedExtensions"])) { |
|
| 135 | + |
|
| 136 | + foreach ($resourceTypeNode["deniedExtensions"] as $extension) { |
|
| 137 | + $this->_deniedExtensions[] = strtolower(trim((string)$e)); |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + else { |
|
| 141 | + $resourceTypeNode["deniedExtensions"] = trim((string)$resourceTypeNode["deniedExtensions"]); |
|
| 142 | + if (strlen($resourceTypeNode["deniedExtensions"])) { |
|
| 143 | + $extensions = explode(",", $resourceTypeNode["deniedExtensions"]); |
|
| 144 | + foreach ($extensions as $e) { |
|
| 145 | + $this->_deniedExtensions[] = strtolower(trim($e)); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Get name |
|
| 154 | + * |
|
| 155 | + * @access public |
|
| 156 | + * @return string |
|
| 157 | + */ |
|
| 158 | + function getName() |
|
| 159 | + { |
|
| 160 | + return $this->_name; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Get url |
|
| 165 | + * |
|
| 166 | + * @access public |
|
| 167 | + * @return string |
|
| 168 | + */ |
|
| 169 | + function getUrl() |
|
| 170 | + { |
|
| 171 | + return $this->_url; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Get directory |
|
| 176 | + * |
|
| 177 | + * @access public |
|
| 178 | + * @return string |
|
| 179 | + */ |
|
| 180 | + function getDirectory() |
|
| 181 | + { |
|
| 182 | + return $this->_directory; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Get max size |
|
| 187 | + * |
|
| 188 | + * @access public |
|
| 189 | + * @return int |
|
| 190 | + */ |
|
| 191 | + function getMaxSize() |
|
| 192 | + { |
|
| 193 | + return $this->_maxSize; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Get allowed extensions |
|
| 198 | + * |
|
| 199 | + * @access public |
|
| 200 | + * @return array[]string |
|
| 201 | + */ |
|
| 202 | + function getAllowedExtensions() |
|
| 203 | + { |
|
| 204 | + return $this->_allowedExtensions; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Get denied extensions |
|
| 209 | + * |
|
| 210 | + * @access public |
|
| 211 | + * @return array[]string |
|
| 212 | + */ |
|
| 213 | + function getDeniedExtensions() |
|
| 214 | + { |
|
| 215 | + return $this->_deniedExtensions; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Check extension, return true if file name is valid. |
|
| 220 | + * Return false if extension is on denied list. |
|
| 221 | + * If allowed extensions are defined, return false if extension isn't on allowed list. |
|
| 222 | + * |
|
| 223 | + * @access public |
|
| 224 | + * @param string $extension extension |
|
| 225 | + * @param boolean $renameIfRequired whether try to rename file or not |
|
| 226 | + * @return boolean |
|
| 227 | + */ |
|
| 228 | + function checkExtension(&$fileName, $renameIfRequired = true) |
|
| 229 | + { |
|
| 230 | + if (strpos($fileName, '.') === false) { |
|
| 231 | + return true; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + if (is_null($this->_config)) { |
|
| 235 | + $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + $toCheck = array(); |
|
| 239 | + |
|
| 240 | + if ($this->_config->getCheckDoubleExtension()) { |
|
| 241 | + $pieces = explode('.', $fileName); |
|
| 242 | + |
|
| 243 | + // First, check the last extension (ex. in file.php.jpg, the "jpg"). |
|
| 244 | + if ( !$this->checkSingleExtension( $pieces[sizeof($pieces)-1] ) ) { |
|
| 245 | + return false; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + if ($renameIfRequired) { |
|
| 249 | + // Check the other extensions, rebuilding the file name. If an extension is |
|
| 250 | + // not allowed, replace the dot with an underscore. |
|
| 251 | + $fileName = $pieces[0] ; |
|
| 252 | + for ($i=1; $i<sizeof($pieces)-1; $i++) { |
|
| 253 | + $fileName .= $this->checkSingleExtension( $pieces[$i] ) ? '.' : '_' ; |
|
| 254 | + $fileName .= $pieces[$i]; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + // Add the last extension to the final name. |
|
| 258 | + $fileName .= '.' . $pieces[sizeof($pieces)-1] ; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + else { |
|
| 262 | + // Check only the last extension (ex. in file.php.jpg, only "jpg"). |
|
| 263 | + return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) ); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + return true; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Check given folder name |
|
| 271 | + * Return true if folder name matches hidden folder names list |
|
| 272 | + * |
|
| 273 | + * @param string $folderName |
|
| 274 | + * @access public |
|
| 275 | + * @return boolean |
|
| 276 | + */ |
|
| 277 | + function checkIsHiddenFolder($folderName) |
|
| 278 | + { |
|
| 279 | + if (is_null($this->_config)) { |
|
| 280 | + $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + $regex = $this->_config->getHideFoldersRegex(); |
|
| 284 | + if ($regex) { |
|
| 285 | + return preg_match($regex, $folderName); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + return false; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Check given file name |
|
| 293 | + * Return true if file name matches hidden file names list |
|
| 294 | + * |
|
| 295 | + * @param string $fileName |
|
| 296 | + * @access public |
|
| 297 | + * @return boolean |
|
| 298 | + */ |
|
| 299 | + function checkIsHiddenFile($fileName) |
|
| 300 | + { |
|
| 301 | + if (is_null($this->_config)) { |
|
| 302 | + $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + $regex = $this->_config->getHideFilesRegex(); |
|
| 306 | + if ($regex) { |
|
| 307 | + return preg_match($regex, $fileName); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + return false; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * Check given path |
|
| 315 | + * Return true if path contains folder name that matches hidden folder names list |
|
| 316 | + * |
|
| 317 | + * @param string $folderName |
|
| 318 | + * @access public |
|
| 319 | + * @return boolean |
|
| 320 | + */ |
|
| 321 | + function checkIsHiddenPath($path) |
|
| 322 | + { |
|
| 323 | + $_clientPathParts = explode("/", trim($path, "/")); |
|
| 324 | + if ($_clientPathParts) { |
|
| 325 | + foreach ($_clientPathParts as $_part) { |
|
| 326 | + if ($this->checkIsHiddenFolder($_part)) { |
|
| 327 | + return true; |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + return false; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + function checkSingleExtension($extension) |
|
| 336 | + { |
|
| 337 | + $extension = strtolower(ltrim($extension,'.')); |
|
| 338 | + |
|
| 339 | + if (sizeof($this->_deniedExtensions)) { |
|
| 340 | + if (in_array($extension, $this->_deniedExtensions)) { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + if (sizeof($this->_allowedExtensions)) { |
|
| 346 | + return in_array($extension, $this->_allowedExtensions); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + return true; |
|
| 350 | + } |
|
| 351 | 351 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if (!strlen($this->_url)) { |
| 98 | 98 | $this->_url = "/"; |
| 99 | 99 | } |
| 100 | - else if(substr($this->_url,-1,1) != "/") { |
|
| 100 | + else if (substr($this->_url, -1, 1) != "/") { |
|
| 101 | 101 | $this->_url .= "/"; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | if (is_null($this->_config)) { |
| 235 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 235 | + $this->_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | $toCheck = array(); |
@@ -241,26 +241,26 @@ discard block |
||
| 241 | 241 | $pieces = explode('.', $fileName); |
| 242 | 242 | |
| 243 | 243 | // First, check the last extension (ex. in file.php.jpg, the "jpg"). |
| 244 | - if ( !$this->checkSingleExtension( $pieces[sizeof($pieces)-1] ) ) { |
|
| 244 | + if (!$this->checkSingleExtension($pieces[sizeof($pieces) - 1])) { |
|
| 245 | 245 | return false; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | if ($renameIfRequired) { |
| 249 | 249 | // Check the other extensions, rebuilding the file name. If an extension is |
| 250 | 250 | // not allowed, replace the dot with an underscore. |
| 251 | - $fileName = $pieces[0] ; |
|
| 252 | - for ($i=1; $i<sizeof($pieces)-1; $i++) { |
|
| 253 | - $fileName .= $this->checkSingleExtension( $pieces[$i] ) ? '.' : '_' ; |
|
| 251 | + $fileName = $pieces[0]; |
|
| 252 | + for ($i = 1; $i < sizeof($pieces) - 1; $i++) { |
|
| 253 | + $fileName .= $this->checkSingleExtension($pieces[$i]) ? '.' : '_'; |
|
| 254 | 254 | $fileName .= $pieces[$i]; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // Add the last extension to the final name. |
| 258 | - $fileName .= '.' . $pieces[sizeof($pieces)-1] ; |
|
| 258 | + $fileName .= '.'.$pieces[sizeof($pieces) - 1]; |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | else { |
| 262 | 262 | // Check only the last extension (ex. in file.php.jpg, only "jpg"). |
| 263 | - return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) ); |
|
| 263 | + return $this->checkSingleExtension(substr($fileName, strrpos($fileName, '.') + 1)); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | return true; |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | function checkIsHiddenFolder($folderName) |
| 278 | 278 | { |
| 279 | 279 | if (is_null($this->_config)) { |
| 280 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 280 | + $this->_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $regex = $this->_config->getHideFoldersRegex(); |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | function checkIsHiddenFile($fileName) |
| 300 | 300 | { |
| 301 | 301 | if (is_null($this->_config)) { |
| 302 | - $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 302 | + $this->_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config"); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $regex = $this->_config->getHideFilesRegex(); |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | function checkSingleExtension($extension) |
| 336 | 336 | { |
| 337 | - $extension = strtolower(ltrim($extension,'.')); |
|
| 337 | + $extension = strtolower(ltrim($extension, '.')); |
|
| 338 | 338 | |
| 339 | 339 | if (sizeof($this->_deniedExtensions)) { |
| 340 | 340 | if (in_array($extension, $this->_deniedExtensions)) { |
@@ -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 |
@@ -96,8 +98,7 @@ discard block |
||
| 96 | 98 | |
| 97 | 99 | if (!strlen($this->_url)) { |
| 98 | 100 | $this->_url = "/"; |
| 99 | - } |
|
| 100 | - else if(substr($this->_url,-1,1) != "/") { |
|
| 101 | + } else if(substr($this->_url,-1,1) != "/") { |
|
| 101 | 102 | $this->_url .= "/"; |
| 102 | 103 | } |
| 103 | 104 | |
@@ -118,8 +119,7 @@ discard block |
||
| 118 | 119 | foreach ($resourceTypeNode["allowedExtensions"] as $e) { |
| 119 | 120 | $this->_allowedExtensions[] = strtolower(trim((string)$e)); |
| 120 | 121 | } |
| 121 | - } |
|
| 122 | - else { |
|
| 122 | + } else { |
|
| 123 | 123 | $resourceTypeNode["allowedExtensions"] = trim((string)$resourceTypeNode["allowedExtensions"]); |
| 124 | 124 | if (strlen($resourceTypeNode["allowedExtensions"])) { |
| 125 | 125 | $extensions = explode(",", $resourceTypeNode["allowedExtensions"]); |
@@ -136,8 +136,7 @@ discard block |
||
| 136 | 136 | foreach ($resourceTypeNode["deniedExtensions"] as $extension) { |
| 137 | 137 | $this->_deniedExtensions[] = strtolower(trim((string)$e)); |
| 138 | 138 | } |
| 139 | - } |
|
| 140 | - else { |
|
| 139 | + } else { |
|
| 141 | 140 | $resourceTypeNode["deniedExtensions"] = trim((string)$resourceTypeNode["deniedExtensions"]); |
| 142 | 141 | if (strlen($resourceTypeNode["deniedExtensions"])) { |
| 143 | 142 | $extensions = explode(",", $resourceTypeNode["deniedExtensions"]); |
@@ -257,8 +256,7 @@ discard block |
||
| 257 | 256 | // Add the last extension to the final name. |
| 258 | 257 | $fileName .= '.' . $pieces[sizeof($pieces)-1] ; |
| 259 | 258 | } |
| 260 | - } |
|
| 261 | - else { |
|
| 259 | + } else { |
|
| 262 | 260 | // Check only the last extension (ex. in file.php.jpg, only "jpg"). |
| 263 | 261 | return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) ); |
| 264 | 262 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * Throw file upload error, return true if error has been thrown, false if error has been catched |
| 37 | 37 | * |
| 38 | 38 | * @param int $number |
| 39 | - * @param string $text |
|
| 39 | + * @param string $exit |
|
| 40 | 40 | * @access public |
| 41 | 41 | */ |
| 42 | 42 | function throwError($number, $uploaded = false, $exit = true) { |
@@ -32,50 +32,50 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class CKFinder_Connector_ErrorHandler_FileUpload extends CKFinder_Connector_ErrorHandler_Base |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Throw file upload error, return true if error has been thrown, false if error has been catched |
|
| 37 | - * |
|
| 38 | - * @param int $number |
|
| 39 | - * @param string $text |
|
| 40 | - * @access public |
|
| 41 | - */ |
|
| 42 | - function throwError($number, $uploaded = false, $exit = true) { |
|
| 43 | - if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) { |
|
| 44 | - return false; |
|
| 45 | - } |
|
| 35 | + /** |
|
| 36 | + * Throw file upload error, return true if error has been thrown, false if error has been catched |
|
| 37 | + * |
|
| 38 | + * @param int $number |
|
| 39 | + * @param string $text |
|
| 40 | + * @access public |
|
| 41 | + */ |
|
| 42 | + function throwError($number, $uploaded = false, $exit = true) { |
|
| 43 | + if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $oRegistry = & CKFinder_Connector_Core_Factory :: getInstance("Core_Registry"); |
|
| 48 | - $sFileName = $oRegistry->get("FileUpload_fileName"); |
|
| 49 | - $sFileUrl = $oRegistry->get("FileUpload_url"); |
|
| 47 | + $oRegistry = & CKFinder_Connector_Core_Factory :: getInstance("Core_Registry"); |
|
| 48 | + $sFileName = $oRegistry->get("FileUpload_fileName"); |
|
| 49 | + $sFileUrl = $oRegistry->get("FileUpload_url"); |
|
| 50 | 50 | |
| 51 | - header('Content-Type: text/html; charset=utf-8'); |
|
| 51 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 52 | 52 | |
| 53 | - $errorMessage = CKFinder_Connector_Utils_Misc :: getErrorMessage($number, $sFileName); |
|
| 54 | - if (!$uploaded) { |
|
| 55 | - $sFileName = ""; |
|
| 56 | - } |
|
| 53 | + $errorMessage = CKFinder_Connector_Utils_Misc :: getErrorMessage($number, $sFileName); |
|
| 54 | + if (!$uploaded) { |
|
| 55 | + $sFileName = ""; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - echo "<script type=\"text/javascript\">"; |
|
| 58 | + echo "<script type=\"text/javascript\">"; |
|
| 59 | 59 | |
| 60 | - if (!empty($_GET['CKFinderFuncNum'])) { |
|
| 61 | - $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName); |
|
| 60 | + if (!empty($_GET['CKFinderFuncNum'])) { |
|
| 61 | + $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName); |
|
| 62 | 62 | |
| 63 | - if (!$uploaded) { |
|
| 64 | - $sFileUrl = ""; |
|
| 65 | - $sFileName = ""; |
|
| 66 | - } |
|
| 63 | + if (!$uploaded) { |
|
| 64 | + $sFileUrl = ""; |
|
| 65 | + $sFileName = ""; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKFinderFuncNum']); |
|
| 69 | - echo "window.parent.CKFinder.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
|
| 70 | - } |
|
| 71 | - else { |
|
| 72 | - echo "window.parent.OnUploadCompleted('" . str_replace("'", "\\'", $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "') ;"; |
|
| 73 | - } |
|
| 68 | + $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKFinderFuncNum']); |
|
| 69 | + echo "window.parent.CKFinder.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
|
| 70 | + } |
|
| 71 | + else { |
|
| 72 | + echo "window.parent.OnUploadCompleted('" . str_replace("'", "\\'", $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "') ;"; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - echo "</script>"; |
|
| 75 | + echo "</script>"; |
|
| 76 | 76 | |
| 77 | - if ($exit) { |
|
| 78 | - exit; |
|
| 79 | - } |
|
| 80 | - } |
|
| 77 | + if ($exit) { |
|
| 78 | + exit; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Include base error handling class |
| 23 | 23 | */ |
| 24 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php"; |
|
| 24 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/ErrorHandler/Base.php"; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * File upload error handler |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKFinderFuncNum']); |
| 69 | - echo "window.parent.CKFinder.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
|
| 69 | + echo "window.parent.CKFinder.tools.callFunction($funcNum, '".str_replace("'", "\\'", $sFileUrl.$sFileName)."', '".str_replace("'", "\\'", $errorMessage)."');"; |
|
| 70 | 70 | } |
| 71 | 71 | else { |
| 72 | - echo "window.parent.OnUploadCompleted('" . str_replace("'", "\\'", $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "') ;"; |
|
| 72 | + echo "window.parent.OnUploadCompleted('".str_replace("'", "\\'", $sFileName)."', '".str_replace("'", "\\'", $errorMessage)."') ;"; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | echo "</script>"; |
@@ -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 |
@@ -67,8 +69,7 @@ discard block |
||
| 67 | 69 | |
| 68 | 70 | $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKFinderFuncNum']); |
| 69 | 71 | echo "window.parent.CKFinder.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
| 70 | - } |
|
| 71 | - else { |
|
| 72 | + } else { |
|
| 72 | 73 | echo "window.parent.OnUploadCompleted('" . str_replace("'", "\\'", $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "') ;"; |
| 73 | 74 | } |
| 74 | 75 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * Throw file upload error, return true if error has been thrown, false if error has been catched |
| 37 | 37 | * |
| 38 | 38 | * @param int $number |
| 39 | - * @param string $text |
|
| 39 | + * @param string $exit |
|
| 40 | 40 | * @access public |
| 41 | 41 | */ |
| 42 | 42 | function throwError($number, $uploaded = false, $exit = true) { |
@@ -32,52 +32,52 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class CKFinder_Connector_ErrorHandler_QuickUpload extends CKFinder_Connector_ErrorHandler_Base |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Throw file upload error, return true if error has been thrown, false if error has been catched |
|
| 37 | - * |
|
| 38 | - * @param int $number |
|
| 39 | - * @param string $text |
|
| 40 | - * @access public |
|
| 41 | - */ |
|
| 42 | - function throwError($number, $uploaded = false, $exit = true) { |
|
| 43 | - if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) { |
|
| 44 | - return false; |
|
| 45 | - } |
|
| 35 | + /** |
|
| 36 | + * Throw file upload error, return true if error has been thrown, false if error has been catched |
|
| 37 | + * |
|
| 38 | + * @param int $number |
|
| 39 | + * @param string $text |
|
| 40 | + * @access public |
|
| 41 | + */ |
|
| 42 | + function throwError($number, $uploaded = false, $exit = true) { |
|
| 43 | + if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $oRegistry = & CKFinder_Connector_Core_Factory :: getInstance("Core_Registry"); |
|
| 48 | - $sFileName = $oRegistry->get("FileUpload_fileName"); |
|
| 49 | - $sFileUrl = $oRegistry->get("FileUpload_url"); |
|
| 47 | + $oRegistry = & CKFinder_Connector_Core_Factory :: getInstance("Core_Registry"); |
|
| 48 | + $sFileName = $oRegistry->get("FileUpload_fileName"); |
|
| 49 | + $sFileUrl = $oRegistry->get("FileUpload_url"); |
|
| 50 | 50 | |
| 51 | - header('Content-Type: text/html; charset=utf-8'); |
|
| 51 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * echo <script> is not called before CKFinder_Connector_Utils_Misc::getErrorMessage |
| 55 | 55 | * because PHP has problems with including files that contain BOM character. |
| 56 | 56 | * Having BOM character after <script> tag causes a javascript error. |
| 57 | 57 | */ |
| 58 | - echo "<script type=\"text/javascript\">"; |
|
| 59 | - if (!empty($_GET['CKEditor'])) { |
|
| 60 | - $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName); |
|
| 58 | + echo "<script type=\"text/javascript\">"; |
|
| 59 | + if (!empty($_GET['CKEditor'])) { |
|
| 60 | + $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName); |
|
| 61 | 61 | |
| 62 | - if (!$uploaded) { |
|
| 63 | - $sFileUrl = ""; |
|
| 64 | - $sFileName = ""; |
|
| 65 | - } |
|
| 62 | + if (!$uploaded) { |
|
| 63 | + $sFileUrl = ""; |
|
| 64 | + $sFileName = ""; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']); |
|
| 68 | - echo "window.parent.CKEDITOR.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
|
| 69 | - } |
|
| 70 | - else { |
|
| 71 | - if (!$uploaded) { |
|
| 72 | - echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;"; |
|
| 73 | - } else { |
|
| 74 | - echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;"; |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - echo "</script>"; |
|
| 67 | + $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']); |
|
| 68 | + echo "window.parent.CKEDITOR.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
|
| 69 | + } |
|
| 70 | + else { |
|
| 71 | + if (!$uploaded) { |
|
| 72 | + echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;"; |
|
| 73 | + } else { |
|
| 74 | + echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;"; |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + echo "</script>"; |
|
| 78 | 78 | |
| 79 | - if ($exit) { |
|
| 80 | - exit; |
|
| 81 | - } |
|
| 82 | - } |
|
| 79 | + if ($exit) { |
|
| 80 | + exit; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Include base error handling class |
| 23 | 23 | */ |
| 24 | -require_once CKFINDER_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php"; |
|
| 24 | +require_once CKFINDER_CONNECTOR_LIB_DIR."/ErrorHandler/Base.php"; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * File upload error handler |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']); |
| 68 | - echo "window.parent.CKEDITOR.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
|
| 68 | + echo "window.parent.CKEDITOR.tools.callFunction($funcNum, '".str_replace("'", "\\'", $sFileUrl.$sFileName)."', '".str_replace("'", "\\'", $errorMessage)."');"; |
|
| 69 | 69 | } |
| 70 | 70 | else { |
| 71 | 71 | if (!$uploaded) { |
| 72 | - echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;"; |
|
| 72 | + echo "window.parent.OnUploadCompleted(".$number.", '', '', '') ;"; |
|
| 73 | 73 | } else { |
| 74 | - echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;"; |
|
| 74 | + echo "window.parent.OnUploadCompleted(".$number.", '".str_replace("'", "\\'", $sFileUrl.$sFileName)."', '".str_replace("'", "\\'", $sFileName)."', '') ;"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | echo "</script>"; |
@@ -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 |
@@ -66,8 +68,7 @@ discard block |
||
| 66 | 68 | |
| 67 | 69 | $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']); |
| 68 | 70 | echo "window.parent.CKEDITOR.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');"; |
| 69 | - } |
|
| 70 | - else { |
|
| 71 | + } else { |
|
| 71 | 72 | if (!$uploaded) { |
| 72 | 73 | echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;"; |
| 73 | 74 | } else { |