summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/controllers/AuthPage.class.php4
-rw-r--r--src/controllers/Config.class.php2
-rw-r--r--src/controllers/Messages.class.php3
-rw-r--r--src/controllers/Plugins.class.php9
-rw-r--r--src/controllers/Users.class.php33
-rw-r--r--src/lib/Controller.class.php7
-rw-r--r--src/lib/DB.class.php16
-rw-r--r--src/lib/Database.class.php20
-rw-r--r--src/lib/Hasher.class.php18
-rw-r--r--src/lib/Login.class.php9
-rw-r--r--src/lib/MessageManager.class.php85
-rw-r--r--src/lib/Model.class.php9
-rw-r--r--src/lib/PluginManager.class.php10
-rw-r--r--src/lib/Singleton.class.php12
-rw-r--r--src/lib/Site.class.php32
-rw-r--r--src/lib/View.class.php5
-rw-r--r--src/models/Auth.class.php42
-rw-r--r--src/models/ContactMethod.class.php3
-rw-r--r--src/views/Template.class.php27
-rw-r--r--src/views/pages/no-conf.html.php8
-rw-r--r--src/views/pages/plugins/index.html.php5
-rw-r--r--src/views/pages/users/500.html.php5
22 files changed, 184 insertions, 180 deletions
diff --git a/src/controllers/AuthPage.class.php b/src/controllers/AuthPage.class.php
index b31d938..1f46f72 100644
--- a/src/controllers/AuthPage.class.php
+++ b/src/controllers/AuthPage.class.php
@@ -1,5 +1,6 @@
<?php
require_once('Login.class.php');
+require_once('Auth.class.php');
Router::register('auth', 'AuthPage');
@@ -41,12 +42,11 @@ class AuthPage extends Controller {
$this->showView('auth/logout');
}
private function maybe_login() {
- global $mm;
$uid = Login::isLoggedIn();
if ($uid===false) {
$this->login();
} else {
- $username = $mm->database()->getUsername($uid);
+ $username = Auth::getInstance($uid)->getName();
$this->showView('auth/index',
array('username'=>$username));
}
diff --git a/src/controllers/Config.class.php b/src/controllers/Config.class.php
index 37d1f09..dc6a884 100644
--- a/src/controllers/Config.class.php
+++ b/src/controllers/Config.class.php
@@ -6,7 +6,7 @@ Router::register('config', 'Config', 'index');
class Config extends Controller {
public function index($routed, $remainder) {
$uid = Login::isLoggedIn();
- if ($uid===false || !Auth::getObj($uid)->isAdmin()) {
+ if ($uid===false || !Auth::getInstance($uid)->isAdmin()) {
$this->http401($routed, $remainder);
return;
}
diff --git a/src/controllers/Messages.class.php b/src/controllers/Messages.class.php
index d28d968..717e18e 100644
--- a/src/controllers/Messages.class.php
+++ b/src/controllers/Messages.class.php
@@ -1,5 +1,6 @@
<?php
require_once('Login.class.php');
+require_once('Auth.class.php');
Router::register('messages', 'Messages', 'index');
Router::register('messages/index', 'Messages', 'index');
@@ -41,7 +42,7 @@ class Messages extends Controller {
public function message($routed, $remainder) {
$uid = Login::isLoggedIn();
- if ($uid===false || !Auth::getObj($uid)->isUser()) {
+ if ($uid===false || !Auth::getInstance($uid)->isUser()) {
$this->http401($routed, $remainder);
return;
}
diff --git a/src/controllers/Plugins.class.php b/src/controllers/Plugins.class.php
index e2b500c..2ed6e7a 100644
--- a/src/controllers/Plugins.class.php
+++ b/src/controllers/Plugins.class.php
@@ -2,13 +2,15 @@
require_once('Login.class.php');
require_once('Plugin.class.php');
require_once('PluginManager.class.php');
+require_once('Auth.class.php');
+require_once('Database.class.php');
Router::register('plugins', 'Plugins');
class Plugins extends Controller {
public function index($routed, $remainder) {
$uid = Login::isLoggedIn();
- if ($uid===false || !Auth::getObj($uid)->isAdmin()) {
+ if ($uid===false || !Auth::getInstance($uid)->isAdmin()) {
$this->http401($routed, $remainder);
return;
}
@@ -25,8 +27,7 @@ class Plugins extends Controller {
}
private function update() {
- global $mm;
- $db = $mm->database();
+ $db = Database::getInstance();
if (isset($_POST['plugins'])) {
$string = $db->arrayToValue($_POST['plugins']);
@@ -45,7 +46,7 @@ class Plugins extends Controller {
}
private function show_index() {
- global $mm; $pm = $mm->pluginManager();
+ $pm = PluginManager::getInstance();
$all_plugins = $pm->listPlugins();
$enabled_plugins = $pm->getActivePlugins();
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php
index a1ad2fe..b75848f 100644
--- a/src/controllers/Users.class.php
+++ b/src/controllers/Users.class.php
@@ -2,6 +2,8 @@
require_once('Login.class.php');
require_once('Auth.class.php');
require_once('DB.class.php');
+require_once('PluginManager.class.php');
+require_once('Database.class.php');
Router::register('users/new' , 'Users', 'new_user');
Router::register('users/index', 'Users', 'index_file');
@@ -73,9 +75,8 @@ class Users extends Controller {
}
if (!isset($vars['errors'])) $vars['errors'] = array();
- global $mm;
- $pm = $mm->pluginManager();
- $db = $mm->database();
+ $db = Database::getInstance();
+ $pm = PluginManager::getInstance();
$vars['antispam_html'] = $pm->callHook('antispam_html');
$vars['userlist'] = $db->getSysConf('anon_userlist');
@@ -83,9 +84,8 @@ class Users extends Controller {
}
public function individual($routed, $remainder) {
- global $mm; // also used for pluginmanager
- $db = $mm->database();
- $pm = $mm->pluginManager();
+ $db = Database::getInstance();
+ $pm = PluginManager::getInstance();
$usernames = implode('/', $remainder);
$uids = array();
@@ -100,7 +100,7 @@ class Users extends Controller {
$vars = array();
if (count($uids)<2) {
- $user = Auth::getObj($uids[0]);
+ $user = Auth::getInstance($uids[0]);
if ($user->isGroup()) $uid = false; // ignore groups.
@@ -130,7 +130,7 @@ class Users extends Controller {
$vars['users'] = array();
foreach ($uids as $uid) {
- $vars['users'][] = Auth::getObj($uid);
+ $vars['users'][] = Auth::getInstance($uid);
}
$vars['usernames'] = $usernames;
$vars['config_options'] = $config_options;
@@ -158,9 +158,8 @@ class Users extends Controller {
* explained.
*/
private function create_user() {
- global $mm;
- $db = $mm->database();
- $pm = $mm->pluginManager();
+ $db = Database::getInstance();
+ $pm = PluginManager::getInstance();
$vars = array();
@$vars['username' ] = $_POST['auth_name'];
@@ -241,8 +240,8 @@ class Users extends Controller {
// Change information //////////////////////////////////////////
$config_options = array();
- global $mm;
- $mm->pluginManager()->callHook('userConfig', &$config_options);
+ $pm = PluginManager::getInstance();
+ $pm->callHook('userConfig', &$config_options);
foreach ($config_options as $group=>$options) {
foreach ($options as $option) {
@@ -314,9 +313,9 @@ class Users extends Controller {
* This will show the user index.
*/
private function show_index($routed, $remainder) {
- global $mm; $db = $mm->database();
+ $db = Database::getInstance();
- $logged_in_user = Auth::getObj(Login::isLoggedIn());
+ $logged_in_user = Auth::getInstance(Login::isLoggedIn());
$anon_userlist = $db->getSysConf('anon_userlist')=='true';
if (!$anon_userlist && !$logged_in_user->isUser()) {
$this->http401($routed, $remainder);
@@ -342,7 +341,7 @@ class Users extends Controller {
return array('key'=>$key, 'name'=>$name, 'type'=>$type);
}
private function getIndexAttribs() {
- $user = Auth::getObj(Login::isLoggedIn());
+ $user = Auth::getInstance(Login::isLoggedIn());
$attribs = array();
$attribs[] = $this->attrib('auth_uid', 'UID');
@@ -364,7 +363,7 @@ class Users extends Controller {
}
private function registrationOpen() {
- global $mm; $db = $mm->database();
+ $db = Database::getInstance();
$val = $db->getSysConf('registration_open');
switch ($val) {
case 'true': return true;
diff --git a/src/lib/Controller.class.php b/src/lib/Controller.class.php
index f9ed59d..05736ee 100644
--- a/src/lib/Controller.class.php
+++ b/src/lib/Controller.class.php
@@ -1,18 +1,13 @@
<?php
-require_once('View.class.php');
-
class Controller {
/**
* Show a $view, in the most appropriate format (according to file
* extension and HTTP Accept header). Pass the array $vars to the view.
*/
protected function showView($view, $vars=null) {
- global $mm;
-
if ($vars===null) { $vars = array(); }
- $vars['template'] = $mm->template();
-
+
$obj = new View($view);
$obj->show($vars);
}
diff --git a/src/lib/DB.class.php b/src/lib/DB.class.php
index 5954726..ac8dafe 100644
--- a/src/lib/DB.class.php
+++ b/src/lib/DB.class.php
@@ -1,7 +1,7 @@
<?php
-
require_once('Auth.class.php');
require_once('Login.class.php');
+require_once('Database.class.php');
class DB {
public static function set($table, $unit, $key, $value, $orig_value) {
@@ -65,8 +65,8 @@ class DB {
}
private static function user_get($uid, $key) {
- $user = Auth::getObj($uid);
- $logged_in_user = Auth::getObj(Login::isLoggedIn());
+ $user = Auth::getInstance($uid);
+ $logged_in_user = Auth::getInstance(Login::isLoggedIn());
$post_key = $key."[$uid]";
@$value = $_POST[$post_key];
@@ -103,7 +103,7 @@ class DB {
'editable'=>$editable);
}
private static function user_set($uid, $key, $value) {
- $user = Auth::getObj($uid);
+ $user = Auth::getInstance($uid);
switch ($key) {
case 'auth_uid':
@@ -127,8 +127,8 @@ class DB {
}
private static function admin_get($plugin, $key) {
- global $mm; $db = $mm->database();
- $user = Auth::getObj(Login::isLoggedIn());
+ $db = Database::getInstance();
+ $user = Auth::getInstance(Login::isLoggedIn());
if ($user->isAdmin()) {
$editable = true;
switch ($plugin) {
@@ -149,8 +149,8 @@ class DB {
'editable'=>$editable);
}
private static function admin_set($plugin, $key, $value) {
- global $mm; $db = $mm->database();
- $user = Auth::getObj(Login::isLoggedIn());
+ $db = Database::getInstance();
+ $user = Auth::getInstance(Login::isLoggedIn());
if (!$user->isAdmin()) {
return false;
}
diff --git a/src/lib/Database.class.php b/src/lib/Database.class.php
index 13d9559..a76d891 100644
--- a/src/lib/Database.class.php
+++ b/src/lib/Database.class.php
@@ -1,12 +1,19 @@
<?php
+require_once('Singleton.class.php');
+require_once('Hasher.class.php');
-class Database {
+class Database extends Singleton {
+ private static $me = null;
private $conf;
private $mysql;
private $db_prefix;
public function __construct($conf_file) {
$this->conf = $conf_file;
+ self::$me = $this;
+ }
+ public static function getInstance() {
+ return self::$me;
}
// Low-Level SQL functions /////////////////////////////////////////////
@@ -114,9 +121,8 @@ class Database {
if (!is_int($uid)) return false;
$table = $this->mysql_table('auth');
- global $mm;
- $hasher = $mm->hasher();
- @$hash = $hasher->HashPassword($password);
+ $hasher = Hasher::getInstance();
+ @$hash = $hasher->hash($password);
$query =
"UPDATE $table \n".
"SET hash='$hash' \n".
@@ -130,12 +136,10 @@ class Database {
return false;
}
- global $mm;
-
$table = $this->mysql_table('auth');
$user = $this->mysql_escape($username);
- $hasher = $mm->hasher();
- @$hash = $hasher->HashPassword($password);
+ $hasher = Hasher::getInstance();
+ @$hash = $hasher->hash($password);
$status = 0;
$query =
"INSERT INTO $table ( name, hash , status) \n".
diff --git a/src/lib/Hasher.class.php b/src/lib/Hasher.class.php
new file mode 100644
index 0000000..dc16d68
--- /dev/null
+++ b/src/lib/Hasher.class.php
@@ -0,0 +1,18 @@
+<?php
+require_once('Singleton.class.php');
+require_once('PasswordHash.class.php');
+
+class Hasher extends Singleton {
+ private $pw_hash;
+
+ function __construct() {
+ $this->pw_hash = new PasswordHash(8, false);
+ }
+
+ public function hash($password) {
+ return $this->pw_hash->HashPassword($password);
+ }
+ public function check($password, $hash) {
+ return $this->pw_hash->CheckPassword($password, $hash);
+ }
+}
diff --git a/src/lib/Login.class.php b/src/lib/Login.class.php
index 870774a..bb21928 100644
--- a/src/lib/Login.class.php
+++ b/src/lib/Login.class.php
@@ -1,4 +1,6 @@
<?php
+require_once('Database.class.php');
+require_once('Hasher.class.php');
class Login {
/** Decalare an empty __construct() so that the login function doesn't
@@ -6,9 +8,8 @@ class Login {
public function __construct() {}
public static function login($username, $password) {
- global $mm;
- $db = $mm->database();
- $hasher = $mm->hasher();
+ $db = Database::getInstance();
+ $hasher = Hasher::getInstance();
$uid = $db->getUID($username);
if ($uid!==false && $db->getStatus($uid)>=3)
@@ -18,7 +19,7 @@ class Login {
return 2;
}
$hash = $db->getPasswordHash($uid);
- if ($hasher->CheckPassword($password, $hash)) {
+ if ($hasher->check($password, $hash)) {
// success
$_SESSION['uid'] = $uid;
return 0;
diff --git a/src/lib/MessageManager.class.php b/src/lib/MessageManager.class.php
deleted file mode 100644
index d327eb7..0000000
--- a/src/lib/MessageManager.class.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-class MessageManager {
- private $conf;
- private $base;
-
- private $users = array();
-
- private $database;
- private $pw_hasher;
- private $template;
- private $pluginManager;
-
- public function __construct($conf_file) {
- $this->conf = $conf_file;
- if (!file_exists($this->conf)) {
- $this->base = $_SERVER['REQUEST_URI'];
- $t = $this->template();
- $t->header('Message Manager');
- $t->paragraph(
- 'Awe shiz, dude, conf.php doesn\'t exist, you '.
- 'need to go through the '.
- '<a href="installer">installer</a>.');
- $t->footer();
- exit();
- }
- session_start();
- }
-
- // Load Things
-
- public function database() {
- if (!isset($this->database)) {
- require_once('Database.class.php');
- $this->database = new Database($this->conf);
- }
- return $this->database;
- }
-
- public function hasher() {
- if (!isset($this->pw_hasher)) {
- require_once('PasswordHash.class.php');
- $this->pw_hasher = new PasswordHash(8, false);
- }
- return $this->pw_hasher;
- }
-
- public function template() {
- if (!isset($this->template)) {
- require_once(VIEWPATH.'/Template.class.php');
- $this->template = new Template($this->baseUrl(), $this);
- }
- return $this->template;
- }
-
- public function pluginManager() {
- if (!isset($this->pluginManager)) {
- require_once('PluginManager.class.php');
- $this->pluginManager = new PluginManager();
- }
- return $this->pluginManager;
- }
-
- // Utility functions
-
- public function shortUrl($longUrl) {
- $ch = curl_init('http://ur1.ca');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFILEDS,
- 'longurl='.urlencode($longUrl));
- $html = curl_exec();
- preg_match('/Your ur1 is: <a href="([^"]*)">/',$html,$matches);
- $shortUrl = $matches[1];
- curl_close($ch);
- return $shortUrl;
- }
-
- public function baseUrl() {
- if (!isset($this->base)) {
- $this->base = $this->database()->getSysConf('baseurl');
- }
- return $this->base;
- }
-}
diff --git a/src/lib/Model.class.php b/src/lib/Model.class.php
new file mode 100644
index 0000000..0cce525
--- /dev/null
+++ b/src/lib/Model.class.php
@@ -0,0 +1,9 @@
+<?php
+require_once('Database.class.php');
+
+abstract class Model {
+ protected $db;
+ public function __construct() {
+ $this->db = Database::getInstance();
+ }
+}
diff --git a/src/lib/PluginManager.class.php b/src/lib/PluginManager.class.php
index 2e3dd2b..ce5a3ef 100644
--- a/src/lib/PluginManager.class.php
+++ b/src/lib/PluginManager.class.php
@@ -1,6 +1,8 @@
<?php
+require_once('Singleton.class.php');
+require_once('Database.class.php');
-class PluginManager {
+class PluginManager extends Singleton {
public $plugins = array();
private $loaded = false;
@@ -8,7 +10,7 @@ class PluginManager {
* Return an instance of the plugin with $plugin_name
*/
public function loadPlugin($plugin_name) {
- global $mm; $db = $mm->database();
+ $db = Database::getInstance();
require_once("$plugin_name.class.php");
$obj = new $plugin_name;
@@ -53,7 +55,7 @@ class PluginManager {
* Return an array of enabled plugin names.
*/
public function getActivePlugins() {
- global $mm; $db = $mm->database();
+ $db = Database::getInstance();
$string = $db->getSysConf('plugins');
return $db->valueToArray($string);
}
@@ -62,7 +64,7 @@ class PluginManager {
* Set the enabled plugins.
*/
public function setActivePlugins($plugins) {
- global $mm; $db = $mm->database();
+ $db = Database::getInstance();
$string = $db->arrayToValue($plugins);
return $db->setSysConf('plugins', $string);
}
diff --git a/src/lib/Singleton.class.php b/src/lib/Singleton.class.php
new file mode 100644
index 0000000..2f8c74f
--- /dev/null
+++ b/src/lib/Singleton.class.php
@@ -0,0 +1,12 @@
+<?php
+
+abstract class Singleton {
+ private static $instances = array();
+ public static function getInstance() {
+ $class = get_called_class();
+ if (!isset(self::$instances[$class])) {
+ self::$instances[$class] = new $class;
+ }
+ return self::$instances[$class];
+ }
+}
diff --git a/src/lib/Site.class.php b/src/lib/Site.class.php
new file mode 100644
index 0000000..1204089
--- /dev/null
+++ b/src/lib/Site.class.php
@@ -0,0 +1,32 @@
+<?php
+require_once('Singleton.class.php');
+require_once('Database.class.php');
+
+class Site extends Singleton {
+ public function shortUrl($longUrl) {
+ $ch = curl_init('http://ur1.ca');
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFILEDS,
+ 'longurl='.urlencode($longUrl));
+ $html = curl_exec();
+ preg_match('/Your ur1 is: <a href="([^"]*)">/',$html,$matches);
+ $shortUrl = $matches[1];
+ curl_close($ch);
+ return $shortUrl;
+ }
+
+ public function baseUrl() {
+ $base = $_SERVER['REQUEST_URI'];
+
+ $db = Database::getInstance();
+ if ($db !== null) {
+ $b = $db->getSysConf('baseurl');
+ if ($b != false) {
+ $base = $b;
+ }
+ }
+
+ return $base;
+ }
+}
diff --git a/src/lib/View.class.php b/src/lib/View.class.php
index 33a9c4e..d7a21d3 100644
--- a/src/lib/View.class.php
+++ b/src/lib/View.class.php
@@ -123,7 +123,10 @@ class View {
$mimes = Mime::ext2mime($this->ext);
header('Content-type: '.$mimes[0]);
-
+
+ require_once(VIEWPATH.'/Template.class.php');
+ $vars['template'] = new Template();
+
global $VARS;
$VARS = $vars;
include($file);
diff --git a/src/models/Auth.class.php b/src/models/Auth.class.php
index 9017bd5..39f627e 100644
--- a/src/models/Auth.class.php
+++ b/src/models/Auth.class.php
@@ -1,15 +1,19 @@
<?php
-require_once('MessageManager.class.php');
+require_once('Model.class.php');
require_once('Login.class.php');
+require_once('Database.class.php');
+
require_once('Group.class.php');
require_once('User.class.php');
-class Auth {
- static $users = array();
- public static function getObj($uid) {
+class Auth extends Model {
+ /**********************************************************************\
+ * Multiton stuff *
+ \**********************************************************************/
+ private static $users = array();
+ public static function getInstance($uid) {
if (!isset(self::$users[$uid])) {
- global $mm;
- $type = $mm->database()->getStatus($uid)<3;
+ $type = Database::getInstance()->getStatus($uid);
switch ($type) {
case 0: // unactivated user
case 1: // user
@@ -21,7 +25,10 @@ class Auth {
}
return self::$users[$uid];
}
-
+
+ /**********************************************************************\
+ * Static stuff *
+ \**********************************************************************/
public static function isNameLegal($name) {
// Current rules:
// * Not in "$illegal_names"
@@ -34,12 +41,13 @@ class Auth {
&& (strpos($name,'!')===false)
&& (strlen($name)<256);
}
-
- protected $db = null;
+
+ /**********************************************************************\
+ * Class stuff *
+ \**********************************************************************/
protected $uid = false;
public function __construct($uid) {
- global $mm;
- $this->db = $mm->database();
+ parent::__construct();
$this->uid = $uid;
}
public function getUID() {
@@ -60,7 +68,7 @@ class Auth {
}
protected function setType($type) {
$logged_in_uid = Login::isLoggedIn();
- $logged_in_obj = Auth::getObj($logged_in_uid);
+ $logged_in_obj = Auth::getInstance($logged_in_uid);
$is_admin = $logged_in_obj->isAdmin();
if (!$is_admin) return false;
return $this->db->setStatus($this->uid, $type);
@@ -97,7 +105,7 @@ class Auth {
$logged_in_uid = Login::isLoggedIn();
$is_me = ($logged_in_uid === $this->uid);
- $logged_in_obj = Auth::getObj($logged_in_uid);
+ $logged_in_obj = Auth::getInstance($logged_in_uid);
$is_user = $logged_in_obj->isUser();
return ($is_me || $is_user);
@@ -106,7 +114,7 @@ class Auth {
$logged_in_uid = Login::isLoggedIn();
$is_me = ($logged_in_uid === $this->uid);
- $logged_in_obj = Auth::getObj($logged_in_uid);
+ $logged_in_obj = Auth::getInstance($logged_in_uid);
$is_admin = $logged_in_obj->isAdmin();
return ($is_me || $is_admin);
@@ -114,7 +122,11 @@ class Auth {
// [user|group]name ////////////////////////////////////////////////////
public function getName() {
- return $this->db->getUsername($this->uid);
+ if ($this->db===null) {
+ return false;
+ } else {
+ return $this->db->getUsername($this->uid);
+ }
}
public function setName($new_name) {
if (!$this->canEdit()) return false;
diff --git a/src/models/ContactMethod.class.php b/src/models/ContactMethod.class.php
index b01e7d3..1dd40ee 100644
--- a/src/models/ContactMethod.class.php
+++ b/src/models/ContactMethod.class.php
@@ -1,11 +1,10 @@
<?php
-
global $CONTACT_METHODS;
if (!isset($CONTACT_METHODS)) {
$CONTACT_METHODS = array();
}
-class ContactMethod {
+class ContactMethod extends Model {
public $verb_slug = ''; // sms
public $addr_slug = ''; // phone
public $verb_text = ''; // text message
diff --git a/src/views/Template.class.php b/src/views/Template.class.php
index bf57e93..9d55b75 100644
--- a/src/views/Template.class.php
+++ b/src/views/Template.class.php
@@ -1,24 +1,19 @@
<?php
+require_once('Singleton.class.php');
+require_once('Site.class.php');
-require_once('Login.class.php');
+require_once('Login.class.php');// used to see if logged in
+require_once('Auth.class.php');// used to get username if we are
-class Template {
+class Template extends Singleton {
private $indent = 0;
private $ret = false;
- private $base = '/';
- private $db = null;
-
+
public function status($status) {
header($_SERVER["SERVER_PROTOCOL"]." $status");
header("Status: $status");
}
- public function __construct($base_url, $mm=null) {
- $this->base = $base_url;
- if ($mm!==null)
- $this->db = $mm->database();
- }
-
public function setRet($ret) {
$this->ret = $ret;
}
@@ -92,7 +87,7 @@ class Template {
echo $str;
}
public function url($page) {
- return $this->base.$page;
+ return Site::getInstance()->baseUrl().$page;
}
public function row($cells) {
@@ -112,12 +107,8 @@ class Template {
echo $str;
}
public function header($title) {
- $db = $this->db;
- if ($db==null) {
- $username = false;
- } else {
- $username = $db->getUsername(Login::isLoggedIn());
- }
+ // username=false if not logged in or not connected to DB
+ $username = Auth::getInstance(Login::isLoggedIn())->getName();
$ret = $this->ret;
$this->ret = true;
diff --git a/src/views/pages/no-conf.html.php b/src/views/pages/no-conf.html.php
new file mode 100644
index 0000000..1f4e3d3
--- /dev/null
+++ b/src/views/pages/no-conf.html.php
@@ -0,0 +1,8 @@
+<?php global $VARS;
+$t = $VARS['template'];
+
+$t->header('Message Manager');
+$t->paragraph('Awe shiz, dude, conf.php doesn\'t exist, you '.
+ 'need to go through the '.
+ '<a href="installer">installer</a>.');
+$t->footer();
diff --git a/src/views/pages/plugins/index.html.php b/src/views/pages/plugins/index.html.php
index 1f89344..b182288 100644
--- a/src/views/pages/plugins/index.html.php
+++ b/src/views/pages/plugins/index.html.php
@@ -1,7 +1,8 @@
-<?php global $VARS, $mm;
+<?php global $VARS;
+require_once('Database.class.php');
$t = $VARS['template'];
$plugins = $VARS['plugins'];
-$db = $mm->database();
+$db = Database::getInstance();
$t->header('Administrator Plugin Management');
$t->openTag('form',array('method'=>'post','action'=>$t->url('plugins')));
diff --git a/src/views/pages/users/500.html.php b/src/views/pages/users/500.html.php
index f4f1c42..339fe63 100644
--- a/src/views/pages/users/500.html.php
+++ b/src/views/pages/users/500.html.php
@@ -1,6 +1,7 @@
-<?php global $VARS, $mm;
+<?php global $VARS;
+require_once('Database.class.php');
$t = $VARS['template'];
-$db = $mm->database();
+$db = Database::getInstance();
$t->status('500 Internal Server Error');
$t->header('Unknown error');