Esempio n. 1
0
         $extensions = $EDITOR->allowedDocExtensions;
         break;
     case 'media':
         $extensions = $EDITOR->allowedMediaExtensions;
         break;
 }
 if ($isFile && !$fs->extensionOK($extension, $extensions)) {
     array_push($failed2, $old);
     $failed3[$old]['reason'] = 'illegal';
     $failed3[$old]['extension'] = $extension;
     $failed3[$old]['name'] = substr($old, 0, strlen($old) - strlen($extension));
     $failed3[$old]['new'] = $new . $extension;
     continue;
 }
 // check filters
 if ($fs->filterMatch($new . $extension, $dir->filters)) {
     array_push($failed2, $old);
     $failed3[$old]['reason'] = 'reserved';
     $failed3[$old]['extension'] = $extension;
     $failed3[$old]['name'] = substr($old, 0, strlen($old) - strlen($extension));
     $failed3[$old]['new'] = $new . $extension;
     continue;
 }
 // check a file with this name doesn't already exist
 if (file_exists($directory . $new . $extension)) {
     array_push($failed2, $old);
     $failed3[$old]['reason'] = 'duplicate';
     $failed3[$old]['extension'] = $extension;
     $failed3[$old]['name'] = substr($old, 0, strlen($old) - strlen($extension));
     $failed3[$old]['new'] = $new . $extension;
     continue;
Esempio n. 2
0
         $fileMsg = true;
     }
     array_push($failed, $file);
     continue;
 } else {
     if (!$isFile && !$dir->deleteFolders) {
         if (!$folderMsg) {
             $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'JSDeleteFoldersPermissionsError'));
             $folderMsg = true;
         }
         array_push($failed, $file);
         continue;
     }
 }
 // check filters
 if ($fs->filterMatch($file, $dir->filters)) {
     array_push($failed, $file);
     continue;
 }
 // check file extension
 $extension = strrchr($file, '.');
 switch ($dir->type) {
     case 'image':
         $extensions = $EDITOR->allowedImageExtensions;
         break;
     case 'document':
         $extensions = $EDITOR->allowedDocExtensions;
         break;
     case 'media':
         $extensions = $EDITOR->allowedMediaExtensions;
         break;
Esempio n. 3
0
         $extensions = $EDITOR->allowedImageExtensions;
         break;
     case 'document':
         $extensions = $EDITOR->allowedDocExtensions;
         break;
     case 'media':
         $extensions = $EDITOR->allowedMediaExtensions;
         break;
 }
 if ($isFile && !$fs->extensionOK($extension, $extensions)) {
     $failed[$file] = 'unknown';
     continue;
 }
 // check filters
 // filter check
 if ($fs->filterMatch($file, $srcDir->filters) || $fs->filterMatch($file, $destDir->filters)) {
     $failed[$file] = 'reserved';
     continue;
 }
 // if file is a folder check that the destination directory is not inside the folder to be moved...
 if (!$isFile) {
     if (substr($destDirectory . $file, 0, strlen($srcDirectory . $file . '/')) == $srcDirectory . $file . '/') {
         $failed[$file] = 'destInsideSrc';
         continue;
     }
 }
 /* check existing files */
 if (file_exists($destDirectory . $file) && !($action == 'copy' && $srcDirectory . $file == $destDirectory . $file)) {
     if (!$destDir->overwrite) {
         $failed[$file] = 'duplicate';
         continue;
Esempio n. 4
0
 function getFolder($id = '', $folderPath = '', &$response, $noError = false)
 {
     global $EDITOR, $DIALOG;
     // initial var check...
     if (!is_string($id) && !is_int($id) || !is_string($folderPath)) {
         if ($response) {
             $response->addAlert('Datatype error.');
             return false;
         } else {
             require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
             $msg = new wproMessageExit();
             $msg->msgCode = WPRO_CRITICAL;
             $msg->msg = 'Datatype error.';
             $msg->alert();
         }
     }
     $fs = new wproFilesystem();
     $this->instanceSupport($this->params);
     if ($id != '') {
         if ($id == 'image') {
             $dir = $EDITOR->getDirectories('image');
             $dir = $dir[0];
         } else {
             if ($id == 'media') {
                 $dir = $EDITOR->getDirectories('media');
                 $dir = $dir[0];
             } else {
                 if ($id == 'document' || $id == 'link') {
                     $dir = $EDITOR->getDirectories('document');
                     $dir = $dir[0];
                 } else {
                     $dir = $EDITOR->getDirById(intval($id));
                 }
             }
         }
         if ($dir) {
             if (!empty($dir->dir)) {
                 $changed = false;
                 // check validity of folderPath
                 if ($folderPath != '' && !$fs->dirNameOK($folderPath)) {
                     if (!$noError) {
                         if ($response) {
                             $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'badFolderPath'));
                             return false;
                         } else {
                             require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
                             $msg = new wproMessageExit();
                             $msg->msgCode = WPRO_CRITICAL;
                             $msg->msg = $DIALOG->langEngine->get('wproCore_fileBrowser', 'JSBadFolderPath');
                             $msg->alert();
                         }
                     } else {
                         $folderpath = '';
                         $changed = true;
                     }
                 }
                 if ($folderPath == '/') {
                     $folderpath = '';
                 }
                 if ($folderPath != '') {
                     // add trailing /
                     if (substr($folderPath, strlen($folderPath) - 1) != '/') {
                         $folderPath .= '/';
                     }
                     // remove beginning slash
                     if (substr($folderPath, 0, 1) == '/') {
                         $folderPath = substr($folderPath, 1);
                     }
                 }
                 // check that folderpath does not match a filter
                 if (!empty($folderPath)) {
                     $fs = new wproFilesystem();
                     if ($fs->filterMatch(basename($folderPath), $dir->filters)) {
                         $folderpath = '';
                     }
                 }
                 // check validity of dir object
                 $oDirectory = $dir->dir;
                 if ($oDirectory != '') {
                     // add trailing /
                     if (substr($oDirectory, strlen($oDirectory) - 1) != '/') {
                         $oDirectory .= '/';
                     }
                 }
                 $oURL = $dir->URL;
                 if ($oURL != '') {
                     // add trailing /
                     if (substr($oURL, strlen($oURL) - 1) != '/') {
                         $oURL .= '/';
                     }
                 }
                 if ($noError && $folderPath != '') {
                     if (!file_exists($oDirectory . $folderPath)) {
                         $folderpath = '';
                         $changed = true;
                     }
                 }
                 // we now have the actual folder and the URL for the folder
                 $directory = $oDirectory . $folderPath;
                 $URL = $oURL . $folderPath;
                 // if the folder does not exist, or is not a folder we must exit
                 if (!file_exists($directory) || is_file($directory)) {
                     if ($response) {
                         $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'fileNotExistError'));
                         return false;
                     } else {
                         require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
                         $msg = new wproMessageExit();
                         $msg->msgCode = WPRO_CRITICAL;
                         $msg->msg = $DIALOG->langEngine->get('wproCore_fileBrowser', 'JSFileNotExistError');
                         $msg->alert();
                     }
                 }
                 return array('dir' => $dir, 'directory' => $directory, 'URL' => $URL, 'changed' => $changed);
             } else {
                 if ($response) {
                     $response->addAlert('The specified directory object is not correctly configured');
                     return false;
                 } else {
                     require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
                     $msg = new wproMessageExit();
                     $msg->msgCode = WPRO_CRITICAL;
                     $msg->msg = 'The specified directory object is not correctly configured';
                     $msg->alert();
                 }
             }
         } else {
             if ($response) {
                 $response->addAlert('No directory matches this ID');
                 return false;
             } else {
                 require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
                 $msg = new wproMessageExit();
                 $msg->msgCode = WPRO_CRITICAL;
                 $msg->msg = 'No directory matches this ID';
                 $msg->alert();
             }
         }
     } else {
         if ($response) {
             $response->addAlert('No directory ID specified');
             return false;
         } else {
             require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
             $msg = new wproMessageExit();
             $msg->msgCode = WPRO_CRITICAL;
             $msg->msg = 'No directory ID specified';
             $msg->alert();
         }
     }
 }
