checking the engine can trigger a database init...
This commit is contained in:
parent
008cc4253b
commit
bcfcca7cda
1 changed files with 6 additions and 6 deletions
|
@ -43,14 +43,14 @@ class User {
|
||||||
|
|
||||||
public static function by_session(/*string*/ $name, /*string*/ $session) {
|
public static function by_session(/*string*/ $name, /*string*/ $session) {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
if($database->engine->name === "mysql") {
|
|
||||||
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess";
|
|
||||||
}
|
|
||||||
$row = $database->cache->get("user-session-$name-$session");
|
$row = $database->cache->get("user-session-$name-$session");
|
||||||
if(!$row) {
|
if(!$row) {
|
||||||
|
if($database->engine->name === "mysql") {
|
||||||
|
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess";
|
||||||
|
}
|
||||||
$row = $database->get_row($query, array("name"=>$name, "ip"=>get_session_ip($config), "sess"=>$session));
|
$row = $database->get_row($query, array("name"=>$name, "ip"=>get_session_ip($config), "sess"=>$session));
|
||||||
$database->cache->set("user-session-$name-$session", $row, 300);
|
$database->cache->set("user-session-$name-$session", $row, 300);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue