summaryrefslogtreecommitdiffstats
path: root/code/user.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'code/user.inc.php')
-rw-r--r--code/user.inc.php142
1 files changed, 69 insertions, 73 deletions
diff --git a/code/user.inc.php b/code/user.inc.php
index 3cd39bf..5aa76d5 100644
--- a/code/user.inc.php
+++ b/code/user.inc.php
@@ -1,99 +1,95 @@
<?PHP
- if(!defined('USER_INC')) {
- define('USER_INC', 1);
+ require_once('code/db.inc.php');
+
+ class User {
+ var $uid = 0, $gid = 0;
+ var $key = '', $type = '';
- require_once('code/db.inc.php');
-
- class User {
- var $uid = 0, $gid = 0;
- var $key = '', $type = '';
-
- function User() {
- if($_COOKIE['login']) {
- $res = $GLOBALS['db']->Execute('SELECT id, gid, sid FROM users WHERE id = ? AND sid = ?',
- array(substr($_COOKIE['login'], 32),
- substr($_COOKIE['login'], 0, 32)));
-
- if($res->RecordCount() && $res->fields[2]) {
- $this->uid = $res->fields[0];
- $this->gid = $res->fields[1];
-
- $this->type = 'cookie';
- $this->key = $_COOKIE['login'];
- }
- }
-
- if($this->uid == 0 && $_GET['login']) {
- $res = $GLOBALS['db']->Execute('SELECT id, gid, sid FROM users WHERE id = ? AND sid = ?',
- array(substr($_GET['login'], 32),
- substr($_GET['login'], 0, 32)));
+ function User() {
+ if($_COOKIE['login']) {
+ $res = $GLOBALS['db']->Execute('SELECT id, gid, sid FROM users WHERE id = ? AND sid = ?',
+ array(substr($_COOKIE['login'], 32),
+ substr($_COOKIE['login'], 0, 32)));
+
+ if($res->RecordCount() && $res->fields[2]) {
+ $this->uid = $res->fields[0];
+ $this->gid = $res->fields[1];
- if($res->RecordCount() && $res->fields[2]) {
- $this->uid = $res->fields[0];
- $this->gid = $res->fields[1];
-
- $this->type = 'url';
- $this->key = $_GET['login'];
- }
+ $this->type = 'cookie';
+ $this->key = $_COOKIE['login'];
}
}
- function Login($name, $pass) {
- $res = $GLOBALS['db']->Execute('SELECT id, gid FROM users WHERE user = ? AND password = ?', array($name, $pass));
-
- if($res->RecordCount()) {
- $id = $res->fields[0];
- $sid = md5(uniqid($name . " * " . $pass . " * " . rand()));
+ if($this->uid == 0 && $_GET['login']) {
+ $res = $GLOBALS['db']->Execute('SELECT id, gid, sid FROM users WHERE id = ? AND sid = ?',
+ array(substr($_GET['login'], 32),
+ substr($_GET['login'], 0, 32)));
- $GLOBALS['db']->Execute('UPDATE users SET sid = ? WHERE id = ?', array($sid, $id));
-
- $this->uid = $id;
+ if($res->RecordCount() && $res->fields[2]) {
+ $this->uid = $res->fields[0];
$this->gid = $res->fields[1];
$this->type = 'url';
- $this->key = $sid . $id;
-
- setcookie('login', $this->key);
-
- return $id;
+ $this->key = $_GET['login'];
}
-
- return 0;
}
+ }
+
+ function Login($name, $pass) {
+ $res = $GLOBALS['db']->Execute('SELECT id, gid FROM users WHERE user = ? AND password = ?', array($name, $pass));
- function Logout() {
- $GLOBALS['db']->Execute('UPDATE users SET sid = \'\' WHERE id = ?', $this->uid);
+ if($res->RecordCount()) {
+ $id = $res->fields[0];
+ $sid = md5(uniqid($name . " * " . $pass . " * " . rand()));
- $this->uid = 0;
- $this->gid = 0;
+ $GLOBALS['db']->Execute('UPDATE users SET sid = ? WHERE id = ?', array($sid, $id));
- $this->type = '';
- $this->key = '';
+ $this->uid = $id;
+ $this->gid = $res->fields[1];
- setcookie('login');
+ $this->type = 'url';
+ $this->key = $sid . $id;
+
+ setcookie('login', $this->key);
+
+ return $id;
}
- function IsAdmin() {
- return ($this->uid != 0 && $this->gid == 0);
- }
+ return 0;
+ }
+
+ function Logout() {
+ $GLOBALS['db']->Execute('UPDATE users SET sid = \'\' WHERE id = ?', $this->uid);
- function GetUid() {
- return $this->uid;
- }
+ $this->uid = 0;
+ $this->gid = 0;
- function GetGid() {
- return $this->gid;
- }
+ $this->type = '';
+ $this->key = '';
- function GetLoginType() {
- return $this->type;
- }
+ setcookie('login');
+ }
+
+ function IsAdmin() {
+ return ($this->uid != 0 && $this->gid == 0);
+ }
- function GetLoginKey() {
- return $this->key;
- }
+ function GetUid() {
+ return $this->uid;
+ }
+
+ function GetGid() {
+ return $this->gid;
}
- $user = new User;
+ function GetLoginType() {
+ return $this->type;
+ }
+
+ function GetLoginKey() {
+ return $this->key;
+ }
}
+
+ $GLOBALS['user'] = new User;
?>