예제 #1
0
파일: view.php 프로젝트: rperello/Anidcore
 public function load($template, $options = array())
 {
     $options = array_merge(array("master" => "master.php", "path" => null), $options);
     $path = $options["path"];
     $this->template_name = basename($template, '.php');
     if (empty($path)) {
         $path = Ac::path("templates");
     }
     if (!is_dir($path)) {
         Ac::exception("The templates directory does not exist: " . $path);
     }
     // To prevent wrong includes, we do a chdir
     chdir($path);
     if (is_readable($template)) {
         $file = $this->template_file = realpath($template);
     } else {
         $file = $this->template_file = $path . $template;
     }
     if ($options["master"] != NULL) {
         if (is_readable($options["master"])) {
             $file = realpath($options["master"]);
         } else {
             $file = $path . $options["master"];
         }
     }
     set_include_path(get_include_path() . PATH_SEPARATOR . $path . PATH_SEPARATOR);
     $content = static::process($file, $this->vars());
     chdir(AC_PATH);
     return $content;
 }
예제 #2
0
 /**
  *
  * @param array $config
  * @throws RuntimeException 
  */
 protected function configureServer()
 {
     if (!is_dir(AC_PATH_LOGS)) {
         mkdir(AC_PATH_LOGS, 0770);
     }
     if (!is_dir(AC_PATH_DATA)) {
         mkdir(AC_PATH_DATA, 0770);
     }
     if (!is_dir(AC_PATH_CONTENT)) {
         mkdir(AC_PATH_CONTENT, 0775);
     }
     //  Error reporting
     error_reporting($this->config["server.error_reporting"]);
     ini_set("display_errors", $this->config["server.display_errors"] ? true : false);
     //stdout = output, stderr=error log file
     //  PHP environment variables
     if (!ini_get('safe_mode')) {
         set_time_limit($this->config["server.max_execution_time"]);
         ini_set("memory_limit", $this->config["server.memory_limit"]);
         ini_set("max_execution_time", $this->config["server.max_execution_time"]);
         ini_set('upload_max_filesize', $this->config["server.upload_max_file_size"]);
         ini_set('post_max_size', $this->config["server.post_max_size"]);
         ini_set('max_input_time', $this->config["server.max_input_time"]);
         ini_set('default_charset', $this->config["server.default_charset"]);
         ini_set('default_mimetype', $this->config["server.default_mimetype"]);
         setlocale(LC_ALL, $this->config["server.locale"]);
         date_default_timezone_set($this->config["server.timezone"]);
         ini_set("log_errors", true);
         ini_set('error_log', $this->config["server.error_log_file"]);
         $this->config["session.name"] = "phpsessid_" . md5($_SERVER["SCRIPT_FILENAME"] . $this->config["key.GLOBAL_SALT"]);
         ini_set("session.name", $this->config["session.name"]);
         ini_set("session.use_cookies", 1);
         ini_set("session.use_only_cookies", 1);
         ini_set("session.cookie_path", $this->config["session.cookie_path"]);
         ini_set("session.cookie_secure", $this->config["session.cookie_secure"]);
         ini_set("session.cookie_lifetime", $this->config["session.cookie_lifetime"]);
         ini_set('session.gc_maxlifetime', $this->config["session.gc_maxlifetime"]);
         ini_set("session.use_trans_sid", 0);
         # do not use PHPSESSID in urls
         ini_set("session.hash_function", 1);
         # use sha1 algorithm (160 bits)
         session_cache_expire($this->config["session.cache_expire"]);
         session_cache_limiter($this->config["session.cache_limiter"]);
     } else {
         Ac::exception("Anidcore Framework cannot be executed under safe_mode");
     }
     Ac::trigger("AcConfigureServer");
 }