瀏覽代碼

Minor cleanups

Andy Baugh 7 年之前
父節點
當前提交
a72184b0c9
共有 6 個文件被更改,包括 15 次插入17 次删除
  1. 1 1
      index.php
  2. 1 1
      lib/tCMS/Auth.inc
  3. 3 5
      lib/tCMS/Config.inc
  4. 4 4
      sys/admin/index.php
  5. 3 3
      templates/default/header.tmpl
  6. 3 3
      templates/default/notconfigured.tmpl

+ 1 - 1
index.php

@@ -7,8 +7,8 @@
     require_once "tCMS/Config.inc";
 
     // Get the config, set the theme (also set the basedir so we don't have to fetch it again).
-    $conf_obj->set_base_dir($basedir);
     $conf_obj = new Config;
+    $conf_obj->set_base_dir($basedir);
     $config = $conf_obj->get();
     $theme = ( !array_key_exists( 'theme', $config ) || empty($config['theme']) ? 'default' : $config['theme'] );
     $themedir = "$basedir/templates/$theme";

+ 1 - 1
lib/tCMS/Auth.inc

@@ -65,7 +65,7 @@
             // Check it
             $conf_obj = new Config;
             $conf = $conf_obj->get('users');
-            if( empty($conf) return [ 'err' => 1, "msg" => "Login Failed: Configuration missing or malformed" ];
+            if( empty($conf) ) return [ 'err' => 1, "msg" => "Login Failed: Configuration missing or malformed" ];
             if( empty($conf[$user]) || empty($conf[$user]['auth_hash']) || !password_verify( $pass, $conf[$user]['auth_hash'] ) ) return [ 'err' => 1, 'msg' => "Login Failed" ];
 
             // Gotta have a touch of eval

+ 3 - 5
lib/tCMS/Config.inc

@@ -4,7 +4,7 @@
         private $confdir = null;
         private $basedir = null;
         private $homedir = null;
-        private array $conf = [
+        private $conf = [
             'users' => [],
             'main'  => [],
         ];
@@ -21,8 +21,7 @@
         public function get_base_dir() {
             if( !empty($this->basedir) ) return $this->basedir;
             $homedir = $this->get_home_dir();
-            $tmp_basedir = ( file_exists( "$homedir/.tCMS_basedir") ? file_get_contents("$homedir/.tCMS_basedir") : "$homedir/.tCMS" );
-            $this->basedir = $tmp_basedir;
+            $this->basedir = ( file_exists( "$homedir/.tCMS_basedir") ? file_get_contents("$homedir/.tCMS_basedir") : "$homedir/.tCMS" );
             return $this->basedir;
         }
 
@@ -41,8 +40,7 @@
         public function get_home_dir() {
             if( !empty($this->homedir) ) return $this->homedir;
             $user_info = posix_getpwuid(posix_geteuid());
-            $homedir = ( $user_info['dir'] ? $user_info['dir'] : '/var/www/' );
-            $this->homedir = $tmp_confdir;
+            $this->homedir = ( $user_info['dir'] ? $user_info['dir'] : '/var/www/' );
             return $this->homedir;
         }
     }

+ 4 - 4
sys/admin/index.php

@@ -8,8 +8,8 @@
     require_once "tCMS/Config.inc";
 
     // Get the config, set the theme (also set the basedir so we don't have to fetch it again).
-    $conf_obj->set_base_dir($basedir);
     $conf_obj = new Config;
+    $conf_obj->set_base_dir($basedir);
     $config = $conf_obj->get();
     $theme = ( !array_key_exists( 'theme', $config ) || empty($config['theme']) ? 'default' : $config['theme'] );
     $themedir = "$basedir/templates/$theme";
@@ -47,9 +47,9 @@
   <meta name="viewport" content="width=device-width">
   <?php
     $links  = '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/structure.css" />';
-    $links += '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/screen.css" media="screen" />';
-    $links += '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/print.css" media="print" />';
-    $links += '<link rel="icon" type="image/vnd.microsoft.icon" href="../../themed/' . $theme . '/img/icon/favicon.ico" />';
+    $links .= '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/screen.css" media="screen" />';
+    $links .= '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/print.css" media="print" />';
+    $links .= '<link rel="icon" type="image/vnd.microsoft.icon" href="../../themed/' . $theme . '/img/icon/favicon.ico" />';
     echo $links;
 
     // TODO inject avatars these via style tags based on config

+ 3 - 3
templates/default/header.tmpl

@@ -4,9 +4,9 @@
   <meta name="viewport" content="width=device-width">
   <?php
     $links  = '<link rel="stylesheet" type="text/css" href="themed/' . $theme . '/css/structure.css" />';
-    $links += '<link rel="stylesheet" type="text/css" href="themed/' . $theme . '/css/screen.css" media="screen" />';
-    $links += '<link rel="stylesheet" type="text/css" href="themed/' . $theme . '/css/print.css" media="print" />';
-    $links += '<link rel="icon" type="image/vnd.microsoft.icon" href="themed/' . $theme . '/img/icon/favicon.ico" />';
+    $links .= '<link rel="stylesheet" type="text/css" href="themed/' . $theme . '/css/screen.css" media="screen" />';
+    $links .= '<link rel="stylesheet" type="text/css" href="themed/' . $theme . '/css/print.css" media="print" />';
+    $links .= '<link rel="icon" type="image/vnd.microsoft.icon" href="themed/' . $theme . '/img/icon/favicon.ico" />';
     echo $links;
 
     // TODO inject avatars these via style tags based on config

+ 3 - 3
templates/default/notconfigured.tmpl

@@ -4,7 +4,7 @@
         <meta charset="utf-8" />
         <meta name="description" content="tCMS"/>
         <meta name="viewport" content="width=device-width">
-        <link rel="icon" type="image/vnd.microsoft.icon" href="img/icon/favicon.ico" />
+        <link rel="icon" type="image/vnd.microsoft.icon" href="<?php echo "themed/$theme"; ?>/img/icon/favicon.ico" />
         <title>
             tCMS Requires Setup to Continue...
         </title>
@@ -55,9 +55,9 @@
         </nav>
         <section>
             <div id="notice">
-                <img alt="Icon indicating a missing file" src="img/mime/missing.gif" />
+                <img alt="Icon indicating a missing file" src="<?php echo "themed/$theme"; ?>/img/mime/missing.gif" />
                 <span>
-                    [INFO] This page is being displayed because sys/admin/config/main.json is missing
+                    [INFO] This page is being displayed because the main configuration file is missing
                     (or corrupted).
                 </span>
             </div>