Beispiel #1
0
                $to = str_replace(PATH_REALROOT_FS . '/sql', '', $file->getPathname());
                if (!file_exists(PATH_MAIN_FS . '/sql' . $to)) {
                    if (!CMS_file::copyTo($file->getPathname(), PATH_MAIN_FS . '/sql' . $to)) {
                        $errorCopy = true;
                        $actionsTodo .= '- Copy file from ' . $file->getPathname() . ' to ' . PATH_MAIN_FS . '/sql' . $to . ' <br/>';
                    } else {
                        //$actionsDone .= '- File copied from '.$file->getPathname().' to '.PATH_MAIN_FS.'/sql'.$to.' <br/>';
                    }
                }
            }
        }
    } catch (Exception $e) {
    }
    //remove old dir
    if (!$errorCopy) {
        if (!CMS_file::deltree(PATH_REALROOT_FS . '/sql', true)) {
            $actionsTodo .= '- Delete directory ' . PATH_REALROOT_WR . '/sql <br/>';
        } else {
            $actionsDone .= '- Deleted directory ' . PATH_REALROOT_WR . '/sql <br/>';
        }
    } else {
        $actionsTodo .= '- Delete directory ' . PATH_REALROOT_WR . '/sql <br/>';
    }
}
//check if config.php is writable
$configWritable = is_writable(PATH_REALROOT_FS . '/config.php');
# Create config for /html
if (is_dir(PATH_REALROOT_FS . '/html') && PATH_PAGES_HTML_FS == PATH_MAIN_FS . '/html') {
    if ($configWritable) {
        $configFile = new CMS_file(PATH_REALROOT_FS . '/config.php');
        if ($configFile->exists()) {
Beispiel #2
0
 /**
  * Clear a type cache
  *
  * @param string $type : the cache type to clear
  * @return boolean
  * @access public
  * @static
  */
 function clearTypeCache($type)
 {
     $type = io::sanitizeAsciiString($type);
     if (!$type) {
         CMS_grandFather::raiseError('$type must be a valid cache type');
         return false;
     }
     if (is_dir(PATH_CACHE_FS . '/' . $type)) {
         // First we'll check all modules to see if one of them implements a clearTypeCache method
         $modules = CMS_modulesCatalog::getAll('id');
         $cleared = false;
         foreach ($modules as $codename => $module) {
             if (method_exists($module, 'clearTypeCache')) {
                 $cleared = $module->clearTypeCache($type);
             }
         }
         // No module deleted the cache, use automne standard cache clear
         if (!$cleared) {
             //delete all type cache
             if (!CMS_file::deltree(PATH_CACHE_FS . '/' . $type, false, true)) {
                 CMS_grandFather::raiseError('Cannot clear cache for type ' . $type);
                 return false;
             }
         }
     }
     return true;
 }
Beispiel #3
0
        } else {
            report('-> Patch installation done without error.');
        }
    } elseif ($exportFile->exists()) {
        //Module datas to import
        $importDatas = $exportFile->getContent();
        if (!$importDatas) {
            report('Error: no content to import or invalid content...', true);
        }
        $import = new CMS_module_import();
        if (!$import->import($importDatas, 'xml', $cms_language, $importLog)) {
            report('Error during datas importation...');
        }
        if (isset($importLog) && $importLog) {
            verbose('Import log: ');
            verbose($importLog);
        }
    } else {
        report('Error : File ' . PATH_TMP_FS . '/patch does not exists ... This file is not a valid Automne patch.', true);
    }
    //remove temporary files
    report('Start cleaning temporary files...');
    if (!CMS_file::deltree(PATH_TMP_FS)) {
        report('Error during temporary folder cleaning...');
    } else {
        verbose('-> Cleaning done.');
    }
    $content .= $send;
    echo $content;
    exit;
}
Beispiel #4
0
 /**
  * Destroy the module
  *
  * @return void
  * @access public
  */
 function destroy()
 {
     global $cms_user;
     // Check module exists and is polymod
     if (!$this->isDestroyable()) {
         return false;
     }
     // CHECK USED ROWS
     $rowsIds = CMS_rowsCatalog::getByModules(array($this->_codename), false, false);
     //delete all module rows
     foreach ($rowsIds as $rowId) {
         $row = CMS_rowsCatalog::getByID($rowId);
         if (is_object($row)) {
             $row->destroy();
         }
     }
     // TREAT CATEGORIES
     $attrs = array("module" => $this->_codename, "language" => CMS_languagesCatalog::getDefaultLanguage(), "level" => -1, "root" => -1, "cms_user" => $cms_user, "clearanceLevel" => CLEARANCE_MODULE_EDIT, "strict" => false);
     $cats = CMS_moduleCategories_catalog::getAll($attrs);
     if ($cats) {
         foreach ($cats as $cat) {
             // Destroy category
             $cat->destroy();
         }
     }
     // TREAT MODULE & VALIDATIONS RIGHTS
     $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tmoduleClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t\t\t or moduleClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t ";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $stack = new CMS_stack();
             $stack->setTextDefinition($r['moduleClearancesStack_pr']);
             $stack->delAllWithOneKey($this->_codename);
             $qInsert = new CMS_query("update profiles set moduleClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'");
         }
     }
     $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tvalidationClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr = '" . io::sanitizeSQLString($this->_codename) . "'\n\t\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $stack = new CMS_stack();
             $stack->setTextDefinition($r['validationClearancesStack_pr']);
             $stack->delAllWithOneKey($this->_codename);
             $qInsert = new CMS_query("update profiles set validationClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'");
         }
     }
     //remove module files
     if (CMS_file::deltreeSimulation(PATH_MODULES_FILES_FS . '/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_MODULES_FILES_FS . '/' . $this->_codename, true);
     }
     //remove JS and CSS
     if (is_dir(PATH_JS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_JS_FS . '/modules/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_JS_FS . '/modules/' . $this->_codename, true);
     }
     if (is_dir(PATH_CSS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_CSS_FS . '/modules/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_CSS_FS . '/modules/' . $this->_codename, true);
     }
     $cssFiles = $this->getCSSFiles('', true);
     foreach ($cssFiles as $mediaCssFiles) {
         foreach ($mediaCssFiles as $cssFile) {
             CMS_file::deleteFile(PATH_REALROOT_FS . '/' . $cssFile);
         }
     }
     //Clear polymod cache
     //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_codename));
     CMS_cache::clearTypeCache('polymod');
     // Destroy module
     return parent::destroy();
 }
Beispiel #5
0
        //remove JS and CSS cache
        if (!CMS_cache::clearTypeCache('text/javascript') || !CMS_cache::clearTypeCache('text/css')) {
            $cms_message = $cms_language->getMessage(MESSAGE_CREATION_ERROR);
        }
        break;
    case 'polymod-cache-reset':
        //remove polymod cache
        if (CMS_cache::clearTypeCache('polymod') && CMS_cache::clearTypeCache('atm-polymod-structure')) {
            $cms_message = $cms_language->getMessage(MESSAGE_OPERATION_DONE);
        } else {
            $cms_message = $cms_language->getMessage(MESSAGE_CREATION_ERROR);
        }
        break;
    case 'cache-reset':
        //remove polymod cache
        if (CMS_file::deltree(PATH_CACHE_FS, false)) {
            $cms_message = $cms_language->getMessage(MESSAGE_OPERATION_DONE);
        } else {
            $cms_message = $cms_language->getMessage(MESSAGE_CREATION_ERROR);
        }
        break;
    case 'update-db':
        ob_start();
        require PATH_ADMIN_FS . '/update.php';
        $content = ob_get_clean();
        break;
}
//set user message if any
if ($cms_message) {
    $view->setActionMessage($cms_message);
}
Beispiel #6
0
function patch($patchFile, &$error)
{
    $archive = new CMS_gzip_file($patchFile);
    if (!$archive->hasError()) {
        $archive->set_options(array('basedir' => PATH_TMP_FS . "/", 'overwrite' => 1, 'level' => 1, 'dontUseFilePerms' => 1, 'forceWriting' => 1));
        if (is_dir(PATH_TMP_FS)) {
            if (!method_exists($archive, 'extract_files') || !$archive->extract_files()) {
                $error = 'Error : Extraction error...';
                return false;
            }
        } else {
            $error = 'Error : Extraction directory does not exist';
            return false;
        }
    } else {
        $error = 'Error : Unable to extract archive wanted ' . $filename . '. It is not a valid format...';
        return false;
    }
    if (!$archive->hasError()) {
        unset($archive);
    } else {
        $error = 'Extraction error...';
        return false;
    }
    //Check files content
    $automnePatch = new CMS_patch();
    //read patch param file and check versions
    $patchFile = new CMS_file(PATH_TMP_FS . "/patch");
    if ($patchFile->exists()) {
        $patch = $patchFile->readContent("array");
    } else {
        $error = 'Error : File ' . PATH_TMP_FS . '/patch does not exists ...';
        return false;
    }
    if (!$automnePatch->checkPatch($patch)) {
        $error = 'Error : Patch does not match current version ...';
        return false;
    }
    //read install param file and do maximum check on it before starting the installation process
    $installFile = new CMS_file(PATH_TMP_FS . "/install");
    if ($installFile->exists()) {
        $install = $installFile->readContent("array");
    } else {
        $error = 'Error : File ' . PATH_TMP_FS . '/install does not exists ...';
        return false;
    }
    $installError = $automnePatch->checkInstall($install, $errorsInfos);
    if ($installError) {
        $error = 'Error : Invalid install file :';
        $error .= $installError;
        return false;
    }
    //start Installation process
    $automnePatch->doInstall($install);
    $installError = false;
    $return = $automnePatch->getReturn();
    foreach ($return as $line) {
        if ($line['type'] == 'report') {
            $error .= $line['text'];
        }
    }
    if ($installError) {
        $error = 'Error during installation process : ' . $error;
        return false;
    }
    //remove temporary files
    !CMS_file::deltree(PATH_TMP_FS);
    return true;
}
Beispiel #7
0
 /**
  * Delete alias files (folder and redirection file)
  *
  * @return boolean true on success, false on failure
  * @access private
  */
 private function _deleteFiles()
 {
     //check if alias directory already exists
     if (!@is_dir($this->getPath(true, PATH_RELATIVETO_FILESYSTEM))) {
         return true;
     }
     //if this directory is used by subaliases, do not delete it
     if ($this->hasSubAliases()) {
         return true;
     }
     //check if directory is used by another alias
     $aliases = CMS_module_cms_aliases::getByName($this->getAlias());
     $otherAlias = false;
     foreach ($aliases as $anAlias) {
         if ($this->getID() != $anAlias->getID() && $this->getPath() == $anAlias->getPath()) {
             $otherAlias = true;
         }
     }
     if ($otherAlias) {
         //another alias still use this directory so, do not delete it
         return true;
     }
     return CMS_file::deltree($this->getPath(true, PATH_RELATIVETO_FILESYSTEM), true);
 }
 /**
  * function deleteFile
  * Delete a file or folder (recursively)
  * @param string $file, the full filename of the file or dir
  * @return boolean true on success, false on failure
  * @static
  */
 function deleteFile($file)
 {
     $file = realpath($file);
     if (is_file($file)) {
         return @unlink($file);
     } elseif (@is_dir($file)) {
         return CMS_file::deltree($file, true);
     } else {
         CMS_grandFather::raiseError("Try to delete a file or dir who does not exists : " . $file);
         return false;
     }
 }