Revision 190, 2.1 KB
(checked in by exi, 15 years ago)
|
This is a big update...
Moved all admin scripts to common/admin.
Moved all includes and classes to common/includes.
Edited all include-paths to reflect the movement.
Fixed a bug with the session system allowing every registered user to access admin pages.
Replaced calls to date() to use a wrapper so gmdate can be used.
Replaced some calls to $config with calls to the static object.
Fixed a big which caused the portrait_grab to not download a new picute.
Added a classified-state to kills.
Removed the sync_server server script in this tree.
Added code to help modules find the includes to index.php.
|
Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | class DBConnection |
---|
4 | { |
---|
5 | function DBConnection() |
---|
6 | { |
---|
7 | if (!$this->id_ = mysql_pconnect(DB_HOST, DB_USER, DB_PASS)) |
---|
8 | die("Unable to connect to mysql database."); |
---|
9 | |
---|
10 | mysql_select_db(DB_NAME); |
---|
11 | } |
---|
12 | |
---|
13 | function id() |
---|
14 | { |
---|
15 | return $this->id_; |
---|
16 | } |
---|
17 | |
---|
18 | function affectedRows() |
---|
19 | { |
---|
20 | return mysql_affected_rows($this->id_); |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | class DBQuery |
---|
25 | { |
---|
26 | function DBQuery() |
---|
27 | { |
---|
28 | $this->executed_ = false; |
---|
29 | $this->dbconn_ = new DBConnection; |
---|
30 | } |
---|
31 | |
---|
32 | function execute($sql) |
---|
33 | { |
---|
34 | $t1 = strtok(microtime(), ' ') + strtok(''); |
---|
35 | |
---|
36 | $this->resid_ = mysql_query($sql, $this->dbconn_->id()); |
---|
37 | |
---|
38 | if ($this->resid_ == false) |
---|
39 | { |
---|
40 | if (defined('DB_HALTONERROR') && DB_HALTONERROR) |
---|
41 | { |
---|
42 | echo "Database error: " . mysql_error($this->dbconn_->id()) . "<br>"; |
---|
43 | echo "SQL: " . $sql . "<br>"; |
---|
44 | exit; |
---|
45 | } |
---|
46 | else |
---|
47 | { |
---|
48 | return false; |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | $this->exectime_ = strtok(microtime(), ' ') + strtok('') - $t1; |
---|
53 | $this->executed_ = true; |
---|
54 | |
---|
55 | if (KB_PROFILE == 2) |
---|
56 | { |
---|
57 | file_put_contents('/tmp/profile.lst', $sql . "\nExecution time: " . $this->exectime_ . "\n", FILE_APPEND); |
---|
58 | } |
---|
59 | |
---|
60 | return true; |
---|
61 | } |
---|
62 | |
---|
63 | function recordCount() |
---|
64 | { |
---|
65 | return mysql_num_rows($this->resid_); |
---|
66 | } |
---|
67 | |
---|
68 | function getRow() |
---|
69 | { |
---|
70 | if ($this->resid_) |
---|
71 | { |
---|
72 | return mysql_fetch_assoc($this->resid_); |
---|
73 | } |
---|
74 | return false; |
---|
75 | } |
---|
76 | |
---|
77 | function rewind() |
---|
78 | { |
---|
79 | @mysql_data_seek($this->resid_, 0); |
---|
80 | } |
---|
81 | |
---|
82 | function getInsertID() |
---|
83 | { |
---|
84 | return mysql_insert_id(); |
---|
85 | } |
---|
86 | |
---|
87 | function execTime() |
---|
88 | { |
---|
89 | return $this->exectime_; |
---|
90 | } |
---|
91 | |
---|
92 | function executed() |
---|
93 | { |
---|
94 | return $this->executed_; |
---|
95 | } |
---|
96 | |
---|
97 | function getErrorMsg() |
---|
98 | { |
---|
99 | $msg = $this->sql_ . "<br>"; |
---|
100 | $msg .= "Query failed. " . mysql_error($this->dbconn_->id()); |
---|
101 | |
---|
102 | return $msg; |
---|
103 | } |
---|
104 | } |
---|
105 | ?> |
---|