blob: 01fe58b664c3d3e90b2e161df60ef48cb6a88da3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
<?php
/**
* DO NOT MOVE THESE DEFINES
*/
define('BAYONET_ROOT', basename(dirname('.')));
define('BAYONET_INCLUDE', BAYONET_ROOT . '/include');
define('BAYONET_CONFIG', BAYONET_ROOT . '/include/config.ini');
require BAYONET_INCLUDE . '/debug.php';
require BAYONET_INCLUDE . '/sql.class.php';
require BAYONET_INCLUDE . '/functions.php';
class Bayonet_Theme
{
static public $index;
static public $header;
static public $footer;
static public $name;
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()
{
if(!isset($_GET['theme']))
{
self::$name = Bayonet_Config::$ini['site']['theme'];
}
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 . '/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';
self::$footer = self::$root_path . '/footer.php';
//decho(get_class_vars(Bayonet_Theme)); //do not re-enable this
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, $config;
// Globally referenced configuration and database variables
$config = Bayonet_Config::$ini;
$db = new Bayonet_SQL();
$db->Connect(
$config['sql']['hostname'],
$config['sql']['username'],
$config['sql']['password']
);
$db->Select_db($config['sql']['database']);
decho("Loading theme: '" . self::$name . "'");
require self::$index;
}
}
class Bayonet_Config
{
static $ini;
static function init()
{
decho('Parsing configuration data');
if(file_exists(BAYONET_CONFIG))
{
self::$ini = parse_ini_file(BAYONET_CONFIG, true);
decho(self::$ini);
}
else
die(BAYONET_CONFIG . ' not found');
}
}
class Bayonet
{
static function init()
{
decho('Initializing Bayonet');
Bayonet_Config::init();
Bayonet_Theme::init();
}
}
Bayonet::init();
?>
|