Ticket #13839: 13839.6.diff
File 13839.6.diff, 3.2 KB (added by , 13 years ago) |
---|
-
wp-admin/setup-config.php
51 51 52 52 require_once(ABSPATH . WPINC . '/compat.php'); 53 53 require_once(ABSPATH . WPINC . '/class-wp-error.php'); 54 require_once(ABSPATH . WPINC . '/formatting.php'); 54 55 55 56 if ( ! file_exists( ABSPATH . 'wp-config-sample.php' ) ) 56 57 wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' ) ); … … 152 153 break; 153 154 154 155 case 2: 155 $dbname = trim($_POST['dbname']); 156 $uname = trim($_POST['uname']); 157 $passwrd = trim($_POST['pwd']); 158 $dbhost = trim($_POST['dbhost']); 159 $prefix = trim($_POST['prefix']); 160 if ( empty($prefix) ) 161 $prefix = 'wp_'; 156 // Turn register_globals off. 157 wp_unregister_GLOBALS(); 162 158 163 // Validate $prefix: it can only contain letters, numbers and underscores 159 // Add magic quotes. 160 wp_magic_quotes(); 161 162 foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key ) 163 $$key = trim( stripslashes( $_POST[ $key ] ) ); 164 165 $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">' . __( 'Try Again' ) . '</a>'; 166 167 if ( empty( $prefix ) ) 168 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); 169 170 // Validate $prefix: it can only contain letters, numbers and underscores. 164 171 if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) 165 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' ) );172 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) ); 166 173 167 174 // Test the db connection. 168 175 /**#@+ … … 170 177 */ 171 178 define('DB_NAME', $dbname); 172 179 define('DB_USER', $uname); 173 define('DB_PASSWORD', $p asswrd);180 define('DB_PASSWORD', $pwd); 174 181 define('DB_HOST', $dbhost); 175 182 /**#@-*/ 176 183 177 184 // We'll fail here if the values are no good. 178 185 require_wp_db(); 179 if ( ! empty( $wpdb->error ) ) { 180 $back = '<p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">' . __( 'Try Again' ) . '</a></p>'; 181 wp_die( $wpdb->error->get_error_message() . $back ); 182 } 186 if ( ! empty( $wpdb->error ) ) 187 wp_die( $wpdb->error->get_error_message() . $tryagain_link ); 183 188 184 189 // Fetch or generate keys and salts. 185 190 $no_api = isset( $_POST['noapi'] ); … … 213 218 $key = 0; 214 219 foreach ( $config_file as &$line ) { 215 220 if ( '$table_prefix =' == substr( $line, 0, 16 ) ) { 216 $line = '$table_prefix = \'' . $prefix. "';\r\n";221 $line = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n"; 217 222 continue; 218 223 } 219 224 … … 228 233 case 'DB_USER' : 229 234 case 'DB_PASSWORD' : 230 235 case 'DB_HOST' : 231 $line = "define('" . $constant . "'," . $padding . "'" . constant( $constant) . "');\r\n";236 $line = "define('" . $constant . "'," . $padding . "'" . addcslashes( constant( $constant ), "\\'" ) . "');\r\n"; 232 237 break; 233 238 case 'AUTH_KEY' : 234 239 case 'SECURE_AUTH_KEY' :