瀏覽代碼

Force trailing slash of $config['base_url'] and force existance of $config['timezone']

Daniel Rudolf 9 年之前
父節點
當前提交
ccac8dd4d3
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      lib/Pico.php

+ 7 - 5
lib/Pico.php

@@ -452,7 +452,10 @@ class Pico
 
 
         if (empty($this->config['base_url'])) {
         if (empty($this->config['base_url'])) {
             $this->config['base_url'] = $this->getBaseUrl();
             $this->config['base_url'] = $this->getBaseUrl();
+        } else {
+            $this->config['base_url'] = rtrim($this->config['base_url'], '/') . '/';
         }
         }
+
         if (empty($this->config['content_dir'])) {
         if (empty($this->config['content_dir'])) {
             // try to guess the content directory
             // try to guess the content directory
             if (is_dir($this->getRootDir() . 'content')) {
             if (is_dir($this->getRootDir() . 'content')) {
@@ -463,15 +466,14 @@ class Pico
         } else {
         } else {
             $this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']);
             $this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']);
         }
         }
-        if (!empty($this->config['timezone'])) {
-            date_default_timezone_set($this->config['timezone']);
-        } else {
+
+        if (empty($this->config['timezone'])) {
             // explicitly set a default timezone to prevent a E_NOTICE
             // explicitly set a default timezone to prevent a E_NOTICE
             // when no timezone is set; the `date_default_timezone_get()`
             // when no timezone is set; the `date_default_timezone_get()`
             // function always returns a timezone, at least UTC
             // function always returns a timezone, at least UTC
-            $defaultTimezone = date_default_timezone_get();
-            date_default_timezone_set($defaultTimezone);
+            $this->config['timezone'] = date_default_timezone_get();
         }
         }
+        date_default_timezone_set($this->config['timezone']);
     }
     }
 
 
     /**
     /**