Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- searchreplacedb2-original.php Fri Aug 26 16:00:48 2011
- +++ searchreplacedb2.php Tue Oct 4 21:52:04 2011
- @@ -239,7 +239,7 @@
- @fclose( $file );
- }
- - preg_match_all( '/define\s*?\(\s*?([\'"])(DB_NAME|DB_USER|DB_PASSWORD|DB_HOST)\s*?,\s*?([\'"])([^\3]*?)\3\s*?\)\s*?;/si', $file_content, $defines );
- + preg_match_all( '/define\s*?\(\s*?([\'"])(DB_NAME|DB_USER|DB_PASSWORD|DB_HOST|DB_CHARSET)\s*?,\s*?([\'"])([^\3]*?)\3\s*?\)\s*?;/si', $file_content, $defines );
- if ( ( isset( $defines[ 2 ] ) && ! empty( $defines[ 2 ] ) ) && ( isset( $defines[ 4 ] ) && ! empty( $defines[ 4 ] ) ) ) {
- foreach( $defines[ 2 ] as $key => $define ) {
- @@ -257,11 +257,14 @@
- case 'DB_HOST':
- $host = $defines[ 4 ][ $key ];
- break;
- + case 'DB_CHARSET':
- + $char = $defines[ 4 ][ $key ];
- + break;
- }
- }
- }
- - return array( $host, $name, $user, $pass );
- + return array( $host, $name, $user, $pass, $char );
- }
- /*
- @@ -279,6 +282,7 @@
- $data = isset( $_POST[ 'data' ] ) ? stripcslashes( $_POST[ 'data' ] ) : ''; // your database
- $user = isset( $_POST[ 'user' ] ) ? stripcslashes( $_POST[ 'user' ] ) : ''; // your db userid
- $pass = isset( $_POST[ 'pass' ] ) ? stripcslashes( $_POST[ 'pass' ] ) : ''; // your db password
- +$char = isset( $_POST[ 'char' ] ) ? stripcslashes( $_POST[ 'char' ] ) : ''; // your db charset
- // Search replace details
- $srch = isset( $_POST[ 'srch' ] ) ? stripcslashes( $_POST[ 'srch' ] ) : '';
- $rplc = isset( $_POST[ 'rplc' ] ) ? stripcslashes( $_POST[ 'rplc' ] ) : '';
- @@ -291,7 +295,7 @@
- // Scan wp-config for the defines. We can't just include it as it will try and load the whole of wordpress.
- if ( $loadwp && file_exists( dirname( __FILE__ ) . '/wp-config.php' ) )
- - list( $host, $data, $user, $pass ) = icit_srdb_define_find( 'wp-config.php' );
- + list( $host, $data, $user, $pass, $char ) = icit_srdb_define_find( 'wp-config.php' );
- // Check the db connection else go back to step two.
- if ( $step >= 3 ) {
- @@ -301,6 +305,13 @@
- $step = 2;
- }
- + if ( ! empty( $char ) ) {
- + if ( function_exists( 'mysql_set_charset' ) )
- + mysql_set_charset( $char, $connection );
- + else
- + mysql_query( 'SET NAMES ' . $char, $connection );
- + }
- +
- // Do we have any tables and if so build the all tables array
- $all_tables = array( );
- $all_tables_mysql = mysql_db_query( $data, 'SHOW TABLES', $connection );
- @@ -511,6 +522,11 @@
- <label for="pass">Password:</label>
- <input class="text" type="password" name="pass" id="pass" value="<?php esc_html_attr( $pass, true ) ?>" />
- </p>
- +
- + <p>
- + <label for="pass">Charset:</label>
- + <input class="text" type="text" name="char" id="char" value="<?php esc_html_attr( $char, true ) ?>" />
- + </p>
- <?php icit_srdb_submit( 'Submit DB details' ); ?>
- </fieldset>
- </form> <?php
- @@ -528,6 +544,7 @@
- <input type="hidden" name="data" value="<?php esc_html_attr( $data, true ) ?>" />
- <input type="hidden" name="user" value="<?php esc_html_attr( $user, true ) ?>" />
- <input type="hidden" name="pass" value="<?php esc_html_attr( $pass, true ) ?>" />
- + <input type="hidden" name="char" value="<?php esc_html_attr( $char, true ) ?>" />
- <p>
- <label for="tables">Tables:</label>
- <select id="tables" name="tables[]" multiple="multiple" class="multi"><?php
- @@ -551,7 +568,8 @@
- <input type="hidden" name="host" id="host" value="<?php esc_html_attr( $host, true ) ?>" />
- <input type="hidden" name="data" id="data" value="<?php esc_html_attr( $data, true ) ?>" />
- <input type="hidden" name="user" id="user" value="<?php esc_html_attr( $user, true ) ?>" />
- - <input type="hidden" name="pass" id="pass" value="<?php esc_html_attr( $pass, true ) ?>" /> <?php
- + <input type="hidden" name="pass" id="pass" value="<?php esc_html_attr( $pass, true ) ?>" />
- + <input type="hidden" name="char" id="char" value="<?php esc_html_attr( $char, true ) ?>" /> <?php
- foreach( $tables as $i => $tab ) {
- printf( '<input type="hidden" name="tables[%s]" value="%s" />', esc_html_attr( $i, false ), esc_html_attr( $tab, false ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement