Revision 30, 1.8 KB
(checked in by exi, 15 years ago)
|
Added base killmail importer, it takes killmails from a specified directory, 1 mail per file.
Changed session interface to php, that reduces siteload by one mysql query and offers room for page variables.
Removed the need to enter a password to post comments if you're logged in as admin.
|
Line | |
---|
1 | <?php |
---|
2 | require_once('db.php'); |
---|
3 | |
---|
4 | class Session |
---|
5 | { |
---|
6 | function Session() |
---|
7 | { |
---|
8 | if ($_REQUEST['PHPSESSID']) |
---|
9 | { |
---|
10 | session_start(); |
---|
11 | } |
---|
12 | // $this->qry_ = new DBQuery(); |
---|
13 | // $this->sql_ = "select * |
---|
14 | // from kb3_sessions ses |
---|
15 | // where ses.ses_id = '" . $cookie . "' |
---|
16 | // and ses.ses_ip = '" . $ip . "'"; |
---|
17 | } |
---|
18 | |
---|
19 | function isAdmin() |
---|
20 | { |
---|
21 | return isset($_SESSION['admin']); |
---|
22 | |
---|
23 | $this->execQuery(); |
---|
24 | return $this->qry_->recordCount() == 1; |
---|
25 | } |
---|
26 | |
---|
27 | function isSuperAdmin() |
---|
28 | { |
---|
29 | return isset($_SESSION['admin_super']); |
---|
30 | |
---|
31 | $this->execQuery(); |
---|
32 | return ($this->qry_->recordCount() == 1 && $this->row_['ses_super'] == 1); |
---|
33 | } |
---|
34 | |
---|
35 | function execQuery() |
---|
36 | { |
---|
37 | return true; |
---|
38 | |
---|
39 | if (!$this->qry_->executed_) |
---|
40 | $this->qry_->execute($this->sql_); |
---|
41 | |
---|
42 | $this->row_ = $this->qry_->getRow(); |
---|
43 | } |
---|
44 | |
---|
45 | function cleanup() |
---|
46 | { |
---|
47 | return true; |
---|
48 | |
---|
49 | $qry = new DBQuery(); |
---|
50 | $qry->execute("delete from kb3_sessions |
---|
51 | where ses_logon < date_sub( now(), INTERVAL '120:0' MINUTE_SECOND )"); |
---|
52 | } |
---|
53 | |
---|
54 | function create($super) |
---|
55 | { |
---|
56 | session_start(); |
---|
57 | $_SESSION['admin'] = 1; |
---|
58 | $_SESSION['admin_super'] = $super; |
---|
59 | // $current = time(); |
---|
60 | // $random = $_SERVER['REMOTE_ADDR'] . $current . KB_SITE; |
---|
61 | // $ses_id = md5($random); |
---|
62 | // |
---|
63 | // if (!setcookie("EVK_COOKIE", $ses_id, 0)) |
---|
64 | // die("Unable to set cookie"); |
---|
65 | // |
---|
66 | // $qry = new DBQuery(); |
---|
67 | // $qry->execute("insert into kb3_sessions values ('" . $ses_id . "', |
---|
68 | // '" . $_SERVER['REMOTE_ADDR'] . "', |
---|
69 | // now(), " . $super . " )"); |
---|
70 | } |
---|
71 | } |
---|
72 | ?> |
---|