예제 #1
0
 /**
     кэш только для основного домена.
     на алиасах не работает! 
 */
 function init91()
 {
     if (core::in_editor() || loader::in_ajax() || loader::in_shell()) {
         return;
     }
     // @todo cancel on errors!
     if (tf_exception::get_last_exception()) {
         return;
     }
     // check current site
     if (!($tsite = $this->get_current_site()) || !$tsite->is_staticable()) {
         return;
     }
     /* save static cache!
           skip logged in users, debug mode
        */
     if ($this->get_core()->cfg('sat_use_static') && !core::lib('auth')->logged_in() && !core::is_debug()) {
         $file = $this->get_static_node_path($tnode = $this->get_router()->get_current_node());
         $pagination_filter = $this->get_router()->get_filter('pagination');
         if ($pagination_filter && ($page = $pagination_filter->get_start())) {
             $file = str_replace('/index.html', "/page/{$page}/index.html", $file);
         }
         core::dprint(array('generate staic : %s', $file), core::E_DEBUG4);
         if (!file_exists($file)) {
             $dir = dirname($file);
             if (!is_dir($dir)) {
                 mkdir($dir, 0777, true);
             }
             file_put_contents($file, core::lib('renderer')->get_buffer());
         }
     }
 }
예제 #2
0
파일: core.php 프로젝트: egregor-dev/SatCMS
 /**
  * Function called on most end of script execution
  * and flush all output to user,
  * close connections and make cleanups
  *
  * Shutdown
  *
  * calls renderer::output
  */
 public function shutdown()
 {
     if (!$this->_from_cache) {
         // send headers if any
         $this->check_last_modified();
         // shutdown
         $this->init(9);
         // in critical errors we have no valid renderer
         if ($r = self::lib('renderer')) {
             if (loader::in_ajax()) {
                 $r->output_ajax();
             } else {
                 $cacher = $this->lib_enabled('page_cacher') ? $this->lib('page_cacher') : false;
                 // Cache if no exceptions and cacher ready
                 if ($cacher && !tf_exception::get_last_exception() && $cacher->is_enabled()) {
                     ob_start();
                     $r->output();
                     $buffer = ob_get_contents();
                     ob_end_clean();
                     echo $buffer;
                     // Alright? Cache it
                     $_url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                     $cacher->cache_page($_url, $buffer);
                 } else {
                     $r->output();
                 }
             }
         }
     }
     // cache
     // shutdown_after
     $this->init(91);
     if ($this->db) {
         $this->db->close();
     }
     $time = self::time_check('core-boot', true);
     if (self::is_debug()) {
         self::cprint('core shutdown : ' . ($this->_from_cache ? 'CACHE : ' : '') . $time . ' ms, mem : ' . memory_get_usage());
     }
     if (!loader::in_ajax()) {
         echo "\n\n<!--\n\tPowered by : " . self::NAME . "\n\tTime elapsed : " . $time . "\n-->\n";
     }
     $this->halt();
 }