public function run()
 {
     try {
         $tempPath = jApp::tempBasePath();
         if ($tempPath == DIRECTORY_SEPARATOR || $tempPath == '' || $tempPath == '/') {
             echo "Error: bad path in jApp::tempBasePath(), it is equals to '" . $tempPath . "' !!\n";
             echo "       Jelix cannot clear the content of the temp directory.\n";
             echo "       Correct the path in your application.init.php or create the corresponding directory\n";
             exit(1);
         }
         if (!jFile::removeDir($tempPath, false, array('.svn', '.dummy'))) {
             echo "Some temp files were not removed\n";
         } else {
             if ($this->verbose()) {
                 echo "All temp files have been removed\n";
             }
         }
     } catch (Exception $e) {
         if ($this->config->helpLang == 'fr') {
             echo "Un ou plusieurs répertoires n'ont pas pu être supprimés.\n" . "Message d'erreur : " . $e->getMessage() . "\n";
         } else {
             echo "One or more directories couldn't be deleted.\n" . "Error: " . $e->getMessage() . "\n";
         }
     }
 }
Esempio n. 2
0
 function clear()
 {
     $confirm = $this->param('confirm');
     if ($confirm == 'Y') {
         jFile::removeDir(jApp::tempPath(), false);
         jMessage::add(jLocale::get('jelixcache~jelixcache.cache.clear.done'));
     } else {
         jMessage::add(jLocale::get('jelixcache~jelixcache.cache.clear.canceled'));
     }
     $rep = $this->getResponse('redirect');
     $rep->action = 'jelixcache~default:index';
     return $rep;
 }
Esempio n. 3
0
 /**
  * Let use one of the available theme
  */
 function useit()
 {
     $theme = (string) $this->param('theme');
     $mainConfig = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $mainConfig->setValue('theme', strtolower($theme));
     $mainConfig->setValue('datepicker', strtolower($theme), 'forms');
     $mainConfig->save();
     jFile::removeDir(jApp::tempPath(), false);
     jMessage::add(jLocale::get('theme.selected'), 'information');
     $rep = $this->getResponse('redirect');
     $rep->action = 'default:index';
     return $rep;
 }
Esempio n. 4
0
 public static function clearTemp()
 {
     if (!defined('JELIX_APP_TEMP_PATH')) {
         echo "Error: JELIX_APP_TEMP_PATH is not defined\n";
         exit(1);
     }
     if (JELIX_APP_TEMP_PATH == DIRECTORY_SEPARATOR || JELIX_APP_TEMP_PATH == '' || JELIX_APP_TEMP_PATH == '/') {
         echo "Error: bad path in JELIX_APP_TEMP_PATH, it is equals to '" . JELIX_APP_TEMP_PATH . "' !!\n";
         echo "       Jelix cannot clear the content of the temp directory.\n";
         echo "       Correct the path in JELIX_APP_TEMP_PATH or create the directory you\n";
         echo "       indicated into JELIX_APP_TEMP_PATH.\n";
         exit(1);
     }
     jFile::removeDir(JELIX_APP_TEMP_PATH, false);
 }
Esempio n. 5
0
 public function run()
 {
     try {
         jFile::removeDir(JELIX_APP_TEMP_PATH, false);
         jFile::removeDir(JELIX_APP_REAL_TEMP_PATH, false);
         if (defined('JELIX_APP_TEMP_CLI_PATH')) {
             jFile::removeDir(JELIX_APP_TEMP_CLI_PATH, false);
         }
     } catch (Exception $e) {
         if (MESSAGE_LANG == 'fr') {
             echo "Un ou plusieurs répertoires n'ont pas pu être supprimés.\n" . "Message d'erreur : " . $e->getMessage() . "\n";
         } else {
             echo "One or more directories couldn't be deleted.\n" . "Error: " . $e->getMessage() . "\n";
         }
     }
 }
Esempio n. 6
0
 public function run()
 {
     try {
         if (!defined('JELIX_APP_TEMP_PATH')) {
             echo "Error: JELIX_APP_TEMP_PATH is not defined\n";
             exit(1);
         }
         if (JELIX_APP_TEMP_PATH == DIRECTORY_SEPARATOR || JELIX_APP_TEMP_PATH == '' || JELIX_APP_TEMP_PATH == '/') {
             echo "Error: bad path in JELIX_APP_TEMP_PATH, it is equals to '" . JELIX_APP_TEMP_PATH . "' !!\n";
             echo "       Jelix cannot clear the content of the temp directory.\n";
             echo "       Correct the path in JELIX_APP_TEMP_PATH or create the directory you\n";
             echo "       indicated into JELIX_APP_TEMP_PATH.\n";
             exit(1);
         }
         jFile::removeDir(JELIX_APP_TEMP_PATH, false);
         if (!defined('JELIX_APP_REAL_TEMP_PATH')) {
             echo "Error: JELIX_APP_REAL_TEMP_PATH is not defined\n";
             exit(1);
         }
         if (JELIX_APP_REAL_TEMP_PATH == DIRECTORY_SEPARATOR || JELIX_APP_REAL_TEMP_PATH == '' || JELIX_APP_REAL_TEMP_PATH == '/') {
             echo "Error: bad path in JELIX_APP_REAL_TEMP_PATH, it is equals to '" . JELIX_APP_REAL_TEMP_PATH . "' !!\n";
             echo "       Jelix cannot clear the content of the temp directory.\n";
             echo "       Correct the path in JELIX_APP_REAL_TEMP_PATH or create the directory you\n";
             echo "       indicated into JELIX_APP_REAL_TEMP_PATH.\n";
             exit(1);
         }
         jFile::removeDir(JELIX_APP_REAL_TEMP_PATH, false);
         if (defined('JELIX_APP_TEMP_CLI_PATH')) {
             if (JELIX_APP_TEMP_CLI_PATH == DIRECTORY_SEPARATOR || JELIX_APP_TEMP_CLI_PATH == '' || JELIX_APP_TEMP_CLI_PATH == '/') {
                 echo "Error: bad path in JELIX_APP_TEMP_CLI_PATH, it is equals to '" . JELIX_APP_TEMP_CLI_PATH . "' !!\n";
                 echo "       Jelix cannot clear the content of the temp directory.\n";
                 echo "       Correct the path in JELIX_APP_TEMP_CLI_PATH or create the directory you\n";
                 echo "       indicated into JELIX_APP_TEMP_CLI_PATH.\n";
                 exit(1);
             }
             jFile::removeDir(JELIX_APP_TEMP_CLI_PATH, false);
         }
     } catch (Exception $e) {
         if (MESSAGE_LANG == 'fr') {
             echo "Un ou plusieurs répertoires n'ont pas pu être supprimés.\n" . "Message d'erreur : " . $e->getMessage() . "\n";
         } else {
             echo "One or more directories couldn't be deleted.\n" . "Error: " . $e->getMessage() . "\n";
         }
     }
 }
 public static function clearTemp($path = '')
 {
     if ($path == '') {
         $path = jApp::tempBasePath();
         if ($path == '') {
             throw new Exception("default temp base path is not defined", 1);
         }
     }
     if ($path == DIRECTORY_SEPARATOR || $path == '' || $path == '/') {
         throw new Exception('given temp path is invalid', 2);
     }
     if (!file_exists($path)) {
         throw new Exception('given temp path does not exists', 3);
     }
     if (!is_writeable($path)) {
         throw new Exception('given temp path does not exists', 4);
     }
     jFile::removeDir($path, false);
 }
Esempio n. 8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $tempPath = \Jelix\Core\App::tempBasePath();
         if ($tempPath == DIRECTORY_SEPARATOR || $tempPath == '' || $tempPath == '/') {
             $output->writeln("<error>Error: bad path in jApp::tempBasePath(), it is equals to '" . $tempPath . "' !!</error>");
             $output->writeln("       Jelix cannot clear the content of the temp directory.");
             $output->writeln("       Correct the path in your application.init.php or create the corresponding directory");
             return 1;
         }
         if (!\jFile::removeDir($tempPath, false, array('.svn', '.git', '.dummy'))) {
             $output->writeln("Some temp files were not removed");
         } else {
             if ($output->isVerbose()) {
                 $output->writeln("All temp files have been removed");
             }
         }
     } catch (\Exception $e) {
         $output->writeln("One or more directories couldn't be deleted.");
         $output->writeln("<error>Error: " . $e->getMessage() . "</error>");
         return 2;
     }
 }
