@@ -26,7 +26,6 @@ |
||
26 | 26 | the session didn't work properly. |
27 | 27 | |
28 | 28 | This may be resolved with 4.3.3. |
29 | - |
|
30 | 29 | */ |
31 | 30 | class ADODB_Encrypt_Secret { |
32 | 31 | /** |
@@ -299,7 +299,7 @@ |
||
299 | 299 | $arr['expireref'] = $$var; |
300 | 300 | } |
301 | 301 | $rs = $ADODB_SESS_CONN->Replace($ADODB_SESSION_TBL,$arr, |
302 | - 'sesskey',$autoQuote = true); |
|
302 | + 'sesskey',$autoQuote = true); |
|
303 | 303 | |
304 | 304 | if (!$rs) { |
305 | 305 | ADOConnection::outp( ' |
@@ -188,8 +188,8 @@ |
||
188 | 188 | $arr['expireref'] = $$var; |
189 | 189 | } |
190 | 190 | $rs = $ADODB_SESS_CONN->Replace($ADODB_SESSION_TBL, |
191 | - $arr, |
|
192 | - 'sesskey',$autoQuote = true); |
|
191 | + $arr, |
|
192 | + 'sesskey',$autoQuote = true); |
|
193 | 193 | |
194 | 194 | if (!$rs) { |
195 | 195 | ADOConnection::outp( ' |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * @param $errmsg the native error msg from the database |
39 | 39 | * @param $p1 $fn specific parameter - see below |
40 | 40 | * @param $P2 $fn specific parameter - see below |
41 | - */ |
|
41 | + */ |
|
42 | 42 | function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) |
43 | 43 | { |
44 | 44 | global $ADODB_Last_PEAR_Error; |
@@ -281,35 +281,35 @@ |
||
281 | 281 | return round(($hits/($reqs+$hits))*100,2); |
282 | 282 | } |
283 | 283 | |
284 | - // start hack |
|
285 | - var $optimizeTableLow = 'CHECK TABLE %s FAST QUICK'; |
|
286 | - var $optimizeTableHigh = 'OPTIMIZE TABLE %s'; |
|
284 | + // start hack |
|
285 | + var $optimizeTableLow = 'CHECK TABLE %s FAST QUICK'; |
|
286 | + var $optimizeTableHigh = 'OPTIMIZE TABLE %s'; |
|
287 | 287 | |
288 | - /** |
|
289 | - * @see adodb_perf#optimizeTable |
|
290 | - */ |
|
291 | - function optimizeTable( $table, $mode = ADODB_OPT_LOW) |
|
292 | - { |
|
293 | - if ( !is_string( $table)) return false; |
|
288 | + /** |
|
289 | + * @see adodb_perf#optimizeTable |
|
290 | + */ |
|
291 | + function optimizeTable( $table, $mode = ADODB_OPT_LOW) |
|
292 | + { |
|
293 | + if ( !is_string( $table)) return false; |
|
294 | 294 | |
295 | - $conn = $this->conn; |
|
296 | - if ( !$conn) return false; |
|
295 | + $conn = $this->conn; |
|
296 | + if ( !$conn) return false; |
|
297 | 297 | |
298 | - $sql = ''; |
|
299 | - switch( $mode) { |
|
300 | - case ADODB_OPT_LOW : $sql = $this->optimizeTableLow; break; |
|
301 | - case ADODB_OPT_HIGH : $sql = $this->optimizeTableHigh; break; |
|
302 | - default : |
|
303 | - { |
|
304 | - // May dont use __FUNCTION__ constant for BC (__FUNCTION__ Added in PHP 4.3.0) |
|
305 | - ADOConnection::outp( sprintf( "<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, __FUNCTION__, $mode)); |
|
306 | - return false; |
|
307 | - } |
|
308 | - } |
|
309 | - $sql = sprintf( $sql, $table); |
|
298 | + $sql = ''; |
|
299 | + switch( $mode) { |
|
300 | + case ADODB_OPT_LOW : $sql = $this->optimizeTableLow; break; |
|
301 | + case ADODB_OPT_HIGH : $sql = $this->optimizeTableHigh; break; |
|
302 | + default : |
|
303 | + { |
|
304 | + // May dont use __FUNCTION__ constant for BC (__FUNCTION__ Added in PHP 4.3.0) |
|
305 | + ADOConnection::outp( sprintf( "<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, __FUNCTION__, $mode)); |
|
306 | + return false; |
|
307 | + } |
|
308 | + } |
|
309 | + $sql = sprintf( $sql, $table); |
|
310 | 310 | |
311 | - return $conn->Execute( $sql) !== false; |
|
312 | - } |
|
313 | - // end hack |
|
311 | + return $conn->Execute( $sql) !== false; |
|
312 | + } |
|
313 | + // end hack |
|
314 | 314 | } |
315 | 315 | ?> |
316 | 316 | \ No newline at end of file |
@@ -40,365 +40,365 @@ |
||
40 | 40 | class Auth_Container_ADOdb extends Auth_Container |
41 | 41 | { |
42 | 42 | |
43 | - /** |
|
44 | - * Additional options for the storage container |
|
45 | - * @var array |
|
46 | - */ |
|
47 | - var $options = array(); |
|
48 | - |
|
49 | - /** |
|
50 | - * DB object |
|
51 | - * @var object |
|
52 | - */ |
|
53 | - var $db = null; |
|
54 | - var $dsn = ''; |
|
43 | + /** |
|
44 | + * Additional options for the storage container |
|
45 | + * @var array |
|
46 | + */ |
|
47 | + var $options = array(); |
|
48 | + |
|
49 | + /** |
|
50 | + * DB object |
|
51 | + * @var object |
|
52 | + */ |
|
53 | + var $db = null; |
|
54 | + var $dsn = ''; |
|
55 | 55 | |
56 | - /** |
|
57 | - * User that is currently selected from the DB. |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - var $activeUser = ''; |
|
61 | - |
|
62 | - // {{{ Constructor |
|
63 | - |
|
64 | - /** |
|
65 | - * Constructor of the container class |
|
66 | - * |
|
67 | - * Initate connection to the database via PEAR::ADOdb |
|
68 | - * |
|
69 | - * @param string Connection data or DB object |
|
70 | - * @return object Returns an error object if something went wrong |
|
71 | - */ |
|
72 | - function Auth_Container_ADOdb($dsn) |
|
73 | - { |
|
74 | - $this->_setDefaults(); |
|
56 | + /** |
|
57 | + * User that is currently selected from the DB. |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + var $activeUser = ''; |
|
61 | + |
|
62 | + // {{{ Constructor |
|
63 | + |
|
64 | + /** |
|
65 | + * Constructor of the container class |
|
66 | + * |
|
67 | + * Initate connection to the database via PEAR::ADOdb |
|
68 | + * |
|
69 | + * @param string Connection data or DB object |
|
70 | + * @return object Returns an error object if something went wrong |
|
71 | + */ |
|
72 | + function Auth_Container_ADOdb($dsn) |
|
73 | + { |
|
74 | + $this->_setDefaults(); |
|
75 | 75 | |
76 | - if (is_array($dsn)) { |
|
77 | - $this->_parseOptions($dsn); |
|
78 | - |
|
79 | - if (empty($this->options['dsn'])) { |
|
80 | - PEAR::raiseError('No connection parameters specified!'); |
|
81 | - } |
|
82 | - } else { |
|
83 | - // Extract db_type from dsn string. |
|
84 | - $this->options['dsn'] = $dsn; |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - // }}} |
|
89 | - // {{{ _connect() |
|
90 | - |
|
91 | - /** |
|
92 | - * Connect to database by using the given DSN string |
|
93 | - * |
|
94 | - * @access private |
|
95 | - * @param string DSN string |
|
96 | - * @return mixed Object on error, otherwise bool |
|
97 | - */ |
|
98 | - function _connect($dsn) |
|
99 | - { |
|
100 | - if (is_string($dsn) || is_array($dsn)) { |
|
101 | - if(!$this->db) { |
|
102 | - $this->db = &ADONewConnection($dsn); |
|
103 | - if( $err = ADODB_Pear_error() ) { |
|
104 | - return PEAR::raiseError($err); |
|
105 | - } |
|
106 | - } |
|
76 | + if (is_array($dsn)) { |
|
77 | + $this->_parseOptions($dsn); |
|
78 | + |
|
79 | + if (empty($this->options['dsn'])) { |
|
80 | + PEAR::raiseError('No connection parameters specified!'); |
|
81 | + } |
|
82 | + } else { |
|
83 | + // Extract db_type from dsn string. |
|
84 | + $this->options['dsn'] = $dsn; |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + // }}} |
|
89 | + // {{{ _connect() |
|
90 | + |
|
91 | + /** |
|
92 | + * Connect to database by using the given DSN string |
|
93 | + * |
|
94 | + * @access private |
|
95 | + * @param string DSN string |
|
96 | + * @return mixed Object on error, otherwise bool |
|
97 | + */ |
|
98 | + function _connect($dsn) |
|
99 | + { |
|
100 | + if (is_string($dsn) || is_array($dsn)) { |
|
101 | + if(!$this->db) { |
|
102 | + $this->db = &ADONewConnection($dsn); |
|
103 | + if( $err = ADODB_Pear_error() ) { |
|
104 | + return PEAR::raiseError($err); |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - } else { |
|
109 | - return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, |
|
110 | - 41, |
|
111 | - PEAR_ERROR_RETURN, |
|
112 | - null, |
|
113 | - null |
|
114 | - ); |
|
115 | - } |
|
108 | + } else { |
|
109 | + return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, |
|
110 | + 41, |
|
111 | + PEAR_ERROR_RETURN, |
|
112 | + null, |
|
113 | + null |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | |
117 | - if(!$this->db) { |
|
118 | - return PEAR::raiseError(ADODB_Pear_error()); |
|
119 | - } else { |
|
120 | - return true; |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - // }}} |
|
125 | - // {{{ _prepare() |
|
126 | - |
|
127 | - /** |
|
128 | - * Prepare database connection |
|
129 | - * |
|
130 | - * This function checks if we have already opened a connection to |
|
131 | - * the database. If that's not the case, a new connection is opened. |
|
132 | - * |
|
133 | - * @access private |
|
134 | - * @return mixed True or a DB error object. |
|
135 | - */ |
|
136 | - function _prepare() |
|
137 | - { |
|
138 | - if(!$this->db) { |
|
139 | - $res = $this->_connect($this->options['dsn']); |
|
140 | - } |
|
141 | - return true; |
|
142 | - } |
|
143 | - |
|
144 | - // }}} |
|
145 | - // {{{ query() |
|
146 | - |
|
147 | - /** |
|
148 | - * Prepare query to the database |
|
149 | - * |
|
150 | - * This function checks if we have already opened a connection to |
|
151 | - * the database. If that's not the case, a new connection is opened. |
|
152 | - * After that the query is passed to the database. |
|
153 | - * |
|
154 | - * @access public |
|
155 | - * @param string Query string |
|
156 | - * @return mixed a DB_result object or DB_OK on success, a DB |
|
157 | - * or PEAR error on failure |
|
158 | - */ |
|
159 | - function query($query) |
|
160 | - { |
|
161 | - $err = $this->_prepare(); |
|
162 | - if ($err !== true) { |
|
163 | - return $err; |
|
164 | - } |
|
165 | - return $this->db->query($query); |
|
166 | - } |
|
167 | - |
|
168 | - // }}} |
|
169 | - // {{{ _setDefaults() |
|
170 | - |
|
171 | - /** |
|
172 | - * Set some default options |
|
173 | - * |
|
174 | - * @access private |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - function _setDefaults() |
|
178 | - { |
|
179 | - $this->options['db_type'] = 'mysql'; |
|
180 | - $this->options['table'] = 'auth'; |
|
181 | - $this->options['usernamecol'] = 'username'; |
|
182 | - $this->options['passwordcol'] = 'password'; |
|
183 | - $this->options['dsn'] = ''; |
|
184 | - $this->options['db_fields'] = ''; |
|
185 | - $this->options['cryptType'] = 'md5'; |
|
186 | - } |
|
187 | - |
|
188 | - // }}} |
|
189 | - // {{{ _parseOptions() |
|
190 | - |
|
191 | - /** |
|
192 | - * Parse options passed to the container class |
|
193 | - * |
|
194 | - * @access private |
|
195 | - * @param array |
|
196 | - */ |
|
197 | - function _parseOptions($array) |
|
198 | - { |
|
199 | - foreach ($array as $key => $value) { |
|
200 | - if (isset($this->options[$key])) { |
|
201 | - $this->options[$key] = $value; |
|
202 | - } |
|
203 | - } |
|
204 | - |
|
205 | - /* Include additional fields if they exist */ |
|
206 | - if(!empty($this->options['db_fields'])){ |
|
207 | - if(is_array($this->options['db_fields'])){ |
|
208 | - $this->options['db_fields'] = join($this->options['db_fields'], ', '); |
|
209 | - } |
|
210 | - $this->options['db_fields'] = ', '.$this->options['db_fields']; |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - // }}} |
|
215 | - // {{{ fetchData() |
|
216 | - |
|
217 | - /** |
|
218 | - * Get user information from database |
|
219 | - * |
|
220 | - * This function uses the given username to fetch |
|
221 | - * the corresponding login data from the database |
|
222 | - * table. If an account that matches the passed username |
|
223 | - * and password is found, the function returns true. |
|
224 | - * Otherwise it returns false. |
|
225 | - * |
|
226 | - * @param string Username |
|
227 | - * @param string Password |
|
228 | - * @return mixed Error object or boolean |
|
229 | - */ |
|
230 | - function fetchData($username, $password) |
|
231 | - { |
|
232 | - // Prepare for a database query |
|
233 | - $err = $this->_prepare(); |
|
234 | - if ($err !== true) { |
|
235 | - return PEAR::raiseError($err->getMessage(), $err->getCode()); |
|
236 | - } |
|
237 | - |
|
238 | - // Find if db_fields contains a *, i so assume all col are selected |
|
239 | - if(strstr($this->options['db_fields'], '*')){ |
|
240 | - $sql_from = "*"; |
|
241 | - } |
|
242 | - else{ |
|
243 | - $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; |
|
244 | - } |
|
117 | + if(!$this->db) { |
|
118 | + return PEAR::raiseError(ADODB_Pear_error()); |
|
119 | + } else { |
|
120 | + return true; |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + // }}} |
|
125 | + // {{{ _prepare() |
|
126 | + |
|
127 | + /** |
|
128 | + * Prepare database connection |
|
129 | + * |
|
130 | + * This function checks if we have already opened a connection to |
|
131 | + * the database. If that's not the case, a new connection is opened. |
|
132 | + * |
|
133 | + * @access private |
|
134 | + * @return mixed True or a DB error object. |
|
135 | + */ |
|
136 | + function _prepare() |
|
137 | + { |
|
138 | + if(!$this->db) { |
|
139 | + $res = $this->_connect($this->options['dsn']); |
|
140 | + } |
|
141 | + return true; |
|
142 | + } |
|
143 | + |
|
144 | + // }}} |
|
145 | + // {{{ query() |
|
146 | + |
|
147 | + /** |
|
148 | + * Prepare query to the database |
|
149 | + * |
|
150 | + * This function checks if we have already opened a connection to |
|
151 | + * the database. If that's not the case, a new connection is opened. |
|
152 | + * After that the query is passed to the database. |
|
153 | + * |
|
154 | + * @access public |
|
155 | + * @param string Query string |
|
156 | + * @return mixed a DB_result object or DB_OK on success, a DB |
|
157 | + * or PEAR error on failure |
|
158 | + */ |
|
159 | + function query($query) |
|
160 | + { |
|
161 | + $err = $this->_prepare(); |
|
162 | + if ($err !== true) { |
|
163 | + return $err; |
|
164 | + } |
|
165 | + return $this->db->query($query); |
|
166 | + } |
|
167 | + |
|
168 | + // }}} |
|
169 | + // {{{ _setDefaults() |
|
170 | + |
|
171 | + /** |
|
172 | + * Set some default options |
|
173 | + * |
|
174 | + * @access private |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + function _setDefaults() |
|
178 | + { |
|
179 | + $this->options['db_type'] = 'mysql'; |
|
180 | + $this->options['table'] = 'auth'; |
|
181 | + $this->options['usernamecol'] = 'username'; |
|
182 | + $this->options['passwordcol'] = 'password'; |
|
183 | + $this->options['dsn'] = ''; |
|
184 | + $this->options['db_fields'] = ''; |
|
185 | + $this->options['cryptType'] = 'md5'; |
|
186 | + } |
|
187 | + |
|
188 | + // }}} |
|
189 | + // {{{ _parseOptions() |
|
190 | + |
|
191 | + /** |
|
192 | + * Parse options passed to the container class |
|
193 | + * |
|
194 | + * @access private |
|
195 | + * @param array |
|
196 | + */ |
|
197 | + function _parseOptions($array) |
|
198 | + { |
|
199 | + foreach ($array as $key => $value) { |
|
200 | + if (isset($this->options[$key])) { |
|
201 | + $this->options[$key] = $value; |
|
202 | + } |
|
203 | + } |
|
204 | + |
|
205 | + /* Include additional fields if they exist */ |
|
206 | + if(!empty($this->options['db_fields'])){ |
|
207 | + if(is_array($this->options['db_fields'])){ |
|
208 | + $this->options['db_fields'] = join($this->options['db_fields'], ', '); |
|
209 | + } |
|
210 | + $this->options['db_fields'] = ', '.$this->options['db_fields']; |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + // }}} |
|
215 | + // {{{ fetchData() |
|
216 | + |
|
217 | + /** |
|
218 | + * Get user information from database |
|
219 | + * |
|
220 | + * This function uses the given username to fetch |
|
221 | + * the corresponding login data from the database |
|
222 | + * table. If an account that matches the passed username |
|
223 | + * and password is found, the function returns true. |
|
224 | + * Otherwise it returns false. |
|
225 | + * |
|
226 | + * @param string Username |
|
227 | + * @param string Password |
|
228 | + * @return mixed Error object or boolean |
|
229 | + */ |
|
230 | + function fetchData($username, $password) |
|
231 | + { |
|
232 | + // Prepare for a database query |
|
233 | + $err = $this->_prepare(); |
|
234 | + if ($err !== true) { |
|
235 | + return PEAR::raiseError($err->getMessage(), $err->getCode()); |
|
236 | + } |
|
237 | + |
|
238 | + // Find if db_fields contains a *, i so assume all col are selected |
|
239 | + if(strstr($this->options['db_fields'], '*')){ |
|
240 | + $sql_from = "*"; |
|
241 | + } |
|
242 | + else{ |
|
243 | + $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; |
|
244 | + } |
|
245 | 245 | |
246 | - $query = "SELECT ".$sql_from. |
|
247 | - " FROM ".$this->options['table']. |
|
248 | - " WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username); |
|
246 | + $query = "SELECT ".$sql_from. |
|
247 | + " FROM ".$this->options['table']. |
|
248 | + " WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username); |
|
249 | 249 | |
250 | - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; |
|
251 | - $rset = $this->db->Execute( $query ); |
|
252 | - $res = $rset->fetchRow(); |
|
253 | - |
|
254 | - if (DB::isError($res)) { |
|
255 | - return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
256 | - } |
|
257 | - if (!is_array($res)) { |
|
258 | - $this->activeUser = ''; |
|
259 | - return false; |
|
260 | - } |
|
261 | - if ($this->verifyPassword(trim($password, "\r\n"), |
|
262 | - trim($res[$this->options['passwordcol']], "\r\n"), |
|
263 | - $this->options['cryptType'])) { |
|
264 | - // Store additional field values in the session |
|
265 | - foreach ($res as $key => $value) { |
|
266 | - if ($key == $this->options['passwordcol'] || |
|
267 | - $key == $this->options['usernamecol']) { |
|
268 | - continue; |
|
269 | - } |
|
270 | - // Use reference to the auth object if exists |
|
271 | - // This is because the auth session variable can change so a static call to setAuthData does not make sence |
|
272 | - if(is_object($this->_auth_obj)){ |
|
273 | - $this->_auth_obj->setAuthData($key, $value); |
|
274 | - } else { |
|
275 | - Auth::setAuthData($key, $value); |
|
276 | - } |
|
277 | - } |
|
278 | - |
|
279 | - return true; |
|
280 | - } |
|
281 | - |
|
282 | - $this->activeUser = $res[$this->options['usernamecol']]; |
|
283 | - return false; |
|
284 | - } |
|
285 | - |
|
286 | - // }}} |
|
287 | - // {{{ listUsers() |
|
288 | - |
|
289 | - function listUsers() |
|
290 | - { |
|
291 | - $err = $this->_prepare(); |
|
292 | - if ($err !== true) { |
|
293 | - return PEAR::raiseError($err->getMessage(), $err->getCode()); |
|
294 | - } |
|
295 | - |
|
296 | - $retVal = array(); |
|
297 | - |
|
298 | - // Find if db_fileds contains a *, i so assume all col are selected |
|
299 | - if(strstr($this->options['db_fields'], '*')){ |
|
300 | - $sql_from = "*"; |
|
301 | - } |
|
302 | - else{ |
|
303 | - $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; |
|
304 | - } |
|
305 | - |
|
306 | - $query = sprintf("SELECT %s FROM %s", |
|
307 | - $sql_from, |
|
308 | - $this->options['table'] |
|
309 | - ); |
|
310 | - $res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC); |
|
311 | - |
|
312 | - if (DB::isError($res)) { |
|
313 | - return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
314 | - } else { |
|
315 | - foreach ($res as $user) { |
|
316 | - $user['username'] = $user[$this->options['usernamecol']]; |
|
317 | - $retVal[] = $user; |
|
318 | - } |
|
319 | - } |
|
320 | - return $retVal; |
|
321 | - } |
|
322 | - |
|
323 | - // }}} |
|
324 | - // {{{ addUser() |
|
325 | - |
|
326 | - /** |
|
327 | - * Add user to the storage container |
|
328 | - * |
|
329 | - * @access public |
|
330 | - * @param string Username |
|
331 | - * @param string Password |
|
332 | - * @param mixed Additional information that are stored in the DB |
|
333 | - * |
|
334 | - * @return mixed True on success, otherwise error object |
|
335 | - */ |
|
336 | - function addUser($username, $password, $additional = "") |
|
337 | - { |
|
338 | - if (function_exists($this->options['cryptType'])) { |
|
339 | - $cryptFunction = $this->options['cryptType']; |
|
340 | - } else { |
|
341 | - $cryptFunction = 'md5'; |
|
342 | - } |
|
343 | - |
|
344 | - $additional_key = ''; |
|
345 | - $additional_value = ''; |
|
346 | - |
|
347 | - if (is_array($additional)) { |
|
348 | - foreach ($additional as $key => $value) { |
|
349 | - $additional_key .= ', ' . $key; |
|
350 | - $additional_value .= ", '" . $value . "'"; |
|
351 | - } |
|
352 | - } |
|
353 | - |
|
354 | - $query = sprintf("INSERT INTO %s (%s, %s%s) VALUES ('%s', '%s'%s)", |
|
355 | - $this->options['table'], |
|
356 | - $this->options['usernamecol'], |
|
357 | - $this->options['passwordcol'], |
|
358 | - $additional_key, |
|
359 | - $username, |
|
360 | - $cryptFunction($password), |
|
361 | - $additional_value |
|
362 | - ); |
|
363 | - |
|
364 | - $res = $this->query($query); |
|
365 | - |
|
366 | - if (DB::isError($res)) { |
|
367 | - return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
368 | - } else { |
|
369 | - return true; |
|
370 | - } |
|
371 | - } |
|
372 | - |
|
373 | - // }}} |
|
374 | - // {{{ removeUser() |
|
375 | - |
|
376 | - /** |
|
377 | - * Remove user from the storage container |
|
378 | - * |
|
379 | - * @access public |
|
380 | - * @param string Username |
|
381 | - * |
|
382 | - * @return mixed True on success, otherwise error object |
|
383 | - */ |
|
384 | - function removeUser($username) |
|
385 | - { |
|
386 | - $query = sprintf("DELETE FROM %s WHERE %s = '%s'", |
|
387 | - $this->options['table'], |
|
388 | - $this->options['usernamecol'], |
|
389 | - $username |
|
390 | - ); |
|
391 | - |
|
392 | - $res = $this->query($query); |
|
393 | - |
|
394 | - if (DB::isError($res)) { |
|
395 | - return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
396 | - } else { |
|
397 | - return true; |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - // }}} |
|
250 | + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; |
|
251 | + $rset = $this->db->Execute( $query ); |
|
252 | + $res = $rset->fetchRow(); |
|
253 | + |
|
254 | + if (DB::isError($res)) { |
|
255 | + return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
256 | + } |
|
257 | + if (!is_array($res)) { |
|
258 | + $this->activeUser = ''; |
|
259 | + return false; |
|
260 | + } |
|
261 | + if ($this->verifyPassword(trim($password, "\r\n"), |
|
262 | + trim($res[$this->options['passwordcol']], "\r\n"), |
|
263 | + $this->options['cryptType'])) { |
|
264 | + // Store additional field values in the session |
|
265 | + foreach ($res as $key => $value) { |
|
266 | + if ($key == $this->options['passwordcol'] || |
|
267 | + $key == $this->options['usernamecol']) { |
|
268 | + continue; |
|
269 | + } |
|
270 | + // Use reference to the auth object if exists |
|
271 | + // This is because the auth session variable can change so a static call to setAuthData does not make sence |
|
272 | + if(is_object($this->_auth_obj)){ |
|
273 | + $this->_auth_obj->setAuthData($key, $value); |
|
274 | + } else { |
|
275 | + Auth::setAuthData($key, $value); |
|
276 | + } |
|
277 | + } |
|
278 | + |
|
279 | + return true; |
|
280 | + } |
|
281 | + |
|
282 | + $this->activeUser = $res[$this->options['usernamecol']]; |
|
283 | + return false; |
|
284 | + } |
|
285 | + |
|
286 | + // }}} |
|
287 | + // {{{ listUsers() |
|
288 | + |
|
289 | + function listUsers() |
|
290 | + { |
|
291 | + $err = $this->_prepare(); |
|
292 | + if ($err !== true) { |
|
293 | + return PEAR::raiseError($err->getMessage(), $err->getCode()); |
|
294 | + } |
|
295 | + |
|
296 | + $retVal = array(); |
|
297 | + |
|
298 | + // Find if db_fileds contains a *, i so assume all col are selected |
|
299 | + if(strstr($this->options['db_fields'], '*')){ |
|
300 | + $sql_from = "*"; |
|
301 | + } |
|
302 | + else{ |
|
303 | + $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; |
|
304 | + } |
|
305 | + |
|
306 | + $query = sprintf("SELECT %s FROM %s", |
|
307 | + $sql_from, |
|
308 | + $this->options['table'] |
|
309 | + ); |
|
310 | + $res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC); |
|
311 | + |
|
312 | + if (DB::isError($res)) { |
|
313 | + return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
314 | + } else { |
|
315 | + foreach ($res as $user) { |
|
316 | + $user['username'] = $user[$this->options['usernamecol']]; |
|
317 | + $retVal[] = $user; |
|
318 | + } |
|
319 | + } |
|
320 | + return $retVal; |
|
321 | + } |
|
322 | + |
|
323 | + // }}} |
|
324 | + // {{{ addUser() |
|
325 | + |
|
326 | + /** |
|
327 | + * Add user to the storage container |
|
328 | + * |
|
329 | + * @access public |
|
330 | + * @param string Username |
|
331 | + * @param string Password |
|
332 | + * @param mixed Additional information that are stored in the DB |
|
333 | + * |
|
334 | + * @return mixed True on success, otherwise error object |
|
335 | + */ |
|
336 | + function addUser($username, $password, $additional = "") |
|
337 | + { |
|
338 | + if (function_exists($this->options['cryptType'])) { |
|
339 | + $cryptFunction = $this->options['cryptType']; |
|
340 | + } else { |
|
341 | + $cryptFunction = 'md5'; |
|
342 | + } |
|
343 | + |
|
344 | + $additional_key = ''; |
|
345 | + $additional_value = ''; |
|
346 | + |
|
347 | + if (is_array($additional)) { |
|
348 | + foreach ($additional as $key => $value) { |
|
349 | + $additional_key .= ', ' . $key; |
|
350 | + $additional_value .= ", '" . $value . "'"; |
|
351 | + } |
|
352 | + } |
|
353 | + |
|
354 | + $query = sprintf("INSERT INTO %s (%s, %s%s) VALUES ('%s', '%s'%s)", |
|
355 | + $this->options['table'], |
|
356 | + $this->options['usernamecol'], |
|
357 | + $this->options['passwordcol'], |
|
358 | + $additional_key, |
|
359 | + $username, |
|
360 | + $cryptFunction($password), |
|
361 | + $additional_value |
|
362 | + ); |
|
363 | + |
|
364 | + $res = $this->query($query); |
|
365 | + |
|
366 | + if (DB::isError($res)) { |
|
367 | + return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
368 | + } else { |
|
369 | + return true; |
|
370 | + } |
|
371 | + } |
|
372 | + |
|
373 | + // }}} |
|
374 | + // {{{ removeUser() |
|
375 | + |
|
376 | + /** |
|
377 | + * Remove user from the storage container |
|
378 | + * |
|
379 | + * @access public |
|
380 | + * @param string Username |
|
381 | + * |
|
382 | + * @return mixed True on success, otherwise error object |
|
383 | + */ |
|
384 | + function removeUser($username) |
|
385 | + { |
|
386 | + $query = sprintf("DELETE FROM %s WHERE %s = '%s'", |
|
387 | + $this->options['table'], |
|
388 | + $this->options['usernamecol'], |
|
389 | + $username |
|
390 | + ); |
|
391 | + |
|
392 | + $res = $this->query($query); |
|
393 | + |
|
394 | + if (DB::isError($res)) { |
|
395 | + return PEAR::raiseError($res->getMessage(), $res->getCode()); |
|
396 | + } else { |
|
397 | + return true; |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + // }}} |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | function showDbg( $string ) { |
@@ -1,157 +1,157 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * Helper functions to convert between ADODB recordset objects and XMLRPC values. |
|
4 | - * Uses John Lim's AdoDB and Edd Dumbill's phpxmlrpc libs |
|
5 | - * |
|
6 | - * @author Daniele Baroncelli |
|
7 | - * @author Gaetano Giunta |
|
8 | - * @copyright (c) 2003 Giunta/Baroncelli. All rights reserved. |
|
9 | - * |
|
10 | - * @todo some more error checking here and there |
|
11 | - * @todo document the xmlrpc-struct used to encode recordset info |
|
12 | - */ |
|
13 | - |
|
14 | - /** |
|
15 | - * Include the main libraries |
|
16 | - */ |
|
17 | - require_once('xmlrpc.inc'); |
|
18 | - require_once('adodb.inc.php'); |
|
2 | + /** |
|
3 | + * Helper functions to convert between ADODB recordset objects and XMLRPC values. |
|
4 | + * Uses John Lim's AdoDB and Edd Dumbill's phpxmlrpc libs |
|
5 | + * |
|
6 | + * @author Daniele Baroncelli |
|
7 | + * @author Gaetano Giunta |
|
8 | + * @copyright (c) 2003 Giunta/Baroncelli. All rights reserved. |
|
9 | + * |
|
10 | + * @todo some more error checking here and there |
|
11 | + * @todo document the xmlrpc-struct used to encode recordset info |
|
12 | + */ |
|
13 | + |
|
14 | + /** |
|
15 | + * Include the main libraries |
|
16 | + */ |
|
17 | + require_once('xmlrpc.inc'); |
|
18 | + require_once('adodb.inc.php'); |
|
19 | 19 | |
20 | - /** |
|
21 | - * Builds an xmlrpc struct value out of an AdoDB recordset |
|
22 | - */ |
|
23 | - function rs2xmlrpcval(&$adodbrs) { |
|
24 | - |
|
25 | - $numfields = $adodbrs->FieldCount(); |
|
26 | - $numrecords = $adodbrs->RecordCount(); |
|
27 | - |
|
28 | - // build structure holding recordset information |
|
29 | - $fieldstruct = array(); |
|
30 | - for ($i = 0; $i < $numfields; $i++) { |
|
31 | - $fld = $adodbrs->FetchField($i); |
|
32 | - $fieldarray = array(); |
|
33 | - if (isset($fld->name)) |
|
34 | - $fieldarray["name"] = new xmlrpcval ($fld->name); |
|
35 | - if (isset($fld->type)) |
|
36 | - $fieldarray["type"] = new xmlrpcval ($fld->type); |
|
37 | - if (isset($fld->max_length)) |
|
38 | - $fieldarray["max_length"] = new xmlrpcval ($fld->max_length, "int"); |
|
39 | - if (isset($fld->not_null)) |
|
40 | - $fieldarray["not_null"] = new xmlrpcval ($fld->not_null, "boolean"); |
|
41 | - if (isset($fld->has_default)) |
|
42 | - $fieldarray["has_default"] = new xmlrpcval ($fld->has_default, "boolean"); |
|
43 | - if (isset($fld->default_value)) |
|
44 | - $fieldarray["default_value"] = new xmlrpcval ($fld->default_value); |
|
45 | - $fieldstruct[$i] = new xmlrpcval ($fieldarray, "struct"); |
|
46 | - } |
|
47 | - $fieldcount = new xmlrpcval ($numfields, "int"); |
|
48 | - $recordcount = new xmlrpcval ($numrecords, "int"); |
|
49 | - $sql = new xmlrpcval ($adodbrs->sql); |
|
50 | - $fieldinfo = new xmlrpcval ($fieldstruct, "array"); |
|
51 | - |
|
52 | - $header = new xmlrpcval ( array( |
|
53 | - "fieldcount" => $fieldcount, |
|
54 | - "recordcount" => $recordcount, |
|
55 | - "sql" => $sql, |
|
56 | - "fieldinfo" => $fieldinfo |
|
57 | - ), "struct"); |
|
58 | - |
|
59 | - // build structure containing recordset data |
|
60 | - $rows = array(); |
|
61 | - while (!$adodbrs->EOF) { |
|
62 | - $columns = array(); |
|
63 | - // This should work on all cases of fetch mode: assoc, num, both or default |
|
64 | - if ($adodbrs->fetchMode == 'ADODB_FETCH_BOTH' || count($adodbrs->fields) == 2 * $adodbrs->FieldCount()) |
|
65 | - for ($i = 0; $i < $numfields; $i++) |
|
66 | - if ($columns[$i] === null) |
|
67 | - $columns[$i] = new xmlrpcval (''); |
|
68 | - else |
|
69 | - $columns[$i] = xmlrpc_encode ($adodbrs->fields[$i]); |
|
70 | - else |
|
71 | - foreach ($adodbrs->fields as $val) |
|
72 | - if ($val === null) |
|
73 | - $columns[$i] = new xmlrpcval (''); |
|
74 | - else |
|
75 | - $columns[] = xmlrpc_encode ($val); |
|
76 | - |
|
77 | - $rows[] = new xmlrpcval ($columns, "array"); |
|
78 | - |
|
79 | - $adodbrs->MoveNext(); |
|
80 | - } |
|
81 | - $body = new xmlrpcval ($rows, "array"); |
|
82 | - |
|
83 | - // put it all together and build final xmlrpc struct |
|
84 | - $xmlrpcrs = new xmlrpcval ( array( |
|
85 | - "header" => $header, |
|
86 | - "body" => $body, |
|
87 | - ), "struct"); |
|
88 | - |
|
89 | - return $xmlrpcrs; |
|
90 | - |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Returns an xmlrpc struct value as string out of an AdoDB recordset |
|
95 | - */ |
|
96 | - function rs2xmlrpcstring (&$adodbrs) { |
|
97 | - $xmlrpc = rs2xmlrpcval ($adodbrs); |
|
98 | - if ($xmlrpc) |
|
99 | - return $xmlrpc->serialize(); |
|
100 | - else |
|
101 | - return null; |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Given a well-formed xmlrpc struct object returns an AdoDB object |
|
106 | - * |
|
107 | - * @todo add some error checking on the input value |
|
108 | - */ |
|
109 | - function xmlrpcval2rs (&$xmlrpcval) { |
|
110 | - |
|
111 | - $fields_array = array(); |
|
112 | - $data_array = array(); |
|
20 | + /** |
|
21 | + * Builds an xmlrpc struct value out of an AdoDB recordset |
|
22 | + */ |
|
23 | + function rs2xmlrpcval(&$adodbrs) { |
|
24 | + |
|
25 | + $numfields = $adodbrs->FieldCount(); |
|
26 | + $numrecords = $adodbrs->RecordCount(); |
|
27 | + |
|
28 | + // build structure holding recordset information |
|
29 | + $fieldstruct = array(); |
|
30 | + for ($i = 0; $i < $numfields; $i++) { |
|
31 | + $fld = $adodbrs->FetchField($i); |
|
32 | + $fieldarray = array(); |
|
33 | + if (isset($fld->name)) |
|
34 | + $fieldarray["name"] = new xmlrpcval ($fld->name); |
|
35 | + if (isset($fld->type)) |
|
36 | + $fieldarray["type"] = new xmlrpcval ($fld->type); |
|
37 | + if (isset($fld->max_length)) |
|
38 | + $fieldarray["max_length"] = new xmlrpcval ($fld->max_length, "int"); |
|
39 | + if (isset($fld->not_null)) |
|
40 | + $fieldarray["not_null"] = new xmlrpcval ($fld->not_null, "boolean"); |
|
41 | + if (isset($fld->has_default)) |
|
42 | + $fieldarray["has_default"] = new xmlrpcval ($fld->has_default, "boolean"); |
|
43 | + if (isset($fld->default_value)) |
|
44 | + $fieldarray["default_value"] = new xmlrpcval ($fld->default_value); |
|
45 | + $fieldstruct[$i] = new xmlrpcval ($fieldarray, "struct"); |
|
46 | + } |
|
47 | + $fieldcount = new xmlrpcval ($numfields, "int"); |
|
48 | + $recordcount = new xmlrpcval ($numrecords, "int"); |
|
49 | + $sql = new xmlrpcval ($adodbrs->sql); |
|
50 | + $fieldinfo = new xmlrpcval ($fieldstruct, "array"); |
|
51 | + |
|
52 | + $header = new xmlrpcval ( array( |
|
53 | + "fieldcount" => $fieldcount, |
|
54 | + "recordcount" => $recordcount, |
|
55 | + "sql" => $sql, |
|
56 | + "fieldinfo" => $fieldinfo |
|
57 | + ), "struct"); |
|
58 | + |
|
59 | + // build structure containing recordset data |
|
60 | + $rows = array(); |
|
61 | + while (!$adodbrs->EOF) { |
|
62 | + $columns = array(); |
|
63 | + // This should work on all cases of fetch mode: assoc, num, both or default |
|
64 | + if ($adodbrs->fetchMode == 'ADODB_FETCH_BOTH' || count($adodbrs->fields) == 2 * $adodbrs->FieldCount()) |
|
65 | + for ($i = 0; $i < $numfields; $i++) |
|
66 | + if ($columns[$i] === null) |
|
67 | + $columns[$i] = new xmlrpcval (''); |
|
68 | + else |
|
69 | + $columns[$i] = xmlrpc_encode ($adodbrs->fields[$i]); |
|
70 | + else |
|
71 | + foreach ($adodbrs->fields as $val) |
|
72 | + if ($val === null) |
|
73 | + $columns[$i] = new xmlrpcval (''); |
|
74 | + else |
|
75 | + $columns[] = xmlrpc_encode ($val); |
|
76 | + |
|
77 | + $rows[] = new xmlrpcval ($columns, "array"); |
|
78 | + |
|
79 | + $adodbrs->MoveNext(); |
|
80 | + } |
|
81 | + $body = new xmlrpcval ($rows, "array"); |
|
82 | + |
|
83 | + // put it all together and build final xmlrpc struct |
|
84 | + $xmlrpcrs = new xmlrpcval ( array( |
|
85 | + "header" => $header, |
|
86 | + "body" => $body, |
|
87 | + ), "struct"); |
|
88 | + |
|
89 | + return $xmlrpcrs; |
|
90 | + |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Returns an xmlrpc struct value as string out of an AdoDB recordset |
|
95 | + */ |
|
96 | + function rs2xmlrpcstring (&$adodbrs) { |
|
97 | + $xmlrpc = rs2xmlrpcval ($adodbrs); |
|
98 | + if ($xmlrpc) |
|
99 | + return $xmlrpc->serialize(); |
|
100 | + else |
|
101 | + return null; |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Given a well-formed xmlrpc struct object returns an AdoDB object |
|
106 | + * |
|
107 | + * @todo add some error checking on the input value |
|
108 | + */ |
|
109 | + function xmlrpcval2rs (&$xmlrpcval) { |
|
110 | + |
|
111 | + $fields_array = array(); |
|
112 | + $data_array = array(); |
|
113 | 113 | |
114 | - // rebuild column information |
|
115 | - $header =& $xmlrpcval->structmem('header'); |
|
114 | + // rebuild column information |
|
115 | + $header =& $xmlrpcval->structmem('header'); |
|
116 | 116 | |
117 | - $numfields = $header->structmem('fieldcount'); |
|
118 | - $numfields = $numfields->scalarval(); |
|
119 | - $numrecords = $header->structmem('recordcount'); |
|
120 | - $numrecords = $numrecords->scalarval(); |
|
121 | - $sqlstring = $header->structmem('sql'); |
|
122 | - $sqlstring = $sqlstring->scalarval(); |
|
117 | + $numfields = $header->structmem('fieldcount'); |
|
118 | + $numfields = $numfields->scalarval(); |
|
119 | + $numrecords = $header->structmem('recordcount'); |
|
120 | + $numrecords = $numrecords->scalarval(); |
|
121 | + $sqlstring = $header->structmem('sql'); |
|
122 | + $sqlstring = $sqlstring->scalarval(); |
|
123 | 123 | |
124 | - $fieldinfo =& $header->structmem('fieldinfo'); |
|
125 | - for ($i = 0; $i < $numfields; $i++) { |
|
126 | - $temp =& $fieldinfo->arraymem($i); |
|
127 | - $fld = new ADOFieldObject(); |
|
128 | - while (list($key,$value) = $temp->structeach()) { |
|
129 | - if ($key == "name") $fld->name = $value->scalarval(); |
|
130 | - if ($key == "type") $fld->type = $value->scalarval(); |
|
131 | - if ($key == "max_length") $fld->max_length = $value->scalarval(); |
|
132 | - if ($key == "not_null") $fld->not_null = $value->scalarval(); |
|
133 | - if ($key == "has_default") $fld->has_default = $value->scalarval(); |
|
134 | - if ($key == "default_value") $fld->default_value = $value->scalarval(); |
|
135 | - } // while |
|
136 | - $fields_array[] = $fld; |
|
137 | - } // for |
|
138 | - |
|
139 | - // fetch recordset information into php array |
|
140 | - $body =& $xmlrpcval->structmem('body'); |
|
141 | - for ($i = 0; $i < $numrecords; $i++) { |
|
142 | - $data_array[$i]= array(); |
|
143 | - $xmlrpcrs_row =& $body->arraymem($i); |
|
144 | - for ($j = 0; $j < $numfields; $j++) { |
|
145 | - $temp =& $xmlrpcrs_row->arraymem($j); |
|
146 | - $data_array[$i][$j] = $temp->scalarval(); |
|
147 | - } // for j |
|
148 | - } // for i |
|
149 | - |
|
150 | - // finally build in-memory recordset object and return it |
|
151 | - $rs = new ADORecordSet_array(); |
|
152 | - $rs->InitArrayFields($data_array,$fields_array); |
|
153 | - return $rs; |
|
154 | - |
|
155 | - } |
|
124 | + $fieldinfo =& $header->structmem('fieldinfo'); |
|
125 | + for ($i = 0; $i < $numfields; $i++) { |
|
126 | + $temp =& $fieldinfo->arraymem($i); |
|
127 | + $fld = new ADOFieldObject(); |
|
128 | + while (list($key,$value) = $temp->structeach()) { |
|
129 | + if ($key == "name") $fld->name = $value->scalarval(); |
|
130 | + if ($key == "type") $fld->type = $value->scalarval(); |
|
131 | + if ($key == "max_length") $fld->max_length = $value->scalarval(); |
|
132 | + if ($key == "not_null") $fld->not_null = $value->scalarval(); |
|
133 | + if ($key == "has_default") $fld->has_default = $value->scalarval(); |
|
134 | + if ($key == "default_value") $fld->default_value = $value->scalarval(); |
|
135 | + } // while |
|
136 | + $fields_array[] = $fld; |
|
137 | + } // for |
|
138 | + |
|
139 | + // fetch recordset information into php array |
|
140 | + $body =& $xmlrpcval->structmem('body'); |
|
141 | + for ($i = 0; $i < $numrecords; $i++) { |
|
142 | + $data_array[$i]= array(); |
|
143 | + $xmlrpcrs_row =& $body->arraymem($i); |
|
144 | + for ($j = 0; $j < $numfields; $j++) { |
|
145 | + $temp =& $xmlrpcrs_row->arraymem($j); |
|
146 | + $data_array[$i][$j] = $temp->scalarval(); |
|
147 | + } // for j |
|
148 | + } // for i |
|
149 | + |
|
150 | + // finally build in-memory recordset object and return it |
|
151 | + $rs = new ADORecordSet_array(); |
|
152 | + $rs->InitArrayFields($data_array,$fields_array); |
|
153 | + return $rs; |
|
154 | + |
|
155 | + } |
|
156 | 156 | |
157 | 157 | ?> |
@@ -43,12 +43,12 @@ |
||
43 | 43 | $rows = $rs->RecordCount(); |
44 | 44 | for ($i=0; $i < $rows; $i++) { |
45 | 45 | if (is_array ($fn)) { |
46 | - $obj = $fn[0]; |
|
47 | - $method = $fn[1]; |
|
48 | - $obj->$method ($rs->_array[$i],$rs); |
|
49 | - } else { |
|
46 | + $obj = $fn[0]; |
|
47 | + $method = $fn[1]; |
|
48 | + $obj->$method ($rs->_array[$i],$rs); |
|
49 | + } else { |
|
50 | 50 | $fn($rs->_array[$i],$rs); |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | if (!$rs->EOF) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ; |
52 | 52 | else { |
53 | 53 | include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php"); |
54 | - } |
|
54 | + } |
|
55 | 55 | return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR]; |
56 | 56 | } |
57 | 57 | |
@@ -91,84 +91,84 @@ discard block |
||
91 | 91 | function adodb_error_pg($errormsg) |
92 | 92 | { |
93 | 93 | if (is_numeric($errormsg)) return (integer) $errormsg; |
94 | - static $error_regexps = array( |
|
95 | - '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, |
|
96 | - '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, |
|
97 | - '/divide by zero$/' => DB_ERROR_DIVZERO, |
|
98 | - '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, |
|
99 | - '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, |
|
100 | - '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, |
|
101 | - '/referential integrity violation/' => DB_ERROR_CONSTRAINT, |
|
94 | + static $error_regexps = array( |
|
95 | + '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, |
|
96 | + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, |
|
97 | + '/divide by zero$/' => DB_ERROR_DIVZERO, |
|
98 | + '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, |
|
99 | + '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, |
|
100 | + '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, |
|
101 | + '/referential integrity violation/' => DB_ERROR_CONSTRAINT, |
|
102 | 102 | '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/' |
103 | 103 | => DB_ERROR_ALREADY_EXISTS |
104 | - ); |
|
104 | + ); |
|
105 | 105 | reset($error_regexps); |
106 | - while (list($regexp,$code) = each($error_regexps)) { |
|
107 | - if (preg_match($regexp, $errormsg)) { |
|
108 | - return $code; |
|
109 | - } |
|
110 | - } |
|
111 | - // Fall back to DB_ERROR if there was no mapping. |
|
112 | - return DB_ERROR; |
|
106 | + while (list($regexp,$code) = each($error_regexps)) { |
|
107 | + if (preg_match($regexp, $errormsg)) { |
|
108 | + return $code; |
|
109 | + } |
|
110 | + } |
|
111 | + // Fall back to DB_ERROR if there was no mapping. |
|
112 | + return DB_ERROR; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | function adodb_error_odbc() |
116 | 116 | { |
117 | 117 | static $MAP = array( |
118 | - '01004' => DB_ERROR_TRUNCATED, |
|
119 | - '07001' => DB_ERROR_MISMATCH, |
|
120 | - '21S01' => DB_ERROR_MISMATCH, |
|
121 | - '21S02' => DB_ERROR_MISMATCH, |
|
122 | - '22003' => DB_ERROR_INVALID_NUMBER, |
|
123 | - '22008' => DB_ERROR_INVALID_DATE, |
|
124 | - '22012' => DB_ERROR_DIVZERO, |
|
125 | - '23000' => DB_ERROR_CONSTRAINT, |
|
126 | - '24000' => DB_ERROR_INVALID, |
|
127 | - '34000' => DB_ERROR_INVALID, |
|
128 | - '37000' => DB_ERROR_SYNTAX, |
|
129 | - '42000' => DB_ERROR_SYNTAX, |
|
130 | - 'IM001' => DB_ERROR_UNSUPPORTED, |
|
131 | - 'S0000' => DB_ERROR_NOSUCHTABLE, |
|
132 | - 'S0001' => DB_ERROR_NOT_FOUND, |
|
133 | - 'S0002' => DB_ERROR_NOSUCHTABLE, |
|
134 | - 'S0011' => DB_ERROR_ALREADY_EXISTS, |
|
135 | - 'S0012' => DB_ERROR_NOT_FOUND, |
|
136 | - 'S0021' => DB_ERROR_ALREADY_EXISTS, |
|
137 | - 'S0022' => DB_ERROR_NOT_FOUND, |
|
118 | + '01004' => DB_ERROR_TRUNCATED, |
|
119 | + '07001' => DB_ERROR_MISMATCH, |
|
120 | + '21S01' => DB_ERROR_MISMATCH, |
|
121 | + '21S02' => DB_ERROR_MISMATCH, |
|
122 | + '22003' => DB_ERROR_INVALID_NUMBER, |
|
123 | + '22008' => DB_ERROR_INVALID_DATE, |
|
124 | + '22012' => DB_ERROR_DIVZERO, |
|
125 | + '23000' => DB_ERROR_CONSTRAINT, |
|
126 | + '24000' => DB_ERROR_INVALID, |
|
127 | + '34000' => DB_ERROR_INVALID, |
|
128 | + '37000' => DB_ERROR_SYNTAX, |
|
129 | + '42000' => DB_ERROR_SYNTAX, |
|
130 | + 'IM001' => DB_ERROR_UNSUPPORTED, |
|
131 | + 'S0000' => DB_ERROR_NOSUCHTABLE, |
|
132 | + 'S0001' => DB_ERROR_NOT_FOUND, |
|
133 | + 'S0002' => DB_ERROR_NOSUCHTABLE, |
|
134 | + 'S0011' => DB_ERROR_ALREADY_EXISTS, |
|
135 | + 'S0012' => DB_ERROR_NOT_FOUND, |
|
136 | + 'S0021' => DB_ERROR_ALREADY_EXISTS, |
|
137 | + 'S0022' => DB_ERROR_NOT_FOUND, |
|
138 | 138 | 'S1000' => DB_ERROR_NOSUCHTABLE, |
139 | - 'S1009' => DB_ERROR_INVALID, |
|
140 | - 'S1090' => DB_ERROR_INVALID, |
|
141 | - 'S1C00' => DB_ERROR_NOT_CAPABLE |
|
142 | - ); |
|
139 | + 'S1009' => DB_ERROR_INVALID, |
|
140 | + 'S1090' => DB_ERROR_INVALID, |
|
141 | + 'S1C00' => DB_ERROR_NOT_CAPABLE |
|
142 | + ); |
|
143 | 143 | return $MAP; |
144 | 144 | } |
145 | 145 | |
146 | 146 | function adodb_error_ibase() |
147 | 147 | { |
148 | 148 | static $MAP = array( |
149 | - -104 => DB_ERROR_SYNTAX, |
|
150 | - -150 => DB_ERROR_ACCESS_VIOLATION, |
|
151 | - -151 => DB_ERROR_ACCESS_VIOLATION, |
|
152 | - -155 => DB_ERROR_NOSUCHTABLE, |
|
153 | - -157 => DB_ERROR_NOSUCHFIELD, |
|
154 | - -158 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
155 | - -170 => DB_ERROR_MISMATCH, |
|
156 | - -171 => DB_ERROR_MISMATCH, |
|
157 | - -172 => DB_ERROR_INVALID, |
|
158 | - -204 => DB_ERROR_INVALID, |
|
159 | - -205 => DB_ERROR_NOSUCHFIELD, |
|
160 | - -206 => DB_ERROR_NOSUCHFIELD, |
|
161 | - -208 => DB_ERROR_INVALID, |
|
162 | - -219 => DB_ERROR_NOSUCHTABLE, |
|
163 | - -297 => DB_ERROR_CONSTRAINT, |
|
164 | - -530 => DB_ERROR_CONSTRAINT, |
|
165 | - -803 => DB_ERROR_CONSTRAINT, |
|
166 | - -551 => DB_ERROR_ACCESS_VIOLATION, |
|
167 | - -552 => DB_ERROR_ACCESS_VIOLATION, |
|
168 | - -922 => DB_ERROR_NOSUCHDB, |
|
169 | - -923 => DB_ERROR_CONNECT_FAILED, |
|
170 | - -924 => DB_ERROR_CONNECT_FAILED |
|
171 | - ); |
|
149 | + -104 => DB_ERROR_SYNTAX, |
|
150 | + -150 => DB_ERROR_ACCESS_VIOLATION, |
|
151 | + -151 => DB_ERROR_ACCESS_VIOLATION, |
|
152 | + -155 => DB_ERROR_NOSUCHTABLE, |
|
153 | + -157 => DB_ERROR_NOSUCHFIELD, |
|
154 | + -158 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
155 | + -170 => DB_ERROR_MISMATCH, |
|
156 | + -171 => DB_ERROR_MISMATCH, |
|
157 | + -172 => DB_ERROR_INVALID, |
|
158 | + -204 => DB_ERROR_INVALID, |
|
159 | + -205 => DB_ERROR_NOSUCHFIELD, |
|
160 | + -206 => DB_ERROR_NOSUCHFIELD, |
|
161 | + -208 => DB_ERROR_INVALID, |
|
162 | + -219 => DB_ERROR_NOSUCHTABLE, |
|
163 | + -297 => DB_ERROR_CONSTRAINT, |
|
164 | + -530 => DB_ERROR_CONSTRAINT, |
|
165 | + -803 => DB_ERROR_CONSTRAINT, |
|
166 | + -551 => DB_ERROR_ACCESS_VIOLATION, |
|
167 | + -552 => DB_ERROR_ACCESS_VIOLATION, |
|
168 | + -922 => DB_ERROR_NOSUCHDB, |
|
169 | + -923 => DB_ERROR_CONNECT_FAILED, |
|
170 | + -924 => DB_ERROR_CONNECT_FAILED |
|
171 | + ); |
|
172 | 172 | |
173 | 173 | return $MAP; |
174 | 174 | } |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | function adodb_error_ifx() |
177 | 177 | { |
178 | 178 | static $MAP = array( |
179 | - '-201' => DB_ERROR_SYNTAX, |
|
180 | - '-206' => DB_ERROR_NOSUCHTABLE, |
|
181 | - '-217' => DB_ERROR_NOSUCHFIELD, |
|
182 | - '-329' => DB_ERROR_NODBSELECTED, |
|
183 | - '-1204' => DB_ERROR_INVALID_DATE, |
|
184 | - '-1205' => DB_ERROR_INVALID_DATE, |
|
185 | - '-1206' => DB_ERROR_INVALID_DATE, |
|
186 | - '-1209' => DB_ERROR_INVALID_DATE, |
|
187 | - '-1210' => DB_ERROR_INVALID_DATE, |
|
188 | - '-1212' => DB_ERROR_INVALID_DATE |
|
189 | - ); |
|
179 | + '-201' => DB_ERROR_SYNTAX, |
|
180 | + '-206' => DB_ERROR_NOSUCHTABLE, |
|
181 | + '-217' => DB_ERROR_NOSUCHFIELD, |
|
182 | + '-329' => DB_ERROR_NODBSELECTED, |
|
183 | + '-1204' => DB_ERROR_INVALID_DATE, |
|
184 | + '-1205' => DB_ERROR_INVALID_DATE, |
|
185 | + '-1206' => DB_ERROR_INVALID_DATE, |
|
186 | + '-1209' => DB_ERROR_INVALID_DATE, |
|
187 | + '-1210' => DB_ERROR_INVALID_DATE, |
|
188 | + '-1212' => DB_ERROR_INVALID_DATE |
|
189 | + ); |
|
190 | 190 | |
191 | 191 | return $MAP; |
192 | 192 | } |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | { |
196 | 196 | static $MAP = array( |
197 | 197 | 1 => DB_ERROR_ALREADY_EXISTS, |
198 | - 900 => DB_ERROR_SYNTAX, |
|
199 | - 904 => DB_ERROR_NOSUCHFIELD, |
|
200 | - 923 => DB_ERROR_SYNTAX, |
|
201 | - 942 => DB_ERROR_NOSUCHTABLE, |
|
202 | - 955 => DB_ERROR_ALREADY_EXISTS, |
|
203 | - 1476 => DB_ERROR_DIVZERO, |
|
204 | - 1722 => DB_ERROR_INVALID_NUMBER, |
|
205 | - 2289 => DB_ERROR_NOSUCHTABLE, |
|
206 | - 2291 => DB_ERROR_CONSTRAINT, |
|
207 | - 2449 => DB_ERROR_CONSTRAINT |
|
208 | - ); |
|
198 | + 900 => DB_ERROR_SYNTAX, |
|
199 | + 904 => DB_ERROR_NOSUCHFIELD, |
|
200 | + 923 => DB_ERROR_SYNTAX, |
|
201 | + 942 => DB_ERROR_NOSUCHTABLE, |
|
202 | + 955 => DB_ERROR_ALREADY_EXISTS, |
|
203 | + 1476 => DB_ERROR_DIVZERO, |
|
204 | + 1722 => DB_ERROR_INVALID_NUMBER, |
|
205 | + 2289 => DB_ERROR_NOSUCHTABLE, |
|
206 | + 2291 => DB_ERROR_CONSTRAINT, |
|
207 | + 2449 => DB_ERROR_CONSTRAINT |
|
208 | + ); |
|
209 | 209 | |
210 | 210 | return $MAP; |
211 | 211 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | { |
215 | 215 | static $MAP = array( |
216 | 216 | 208 => DB_ERROR_NOSUCHTABLE, |
217 | - 2601 => DB_ERROR_ALREADY_EXISTS |
|
218 | - ); |
|
217 | + 2601 => DB_ERROR_ALREADY_EXISTS |
|
218 | + ); |
|
219 | 219 | |
220 | 220 | return $MAP; |
221 | 221 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | { |
225 | 225 | static $MAP = array( |
226 | 226 | 1 => DB_ERROR_SYNTAX |
227 | - ); |
|
227 | + ); |
|
228 | 228 | |
229 | 229 | return $MAP; |
230 | 230 | } |
@@ -232,26 +232,26 @@ discard block |
||
232 | 232 | function adodb_error_mysql() |
233 | 233 | { |
234 | 234 | static $MAP = array( |
235 | - 1004 => DB_ERROR_CANNOT_CREATE, |
|
236 | - 1005 => DB_ERROR_CANNOT_CREATE, |
|
237 | - 1006 => DB_ERROR_CANNOT_CREATE, |
|
238 | - 1007 => DB_ERROR_ALREADY_EXISTS, |
|
239 | - 1008 => DB_ERROR_CANNOT_DROP, |
|
235 | + 1004 => DB_ERROR_CANNOT_CREATE, |
|
236 | + 1005 => DB_ERROR_CANNOT_CREATE, |
|
237 | + 1006 => DB_ERROR_CANNOT_CREATE, |
|
238 | + 1007 => DB_ERROR_ALREADY_EXISTS, |
|
239 | + 1008 => DB_ERROR_CANNOT_DROP, |
|
240 | 240 | 1045 => DB_ERROR_ACCESS_VIOLATION, |
241 | - 1046 => DB_ERROR_NODBSELECTED, |
|
241 | + 1046 => DB_ERROR_NODBSELECTED, |
|
242 | 242 | 1049 => DB_ERROR_NOSUCHDB, |
243 | - 1050 => DB_ERROR_ALREADY_EXISTS, |
|
244 | - 1051 => DB_ERROR_NOSUCHTABLE, |
|
245 | - 1054 => DB_ERROR_NOSUCHFIELD, |
|
246 | - 1062 => DB_ERROR_ALREADY_EXISTS, |
|
247 | - 1064 => DB_ERROR_SYNTAX, |
|
248 | - 1100 => DB_ERROR_NOT_LOCKED, |
|
249 | - 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
250 | - 1146 => DB_ERROR_NOSUCHTABLE, |
|
251 | - 1048 => DB_ERROR_CONSTRAINT, |
|
252 | - 2002 => DB_ERROR_CONNECT_FAILED, |
|
243 | + 1050 => DB_ERROR_ALREADY_EXISTS, |
|
244 | + 1051 => DB_ERROR_NOSUCHTABLE, |
|
245 | + 1054 => DB_ERROR_NOSUCHFIELD, |
|
246 | + 1062 => DB_ERROR_ALREADY_EXISTS, |
|
247 | + 1064 => DB_ERROR_SYNTAX, |
|
248 | + 1100 => DB_ERROR_NOT_LOCKED, |
|
249 | + 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
250 | + 1146 => DB_ERROR_NOSUCHTABLE, |
|
251 | + 1048 => DB_ERROR_CONSTRAINT, |
|
252 | + 2002 => DB_ERROR_CONNECT_FAILED, |
|
253 | 253 | 2005 => DB_ERROR_CONNECT_FAILED |
254 | - ); |
|
254 | + ); |
|
255 | 255 | |
256 | 256 | return $MAP; |
257 | 257 | } |