summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-10-27 19:44:10 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-10-27 19:44:10 -0400
commit29a3ffb99435827d5a7ea6886ac22bd2ee18d593 (patch)
tree511928e110e52d210c9707ab22e952b01b3368b1
parent40bef9550687ed2b5a0c55feafc0b0dd015177e2 (diff)
I think this fixes everything, but it now depends on PHP 5.3+
The introduction of the dependency on PHP 5.3 is that lib/Singleton.class uses `get_called_class()'
-rw-r--r--index.php2
-rw-r--r--src/lib/Database.class.php4
-rw-r--r--src/lib/Login.class.php2
-rw-r--r--src/lib/Model.class.php2
-rw-r--r--src/lib/Singleton.class.php10
-rw-r--r--src/models/Auth.class.php2
6 files changed, 12 insertions, 10 deletions
diff --git a/index.php b/index.php
index 231b4d6..6c17d47 100644
--- a/index.php
+++ b/index.php
@@ -52,7 +52,9 @@ require_once('View.class.php');
require_once('Controller.class.php');
// Check if we have a database configuration ///////////////////////////////////
+$conf_file = BASEPATH.'/conf.php';
if (file_exists($conf_file)) {
+ require_once('Database.class.php');
new Database($conf_file);
session_start();
} else {
diff --git a/src/lib/Database.class.php b/src/lib/Database.class.php
index 1e98511..a76d891 100644
--- a/src/lib/Database.class.php
+++ b/src/lib/Database.class.php
@@ -122,7 +122,7 @@ class Database extends Singleton {
$table = $this->mysql_table('auth');
$hasher = Hasher::getInstance();
- @$hash = $hasher->hashPassword($password);
+ @$hash = $hasher->hash($password);
$query =
"UPDATE $table \n".
"SET hash='$hash' \n".
@@ -139,7 +139,7 @@ class Database extends Singleton {
$table = $this->mysql_table('auth');
$user = $this->mysql_escape($username);
$hasher = Hasher::getInstance();
- @$hash = $hasher->hashPassword($password);
+ @$hash = $hasher->hash($password);
$status = 0;
$query =
"INSERT INTO $table ( name, hash , status) \n".
diff --git a/src/lib/Login.class.php b/src/lib/Login.class.php
index a470176..bb21928 100644
--- a/src/lib/Login.class.php
+++ b/src/lib/Login.class.php
@@ -19,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/Model.class.php b/src/lib/Model.class.php
index 14f59d4..0cce525 100644
--- a/src/lib/Model.class.php
+++ b/src/lib/Model.class.php
@@ -4,6 +4,6 @@ require_once('Database.class.php');
abstract class Model {
protected $db;
public function __construct() {
- $db = Database::getInstance();
+ $this->db = Database::getInstance();
}
}
diff --git a/src/lib/Singleton.class.php b/src/lib/Singleton.class.php
index 4eb3bb3..2f8c74f 100644
--- a/src/lib/Singleton.class.php
+++ b/src/lib/Singleton.class.php
@@ -1,12 +1,12 @@
<?php
abstract class Singleton {
- private static $obj;
+ private static $instances = array();
public static function getInstance() {
- if (!isset(self::$obj)) {
- $class = get_called_class();
- self::$obj = new $class;
+ $class = get_called_class();
+ if (!isset(self::$instances[$class])) {
+ self::$instances[$class] = new $class;
}
- return self::$obj;
+ return self::$instances[$class];
}
}
diff --git a/src/models/Auth.class.php b/src/models/Auth.class.php
index bb35be5..39f627e 100644
--- a/src/models/Auth.class.php
+++ b/src/models/Auth.class.php
@@ -13,7 +13,7 @@ class Auth extends Model {
private static $users = array();
public static function getInstance($uid) {
if (!isset(self::$users[$uid])) {
- $type = Database::getInstance()->getStatus($uid)<3;
+ $type = Database::getInstance()->getStatus($uid);
switch ($type) {
case 0: // unactivated user
case 1: // user