Esempio n. 9
0
 static function checkTempPath()
 {
     $tempBasePath = \Jelix\Core\App::tempBasePath();
     // we always clean the temp directory. But first, let's check the temp path (see ticket #840)...
     if ($tempBasePath == DIRECTORY_SEPARATOR || $tempBasePath == '' || $tempBasePath == '/') {
         throw new Exception("Error: bad path in \\Jelix\\Core\\App::tempBasePath(), it is equals to '" . $tempBasePath . "' !!\n" . "       Jelix cannot clear the content of the temp directory.\n" . "       Correct the path for the temp directory or create the directory you\n" . "       indicated with \\Jelix\\Core\\App in your application.init.php.\n");
     }
     jFile::removeDir(\Jelix\Core\App::tempPath(), false, array('.svn', '.dummy'));
 }
 /**
  * Clears the cache directory
  */
 public function clearCache()
 {
     jFile::removeDir($this->cachePath, false);
 }
Esempio n. 11
0
if (file_exists(JELIXS_APPTPL_PATH) && file_exists(JELIXS_APPTPL_PATH . 'application.init.php')) {
    if (!file_exists(JELIXS_APPTPL_PATH . 'jelix-scripts.init.php')) {
        echo "Error: jelix-scripts.init.php doesn't exist in your application\n";
        echo "       You must create this file which should be similar to application.init.php\n";
        echo "       but with a different temp directory.\n";
        echo "       it should also declare a constant JELIX_APP_REAL_TEMP_PATH which should contain\n";
        echo "       the path to the temp directory indicated in application.init.php.\n";
        exit(1);
    }
    include JELIXS_APPTPL_PATH . 'jelix-scripts.init.php';
    if (!class_exists('jCoordinator', false)) {
        // for old application.init.php which doesn't include init.php
        include JELIXS_INIT_PATH;
    }
    // we always clean the temp directory.
    jFile::removeDir(JELIX_APP_TEMP_PATH, false);
} else {
    if ($commandName != 'createapp' && $commandName != 'help') {
        echo "Error: the given application doesn't exist (" . JELIXS_APPTPL_PATH . " )\n";
        exit(1);
    }
    include JELIXS_INIT_PATH;
    define('JELIX_APP_PATH', JELIXS_APPTPL_PATH);
    define('JELIX_APP_REAL_TEMP_PATH', JELIXS_APPTPL_TEMP_PATH);
    define('JELIX_APP_CLI_TEMP_PATH', substr(JELIXS_APPTPL_TEMP_PATH, 0, -1) . '-cli/');
    define('JELIX_APP_TEMP_PATH', substr(JELIXS_APPTPL_TEMP_PATH, 0, -1) . '-jelix-scripts/');
    define('JELIX_APP_VAR_PATH', JELIXS_APPTPL_VAR_PATH);
    define('JELIX_APP_LOG_PATH', JELIXS_APPTPL_LOG_PATH);
    define('JELIX_APP_CONFIG_PATH', JELIXS_APPTPL_CONFIG_PATH);
    define('JELIX_APP_WWW_PATH', JELIXS_APPTPL_WWW_PATH);
    define('JELIX_APP_CMD_PATH', JELIXS_APPTPL_CMD_PATH);
Esempio n. 12
0
 public static function clearLayerCache($repository, $project, $layer)
 {
     // Storage type
     $ser = lizmap::getServices();
     $cacheStorageType = $ser->cacheStorageType;
     // Cache root directory
     if ($cacheStorageType != 'redis') {
         $cacheRootDirectory = $ser->cacheRootDirectory;
         if (!is_writable($cacheRootDirectory) or !is_dir($cacheRootDirectory)) {
             $cacheRootDirectory = sys_get_temp_dir();
         }
         // Directory where cached files are stored for the project
         $cacheProjectDir = $cacheRootDirectory . '/' . $repository . '/' . $project . '/';
         $results = array();
         if (file_exists($cacheProjectDir)) {
             // Open the directory and walk through the filenames
             $handle = opendir($cacheProjectDir);
             while (false !== ($entry = readdir($handle))) {
                 if ($entry != "." && $entry != "..") {
                     // Get directories and files corresponding to the layer
                     if (preg_match('#(^|_)' . $layer . '($|_)#', $entry)) {
                         $results[] = $cacheProjectDir . $entry;
                     }
                 }
             }
             closedir($handle);
             foreach ($results as $rem) {
                 if (is_dir($rem)) {
                     jFile::removeDir($rem);
                 } else {
                     unlink($rem);
                 }
             }
         }
     } else {
         // FIXME: removing by layer is not supported for the moment. For the moment, we flush all layers of the project.
         $cacheName = 'lizmapCache_' . $repository . '_' . $project;
         self::declareRedisProfile($ser, $cacheName, $repository, $project);
         jCache::flush($cacheName);
     }
     jEvent::notify('lizmapProxyClearLayerCache', array('repository' => $repository, 'project' => $project, 'layer' => $layer));
 }
 /**
  * Empty a map service cache
  * @param string $repository Repository for which to remove all tile cache
  * @return Redirection to the index
  */
 function removeLayerCache()
 {
     $repository = $this->param('repository');
     $project = $this->param('project');
     $layer = $this->param('layer');
     // Get config utility
     $lrep = lizmap::getRepository($repository);
     $ser = lizmap::getServices();
     $lproj = lizmap::getProject($repository . '~' . $project);
     $project = $lproj->getKey();
     // Remove the cache for the layer
     $cacheRootDirectory = $ser->cacheRootDirectory;
     $cacheProjectDir = $cacheRootDirectory . '/' . $lrep->getKey() . '/' . $project . '/';
     $handle = opendir($cacheProjectDir);
     $results = array();
     // Open the directory and walk through the filenames
     while (false !== ($entry = readdir($handle))) {
         if ($entry != "." && $entry != "..") {
             // Get directories and files corresponding to the layer
             if (preg_match('#^' . $layer . '_#', $entry) or $entry == $layer) {
                 $results[] = $cacheProjectDir . $entry;
             }
         }
     }
     closedir($handle);
     // Remove layer files and folder cache
     if ($lrep && $lproj) {
         foreach ($results as $rem) {
             if (is_dir($rem)) {
                 jFile::removeDir($rem);
             } else {
                 unlink($rem);
             }
         }
     }
     jMessage::add(jLocale::get("admin~admin.cache.layer.removed", array($layer)));
     // Redirect to the index
     $rep = $this->getResponse("redirect");
     $rep->action = "admin~config:index";
     return $rep;
 }
Esempio n. 14
0
 /**
  * clear all zone cache or all cache of a specific zone
  * @param string $name zone selector
  * @since 1.0b1
  */
 public static function clearAll($name = '')
 {
     $dir = jApp::tempPath('zonecache/');
     if (!file_exists($dir)) {
         return;
     }
     if ($name != '') {
         $sel = new jSelectorZone($name);
         $dir .= $sel->module . '/' . strtolower($sel->resource) . 'zone/';
     }
     jFile::removeDir($dir, false);
 }
Esempio n. 15
0
 public static function clearTemp()
 {
     jFile::removeDir(JELIX_APP_TEMP_PATH, false);
 }
Esempio n. 16
0
 public function setUp()
 {
     if (file_exists(jApp::tempPath() . 'kvfiles/tests/')) {
         jFile::removeDir(jApp::tempPath() . 'kvfiles/tests/', false);
     }
 }
Esempio n. 17
0
 function uninstall()
 {
     $rep = $this->getResponse('json');
     //$rep->addJSLink('monscript.js');
     $module = $this->param("app");
     if (!empty($module)) {
         $base = "modules/";
         $d = 0;
         $config = parse_ini_file('var/config/mainconfig.ini.php');
         if ($config['startModule'] != $module) {
             $this->uninstallScript($module);
             jFile::removeDir($base . '/' . $module);
             $this->removeConfig($module);
             $this->msg = "module desinstallé";
             $this->success = true;
         } else {
             $d = 1;
             $this->msg = "le module par defaut ne peut etre desinstallé";
             $this->success = false;
         }
     }
     $moduleDir = $this->allModules();
     $rep->data = array('success' => $this->success, 'msg' => $this->msg);
     return $rep;
 }
Esempio n. 18
0
 public function setUp()
 {
     if (file_exists(jApp::tempPath() . 'cache')) {
         jFile::removeDir(jApp::tempPath() . 'cache/', false);
     }
 }