示例#1
0
 /**
  * Regenerate all cache files
  * @return void
  */
 function procAdminRecompileCacheFile()
 {
     // rename cache dir
     Rhymix\Framework\Storage::move(\RX_BASEDIR . 'files/cache', \RX_BASEDIR . 'files/cache_' . time());
     Rhymix\Framework\Storage::createDirectory(\RX_BASEDIR . 'files/cache');
     // remove module extend cache
     Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/config/module_extend.php');
     // remove debug files
     Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/_debug_message.php');
     Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/_debug_db_query.php');
     Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/_db_slow_query.php');
     $oModuleModel = getModel('module');
     $module_list = $oModuleModel->getModuleList();
     // call recompileCache for each module
     foreach ($module_list as $module) {
         $oModule = NULL;
         $oModule = getClass($module->module);
         if (method_exists($oModule, 'recompileCache')) {
             $oModule->recompileCache();
         }
     }
     // remove object cache
     if (!in_array(Rhymix\Framework\Cache::getDriverName(), array('file', 'sqlite', 'dummy'))) {
         Rhymix\Framework\Cache::clearAll();
     }
     // remove old cache dir
     $tmp_cache_list = FileHandler::readDir(\RX_BASEDIR . 'files', '/^(cache_[0-9]+)/');
     if ($tmp_cache_list) {
         foreach ($tmp_cache_list as $tmp_dir) {
             if (strval($tmp_dir) !== '') {
                 $tmp_dir = \RX_BASEDIR . 'files/' . strval($tmp_dir);
                 if (!Rhymix\Framework\Storage::isDirectory($tmp_dir)) {
                     continue;
                 }
                 // If possible, use system command to speed up recursive deletion
                 if (function_exists('exec') && !preg_match('/(?<!_)exec/', ini_get('disable_functions'))) {
                     if (strncasecmp(\PHP_OS, 'win', 3) == 0) {
                         @exec('rmdir /S /Q ' . escapeshellarg($tmp_dir));
                     } else {
                         @exec('rm -rf ' . escapeshellarg($tmp_dir));
                     }
                 }
                 // If the directory still exists, delete using PHP.
                 Rhymix\Framework\Storage::deleteDirectory($tmp_dir);
             }
         }
     }
     // remove duplicate indexes (only for CUBRID)
     $db_type = Context::getDBType();
     if ($db_type == 'cubrid') {
         $db = DB::getInstance();
         $db->deleteDuplicateIndexes();
     }
     // check autoinstall packages
     $oAutoinstallAdminController = getAdminController('autoinstall');
     $oAutoinstallAdminController->checkInstalled();
     $this->setMessage('success_updated');
 }
示例#2
0
 /**
  * Remove files in the target directory
  *
  * This function keeps the directory structure.
  *
  * @param string $path Path of the target directory
  * @return void
  */
 public static function removeFilesInDir($path)
 {
     return Rhymix\Framework\Storage::deleteDirectory(self::getRealPath($path), false);
 }