Ticket #10918: 10918.diff
| File 10918.diff, 65.8 KB (added by , 16 years ago) |
|---|
-
wp-includes/wp-db.php
1 1 <?php 2 /** 3 * WordPress DB Class 4 * 5 * Original code from {@link http://php.justinvincent.com Justin Vincent (justin@visunet.ie)} 6 * 7 * @package WordPress 8 * @subpackage Database 9 * @since 0.71 10 */ 2 // help maintain backwards compatibility. 3 if ( !defined('DB_TYPE') ) { 4 define('DB_TYPE', 'mysql'); 5 } 11 6 12 /** 13 * @since 0.71 14 */ 15 define('EZSQL_VERSION', 'WP1.25'); 7 require_once(dirname(__FILE__) . '/wp-db/' . DB_TYPE . '/' . DB_TYPE . '.php'); 16 8 17 /** 18 * @since 0.71 19 */ 20 define('OBJECT', 'OBJECT', true); 21 22 /** 23 * @since {@internal Version Unknown}} 24 */ 25 define('OBJECT_K', 'OBJECT_K', false); 26 27 /** 28 * @since 0.71 29 */ 30 define('ARRAY_A', 'ARRAY_A', false); 31 32 /** 33 * @since 0.71 34 */ 35 define('ARRAY_N', 'ARRAY_N', false); 36 37 /** 38 * WordPress Database Access Abstraction Object 39 * 40 * It is possible to replace this class with your own 41 * by setting the $wpdb global variable in wp-content/db.php 42 * file with your class. You can name it wpdb also, since 43 * this file will not be included, if the other file is 44 * available. 45 * 46 * @link http://codex.wordpress.org/Function_Reference/wpdb_Class 47 * 48 * @package WordPress 49 * @subpackage Database 50 * @since 0.71 51 * @final 52 */ 53 class wpdb { 54 9 if ( !isset($wpdb) ) { 55 10 /** 56 * Whether to show SQL/DB errors 57 * 58 * @since 0.71 59 * @access private 60 * @var bool 61 */ 62 var $show_errors = false; 63 64 /** 65 * Whether to suppress errors during the DB bootstrapping. 66 * 67 * @access private 68 * @since {@internal Version Unknown}} 69 * @var bool 70 */ 71 var $suppress_errors = false; 72 73 /** 74 * The last error during query. 75 * 76 * @since {@internal Version Unknown}} 77 * @var string 78 */ 79 var $last_error = ''; 80 81 /** 82 * Amount of queries made 83 * 84 * @since 1.2.0 85 * @access private 86 * @var int 87 */ 88 var $num_queries = 0; 89 90 /** 91 * Saved result of the last query made 92 * 93 * @since 1.2.0 94 * @access private 95 * @var array 96 */ 97 var $last_query; 98 99 /** 100 * Saved info on the table column 101 * 102 * @since 1.2.0 103 * @access private 104 * @var array 105 */ 106 var $col_info; 107 108 /** 109 * Saved queries that were executed 110 * 111 * @since 1.5.0 112 * @access private 113 * @var array 114 */ 115 var $queries; 116 117 /** 118 * WordPress table prefix 119 * 120 * You can set this to have multiple WordPress installations 121 * in a single database. The second reason is for possible 122 * security precautions. 123 * 124 * @since 0.71 125 * @access private 126 * @var string 127 */ 128 var $prefix = ''; 129 130 /** 131 * Whether the database queries are ready to start executing. 132 * 133 * @since 2.5.0 134 * @access private 135 * @var bool 136 */ 137 var $ready = false; 138 139 /** 140 * WordPress Posts table 141 * 142 * @since 1.5.0 143 * @access public 144 * @var string 145 */ 146 var $posts; 147 148 /** 149 * WordPress Users table 150 * 151 * @since 1.5.0 152 * @access public 153 * @var string 154 */ 155 var $users; 156 157 /** 158 * WordPress Categories table 159 * 160 * @since 1.5.0 161 * @access public 162 * @var string 163 */ 164 var $categories; 165 166 /** 167 * WordPress Post to Category table 168 * 169 * @since 1.5.0 170 * @access public 171 * @var string 172 */ 173 var $post2cat; 174 175 /** 176 * WordPress Comments table 177 * 178 * @since 1.5.0 179 * @access public 180 * @var string 181 */ 182 var $comments; 183 184 /** 185 * WordPress Links table 186 * 187 * @since 1.5.0 188 * @access public 189 * @var string 190 */ 191 var $links; 192 193 /** 194 * WordPress Options table 195 * 196 * @since 1.5.0 197 * @access public 198 * @var string 199 */ 200 var $options; 201 202 /** 203 * WordPress Post Metadata table 204 * 205 * @since {@internal Version Unknown}} 206 * @access public 207 * @var string 208 */ 209 var $postmeta; 210 211 /** 212 * WordPress Comment Metadata table 213 * 214 * @since 2.9 215 * @access public 216 * @var string 217 */ 218 var $commentmeta; 219 220 /** 221 * WordPress User Metadata table 222 * 223 * @since 2.3.0 224 * @access public 225 * @var string 226 */ 227 var $usermeta; 228 229 /** 230 * WordPress Terms table 231 * 232 * @since 2.3.0 233 * @access public 234 * @var string 235 */ 236 var $terms; 237 238 /** 239 * WordPress Term Taxonomy table 240 * 241 * @since 2.3.0 242 * @access public 243 * @var string 244 */ 245 var $term_taxonomy; 246 247 /** 248 * WordPress Term Relationships table 249 * 250 * @since 2.3.0 251 * @access public 252 * @var string 253 */ 254 var $term_relationships; 255 256 /** 257 * List of WordPress tables 258 * 259 * @since {@internal Version Unknown}} 260 * @access private 261 * @var array 262 */ 263 var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 264 'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta'); 265 266 /** 267 * List of deprecated WordPress tables 268 * 269 * @since 2.9.0 270 * @access private 271 * @var array 272 */ 273 var $old_tables = array('categories', 'post2cat', 'link2cat'); 274 275 276 /** 277 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php. 278 * 279 * Keys are colmn names, values are format types: 'ID' => '%d' 280 * 281 * @since 2.8.0 282 * @see wpdb:prepare() 283 * @see wpdb:insert() 284 * @see wpdb:update() 285 * @access public 286 * @war array 287 */ 288 var $field_types = array(); 289 290 /** 291 * Database table columns charset 292 * 293 * @since 2.2.0 294 * @access public 295 * @var string 296 */ 297 var $charset; 298 299 /** 300 * Database table columns collate 301 * 302 * @since 2.2.0 303 * @access public 304 * @var string 305 */ 306 var $collate; 307 308 /** 309 * Whether to use mysql_real_escape_string 310 * 311 * @since 2.8.0 312 * @access public 313 * @var bool 314 */ 315 var $real_escape = false; 316 317 /** 318 * Database Username 319 * 320 * @since 2.9.0 321 * @access private 322 * @var string 323 */ 324 var $dbuser; 325 326 /** 327 * Connects to the database server and selects a database 328 * 329 * PHP4 compatibility layer for calling the PHP5 constructor. 330 * 331 * @uses wpdb::__construct() Passes parameters and returns result 332 * @since 0.71 333 * 334 * @param string $dbuser MySQL database user 335 * @param string $dbpassword MySQL database password 336 * @param string $dbname MySQL database name 337 * @param string $dbhost MySQL database host 338 */ 339 function wpdb($dbuser, $dbpassword, $dbname, $dbhost) { 340 return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost); 341 } 342 343 /** 344 * Connects to the database server and selects a database 345 * 346 * PHP5 style constructor for compatibility with PHP5. Does 347 * the actual setting up of the class properties and connection 348 * to the database. 349 * 350 * @since 2.0.8 351 * 352 * @param string $dbuser MySQL database user 353 * @param string $dbpassword MySQL database password 354 * @param string $dbname MySQL database name 355 * @param string $dbhost MySQL database host 356 */ 357 function __construct($dbuser, $dbpassword, $dbname, $dbhost) { 358 register_shutdown_function(array(&$this, "__destruct")); 359 360 if ( defined('WP_DEBUG') and WP_DEBUG == true ) 361 $this->show_errors(); 362 363 if ( defined('DB_CHARSET') ) 364 $this->charset = DB_CHARSET; 365 366 if ( defined('DB_COLLATE') ) 367 $this->collate = DB_COLLATE; 368 369 $this->dbuser = $dbuser; 370 371 $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true); 372 if (!$this->dbh) { 373 $this->bail(sprintf(/*WP_I18N_DB_CONN_ERROR*/" 374 <h1>Error establishing a database connection</h1> 375 <p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p> 376 <ul> 377 <li>Are you sure you have the correct username and password?</li> 378 <li>Are you sure that you have typed the correct hostname?</li> 379 <li>Are you sure that the database server is running?</li> 380 </ul> 381 <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p> 382 "/*/WP_I18N_DB_CONN_ERROR*/, $dbhost), 'db_connect_fail'); 383 return; 384 } 385 386 $this->ready = true; 387 388 if ( $this->has_cap( 'collation' ) ) { 389 if ( !empty($this->charset) ) { 390 if ( function_exists('mysql_set_charset') ) { 391 mysql_set_charset($this->charset, $this->dbh); 392 $this->real_escape = true; 393 } else { 394 $collation_query = "SET NAMES '{$this->charset}'"; 395 if ( !empty($this->collate) ) 396 $collation_query .= " COLLATE '{$this->collate}'"; 397 $this->query($collation_query); 398 } 399 } 400 } 401 402 $this->select($dbname); 403 } 404 405 /** 406 * PHP5 style destructor and will run when database object is destroyed. 407 * 408 * @since 2.0.8 409 * 410 * @return bool Always true 411 */ 412 function __destruct() { 413 return true; 414 } 415 416 /** 417 * Sets the table prefix for the WordPress tables. 418 * 419 * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to 420 * override the WordPress users and usersmeta tables that would otherwise be determined by the $prefix. 421 * 422 * @since 2.5.0 423 * 424 * @param string $prefix Alphanumeric name for the new prefix. 425 * @return string|WP_Error Old prefix or WP_Error on error 426 */ 427 function set_prefix($prefix) { 428 429 if ( preg_match('|[^a-z0-9_]|i', $prefix) ) 430 return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/); 431 432 $old_prefix = $this->prefix; 433 $this->prefix = $prefix; 434 435 foreach ( (array) $this->tables as $table ) 436 $this->$table = $this->prefix . $table; 437 438 if ( defined('CUSTOM_USER_TABLE') ) 439 $this->users = CUSTOM_USER_TABLE; 440 441 if ( defined('CUSTOM_USER_META_TABLE') ) 442 $this->usermeta = CUSTOM_USER_META_TABLE; 443 444 return $old_prefix; 445 } 446 447 /** 448 * Selects a database using the current database connection. 449 * 450 * The database name will be changed based on the current database 451 * connection. On failure, the execution will bail and display an DB error. 452 * 453 * @since 0.71 454 * 455 * @param string $db MySQL database name 456 * @return null Always null. 457 */ 458 function select($db) { 459 if (!@mysql_select_db($db, $this->dbh)) { 460 $this->ready = false; 461 $this->bail(sprintf(/*WP_I18N_DB_SELECT_DB*/' 462 <h1>Can’t select database</h1> 463 <p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>%1$s</code> database.</p> 464 <ul> 465 <li>Are you sure it exists?</li> 466 <li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li> 467 <li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li> 468 </ul> 469 <p>If you don\'t know how to setup a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="http://wordpress.org/support/">WordPress Support Forums</a>.</p>'/*/WP_I18N_DB_SELECT_DB*/, $db, $this->dbuser), 'db_select_fail'); 470 return; 471 } 472 } 473 474 function _weak_escape($string) { 475 return addslashes($string); 476 } 477 478 function _real_escape($string) { 479 if ( $this->dbh && $this->real_escape ) 480 return mysql_real_escape_string( $string, $this->dbh ); 481 else 482 return addslashes( $string ); 483 } 484 485 function _escape($data) { 486 if ( is_array($data) ) { 487 foreach ( (array) $data as $k => $v ) { 488 if ( is_array($v) ) 489 $data[$k] = $this->_escape( $v ); 490 else 491 $data[$k] = $this->_real_escape( $v ); 492 } 493 } else { 494 $data = $this->_real_escape( $data ); 495 } 496 497 return $data; 498 } 499 500 /** 501 * Escapes content for insertion into the database using addslashes(), for security 502 * 503 * @since 0.71 504 * 505 * @param string|array $data 506 * @return string query safe string 507 */ 508 function escape($data) { 509 if ( is_array($data) ) { 510 foreach ( (array) $data as $k => $v ) { 511 if ( is_array($v) ) 512 $data[$k] = $this->escape( $v ); 513 else 514 $data[$k] = $this->_weak_escape( $v ); 515 } 516 } else { 517 $data = $this->_weak_escape( $data ); 518 } 519 520 return $data; 521 } 522 523 /** 524 * Escapes content by reference for insertion into the database, for security 525 * 526 * @since 2.3.0 527 * 528 * @param string $s 529 */ 530 function escape_by_ref(&$string) { 531 $string = $this->_real_escape( $string ); 532 } 533 534 /** 535 * Prepares a SQL query for safe execution. Uses sprintf()-like syntax. 536 * 537 * This function only supports a small subset of the sprintf syntax; it only supports %d (decimal number), %s (string). 538 * Does not support sign, padding, alignment, width or precision specifiers. 539 * Does not support argument numbering/swapping. 540 * 541 * May be called like {@link http://php.net/sprintf sprintf()} or like {@link http://php.net/vsprintf vsprintf()}. 542 * 543 * Both %d and %s should be left unquoted in the query string. 544 * 545 * <code> 546 * wpdb::prepare( "SELECT * FROM `table` WHERE `column` = %s AND `field` = %d", "foo", 1337 ) 547 * </code> 548 * 549 * @link http://php.net/sprintf Description of syntax. 550 * @since 2.3.0 551 * 552 * @param string $query Query statement with sprintf()-like placeholders 553 * @param array|mixed $args The array of variables to substitute into the query's placeholders if being called like {@link http://php.net/vsprintf vsprintf()}, or the first variable to substitute into the query's placeholders if being called like {@link http://php.net/sprintf sprintf()}. 554 * @param mixed $args,... further variables to substitute into the query's placeholders if being called like {@link http://php.net/sprintf sprintf()}. 555 * @return null|string Sanitized query string 556 */ 557 function prepare($query = null) { // ( $query, *$args ) 558 if ( is_null( $query ) ) 559 return; 560 $args = func_get_args(); 561 array_shift($args); 562 // If args were passed as an array (as in vsprintf), move them up 563 if ( isset($args[0]) && is_array($args[0]) ) 564 $args = $args[0]; 565 $query = str_replace("'%s'", '%s', $query); // in case someone mistakenly already singlequoted it 566 $query = str_replace('"%s"', '%s', $query); // doublequote unquoting 567 $query = str_replace('%s', "'%s'", $query); // quote the strings 568 array_walk($args, array(&$this, 'escape_by_ref')); 569 return @vsprintf($query, $args); 570 } 571 572 /** 573 * Print SQL/DB error. 574 * 575 * @since 0.71 576 * @global array $EZSQL_ERROR Stores error information of query and error string 577 * 578 * @param string $str The error to display 579 * @return bool False if the showing of errors is disabled. 580 */ 581 function print_error($str = '') { 582 global $EZSQL_ERROR; 583 584 if (!$str) $str = mysql_error($this->dbh); 585 $EZSQL_ERROR[] = array ('query' => $this->last_query, 'error_str' => $str); 586 587 if ( $this->suppress_errors ) 588 return false; 589 590 if ( $caller = $this->get_caller() ) 591 $error_str = sprintf(/*WP_I18N_DB_QUERY_ERROR_FULL*/'WordPress database error %1$s for query %2$s made by %3$s'/*/WP_I18N_DB_QUERY_ERROR_FULL*/, $str, $this->last_query, $caller); 592 else 593 $error_str = sprintf(/*WP_I18N_DB_QUERY_ERROR*/'WordPress database error %1$s for query %2$s'/*/WP_I18N_DB_QUERY_ERROR*/, $str, $this->last_query); 594 595 $log_error = true; 596 if ( ! function_exists('error_log') ) 597 $log_error = false; 598 599 $log_file = @ini_get('error_log'); 600 if ( !empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file) ) 601 $log_error = false; 602 603 if ( $log_error ) 604 @error_log($error_str, 0); 605 606 // Is error output turned on or not.. 607 if ( !$this->show_errors ) 608 return false; 609 610 $str = htmlspecialchars($str, ENT_QUOTES); 611 $query = htmlspecialchars($this->last_query, ENT_QUOTES); 612 613 // If there is an error then take note of it 614 print "<div id='error'> 615 <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br /> 616 <code>$query</code></p> 617 </div>"; 618 } 619 620 /** 621 * Enables showing of database errors. 622 * 623 * This function should be used only to enable showing of errors. 624 * wpdb::hide_errors() should be used instead for hiding of errors. However, 625 * this function can be used to enable and disable showing of database 626 * errors. 627 * 628 * @since 0.71 629 * 630 * @param bool $show Whether to show or hide errors 631 * @return bool Old value for showing errors. 632 */ 633 function show_errors( $show = true ) { 634 $errors = $this->show_errors; 635 $this->show_errors = $show; 636 return $errors; 637 } 638 639 /** 640 * Disables showing of database errors. 641 * 642 * @since 0.71 643 * 644 * @return bool Whether showing of errors was active or not 645 */ 646 function hide_errors() { 647 $show = $this->show_errors; 648 $this->show_errors = false; 649 return $show; 650 } 651 652 /** 653 * Whether to suppress database errors. 654 * 655 * @param unknown_type $suppress 656 * @return unknown 657 */ 658 function suppress_errors( $suppress = true ) { 659 $errors = $this->suppress_errors; 660 $this->suppress_errors = $suppress; 661 return $errors; 662 } 663 664 /** 665 * Kill cached query results. 666 * 667 * @since 0.71 668 */ 669 function flush() { 670 $this->last_result = array(); 671 $this->col_info = null; 672 $this->last_query = null; 673 } 674 675 /** 676 * Perform a MySQL database query, using current database connection. 677 * 678 * More information can be found on the codex page. 679 * 680 * @since 0.71 681 * 682 * @param string $query 683 * @return int|false Number of rows affected/selected or false on error 684 */ 685 function query($query) { 686 if ( ! $this->ready ) 687 return false; 688 689 // filter the query, if filters are available 690 // NOTE: some queries are made before the plugins have been loaded, and thus cannot be filtered with this method 691 if ( function_exists('apply_filters') ) 692 $query = apply_filters('query', $query); 693 694 // initialise return 695 $return_val = 0; 696 $this->flush(); 697 698 // Log how the function was called 699 $this->func_call = "\$db->query(\"$query\")"; 700 701 // Keep track of the last query for debug.. 702 $this->last_query = $query; 703 704 // Perform the query via std mysql_query function.. 705 if ( defined('SAVEQUERIES') && SAVEQUERIES ) 706 $this->timer_start(); 707 708 $this->result = @mysql_query($query, $this->dbh); 709 ++$this->num_queries; 710 711 if ( defined('SAVEQUERIES') && SAVEQUERIES ) 712 $this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() ); 713 714 // If there is an error then take note of it.. 715 if ( $this->last_error = mysql_error($this->dbh) ) { 716 $this->print_error(); 717 return false; 718 } 719 720 if ( preg_match("/^\\s*(insert|delete|update|replace|alter) /i",$query) ) { 721 $this->rows_affected = mysql_affected_rows($this->dbh); 722 // Take note of the insert_id 723 if ( preg_match("/^\\s*(insert|replace) /i",$query) ) { 724 $this->insert_id = mysql_insert_id($this->dbh); 725 } 726 // Return number of rows affected 727 $return_val = $this->rows_affected; 728 } else { 729 $i = 0; 730 while ($i < @mysql_num_fields($this->result)) { 731 $this->col_info[$i] = @mysql_fetch_field($this->result); 732 $i++; 733 } 734 $num_rows = 0; 735 while ( $row = @mysql_fetch_object($this->result) ) { 736 $this->last_result[$num_rows] = $row; 737 $num_rows++; 738 } 739 740 @mysql_free_result($this->result); 741 742 // Log number of rows the query returned 743 $this->num_rows = $num_rows; 744 745 // Return number of rows selected 746 $return_val = $this->num_rows; 747 } 748 749 return $return_val; 750 } 751 752 /** 753 * Insert a row into a table. 754 * 755 * <code> 756 * wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) ) 757 * </code> 758 * 759 * @since 2.5.0 760 * @see wpdb::prepare() 761 * 762 * @param string $table table name 763 * @param array $data Data to insert (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped). 764 * @param array|string $format (optional) An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings. 765 * @return int|false The number of rows inserted, or false on error. 766 */ 767 function insert($table, $data, $format = null) { 768 $formats = $format = (array) $format; 769 $fields = array_keys($data); 770 $formatted_fields = array(); 771 foreach ( $fields as $field ) { 772 if ( !empty($format) ) 773 $form = ( $form = array_shift($formats) ) ? $form : $format[0]; 774 elseif ( isset($this->field_types[$field]) ) 775 $form = $this->field_types[$field]; 776 else 777 $form = '%s'; 778 $formatted_fields[] = $form; 779 } 780 $sql = "INSERT INTO `$table` (`" . implode( '`,`', $fields ) . "`) VALUES ('" . implode( "','", $formatted_fields ) . "')"; 781 return $this->query( $this->prepare( $sql, $data) ); 782 } 783 784 785 /** 786 * Update a row in the table 787 * 788 * <code> 789 * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) ) 790 * </code> 791 * 792 * @since 2.5.0 793 * @see wpdb::prepare() 794 * 795 * @param string $table table name 796 * @param array $data Data to update (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped). 797 * @param array $where A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw". 798 * @param array|string $format (optional) An array of formats to be mapped to each of the values in $data. If string, that format will be used for all of the values in $data. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings. 799 * @param array|string $format_where (optional) An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $where will be treated as strings. 800 * @return int|false The number of rows updated, or false on error. 801 */ 802 function update($table, $data, $where, $format = null, $where_format = null) { 803 if ( !is_array( $where ) ) 804 return false; 805 806 $formats = $format = (array) $format; 807 $bits = $wheres = array(); 808 foreach ( (array) array_keys($data) as $field ) { 809 if ( !empty($format) ) 810 $form = ( $form = array_shift($formats) ) ? $form : $format[0]; 811 elseif ( isset($this->field_types[$field]) ) 812 $form = $this->field_types[$field]; 813 else 814 $form = '%s'; 815 $bits[] = "`$field` = {$form}"; 816 } 817 818 $where_formats = $where_format = (array) $where_format; 819 foreach ( (array) array_keys($where) as $field ) { 820 if ( !empty($where_format) ) 821 $form = ( $form = array_shift($where_formats) ) ? $form : $where_format[0]; 822 elseif ( isset($this->field_types[$field]) ) 823 $form = $this->field_types[$field]; 824 else 825 $form = '%s'; 826 $wheres[] = "`$field` = {$form}"; 827 } 828 829 $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ); 830 return $this->query( $this->prepare( $sql, array_merge(array_values($data), array_values($where))) ); 831 } 832 833 /** 834 * Retrieve one variable from the database. 835 * 836 * Executes a SQL query and returns the value from the SQL result. 837 * If the SQL result contains more than one column and/or more than one row, this function returns the value in the column and row specified. 838 * If $query is null, this function returns the value in the specified column and row from the previous SQL result. 839 * 840 * @since 0.71 841 * 842 * @param string|null $query SQL query. If null, use the result from the previous query. 843 * @param int $x (optional) Column of value to return. Indexed from 0. 844 * @param int $y (optional) Row of value to return. Indexed from 0. 845 * @return string Database query result 846 */ 847 function get_var($query=null, $x = 0, $y = 0) { 848 $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; 849 if ( $query ) 850 $this->query($query); 851 852 // Extract var out of cached results based x,y vals 853 if ( !empty( $this->last_result[$y] ) ) { 854 $values = array_values(get_object_vars($this->last_result[$y])); 855 } 856 857 // If there is a value return it else return null 858 return (isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null; 859 } 860 861 /** 862 * Retrieve one row from the database. 863 * 864 * Executes a SQL query and returns the row from the SQL result. 865 * 866 * @since 0.71 867 * 868 * @param string|null $query SQL query. 869 * @param string $output (optional) one of ARRAY_A | ARRAY_N | OBJECT constants. Return an associative array (column => value, ...), a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively. 870 * @param int $y (optional) Row to return. Indexed from 0. 871 * @return mixed Database query result in format specifed by $output 872 */ 873 function get_row($query = null, $output = OBJECT, $y = 0) { 874 $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; 875 if ( $query ) 876 $this->query($query); 877 else 878 return null; 879 880 if ( !isset($this->last_result[$y]) ) 881 return null; 882 883 if ( $output == OBJECT ) { 884 return $this->last_result[$y] ? $this->last_result[$y] : null; 885 } elseif ( $output == ARRAY_A ) { 886 return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null; 887 } elseif ( $output == ARRAY_N ) { 888 return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null; 889 } else { 890 $this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/); 891 } 892 } 893 894 /** 895 * Retrieve one column from the database. 896 * 897 * Executes a SQL query and returns the column from the SQL result. 898 * If the SQL result contains more than one column, this function returns the column specified. 899 * If $query is null, this function returns the specified column from the previous SQL result. 900 * 901 * @since 0.71 902 * 903 * @param string|null $query SQL query. If null, use the result from the previous query. 904 * @param int $x Column to return. Indexed from 0. 905 * @return array Database query result. Array indexed from 0 by SQL result row number. 906 */ 907 function get_col($query = null , $x = 0) { 908 if ( $query ) 909 $this->query($query); 910 911 $new_array = array(); 912 // Extract the column values 913 for ( $i=0; $i < count($this->last_result); $i++ ) { 914 $new_array[$i] = $this->get_var(null, $x, $i); 915 } 916 return $new_array; 917 } 918 919 /** 920 * Retrieve an entire SQL result set from the database (i.e., many rows) 921 * 922 * Executes a SQL query and returns the entire SQL result. 923 * 924 * @since 0.71 925 * 926 * @param string $query SQL query. 927 * @param string $output (optional) ane of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. With one of the first three, return an array of rows indexed from 0 by SQL result row number. Each row is an associative array (column => value, ...), a numerically indexed array (0 => value, ...), or an object. ( ->column = value ), respectively. With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value. Duplicate keys are discarded. 928 * @return mixed Database query results 929 */ 930 function get_results($query = null, $output = OBJECT) { 931 $this->func_call = "\$db->get_results(\"$query\", $output)"; 932 933 if ( $query ) 934 $this->query($query); 935 else 936 return null; 937 938 if ( $output == OBJECT ) { 939 // Return an integer-keyed array of row objects 940 return $this->last_result; 941 } elseif ( $output == OBJECT_K ) { 942 // Return an array of row objects with keys from column 1 943 // (Duplicates are discarded) 944 foreach ( $this->last_result as $row ) { 945 $key = array_shift( get_object_vars( $row ) ); 946 if ( !isset( $new_array[ $key ] ) ) 947 $new_array[ $key ] = $row; 948 } 949 return $new_array; 950 } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { 951 // Return an integer-keyed array of... 952 if ( $this->last_result ) { 953 $i = 0; 954 foreach( (array) $this->last_result as $row ) { 955 if ( $output == ARRAY_N ) { 956 // ...integer-keyed row arrays 957 $new_array[$i] = array_values( get_object_vars( $row ) ); 958 } else { 959 // ...column name-keyed row arrays 960 $new_array[$i] = get_object_vars( $row ); 961 } 962 ++$i; 963 } 964 return $new_array; 965 } 966 } 967 } 968 969 /** 970 * Retrieve column metadata from the last query. 971 * 972 * @since 0.71 973 * 974 * @param string $info_type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill 975 * @param int $col_offset 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type 976 * @return mixed Column Results 977 */ 978 function get_col_info($info_type = 'name', $col_offset = -1) { 979 if ( $this->col_info ) { 980 if ( $col_offset == -1 ) { 981 $i = 0; 982 foreach( (array) $this->col_info as $col ) { 983 $new_array[$i] = $col->{$info_type}; 984 $i++; 985 } 986 return $new_array; 987 } else { 988 return $this->col_info[$col_offset]->{$info_type}; 989 } 990 } 991 } 992 993 /** 994 * Starts the timer, for debugging purposes. 995 * 996 * @since 1.5.0 997 * 998 * @return true 999 */ 1000 function timer_start() { 1001 $mtime = microtime(); 1002 $mtime = explode(' ', $mtime); 1003 $this->time_start = $mtime[1] + $mtime[0]; 1004 return true; 1005 } 1006 1007 /** 1008 * Stops the debugging timer. 1009 * 1010 * @since 1.5.0 1011 * 1012 * @return int Total time spent on the query, in milliseconds 1013 */ 1014 function timer_stop() { 1015 $mtime = microtime(); 1016 $mtime = explode(' ', $mtime); 1017 $time_end = $mtime[1] + $mtime[0]; 1018 $time_total = $time_end - $this->time_start; 1019 return $time_total; 1020 } 1021 1022 /** 1023 * Wraps errors in a nice header and footer and dies. 1024 * 1025 * Will not die if wpdb::$show_errors is true 1026 * 1027 * @since 1.5.0 1028 * 1029 * @param string $message The Error message 1030 * @param string $error_code (optional) A Computer readable string to identify the error. 1031 * @return false|void 1032 */ 1033 function bail($message, $error_code = '500') { 1034 if ( !$this->show_errors ) { 1035 if ( class_exists('WP_Error') ) 1036 $this->error = new WP_Error($error_code, $message); 1037 else 1038 $this->error = $message; 1039 return false; 1040 } 1041 wp_die($message); 1042 } 1043 1044 /** 1045 * Whether or not MySQL database is at least the required minimum version. 1046 * 1047 * @since 2.5.0 1048 * @uses $wp_version 1049 * 1050 * @return WP_Error 1051 */ 1052 function check_database_version() 1053 { 1054 global $wp_version; 1055 // Make sure the server has MySQL 4.0 1056 if ( version_compare($this->db_version(), '4.0.0', '<') ) 1057 return new WP_Error('database_version',sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version)); 1058 } 1059 1060 /** 1061 * Whether of not the database supports collation. 1062 * 1063 * Called when WordPress is generating the table scheme. 1064 * 1065 * @since 2.5.0 1066 * 1067 * @return bool True if collation is supported, false if version does not 1068 */ 1069 function supports_collation() { 1070 return $this->has_cap( 'collation' ); 1071 } 1072 1073 /** 1074 * Generic function to determine if a database supports a particular feature 1075 * @param string $db_cap the feature 1076 * @param false|string|resource $dbh_or_table (not implemented) Which database to test. False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource. 1077 * @return bool 1078 */ 1079 function has_cap( $db_cap ) { 1080 $version = $this->db_version(); 1081 1082 switch ( strtolower( $db_cap ) ) : 1083 case 'collation' : // @since 2.5.0 1084 case 'group_concat' : // @since 2.7 1085 case 'subqueries' : // @since 2.7 1086 return version_compare($version, '4.1', '>='); 1087 break; 1088 endswitch; 1089 1090 return false; 1091 } 1092 1093 /** 1094 * Retrieve the name of the function that called wpdb. 1095 * 1096 * Requires PHP 4.3 and searches up the list of functions until it reaches 1097 * the one that would most logically had called this method. 1098 * 1099 * @since 2.5.0 1100 * 1101 * @return string The name of the calling function 1102 */ 1103 function get_caller() { 1104 // requires PHP 4.3+ 1105 if ( !is_callable('debug_backtrace') ) 1106 return ''; 1107 1108 $bt = debug_backtrace(); 1109 $caller = array(); 1110 1111 $bt = array_reverse( $bt ); 1112 foreach ( (array) $bt as $call ) { 1113 if ( @$call['class'] == __CLASS__ ) 1114 continue; 1115 $function = $call['function']; 1116 if ( isset( $call['class'] ) ) 1117 $function = $call['class'] . "->$function"; 1118 $caller[] = $function; 1119 } 1120 $caller = join( ', ', $caller ); 1121 1122 return $caller; 1123 } 1124 1125 /** 1126 * The database version number 1127 * @param false|string|resource $dbh_or_table (not implemented) Which database to test. False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource. 1128 * @return false|string false on failure, version number on success 1129 */ 1130 function db_version() { 1131 return preg_replace('/[^0-9.].*/', '', mysql_get_server_info( $this->dbh )); 1132 } 1133 } 1134 1135 if ( ! isset($wpdb) ) { 1136 /** 1137 * WordPress Database Object, if it isn't set already in wp-content/db.php 1138 * @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database 1139 * @since 0.71 1140 */ 11 * WordPress Database Object, if it isn't set already in wp-content/db.php 12 * @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database 13 * @since 0.71 14 */ 1141 15 $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 1142 16 } 1143 ?> -
wp-config-sample.php
1 1 <?php 2 /** 2 /** 3 3 * The base configurations of the WordPress. 4 4 * 5 5 * This file has the following configurations: MySQL settings, Table Prefix, … … 18 18 /** The name of the database for WordPress */ 19 19 define('DB_NAME', 'putyourdbnamehere'); 20 20 21 /** MySQL database username */21 /** Database username */ 22 22 define('DB_USER', 'usernamehere'); 23 23 24 /** MySQL database password */24 /** Database password */ 25 25 define('DB_PASSWORD', 'yourpasswordhere'); 26 26 27 /** MySQLhostname */27 /** Database hostname */ 28 28 define('DB_HOST', 'localhost'); 29 29 30 /** Database Type. Defaults to mysql */ 31 define('DB_TYPE', 'mysql'); 32 30 33 /** Database Charset to use in creating database tables. */ 31 34 define('DB_CHARSET', 'utf8'); 32 35 … … 70 73 71 74 /** WordPress absolute path to the Wordpress directory. */ 72 75 if ( !defined('ABSPATH') ) 73 define('ABSPATH', dirname(__FILE__) . '/');76 define('ABSPATH', dirname(__FILE__) . '/'); 74 77 75 78 /** Sets up WordPress vars and included files. */ 76 require_once(ABSPATH . 'wp-settings.php'); 79 require_once(ABSPATH . 'wp-settings.php'); 80 No newline at end of file -
wp-admin/includes/schema.php
19 19 // Declare these as global in case schema.php is included from a function. 20 20 global $wpdb, $wp_queries; 21 21 22 if ( $wpdb->has_cap( 'collation' ) ) {23 if ( ! empty($wpdb->charset) )24 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";25 if ( ! empty($wpdb->collate) )26 $charset_collate .= " COLLATE $wpdb->collate";22 if ( DB_TYPE == 'mysql' && $wpdb->has_cap( 'collation' ) ) { 23 if ( ! empty($wpdb->charset) ) 24 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 25 if ( ! empty($wpdb->collate) ) 26 $charset_collate .= " COLLATE $wpdb->collate"; 27 27 } 28 28 29 29 /** Create WordPress database tables SQL */ … … 54 54 PRIMARY KEY (object_id,term_taxonomy_id), 55 55 KEY term_taxonomy_id (term_taxonomy_id) 56 56 ) $charset_collate; 57 CREATE TABLE $wpdb->commentmeta (58 meta_id bigint(20) unsigned NOT NULL auto_increment,59 comment_id bigint(20) unsigned NOT NULL default '0',60 meta_key varchar(255) default NULL,61 meta_value longtext,62 PRIMARY KEY (meta_id),63 KEY comment_id (comment_id),64 KEY meta_key (meta_key)65 ) $charset_collate;66 57 CREATE TABLE $wpdb->comments ( 67 58 comment_ID bigint(20) unsigned NOT NULL auto_increment, 68 59 comment_post_ID bigint(20) unsigned NOT NULL default '0', … … 108 99 option_name varchar(64) NOT NULL default '', 109 100 option_value longtext NOT NULL, 110 101 autoload varchar(20) NOT NULL default 'yes', 111 PRIMARY KEY (option_ name),112 KEY option_ id (option_id)102 PRIMARY KEY (option_id,blog_id,option_name), 103 KEY option_name (option_name) 113 104 ) $charset_collate; 114 105 CREATE TABLE $wpdb->postmeta ( 115 106 meta_id bigint(20) unsigned NOT NULL auto_increment, … … 182 173 * @uses $wp_db_version 183 174 */ 184 175 function populate_options() { 185 global $wpdb, $wp_db_version;176 global $wpdb, $wp_db_version; 186 177 187 $guessurl = wp_guess_url();178 $guessurl = wp_guess_url(); 188 179 189 do_action('populate_options');180 do_action('populate_options'); 190 181 191 if ( ini_get('safe_mode') ) {192 // Safe mode screws up mkdir(), so we must use a flat structure.193 $uploads_use_yearmonth_folders = 0;194 $upload_path = WP_CONTENT_DIR;195 } else {196 $uploads_use_yearmonth_folders = 1;197 $upload_path = WP_CONTENT_DIR . '/uploads';198 }182 if ( ini_get('safe_mode') ) { 183 // Safe mode screws up mkdir(), so we must use a flat structure. 184 $uploads_use_yearmonth_folders = 0; 185 $upload_path = WP_CONTENT_DIR; 186 } else { 187 $uploads_use_yearmonth_folders = 1; 188 $upload_path = WP_CONTENT_DIR . '/uploads'; 189 } 199 190 200 $options = array( 201 'siteurl' => $guessurl, 202 'blogname' => __('My Blog'), 203 'blogdescription' => __('Just another WordPress weblog'), 204 'users_can_register' => 0, 205 'admin_email' => 'you@example.com', 206 'start_of_week' => 1, 207 'use_balanceTags' => 0, 208 'use_smilies' => 1, 209 'require_name_email' => 1, 210 'comments_notify' => 1, 211 'posts_per_rss' => 10, 212 'rss_use_excerpt' => 0, 213 'mailserver_url' => 'mail.example.com', 214 'mailserver_login' => 'login@example.com', 215 'mailserver_pass' => 'password', 216 'mailserver_port' => 110, 217 'default_category' => 1, 218 'default_comment_status' => 'open', 219 'default_ping_status' => 'open', 220 'default_pingback_flag' => 1, 221 'default_post_edit_rows' => 10, 222 'posts_per_page' => 10, 223 /* translators: default date format, see http://php.net/date */ 224 'date_format' => __('F j, Y'), 225 /* translators: default time format, see http://php.net/date */ 226 'time_format' => __('g:i a'), 227 /* translators: links last updated date format, see http://php.net/date */ 228 'links_updated_date_format' => __('F j, Y g:i a'), 229 'links_recently_updated_prepend' => '<em>', 230 'links_recently_updated_append' => '</em>', 231 'links_recently_updated_time' => 120, 232 'comment_moderation' => 0, 233 'moderation_notify' => 1, 234 'permalink_structure' => '', 235 'gzipcompression' => 0, 236 'hack_file' => 0, 237 'blog_charset' => 'UTF-8', 238 'moderation_keys' => '', 239 'active_plugins' => array(), 240 'home' => $guessurl, 241 'category_base' => '', 242 'ping_sites' => 'http://rpc.pingomatic.com/', 243 'advanced_edit' => 0, 244 'comment_max_links' => 2, 245 'gmt_offset' => date('Z') / 3600, 191 $options = array( 192 'siteurl' => $guessurl, 193 'blogname' => __('My Blog'), 194 'blogdescription' => __('Just another WordPress weblog'), 195 'users_can_register' => 0, 196 'admin_email' => 'you@example.com', 197 'start_of_week' => 1, 198 'use_balanceTags' => 0, 199 'use_smilies' => 1, 200 'require_name_email' => 1, 201 'comments_notify' => 1, 202 'posts_per_rss' => 10, 203 'rss_excerpt_length' => 50, 204 'rss_use_excerpt' => 0, 205 'mailserver_url' => 'mail.example.com', 206 'mailserver_login' => 'login@example.com', 207 'mailserver_pass' => 'password', 208 'mailserver_port' => 110, 209 'default_category' => 1, 210 'default_comment_status' => 'open', 211 'default_ping_status' => 'open', 212 'default_pingback_flag' => 1, 213 'default_post_edit_rows' => 10, 214 'posts_per_page' => 10, 215 /* translators: default date format, see http://php.net/date */ 216 'date_format' => __('F j, Y'), 217 /* translators: default time format, see http://php.net/date */ 218 'time_format' => __('g:i a'), 219 /* translators: links last updated date format, see http://php.net/date */ 220 'links_updated_date_format' => __('F j, Y g:i a'), 221 'links_recently_updated_prepend' => '<em>', 222 'links_recently_updated_append' => '</em>', 223 'links_recently_updated_time' => 120, 224 'comment_moderation' => 0, 225 'moderation_notify' => 1, 226 'permalink_structure' => '', 227 'gzipcompression' => 0, 228 'hack_file' => 0, 229 'blog_charset' => 'UTF-8', 230 'moderation_keys' => '', 231 'active_plugins' => array(), 232 'home' => $guessurl, 233 'category_base' => '', 234 'ping_sites' => 'http://rpc.pingomatic.com/', 235 'advanced_edit' => 0, 236 'comment_max_links' => 2, 237 'gmt_offset' => date('Z') / 3600, 246 238 247 // 1.5248 'default_email_category' => 1,249 'recently_edited' => '',250 'use_linksupdate' => 0,251 'template' => 'default',252 'stylesheet' => 'default',253 'comment_whitelist' => 1,254 'blacklist_keys' => '',255 'comment_registration' => 0,256 'rss_language' => 'en',257 'html_type' => 'text/html',239 // 1.5 240 'default_email_category' => 1, 241 'recently_edited' => '', 242 'use_linksupdate' => 0, 243 'template' => 'default', 244 'stylesheet' => 'default', 245 'comment_whitelist' => 1, 246 'blacklist_keys' => '', 247 'comment_registration' => 0, 248 'rss_language' => 'en', 249 'html_type' => 'text/html', 258 250 259 // 1.5.1260 'use_trackback' => 0,251 // 1.5.1 252 'use_trackback' => 0, 261 253 262 // 2.0263 'default_role' => 'subscriber',264 'db_version' => $wp_db_version,254 // 2.0 255 'default_role' => 'subscriber', 256 'db_version' => $wp_db_version, 265 257 266 // 2.0.1267 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,268 'upload_path' => $upload_path,258 // 2.0.1 259 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 260 'upload_path' => $upload_path, 269 261 270 // 2.0.3271 'secret' => wp_generate_password(64),262 // 2.0.3 263 'secret' => wp_generate_password(64), 272 264 273 // 2.1274 'blog_public' => '1',275 'default_link_category' => 2,276 'show_on_front' => 'posts',265 // 2.1 266 'blog_public' => '1', 267 'default_link_category' => 2, 268 'show_on_front' => 'posts', 277 269 278 // 2.2279 'tag_base' => '',270 // 2.2 271 'tag_base' => '', 280 272 281 // 2.5282 'show_avatars' => '1',283 'avatar_rating' => 'G',284 'upload_url_path' => '',285 'thumbnail_size_w' => 150,286 'thumbnail_size_h' => 150,287 'thumbnail_crop' => 1,288 'medium_size_w' => 300,289 'medium_size_h' => 300,273 // 2.5 274 'show_avatars' => '1', 275 'avatar_rating' => 'G', 276 'upload_url_path' => '', 277 'thumbnail_size_w' => 150, 278 'thumbnail_size_h' => 150, 279 'thumbnail_crop' => 1, 280 'medium_size_w' => 300, 281 'medium_size_h' => 300, 290 282 291 // 2.6292 'avatar_default' => 'mystery',293 'enable_app' => 0,294 'enable_xmlrpc' => 0,283 // 2.6 284 'avatar_default' => 'mystery', 285 'enable_app' => 0, 286 'enable_xmlrpc' => 0, 295 287 296 // 2.7297 'large_size_w' => 1024,298 'large_size_h' => 1024,299 'image_default_link_type' => 'file',300 'image_default_size' => '',301 'image_default_align' => '',302 'close_comments_for_old_posts' => 0,303 'close_comments_days_old' => 14,304 'thread_comments' => 0,305 'thread_comments_depth' => 5,306 'page_comments' => 1,307 'comments_per_page' => 50,308 'default_comments_page' => 'newest',309 'comment_order' => 'asc',310 'sticky_posts' => array(),311 'widget_categories' => array(),312 'widget_text' => array(),313 'widget_rss' => array(),288 // 2.7 289 'large_size_w' => 1024, 290 'large_size_h' => 1024, 291 'image_default_link_type' => 'file', 292 'image_default_size' => '', 293 'image_default_align' => '', 294 'close_comments_for_old_posts' => 0, 295 'close_comments_days_old' => 14, 296 'thread_comments' => 0, 297 'thread_comments_depth' => 5, 298 'page_comments' => 1, 299 'comments_per_page' => 50, 300 'default_comments_page' => 'newest', 301 'comment_order' => 'asc', 302 'sticky_posts' => array(), 303 'widget_categories' => array(), 304 'widget_text' => array(), 305 'widget_rss' => array(), 314 306 315 // 2.8316 'timezone_string' => ''317 );307 // 2.8 308 'timezone_string' => '' 309 ); 318 310 319 // Set autoload to no for these options320 $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );311 // Set autoload to no for these options 312 $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); 321 313 322 $existing_options = $wpdb->get_col("SELECT option_name FROM $wpdb->options");314 $existing_options = $wpdb->get_col("SELECT option_name FROM $wpdb->options"); 323 315 324 $insert = '';325 foreach ( $options as $option => $value ) {326 if ( in_array($option, $existing_options) )327 continue;328 if ( in_array($option, $fat_options) )329 $autoload = 'no';330 else331 $autoload = 'yes';316 $insert = ''; 317 foreach ( $options as $option => $value ) { 318 if ( in_array($option, $existing_options) ) 319 continue; 320 if ( in_array($option, $fat_options) ) 321 $autoload = 'no'; 322 else 323 $autoload = 'yes'; 332 324 333 $option = $wpdb->escape($option);334 if ( is_array($value) )335 $value = serialize($value);336 $value = $wpdb->escape($value);337 if ( !empty($insert) )338 $insert .= ', ';339 $insert .= "('$option', '$value', '$autoload')";340 }325 $option = $wpdb->escape($option); 326 if ( is_array($value) ) 327 $value = serialize($value); 328 $value = $wpdb->escape($value); 329 if ( !empty($insert) ) 330 $insert .= ', '; 331 $insert .= "('$option', '$value', '$autoload')"; 332 } 341 333 342 if ( !empty($insert) )343 $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert);334 if ( !empty($insert) ) 335 $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert); 344 336 345 // in case it is set, but blank, update "home"346 if ( !__get_option('home') ) update_option('home', $guessurl);337 // in case it is set, but blank, update "home" 338 if ( !__get_option('home') ) update_option('home', $guessurl); 347 339 348 // Delete unused options349 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts',350 'page_uris', 'rewrite_rules', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length');351 foreach ($unusedoptions as $option)352 delete_option($option);340 // Delete unused options 341 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 342 'page_uris', 'rewrite_rules', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed'); 343 foreach ($unusedoptions as $option) 344 delete_option($option); 353 345 } 354 346 355 347 /** … … 358 350 * @since 2.0.0 359 351 */ 360 352 function populate_roles() { 361 populate_roles_160();362 populate_roles_210();363 populate_roles_230();364 populate_roles_250();365 populate_roles_260();366 populate_roles_270();367 populate_roles_280();353 populate_roles_160(); 354 populate_roles_210(); 355 populate_roles_230(); 356 populate_roles_250(); 357 populate_roles_260(); 358 populate_roles_270(); 359 populate_roles_280(); 368 360 } 369 361 370 362 /** … … 373 365 * @since 2.0.0 374 366 */ 375 367 function populate_roles_160() { 376 // Add roles368 // Add roles 377 369 378 // Dummy gettext calls to get strings in the catalog.379 /* translators: user role */380 _x('Administrator', 'User role');381 /* translators: user role */382 _x('Editor', 'User role');383 /* translators: user role */384 _x('Author', 'User role');385 /* translators: user role */386 _x('Contributor', 'User role');387 /* translators: user role */388 _x('Subscriber', 'User role');370 // Dummy gettext calls to get strings in the catalog. 371 /* translators: user role */ 372 _x('Administrator', 'User role'); 373 /* translators: user role */ 374 _x('Editor', 'User role'); 375 /* translators: user role */ 376 _x('Author', 'User role'); 377 /* translators: user role */ 378 _x('Contributor', 'User role'); 379 /* translators: user role */ 380 _x('Subscriber', 'User role'); 389 381 390 add_role('administrator', 'Administrator');391 add_role('editor', 'Editor');392 add_role('author', 'Author');393 add_role('contributor', 'Contributor');394 add_role('subscriber', 'Subscriber');382 add_role('administrator', 'Administrator'); 383 add_role('editor', 'Editor'); 384 add_role('author', 'Author'); 385 add_role('contributor', 'Contributor'); 386 add_role('subscriber', 'Subscriber'); 395 387 396 // Add caps for Administrator role397 $role =& get_role('administrator');398 $role->add_cap('switch_themes');399 $role->add_cap('edit_themes');400 $role->add_cap('activate_plugins');401 $role->add_cap('edit_plugins');402 $role->add_cap('edit_users');403 $role->add_cap('edit_files');404 $role->add_cap('manage_options');405 $role->add_cap('moderate_comments');406 $role->add_cap('manage_categories');407 $role->add_cap('manage_links');408 $role->add_cap('upload_files');409 $role->add_cap('import');410 $role->add_cap('unfiltered_html');411 $role->add_cap('edit_posts');412 $role->add_cap('edit_others_posts');413 $role->add_cap('edit_published_posts');414 $role->add_cap('publish_posts');415 $role->add_cap('edit_pages');416 $role->add_cap('read');417 $role->add_cap('level_10');418 $role->add_cap('level_9');419 $role->add_cap('level_8');420 $role->add_cap('level_7');421 $role->add_cap('level_6');422 $role->add_cap('level_5');423 $role->add_cap('level_4');424 $role->add_cap('level_3');425 $role->add_cap('level_2');426 $role->add_cap('level_1');427 $role->add_cap('level_0');388 // Add caps for Administrator role 389 $role =& get_role('administrator'); 390 $role->add_cap('switch_themes'); 391 $role->add_cap('edit_themes'); 392 $role->add_cap('activate_plugins'); 393 $role->add_cap('edit_plugins'); 394 $role->add_cap('edit_users'); 395 $role->add_cap('edit_files'); 396 $role->add_cap('manage_options'); 397 $role->add_cap('moderate_comments'); 398 $role->add_cap('manage_categories'); 399 $role->add_cap('manage_links'); 400 $role->add_cap('upload_files'); 401 $role->add_cap('import'); 402 $role->add_cap('unfiltered_html'); 403 $role->add_cap('edit_posts'); 404 $role->add_cap('edit_others_posts'); 405 $role->add_cap('edit_published_posts'); 406 $role->add_cap('publish_posts'); 407 $role->add_cap('edit_pages'); 408 $role->add_cap('read'); 409 $role->add_cap('level_10'); 410 $role->add_cap('level_9'); 411 $role->add_cap('level_8'); 412 $role->add_cap('level_7'); 413 $role->add_cap('level_6'); 414 $role->add_cap('level_5'); 415 $role->add_cap('level_4'); 416 $role->add_cap('level_3'); 417 $role->add_cap('level_2'); 418 $role->add_cap('level_1'); 419 $role->add_cap('level_0'); 428 420 429 // Add caps for Editor role430 $role =& get_role('editor');431 $role->add_cap('moderate_comments');432 $role->add_cap('manage_categories');433 $role->add_cap('manage_links');434 $role->add_cap('upload_files');435 $role->add_cap('unfiltered_html');436 $role->add_cap('edit_posts');437 $role->add_cap('edit_others_posts');438 $role->add_cap('edit_published_posts');439 $role->add_cap('publish_posts');440 $role->add_cap('edit_pages');441 $role->add_cap('read');442 $role->add_cap('level_7');443 $role->add_cap('level_6');444 $role->add_cap('level_5');445 $role->add_cap('level_4');446 $role->add_cap('level_3');447 $role->add_cap('level_2');448 $role->add_cap('level_1');449 $role->add_cap('level_0');421 // Add caps for Editor role 422 $role =& get_role('editor'); 423 $role->add_cap('moderate_comments'); 424 $role->add_cap('manage_categories'); 425 $role->add_cap('manage_links'); 426 $role->add_cap('upload_files'); 427 $role->add_cap('unfiltered_html'); 428 $role->add_cap('edit_posts'); 429 $role->add_cap('edit_others_posts'); 430 $role->add_cap('edit_published_posts'); 431 $role->add_cap('publish_posts'); 432 $role->add_cap('edit_pages'); 433 $role->add_cap('read'); 434 $role->add_cap('level_7'); 435 $role->add_cap('level_6'); 436 $role->add_cap('level_5'); 437 $role->add_cap('level_4'); 438 $role->add_cap('level_3'); 439 $role->add_cap('level_2'); 440 $role->add_cap('level_1'); 441 $role->add_cap('level_0'); 450 442 451 // Add caps for Author role452 $role =& get_role('author');453 $role->add_cap('upload_files');454 $role->add_cap('edit_posts');455 $role->add_cap('edit_published_posts');456 $role->add_cap('publish_posts');457 $role->add_cap('read');458 $role->add_cap('level_2');459 $role->add_cap('level_1');460 $role->add_cap('level_0');443 // Add caps for Author role 444 $role =& get_role('author'); 445 $role->add_cap('upload_files'); 446 $role->add_cap('edit_posts'); 447 $role->add_cap('edit_published_posts'); 448 $role->add_cap('publish_posts'); 449 $role->add_cap('read'); 450 $role->add_cap('level_2'); 451 $role->add_cap('level_1'); 452 $role->add_cap('level_0'); 461 453 462 // Add caps for Contributor role463 $role =& get_role('contributor');464 $role->add_cap('edit_posts');465 $role->add_cap('read');466 $role->add_cap('level_1');467 $role->add_cap('level_0');454 // Add caps for Contributor role 455 $role =& get_role('contributor'); 456 $role->add_cap('edit_posts'); 457 $role->add_cap('read'); 458 $role->add_cap('level_1'); 459 $role->add_cap('level_0'); 468 460 469 // Add caps for Subscriber role470 $role =& get_role('subscriber');471 $role->add_cap('read');472 $role->add_cap('level_0');461 // Add caps for Subscriber role 462 $role =& get_role('subscriber'); 463 $role->add_cap('read'); 464 $role->add_cap('level_0'); 473 465 } 474 466 475 467 /** … … 478 470 * @since 2.1.0 479 471 */ 480 472 function populate_roles_210() { 481 $roles = array('administrator', 'editor');482 foreach ($roles as $role) {483 $role =& get_role($role);484 if ( empty($role) )485 continue;473 $roles = array('administrator', 'editor'); 474 foreach ($roles as $role) { 475 $role =& get_role($role); 476 if ( empty($role) ) 477 continue; 486 478 487 $role->add_cap('edit_others_pages');488 $role->add_cap('edit_published_pages');489 $role->add_cap('publish_pages');490 $role->add_cap('delete_pages');491 $role->add_cap('delete_others_pages');492 $role->add_cap('delete_published_pages');493 $role->add_cap('delete_posts');494 $role->add_cap('delete_others_posts');495 $role->add_cap('delete_published_posts');496 $role->add_cap('delete_private_posts');497 $role->add_cap('edit_private_posts');498 $role->add_cap('read_private_posts');499 $role->add_cap('delete_private_pages');500 $role->add_cap('edit_private_pages');501 $role->add_cap('read_private_pages');502 }479 $role->add_cap('edit_others_pages'); 480 $role->add_cap('edit_published_pages'); 481 $role->add_cap('publish_pages'); 482 $role->add_cap('delete_pages'); 483 $role->add_cap('delete_others_pages'); 484 $role->add_cap('delete_published_pages'); 485 $role->add_cap('delete_posts'); 486 $role->add_cap('delete_others_posts'); 487 $role->add_cap('delete_published_posts'); 488 $role->add_cap('delete_private_posts'); 489 $role->add_cap('edit_private_posts'); 490 $role->add_cap('read_private_posts'); 491 $role->add_cap('delete_private_pages'); 492 $role->add_cap('edit_private_pages'); 493 $role->add_cap('read_private_pages'); 494 } 503 495 504 $role =& get_role('administrator');505 if ( ! empty($role) ) {506 $role->add_cap('delete_users');507 $role->add_cap('create_users');508 }496 $role =& get_role('administrator'); 497 if ( ! empty($role) ) { 498 $role->add_cap('delete_users'); 499 $role->add_cap('create_users'); 500 } 509 501 510 $role =& get_role('author');511 if ( ! empty($role) ) {512 $role->add_cap('delete_posts');513 $role->add_cap('delete_published_posts');514 }502 $role =& get_role('author'); 503 if ( ! empty($role) ) { 504 $role->add_cap('delete_posts'); 505 $role->add_cap('delete_published_posts'); 506 } 515 507 516 $role =& get_role('contributor');517 if ( ! empty($role) ) {518 $role->add_cap('delete_posts');519 }508 $role =& get_role('contributor'); 509 if ( ! empty($role) ) { 510 $role->add_cap('delete_posts'); 511 } 520 512 } 521 513 522 514 /** … … 525 517 * @since 2.3.0 526 518 */ 527 519 function populate_roles_230() { 528 $role =& get_role( 'administrator' );520 $role =& get_role( 'administrator' ); 529 521 530 if ( !empty( $role ) ) {531 $role->add_cap( 'unfiltered_upload' );532 }522 if ( !empty( $role ) ) { 523 $role->add_cap( 'unfiltered_upload' ); 524 } 533 525 } 534 526 535 527 /** … … 538 530 * @since 2.5.0 539 531 */ 540 532 function populate_roles_250() { 541 $role =& get_role( 'administrator' );533 $role =& get_role( 'administrator' ); 542 534 543 if ( !empty( $role ) ) {544 $role->add_cap( 'edit_dashboard' );545 }535 if ( !empty( $role ) ) { 536 $role->add_cap( 'edit_dashboard' ); 537 } 546 538 } 547 539 548 540 /** … … 551 543 * @since 2.6.0 552 544 */ 553 545 function populate_roles_260() { 554 $role =& get_role( 'administrator' );546 $role =& get_role( 'administrator' ); 555 547 556 if ( !empty( $role ) ) {557 $role->add_cap( 'update_plugins' );558 $role->add_cap( 'delete_plugins' );559 }548 if ( !empty( $role ) ) { 549 $role->add_cap( 'update_plugins' ); 550 $role->add_cap( 'delete_plugins' ); 551 } 560 552 } 561 553 562 554 /** … … 565 557 * @since 2.7.0 566 558 */ 567 559 function populate_roles_270() { 568 $role =& get_role( 'administrator' );560 $role =& get_role( 'administrator' ); 569 561 570 if ( !empty( $role ) ) {571 $role->add_cap( 'install_plugins' );572 $role->add_cap( 'update_themes' );573 }562 if ( !empty( $role ) ) { 563 $role->add_cap( 'install_plugins' ); 564 $role->add_cap( 'update_themes' ); 565 } 574 566 } 575 567 576 568 /** … … 579 571 * @since 2.8.0 580 572 */ 581 573 function populate_roles_280() { 582 $role =& get_role( 'administrator' );574 $role =& get_role( 'administrator' ); 583 575 584 if ( !empty( $role ) ) {585 $role->add_cap( 'install_themes' );586 }576 if ( !empty( $role ) ) { 577 $role->add_cap( 'install_themes' ); 578 } 587 579 } 588 580 589 581 ?> -
wp-admin/setup-config.php
35 35 36 36 $configFile = file(ABSPATH . 'wp-config-sample.php'); 37 37 38 if ( !is_writable(ABSPATH)) 39 wp_die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually."); 40 38 41 // Check if wp-config.php has been created 39 42 if (file_exists(ABSPATH . 'wp-config.php')) 40 43 wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>"); 41 44 42 // Check if wp-config.php exists above the root directory but is not part of another install43 if (file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp- settings.php'))45 // Check if wp-config.php exists above the root directory 46 if (file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-load.php')) 44 47 wp_die("<p>The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>"); 45 48 46 49 if (isset($_GET['step'])) … … 83 86 <li>Database username</li> 84 87 <li>Database password</li> 85 88 <li>Database host</li> 89 <li>Database type</li> 86 90 <li>Table prefix (if you want to run more than one WordPress in a single database) </li> 87 91 </ol> 88 92 <p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p> … … 106 110 <tr> 107 111 <th scope="row"><label for="uname">User Name</label></th> 108 112 <td><input name="uname" id="uname" type="text" size="25" value="username" /></td> 109 <td>Your MySQLusername</td>113 <td>Your DB username</td> 110 114 </tr> 111 115 <tr> 112 116 <th scope="row"><label for="pwd">Password</label></th> 113 117 <td><input name="pwd" id="pwd" type="text" size="25" value="password" /></td> 114 <td>...and MySQLpassword.</td>118 <td>...and DB password.</td> 115 119 </tr> 116 120 <tr> 117 121 <th scope="row"><label for="dbhost">Database Host</label></th> 118 122 <td><input name="dbhost" id="dbhost" type="text" size="25" value="localhost" /></td> 119 <td> 99% chance you won't need to change this value.</td>123 <td>DB host.</td> 120 124 </tr> 121 125 <tr> 126 <th scope="row"><label for="dbtype">Database Type</label></th> 127 <td> 128 <select name="dbtype" id="dbtype"> 129 <?php 130 $folders = array(); 131 if (is_dir(ABSPATH . 'wp-includes/wp-db/')) { 132 $dir = ABSPATH . 'wp-includes/wp-db/'; 133 $handle = dir($dir); 134 while ($filename = $handle->read()) { 135 $restricted = array('.','..','.svn'); 136 $path = realpath($dir.$filename); 137 if (is_dir($path) && !in_array($filename,$restricted)) { 138 if ($path !== '/') { 139 $path .= '/'; 140 } 141 if (is_readable($path)) { 142 $folders[] = $filename; 143 } 144 } 145 } 146 } 147 if (empty($folders)) { 148 $folders[] = 'mysql'; // should always have at least mysql 149 } 150 foreach($folders as $folder) { 151 // mysql as default 152 if ($folder == 'mysql') { 153 echo "<option value=\"$folder\" selected=\"true\">MySQL</option>\n"; 154 } elseif ($folder == 'sqlsrv') { 155 echo "<option value=\"$folder\">SQL Server using MS PHP driver (SQLSRV; PHP5 & Win req.)</option>\n"; 156 } elseif ($folder == 'mssql') { 157 echo "<option value=\"$folder\">SQL Server using PHP native driver (MSSQL)</option>\n"; 158 } else { 159 echo "<option value=\"$folder\">$folder</option>\n"; 160 } 161 } 162 ?> 163 </select> 164 <td>The DB Type.</td> 165 </tr> 166 <tr> 122 167 <th scope="row"><label for="prefix">Table Prefix</label></th> 123 168 <td><input name="prefix" id="prefix" type="text" id="prefix" value="wp_" size="25" /></td> 124 169 <td>If you want to run multiple WordPress installations in a single database, change this.</td> … … 134 179 $uname = trim($_POST['uname']); 135 180 $passwrd = trim($_POST['pwd']); 136 181 $dbhost = trim($_POST['dbhost']); 182 $dbtype = trim($_POST['dbtype']); 137 183 $prefix = trim($_POST['prefix']); 138 184 if (empty($prefix)) $prefix = 'wp_'; 139 185 … … 145 191 define('DB_USER', $uname); 146 192 define('DB_PASSWORD', $passwrd); 147 193 define('DB_HOST', $dbhost); 194 define('DB_TYPE', $dbtype); 148 195 /**#@-*/ 149 196 150 197 // We'll fail here if the values are no good. … … 152 199 if ( !empty($wpdb->error) ) 153 200 wp_die($wpdb->error->get_error_message()); 154 201 202 $handle = fopen(ABSPATH . 'wp-config.php', 'w'); 203 155 204 foreach ($configFile as $line_num => $line) { 156 205 switch (substr($line,0,16)) { 157 206 case "define('DB_NAME'": 158 $configFile[$line_num] = str_replace("putyourdbnamehere", $dbname, $line);207 fwrite($handle, str_replace("putyourdbnamehere", $dbname, $line)); 159 208 break; 160 209 case "define('DB_USER'": 161 $configFile[$line_num] = str_replace("'usernamehere'", "'$uname'", $line);210 fwrite($handle, str_replace("'usernamehere'", "'$uname'", $line)); 162 211 break; 163 212 case "define('DB_PASSW": 164 $configFile[$line_num] = str_replace("'yourpasswordhere'", "'$passwrd'", $line);213 fwrite($handle, str_replace("'yourpasswordhere'", "'$passwrd'", $line)); 165 214 break; 166 215 case "define('DB_HOST'": 167 $configFile[$line_num] = str_replace("localhost", $dbhost, $line);216 fwrite($handle, str_replace("localhost", $dbhost, $line)); 168 217 break; 218 case "define('DB_TYPE'": 219 fwrite($handle, str_replace("mysql", $dbtype, $line)); 220 break; 169 221 case '$table_prefix =': 170 $configFile[$line_num] = str_replace('wp_', $prefix, $line);222 fwrite($handle, str_replace('wp_', $prefix, $line)); 171 223 break; 224 default: 225 fwrite($handle, $line); 172 226 } 173 227 } 174 if ( ! is_writable(ABSPATH) ) : 175 display_header(); 228 fclose($handle); 229 chmod(ABSPATH . 'wp-config.php', 0666); 230 231 display_header(); 176 232 ?> 177 <p>Sorry, but I can't write the <code>wp-config.php</code> file.</p>178 <p>You can create the <code>wp-config.php</code> manually and paste the following text into it.</p>179 <textarea cols="90" rows="15"><?php180 foreach( $configFile as $line ) {181 echo htmlentities($line);182 }183 ?></textarea>184 <p>After you've done that, click "Run the install."</p>185 <p class="step"><a href="install.php" class="button">Run the install</a></p>186 <?php187 else :188 $handle = fopen(ABSPATH . 'wp-config.php', 'w');189 foreach( $configFile as $line ) {190 fwrite($handle, $line);191 }192 fclose($handle);193 chmod(ABSPATH . 'wp-config.php', 0666);194 display_header();195 ?>196 233 <p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…</p> 197 234 198 235 <p class="step"><a href="install.php" class="button">Run the install</a></p> 199 236 <?php 200 endif;201 237 break; 202 238 } 203 239 ?>