private function generate_cache_file()
 {
     try {
         $cache_file = new File($this->cache_file_path);
         $cache_file->open(File::WRITE);
         $cache_file->lock();
         $cache_file->write($this->get_parsed_content());
         $cache_file->unlock();
         $cache_file->close();
         $cache_file->change_chmod(0666);
     } catch (IOException $ex) {
         throw new TemplateLoadingException('The template file cache couldn\'t been written due to this problem: ' . $ex->getMessage());
     }
 }
Example #2
0
if (!isset($LANGS_CONFIG[$user_lang]['secure']) || !$User->check_level($LANGS_CONFIG[$user_lang]['secure'])) {
    $user_lang = $CONFIG['lang'];
}
$User->set_user_lang(find_require_dir(PATH_TO_ROOT . '/lang/', $user_lang));
$LANG = array();
require_once PATH_TO_ROOT . '/lang/' . get_ulang() . '/main.php';
require_once PATH_TO_ROOT . '/lang/' . get_ulang() . '/errors.php';
$Cache->load('day');
if (gmdate_format('j', time(), TIMEZONE_SITE) != $_record_day && !empty($_record_day)) {
    import('io/filesystem/file');
    $lock_file = new File(PATH_TO_ROOT . '/cache/changeday_lock');
    if (!$lock_file->exists()) {
        $lock_file->write('');
        $lock_file->flush();
    }
    $lock_file->lock(false);
    $yesterday_timestamp = time() - 86400;
    if ((int) $Sql->query("\n\t    SELECT COUNT(*)\n            FROM " . DB_TABLE_STATS . "\n            WHERE stats_year = '" . gmdate_format('Y', $yesterday_timestamp, TIMEZONE_SYSTEM) . "' AND\n                stats_month = '" . gmdate_format('m', $yesterday_timestamp, TIMEZONE_SYSTEM) . "' AND\n                stats_day = '" . gmdate_format('d', $yesterday_timestamp, TIMEZONE_SYSTEM) . "'", __LINE__, __FILE__) == 0) {
        $Cache->generate_file('day');
        require_once PATH_TO_ROOT . '/kernel/changeday.php';
        change_day();
    }
    $lock_file->close();
}
define('MODULE_NAME', get_module_name());
if (isset($MODULES[MODULE_NAME])) {
    if ($MODULES[MODULE_NAME]['activ'] == 0) {
        $Errorh->handler('e_unactivated_module', E_USER_REDIRECT);
    } else {
        if (!$User->check_auth($MODULES[MODULE_NAME]['auth'], ACCESS_MODULE)) {
            $Errorh->handler('e_auth', E_USER_REDIRECT);
 private function generate_cache_file()
 {
     $real_file_content = @file_get_contents($this->real_filepath);
     if ($real_file_content === false) {
         throw new FileTemplateLoadingException($this->filepath, $this->real_filepath);
     }
     $parser = new TemplateSyntaxParser();
     $result = $parser->parse($real_file_content);
     try {
         $cache_file = new File($this->cache_filepath);
         $cache_file->open(File::WRITE);
         $cache_file->lock();
         $cache_file->write($result);
         $cache_file->unlock();
         $cache_file->close();
         $cache_file->change_chmod(0666);
     } catch (IOException $ex) {
         throw new TemplateLoadingException('The template file cache couldn\'t been written due to this problem :' . $ex->getMessage());
     }
 }
 /**
  * Exports optimized content to a file.
  */
 public function export_to_file($location)
 {
     if (!empty($this->files) || !empty($this->scripts)) {
         $file = new File($location);
         $file->delete();
         $file->open(File::WRITE);
         $file->lock();
         $file->write($this->content);
         $file->unlock();
         $file->close();
         $file->change_chmod(0666);
     }
 }
Example #5
0
 function write($module_name, &$cache_string)
 {
     $file_path = PATH_TO_ROOT . '/cache/' . $module_name . '.php';
     import('io/filesystem/file');
     $cache_file = new File($file_path, WRITE);
     $cache_file->delete();
     $cache_file->open();
     $cache_file->lock();
     $cache_file->write("<?php\n" . $cache_string . "\n?>");
     $cache_file->unlock();
     $cache_file->close();
     $cache_file->change_chmod(0666);
     if (!file_exists($file_path) && filesize($file_path) == 0) {
         $Errorh->handler('Cache -> La génération du fichier de cache <strong>' . $file . '</strong> a échoué!', E_USER_ERROR, __LINE__, __FILE__);
     }
 }
Example #6
0
 function _save($file_cache_path)
 {
     import('io/filesystem/file');
     $file = new File($file_cache_path);
     $file->open(WRITE);
     $file->lock();
     $file->write($this->template);
     $file->unlock();
     $file->close();
     $file->change_chmod(0666);
 }