Esempio n. 5
0
     $msg->msg = $DIALOG->langEngine->get('wproCore_fileBrowser', 'fileNotExistError');
     $msg->alert();
 }
 // check extension
 // check file extension
 $extension = strrchr($image, '.');
 if (!$fs->extensionOK($extension, array('.jpg', '.jpeg', '.gif', '.png'))) {
     require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
     $msg = new wproMessageExit();
     $msg->msgCode = WPRO_CRITICAL;
     $msg->msg = $DIALOG->langEngine->get('wproCore_fileBrowser', 'editImageExtensionError');
     $msg->alert();
 }
 // check filters
 // filter check
 if ($fs->filterMatch($image, $dir->filters)) {
     require_once WPRO_DIR . 'core/libs/wproMessageExit.class.php';
     $msg = new wproMessageExit();
     $msg->msgCode = WPRO_CRITICAL;
     $msg->msg = $DIALOG->langEngine->get('wproCore_fileBrowser', 'Bad name');
     $msg->alert();
 }
 if (!isset($WPRO_SESS->data['imageEditor'])) {
     $WPRO_SESS->data['imageEditor'] = array();
 }
 $WPRO_SESS->data['imageEditor'][$editorID] = array();
 $WPRO_SESS->data['imageEditor'][$editorID]['temp'] = '';
 $WPRO_SESS->data['imageEditor'][$editorID]['file'] = $image;
 $WPRO_SESS->doSave = true;
 list($width, $height) = @getimagesize($directory . $image);
 $width = intval($width);
Esempio n. 6
0
 if (!$dir->createFolders) {
     $this->displayFolderList($folderId, $folderPath, $page, $sortBy, $sortDir, $view, array(), $history, $response);
     $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'JSNewFolderPermissionsError'));
     $response->addScriptCall("dialog.hideLoadMessage", '');
     $response->addScriptCall("hideMessageBox", '');
     return $response;
 }
 if (!$fs->fileNameOK($name)) {
     $this->displayFolderList($folderId, $folderPath, $page, $sortBy, $sortDir, $view, array(), $history, $response);
     $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'JSFileNameError'));
     $response->addScriptCall("document.dialogForm.newFolderName.focus", '');
     $response->addScriptCall("dialog.hideLoadMessage", '');
     return $response;
 }
 // filter check
 if ($fs->filterMatch($name, $dir->filters)) {
     $this->displayFolderList($folderId, $folderPath, $page, $sortBy, $sortDir, $view, array(), $history, $response);
     $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'JSReservedNameError'));
     $response->addScriptCall("document.dialogForm.newFolderName.focus", '');
     $response->addScriptCall("dialog.hideLoadMessage", '');
     return $response;
 }
 $exists = file_exists($directory . $name);
 if ($exists) {
     $this->displayFolderList($folderId, $folderPath, $page, $sortBy, $sortDir, $view, array(), $history, $response);
     $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'JSFolderExistsError'));
     $response->addScriptCall("document.dialogForm.newFolderName.focus", '');
     $response->addScriptCall("dialog.hideLoadMessage", '');
     return $response;
 }
 if ($fs->makeDir($directory . $name, $EDITOR->folderCHMOD)) {