Ejemplo n.º 1
0
" />
				</p>

				<?php 
        icit_srdb_submit('Submit Search string', 'Are you REALLY sure you want to go ahead and do this?');
        ?>
			</fieldset>
		</form>	<?php 
        break;
    case 5:
        @set_time_limit(60 * 10);
        // Try to push the allowed memory up, while we're at it
        @ini_set('memory_limit', '1024M');
        // Process the tables
        if (isset($connection)) {
            $report = icit_srdb_replacer($connection, $srch, $rplc, $tables);
        }
        // Output any errors encountered during the db work.
        if (!empty($report['errors']) && is_array($report['errors'])) {
            echo '<div class="error">';
            foreach ($report['errors'] as $error) {
                echo '<p>' . $error . '</p>';
            }
            echo '</div>';
        }
        // Calc the time taken.
        $time = array_sum(explode(' ', $report['end'])) - array_sum(explode(' ', $report['start']));
        ?>

		<h2>Completed</h2>
		<p><?php 
                        $xlsx = new SimpleXLSX($srch_file);
                        foreach ($xlsx->rows() as $row) {
                            $search = $row[0];
                            $replace = $row[1];
                            $search = trim($search);
                            $replace = trim($replace);
                            $search = $search == '' ? null : $search;
                            $replace = $replace == '' ? null : $replace;
                            if ($search !== null && $replace !== null) {
                                $search_replaces[$search] = $replace;
                            }
                        }
                    }
                }
                foreach ($search_replaces as $search => $replace) {
                    $reports[] = array_merge(array('search' => $search, 'replace' => $replace), icit_srdb_replacer($connection, $search, $replace, $tables));
                }
                ?>
                            <h2>Completed</h2><?php 
                $total_time = 0;
                foreach ($reports as $report) {
                    $time = array_sum(explode(' ', $report['end'])) - array_sum(explode(' ', $report['start']));
                    $total_time += $time;
                    ?>
<p><?php 
                    printf('In the process of replacing <strong>"%s"</strong> with <strong>"%s"</strong> we scanned <strong>%d</strong> tables with a total of <strong>%d</strong> rows, <strong>%d</strong> cells were changed and <strong>%d</strong> db update performed and it all took <strong>%f</strong> seconds.', $report['search'], $report['replace'], $report['tables'], $report['rows'], $report['change'], $report['updates'], $time);
                    ?>
</p> <?php 
                }
                printf("A total time of <strong>%f</strong> seconds was required to complete all replaces.", $total_time);
            }
Ejemplo n.º 3
0
    return $currentSiteUrl;
}
/**
 * @param type $search URL of the previous site.
 * @param type $replace URL of the current site.
 * @return type total time it took for the operation.
 */
function wpa_safe_replace_wrapper($search, $replace)
{
    if (!function_exists('icit_srdb_replacer') && !function_exists('recursive_unserialize_replace')) {
        require_once 'icit_srdb_replacer.php';
    }
    $connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    $all_tables = array();
    @mysql_select_db(DB_NAME, $connection);
    $all_tables_mysql = @mysql_query('SHOW TABLES', $connection);
    if (!$all_tables_mysql) {
        wpa_backup_error('dbrest', mysql_error(), true);
    } else {
        while ($table = mysql_fetch_array($all_tables_mysql)) {
Ejemplo n.º 4
0
/**
 * @param type $search URL of the previous site.
 * @param type $replace URL of the current site.
 * @return type total time it took for the operation.
 */
function wpa_safe_replace_wrapper($search, $replace, $prefix)
{
    if (!function_exists('icit_srdb_replacer') && !function_exists('recursive_unserialize_replace')) {
        require_once 'icit_srdb_replacer.php';
    }
    wpa_wpc_log('search and replace started');
    $connection = wpa_wpc_mysql_connect();
    if (false === $connection) {
        wpa_wpc_log('mysql connection failure @ safe replace wrapper - error : "' . mysql_error($connection) . '" retrying..');
        mysql_close($connection);
        sleep(1);
        $connection = wpa_wpc_mysql_connect();
    }
    $all_tables = array();
    if (isset($_POST['ignore_prefix']) && 'true' === $_POST['ignore_prefix']) {
        wpa_wpc_log('ignore table prefix enabled, search and replace will scan all the tables in the database');
        $all_tables_mysql = @mysql_query('SHOW TABLES', $connection);
    } else {
        $all_tables_mysql = @mysql_query('SHOW TABLES LIKE "' . $prefix . '%"', $connection);
    }
    while ($table = mysql_fetch_array($all_tables_mysql)) {
        $all_tables[] = $table[0];
    }
    wpa_wpc_log(sprintf('there are %d tables to scan', count($all_tables)));
    $report = icit_srdb_replacer($connection, $search, $replace, $all_tables);
    mysql_close($connection);
    wpa_wpc_log('search and replace finished');
    return $report;
}