Changeset 955
- Timestamp:
- 11/17/2007 12:48:56 AM (18 years ago)
- Location:
- tags/0.8.3
- Files:
-
- 1 deleted
- 5 edited
-
bb-admin/upgrade-schema.php (modified) (3 diffs)
-
bb-includes/classes.php (modified) (1 diff)
-
bb-includes/db-base.php (deleted)
-
bb-includes/db-mysqli.php (modified) (6 diffs)
-
bb-includes/db.php (modified) (6 diffs)
-
bb-settings.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/0.8.3/bb-admin/upgrade-schema.php
r954 r955 3 3 4 4 $charset_collate = ''; 5 $user_charset_collate = '';6 5 7 if ( !defined( 'BB_MYSQLI' ) ) 8 die( __('Database class not loaded.') ); 9 10 if ( $bbdb->has_cap( 'collation', $bbdb->forums ) ) { 6 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { 11 7 if ( ! empty($bbdb->charset) ) 12 8 $charset_collate = "DEFAULT CHARACTER SET $bbdb->charset"; 13 9 if ( ! empty($bbdb->collate) ) 14 10 $charset_collate .= " COLLATE $bbdb->collate"; 15 }16 17 if ( $bbdb->has_cap( 'collation', $bbdb->users ) ) {18 if ( ! empty($bbdb->charset) )19 $user_charset_collate = "DEFAULT CHARACTER SET $bbdb->charset";20 if ( ! empty($bbdb->collate) )21 $user_charset_collate .= " COLLATE $bbdb->collate";22 11 } 23 12 … … 91 80 PRIMARY KEY (ID), 92 81 UNIQUE KEY user_login (user_login) 93 ) $ user_charset_collate;82 ) $charset_collate; 94 83 CREATE TABLE $bbdb->usermeta ( 95 84 umeta_id bigint(20) NOT NULL auto_increment, … … 100 89 KEY user_id (user_id), 101 90 KEY meta_key (meta_key) 102 ) $ user_charset_collate;91 ) $charset_collate; 103 92 CREATE TABLE $bbdb->tags ( 104 93 tag_id bigint(20) unsigned NOT NULL auto_increment, -
tags/0.8.3/bb-includes/classes.php
r954 r955 286 286 $fields .= ", MIN(p.post_id) as post_id"; 287 287 288 if ( $bbdb->has_cap( 'GROUP_CONCAT', $bbdb->posts ) ) 288 // GROUP_CONCAT requires MySQL >= 4.1 289 if ( version_compare('4.1', mysql_get_client_info(), '<=') ) 289 290 $fields .= ", GROUP_CONCAT(p.post_text SEPARATOR ' ') AS post_text"; 290 291 else -
tags/0.8.3/bb-includes/db-mysqli.php
r954 r955 1 1 <?php 2 define( 'BB_MYSQLI', true ); 3 4 class bbdb extends bbdb_base { 2 3 define('OBJECT', 'OBJECT', true); 4 define('ARRAY_A', 'ARRAY_A', false); 5 define('ARRAY_N', 'ARRAY_N', false); 6 7 if (!defined('SAVEQUERIES')) 8 define('SAVEQUERIES', false); 9 10 class bbdb { 11 12 var $show_errors = true; 13 var $num_queries = 0; 14 var $retries = 0; 15 var $last_query; 16 var $col_info; 17 var $queries; 18 19 // Our tables 20 var $forums; 21 var $posts; 22 var $topics; 23 var $users; 24 25 var $charset; 26 var $collate; 27 5 28 // ================================================================== 6 29 // DB Constructor - connects to the server and selects a database 7 30 8 31 function bbdb($dbuser, $dbpassword, $dbname, $dbhost) { 9 return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost); 10 } 11 12 function __construct($dbuser, $dbpassword, $dbname, $dbhost) { 13 return parent::__construct($dbuser, $dbpassword, $dbname, $dbhost); 14 } 15 16 function __destruct() { 32 if ( defined('BBDB_CHARSET') ) 33 $this->charset = BBDB_CHARSET; 34 if ( defined('BBDB_COLLATE') ) 35 $this->collate = BBDB_COLLATE; 36 37 $this->db_connect(); 17 38 return true; 39 18 40 } 19 41 … … 56 78 $this->$dbhname = @mysqli_connect( $server->host, $server->user, $server->pass, null, $server->port ); 57 79 58 if ( !empty($this->charset) && $this->has_cap( 'collation', $this->$dbhname) )80 if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 59 81 $this->query("SET NAMES '$this->charset'"); 60 82 … … 64 86 65 87 return $this->$dbhname; 88 } 89 90 function get_table_from_query ( $q ) { 91 If( substr( $q, -1 ) == ';' ) 92 $q = substr( $q, 0, -1 ); 93 if ( preg_match('/^\s*SELECT.*?\s+FROM\s+`?(\w+)`?\s*/is', $q, $maybe) ) 94 return $maybe[1]; 95 if ( preg_match('/^\s*UPDATE IGNORE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 96 return $maybe[1]; 97 if ( preg_match('/^\s*UPDATE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 98 return $maybe[1]; 99 if ( preg_match('/^\s*INSERT INTO\s+`?(\w+)`?\s*/is', $q, $maybe) ) 100 return $maybe[1]; 101 if ( preg_match('/^\s*INSERT IGNORE INTO\s+`?(\w+)`?\s*/is', $q, $maybe) ) 102 return $maybe[1]; 103 if ( preg_match('/^\s*REPLACE INTO\s+`?(\w+)`?\s*/is', $q, $maybe) ) 104 return $maybe[1]; 105 if ( preg_match('/^\s*DELETE\s+FROM\s+`?(\w+)`?\s*/is', $q, $maybe) ) 106 return $maybe[1]; 107 if ( preg_match('/^\s*OPTIMIZE\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 108 return $maybe[1]; 109 if ( preg_match('/^SHOW TABLE STATUS (LIKE|FROM) \'?`?(\w+)\'?`?\s*/is', $q, $maybe) ) 110 return $maybe[1]; 111 if ( preg_match('/^SHOW INDEX FROM `?(\w+)`?\s*/is', $q, $maybe) ) 112 return $maybe[1]; 113 if ( preg_match('/^\s*CREATE\s+TABLE\s+IF\s+NOT\s+EXISTS\s+`?(\w+)`?\s*/is', $q, $maybe) ) 114 return $maybe[1]; 115 if ( preg_match('/^\s*SHOW CREATE TABLE `?(\w+?)`?\s*/is', $q, $maybe) ) 116 return $maybe[1]; 117 if ( preg_match('/^SHOW CREATE TABLE (wp_[a-z0-9_]+)/is', $q, $maybe) ) 118 return $maybe[1]; 119 if ( preg_match('/^\s*CREATE\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 120 return $maybe[1]; 121 if ( preg_match('/^\s*DROP\s+TABLE\s+IF\s+EXISTS\s+`?(\w+)`?\s*/is', $q, $maybe) ) 122 return $maybe[1]; 123 if ( preg_match('/^\s*DROP\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 124 return $maybe[1]; 125 if ( preg_match('/^\s*DESCRIBE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 126 return $maybe[1]; 127 if ( preg_match('/^\s*ALTER\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 128 return $maybe[1]; 129 130 return false; 66 131 } 67 132 … … 74 139 die('Cannot select DB.'); 75 140 } 141 } 142 143 // ==================================================================== 144 // Format a string correctly for safe insert under all PHP conditions 145 146 function escape($str) { 147 return addslashes($str); 148 } 149 150 function escape_deep( $array ) { 151 return is_array($array) ? array_map(array(&$this, 'escape_deep'), $array) : $this->escape( $array ); 152 } 153 154 /** 155 * Escapes content by reference for insertion into the database, for security 156 * @param string $s 157 */ 158 function escape_by_ref(&$s) { 159 $s = $this->escape($s); 160 } 161 162 /** 163 * Prepares a SQL query for safe use, using sprintf() syntax 164 */ 165 function prepare($args=NULL) { 166 if ( NULL === $args ) 167 return; 168 $args = func_get_args(); 169 $query = array_shift($args); 170 $query = str_replace("'%s'", '%s', $query); // in case someone mistakenly already singlequoted it 171 $query = str_replace('"%s"', '%s', $query); // doublequote unquoting 172 $query = str_replace('%s', "'%s'", $query); // quote the strings 173 array_walk($args, array(&$this, 'escape_by_ref')); 174 return @vsprintf($query, $args); 76 175 } 77 176 … … 98 197 99 198 // ================================================================== 199 // Turn error handling on or off.. 200 201 function show_errors() { 202 $this->show_errors = true; 203 } 204 205 function hide_errors() { 206 $this->show_errors = false; 207 } 208 209 // ================================================================== 210 // Kill cached query results 211 212 function flush() { 213 $this->last_result = null; 214 $this->col_info = null; 215 $this->last_query = null; 216 } 217 218 // ================================================================== 100 219 // Basic Query - see docs for more detail 101 220 … … 165 284 } 166 285 167 // table name or mysql resource 168 function db_version( $dbh = false ) { 169 if ( !$dbh ) 170 $dbh = $this->forums; 171 172 if ( !is_resource( $dbh ) ) 173 $dbh = $this->db_connect( "DESCRIBE $dbh" ); 174 175 return mysqli_get_server_info( $dbh ); 286 // ================================================================== 287 // Get one variable from the DB - see docs for more detail 288 289 function get_var($query=null, $x = 0, $y = 0) { 290 $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; 291 if ( $query ) 292 $this->query($query); 293 294 // Extract var out of cached results based x,y vals 295 if ( $this->last_result[$y] ) { 296 $values = array_values(get_object_vars($this->last_result[$y])); 297 } 298 299 // If there is a value return it else return null 300 return (isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null; 301 } 302 303 // ================================================================== 304 // Get one row from the DB - see docs for more detail 305 306 function get_row($query = null, $output = OBJECT, $y = 0) { 307 $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; 308 if ( $query ) 309 $this->query($query); 310 311 if ( $output == OBJECT ) { 312 return $this->last_result[$y] ? $this->last_result[$y] : null; 313 } elseif ( $output == ARRAY_A ) { 314 return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null; 315 } elseif ( $output == ARRAY_N ) { 316 return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null; 317 } else { 318 $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"); 319 } 320 } 321 322 // ================================================================== 323 // Function to get 1 column from the cached result set based in X index 324 // se docs for usage and info 325 326 function get_col($query = null , $x = 0) { 327 if ( $query ) 328 $this->query($query); 329 330 // Extract the column values 331 for ( $i=0; $i < count($this->last_result); $i++ ) { 332 $new_array[$i] = $this->get_var(null, $x, $i); 333 } 334 return $new_array; 335 } 336 337 // ================================================================== 338 // Return the the query as a result set - see docs for more details 339 340 function get_results($query = null, $output = OBJECT) { 341 $this->func_call = "\$db->get_results(\"$query\", $output)"; 342 343 if ( $query ) 344 $this->query($query); 345 346 // Send back array of objects. Each row is an object 347 if ( $output == OBJECT ) { 348 return $this->last_result; 349 } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { 350 if ( $this->last_result ) { 351 $i = 0; 352 foreach( $this->last_result as $row ) { 353 $new_array[$i] = (array) $row; 354 if ( $output == ARRAY_N ) { 355 $new_array[$i] = array_values($new_array[$i]); 356 } 357 $i++; 358 } 359 return $new_array; 360 } else { 361 return null; 362 } 363 } 364 } 365 366 367 // ================================================================== 368 // Function to get column meta data info pertaining to the last query 369 // see docs for more info and usage 370 371 function get_col_info($info_type = 'name', $col_offset = -1) { 372 if ( $this->col_info ) { 373 if ( $col_offset == -1 ) { 374 $i = 0; 375 foreach($this->col_info as $col ) { 376 $new_array[$i] = $col->{$info_type}; 377 $i++; 378 } 379 return $new_array; 380 } else { 381 return $this->col_info[$col_offset]->{$info_type}; 382 } 383 } 384 } 385 386 function timer_start() { 387 $mtime = microtime(); 388 $mtime = explode(' ', $mtime); 389 $this->time_start = $mtime[1] + $mtime[0]; 390 return true; 391 } 392 393 function timer_stop($precision = 3) { 394 $mtime = microtime(); 395 $mtime = explode(' ', $mtime); 396 $time_end = $mtime[1] + $mtime[0]; 397 $time_total = $time_end - $this->time_start; 398 return $time_total; 399 } 400 401 function bail($message) { // Just wraps errors in a nice header and footer 402 if ( !$this->show_errors ) 403 return false; 404 echo <<<HEAD 405 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 406 <html xmlns="http://www.w3.org/1999/xhtml"> 407 <head> 408 <title>bbPress › Error</title> 409 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 410 <style media="screen" type="text/css"> 411 <!-- 412 html { 413 background: #eee; 414 } 415 body { 416 background: #fff; 417 color: #000; 418 font-family: Georgia, "Times New Roman", Times, serif; 419 margin-left: 25%; 420 margin-right: 25%; 421 padding: .2em 2em; 422 } 423 424 h1 { 425 color: #006; 426 font-size: 18px; 427 font-weight: lighter; 428 } 429 430 h2 { 431 font-size: 16px; 432 } 433 434 p, li, dt { 435 line-height: 140%; 436 padding-bottom: 2px; 437 } 438 439 ul, ol { 440 padding: 5px 5px 5px 20px; 441 } 442 #logo { 443 margin-bottom: 2em; 444 } 445 --> 446 </style> 447 </head> 448 <body> 449 <h1 id="logo"><img alt="bbPress" src="http://bbpress.org/bbpress.png" /></h1> 450 HEAD; 451 echo $message; 452 echo "</body></html>"; 453 die(); 176 454 } 177 455 } -
tags/0.8.3/bb-includes/db.php
r954 r955 1 1 <?php 2 define( 'BB_MYSQLI', false ); 3 4 class bbdb extends bbdb_base { 2 3 define('OBJECT', 'OBJECT', true); 4 define('ARRAY_A', 'ARRAY_A', false); 5 define('ARRAY_N', 'ARRAY_N', false); 6 7 if (!defined('SAVEQUERIES')) 8 define('SAVEQUERIES', false); 9 10 class bbdb { 11 12 var $show_errors = true; 13 var $num_queries = 0; 14 var $retries = 0; 15 var $last_query; 16 var $col_info; 17 var $queries; 18 19 // Our tables 20 var $forums; 21 var $posts; 22 var $topics; 23 var $users; 24 25 var $charset; 26 var $collate; 27 5 28 // ================================================================== 6 29 // DB Constructor - connects to the server and selects a database 7 30 8 31 function bbdb($dbuser, $dbpassword, $dbname, $dbhost) { 9 return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost); 10 } 11 12 function __construct($dbuser, $dbpassword, $dbname, $dbhost) { 13 return parent::__construct($dbuser, $dbpassword, $dbname, $dbhost); 14 } 15 16 function __destruct() { 32 if ( defined('BBDB_CHARSET') ) 33 $this->charset = BBDB_CHARSET; 34 if ( defined('BBDB_COLLATE') ) 35 $this->collate = BBDB_COLLATE; 36 37 $this->db_connect(); 17 38 return true; 39 18 40 } 19 41 … … 49 71 $this->$dbhname = @mysql_connect( $server->host, $server->user, $server->pass, true ); 50 72 51 if ( !empty($this->charset) && $this->has_cap( 'collation', $this->$dbhname) )73 if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 52 74 $this->query("SET NAMES '$this->charset'"); 53 75 … … 57 79 58 80 return $this->$dbhname; 81 } 82 83 function get_table_from_query ( $q ) { 84 If( substr( $q, -1 ) == ';' ) 85 $q = substr( $q, 0, -1 ); 86 if ( preg_match('/^\s*SELECT.*?\s+FROM\s+`?(\w+)`?\s*/is', $q, $maybe) ) 87 return $maybe[1]; 88 if ( preg_match('/^\s*UPDATE IGNORE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 89 return $maybe[1]; 90 if ( preg_match('/^\s*UPDATE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 91 return $maybe[1]; 92 if ( preg_match('/^\s*INSERT INTO\s+`?(\w+)`?\s*/is', $q, $maybe) ) 93 return $maybe[1]; 94 if ( preg_match('/^\s*INSERT IGNORE INTO\s+`?(\w+)`?\s*/is', $q, $maybe) ) 95 return $maybe[1]; 96 if ( preg_match('/^\s*REPLACE INTO\s+`?(\w+)`?\s*/is', $q, $maybe) ) 97 return $maybe[1]; 98 if ( preg_match('/^\s*DELETE\s+FROM\s+`?(\w+)`?\s*/is', $q, $maybe) ) 99 return $maybe[1]; 100 if ( preg_match('/^\s*OPTIMIZE\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 101 return $maybe[1]; 102 if ( preg_match('/^SHOW TABLE STATUS (LIKE|FROM) \'?`?(\w+)\'?`?\s*/is', $q, $maybe) ) 103 return $maybe[1]; 104 if ( preg_match('/^SHOW INDEX FROM `?(\w+)`?\s*/is', $q, $maybe) ) 105 return $maybe[1]; 106 if ( preg_match('/^\s*CREATE\s+TABLE\s+IF\s+NOT\s+EXISTS\s+`?(\w+)`?\s*/is', $q, $maybe) ) 107 return $maybe[1]; 108 if ( preg_match('/^\s*SHOW CREATE TABLE `?(\w+?)`?\s*/is', $q, $maybe) ) 109 return $maybe[1]; 110 if ( preg_match('/^SHOW CREATE TABLE (wp_[a-z0-9_]+)/is', $q, $maybe) ) 111 return $maybe[1]; 112 if ( preg_match('/^\s*CREATE\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 113 return $maybe[1]; 114 if ( preg_match('/^\s*DROP\s+TABLE\s+IF\s+EXISTS\s+`?(\w+)`?\s*/is', $q, $maybe) ) 115 return $maybe[1]; 116 if ( preg_match('/^\s*DROP\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 117 return $maybe[1]; 118 if ( preg_match('/^\s*DESCRIBE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 119 return $maybe[1]; 120 if ( preg_match('/^\s*ALTER\s+TABLE\s+`?(\w+)`?\s*/is', $q, $maybe) ) 121 return $maybe[1]; 122 123 return false; 59 124 } 60 125 … … 67 132 die('Cannot select DB.'); 68 133 } 134 } 135 136 // ==================================================================== 137 // Format a string correctly for safe insert under all PHP conditions 138 139 function escape($str) { 140 return addslashes($str); 141 } 142 143 function escape_deep( $array ) { 144 return is_array($array) ? array_map(array(&$this, 'escape_deep'), $array) : $this->escape( $array ); 145 } 146 147 /** 148 * Escapes content by reference for insertion into the database, for security 149 * @param string $s 150 */ 151 function escape_by_ref(&$s) { 152 $s = $this->escape($s); 153 } 154 155 /** 156 * Prepares a SQL query for safe use, using sprintf() syntax 157 */ 158 function prepare($args=NULL) { 159 if ( NULL === $args ) 160 return; 161 $args = func_get_args(); 162 $query = array_shift($args); 163 $query = str_replace("'%s'", '%s', $query); // in case someone mistakenly already singlequoted it 164 $query = str_replace('"%s"', '%s', $query); // doublequote unquoting 165 $query = str_replace('%s', "'%s'", $query); // quote the strings 166 array_walk($args, array(&$this, 'escape_by_ref')); 167 return @vsprintf($query, $args); 69 168 } 70 169 … … 91 190 92 191 // ================================================================== 192 // Turn error handling on or off.. 193 194 function show_errors() { 195 $this->show_errors = true; 196 } 197 198 function hide_errors() { 199 $this->show_errors = false; 200 } 201 202 // ================================================================== 203 // Kill cached query results 204 205 function flush() { 206 $this->last_result = null; 207 $this->col_info = null; 208 $this->last_query = null; 209 } 210 211 // ================================================================== 93 212 // Basic Query - see docs for more detail 94 213 … … 158 277 } 159 278 160 // table name or mysql resource 161 function db_version( $dbh = false ) { 162 if ( !$dbh ) 163 $dbh = $this->forums; 164 165 if ( !is_resource( $dbh ) ) 166 $dbh = $this->db_connect( "DESCRIBE $dbh" ); 167 168 return mysql_get_server_info( $dbh ); 279 // ================================================================== 280 // Get one variable from the DB - see docs for more detail 281 282 function get_var($query=null, $x = 0, $y = 0) { 283 $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; 284 if ( $query ) 285 $this->query($query); 286 287 // Extract var out of cached results based x,y vals 288 if ( $this->last_result[$y] ) { 289 $values = array_values(get_object_vars($this->last_result[$y])); 290 } 291 292 // If there is a value return it else return null 293 return (isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null; 294 } 295 296 // ================================================================== 297 // Get one row from the DB - see docs for more detail 298 299 function get_row($query = null, $output = OBJECT, $y = 0) { 300 $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; 301 if ( $query ) 302 $this->query($query); 303 304 if ( $output == OBJECT ) { 305 return $this->last_result[$y] ? $this->last_result[$y] : null; 306 } elseif ( $output == ARRAY_A ) { 307 return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null; 308 } elseif ( $output == ARRAY_N ) { 309 return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null; 310 } else { 311 $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"); 312 } 313 } 314 315 // ================================================================== 316 // Function to get 1 column from the cached result set based in X index 317 // se docs for usage and info 318 319 function get_col($query = null , $x = 0) { 320 if ( $query ) 321 $this->query($query); 322 323 // Extract the column values 324 for ( $i=0; $i < count($this->last_result); $i++ ) { 325 $new_array[$i] = $this->get_var(null, $x, $i); 326 } 327 return $new_array; 328 } 329 330 // ================================================================== 331 // Return the the query as a result set - see docs for more details 332 333 function get_results($query = null, $output = OBJECT) { 334 $this->func_call = "\$db->get_results(\"$query\", $output)"; 335 336 if ( $query ) 337 $this->query($query); 338 339 // Send back array of objects. Each row is an object 340 if ( $output == OBJECT ) { 341 return $this->last_result; 342 } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { 343 if ( $this->last_result ) { 344 $i = 0; 345 foreach( $this->last_result as $row ) { 346 $new_array[$i] = (array) $row; 347 if ( $output == ARRAY_N ) { 348 $new_array[$i] = array_values($new_array[$i]); 349 } 350 $i++; 351 } 352 return $new_array; 353 } else { 354 return null; 355 } 356 } 357 } 358 359 360 // ================================================================== 361 // Function to get column meta data info pertaining to the last query 362 // see docs for more info and usage 363 364 function get_col_info($info_type = 'name', $col_offset = -1) { 365 if ( $this->col_info ) { 366 if ( $col_offset == -1 ) { 367 $i = 0; 368 foreach($this->col_info as $col ) { 369 $new_array[$i] = $col->{$info_type}; 370 $i++; 371 } 372 return $new_array; 373 } else { 374 return $this->col_info[$col_offset]->{$info_type}; 375 } 376 } 377 } 378 379 function timer_start() { 380 $mtime = microtime(); 381 $mtime = explode(' ', $mtime); 382 $this->time_start = $mtime[1] + $mtime[0]; 383 return true; 384 } 385 386 function timer_stop($precision = 3) { 387 $mtime = microtime(); 388 $mtime = explode(' ', $mtime); 389 $time_end = $mtime[1] + $mtime[0]; 390 $time_total = $time_end - $this->time_start; 391 return $time_total; 392 } 393 394 function bail($message) { // Just wraps errors in a nice header and footer 395 if ( !$this->show_errors ) 396 return false; 397 echo <<<HEAD 398 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 399 <html xmlns="http://www.w3.org/1999/xhtml"> 400 <head> 401 <title>bbPress › Error</title> 402 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 403 <style media="screen" type="text/css"> 404 <!-- 405 html { 406 background: #eee; 407 } 408 body { 409 background: #fff; 410 color: #000; 411 font-family: Georgia, "Times New Roman", Times, serif; 412 margin-left: 25%; 413 margin-right: 25%; 414 padding: .2em 2em; 415 } 416 417 h1 { 418 color: #006; 419 font-size: 18px; 420 font-weight: lighter; 421 } 422 423 h2 { 424 font-size: 16px; 425 } 426 427 p, li, dt { 428 line-height: 140%; 429 padding-bottom: 2px; 430 } 431 432 ul, ol { 433 padding: 5px 5px 5px 20px; 434 } 435 #logo { 436 margin-bottom: 2em; 437 } 438 --> 439 </style> 440 </head> 441 <body> 442 <h1 id="logo"><img alt="bbPress" src="http://bbpress.org/bbpress.png" /></h1> 443 HEAD; 444 echo $message; 445 echo "</body></html>"; 446 die(); 169 447 } 170 448 } -
tags/0.8.3/bb-settings.php
r954 r955 9 9 if ( !$bb_table_prefix ) 10 10 die('You must specify a table prefix in your <code>config.php</code> file.'); 11 12 if ( preg_match('/[^A-Za-z0-9_]/', $bb_table_prefix) ) 13 die('Your table prefix may only contain letters, numbers and underscores.'); 11 14 12 15 if ( !defined('BBPATH') ) … … 85 88 define('BBTHEMEURL', $bb->uri . 'my-templates/'); 86 89 87 require( BBPATH . BBINC . 'db-base.php');88 90 if ( extension_loaded('mysqli') ) { 89 91 require( BBPATH . BBINC . 'db-mysqli.php'); … … 92 94 } 93 95 94 require( BBPATH . BBINC . 'compat.php');95 require( BBPATH . BBINC . 'wp-functions.php');96 require( BBPATH . BBINC . 'functions.php');97 require( BBPATH . BBINC . 'wp-classes.php');98 require( BBPATH . BBINC . 'classes.php');99 100 if ( is_wp_error( $bbdb->set_prefix( $bb_table_prefix ) ) ) 101 die('Your table prefix may only contain letters, numbers and underscores.');96 $bbdb->forums = $bb_table_prefix . 'forums'; 97 $bbdb->posts = $bb_table_prefix . 'posts'; 98 $bbdb->topics = $bb_table_prefix . 'topics'; 99 $bbdb->topicmeta = $bb_table_prefix . 'topicmeta'; 100 $bbdb->users = ( $bb->wp_table_prefix ? $bb->wp_table_prefix : $bb_table_prefix ) . 'users'; 101 $bbdb->usermeta = ( $bb->wp_table_prefix ? $bb->wp_table_prefix : $bb_table_prefix ) . 'usermeta'; 102 $bbdb->tags = $bb_table_prefix . 'tags'; 103 $bbdb->tagged = $bb_table_prefix . 'tagged'; 102 104 103 105 foreach ( array('use_cache', 'secret', 'debug', 'wp_table_prefix', 'wp_home', 'wp_siteurl', 'cookiedomain', 'static_title', 'load_options', 'akismet_key') as $o ) … … 111 113 unset($i); 112 114 115 require( BBPATH . BBINC . 'functions.php'); 116 require( BBPATH . BBINC . 'wp-classes.php'); 117 require( BBPATH . BBINC . 'classes.php'); 113 118 require( BBPATH . BBINC . 'formatting-functions.php'); 114 119 require( BBPATH . BBINC . 'template-functions.php'); … … 116 121 require( BBPATH . BBINC . 'cache.php'); 117 122 require( BBPATH . BBINC . 'deprecated.php'); 123 require( BBPATH . BBINC . 'wp-functions.php'); 118 124 if ( defined('BBLANG') && '' != constant('BBLANG') ) { 119 125 include_once(BBPATH . BBINC . 'streams.php'); … … 128 134 require( BBPATH . BBINC . 'default-filters.php'); 129 135 require( BBPATH . BBINC . 'script-loader.php'); 136 require( BBPATH . BBINC . 'compat.php'); 130 137 131 138 if ( !bb_is_installed() && false === strpos($_SERVER['PHP_SELF'], 'install.php') && !defined('BB_INSTALLING') )
Note: See TracChangeset
for help on using the changeset viewer.