aboutsummaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php40
1 files changed, 35 insertions, 5 deletions
diff --git a/index.php b/index.php
index 9d09f48..f9b7177 100644
--- a/index.php
+++ b/index.php
@@ -1,10 +1,12 @@
<?php
+/**
+ * DO NOT MOVE THESE DEFINES
+ */
define('BAYONET_ROOT', basename(dirname('.')));
define('BAYONET_INCLUDE', BAYONET_ROOT . '/include');
-define('BAYONET_CONFIG', 'include/config.ini');
+define('BAYONET_CONFIG', BAYONET_ROOT . '/include/config.ini');
-require_once BAYONET_CONFIG;
require BAYONET_INCLUDE . '/config.php';
require BAYONET_INCLUDE . '/debug.php';
require BAYONET_INCLUDE . '/sql.class.php';
@@ -28,18 +30,33 @@ class Bayonet_Theme
static public $root_path;
static public $include_path;
static public $image_path;
+ static public $config_path;
static public $config;
static public $primary_css;
static function init()
{
- self::$name = Bayonet_Config::$ini['Theme']['name'];
+ if(!isset($_GET['theme']))
+ {
+ self::$name = Bayonet_Config::$ini['Theme']['name'];
+ }
+ else
+ {
+ self::$name = $_GET['theme'];
+ }
+
decho('Initializing theme variables for \'' . self::$name . '\'');
self::$root_path = dirname(BAYONET_ROOT) . '/themes/' . self::$name;
self::$include_path = self::$root_path . '/include';
self::$image_path = self::$root_path . '/images';
- self::$primary_css = self::$include_path . '/' . self::$name . '.css';
- self::$config = parse_ini_file(self::$include_path . '/' . self::$name . '.ini', true);
+ self::$primary_css = self::$include_path . '/primary.css';
+ self::$config_path = self::$include_path . '/theme.ini';
+
+ if(!self::is_valid())
+ {
+ die('Theme failed during initialization.');
+ }
+ self::$config = parse_ini_file(self::$config_path, true);
self::$index = self::$root_path . '/index.php';
self::$header = self::$root_path . '/header.php';
@@ -49,9 +66,22 @@ class Bayonet_Theme
self::load();
}
+ static private function is_valid()
+ {
+ if(
+ file_exists(self::$root_path) &&
+ file_exists(self::$include_path) &&
+ file_exists(self::$config_path)
+ )
+ return true;
+ else
+ return false;
+ }
+
static function load()
{
global $db;
+
decho("Loading theme: '" . self::$name . "'");
require self::$index;
}