Ticket #13839: 13839.5.diff
File 13839.5.diff, 3.0 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 wp_magic_quotes(); 162 157 158 $dbname = trim( stripslashes( $_POST['dbname'] ) ); 159 $uname = trim( stripslashes( $_POST['uname'] ) ); 160 $passwrd = trim( stripslashes( $_POST['pwd'] ) ); 161 $dbhost = trim( stripslashes( $_POST['dbhost'] ) ); 162 $prefix = trim( stripslashes( $_POST['prefix'] ) ); 163 164 $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>'; 165 166 if ( empty( $prefix ) ) 167 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); 168 163 169 // Validate $prefix: it can only contain letters, numbers and underscores 164 170 if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) 165 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' ) );171 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) ); 166 172 167 173 // Test the db connection. 168 174 /**#@+ … … 176 182 177 183 // We'll fail here if the values are no good. 178 184 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 } 185 if ( ! empty( $wpdb->error ) ) 186 wp_die( $wpdb->error->get_error_message() . $tryagain_link ); 183 187 184 188 // Fetch or generate keys and salts. 185 189 $no_api = isset( $_POST['noapi'] ); … … 213 217 $key = 0; 214 218 foreach ( $config_file as &$line ) { 215 219 if ( '$table_prefix =' == substr( $line, 0, 16 ) ) { 216 $line = '$table_prefix = \'' . $prefix. "';\r\n";220 $line = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n"; 217 221 continue; 218 222 } 219 223 … … 228 232 case 'DB_USER' : 229 233 case 'DB_PASSWORD' : 230 234 case 'DB_HOST' : 231 $line = "define('" . $constant . "'," . $padding . "'" . constant( $constant ) . "');\r\n"; 235 $value = addcslashes( constant( $constant ), "\\'" ); 236 $line = "define('" . $constant . "'," . $padding . "'" . $value . "');\r\n"; 232 237 break; 233 238 case 'AUTH_KEY' : 234 239 case 'SECURE_AUTH_KEY' :