All pastes #2444926 Raw Edit

Someone

public unlisted php v1 · immutable
#2444926 ·published 2013-09-07 09:53 UTC
rendered paste body
<?php$infile = "sqldump.sql";if( @$argv[1] )      $infile = $argv[1];  //$old = 'http://guardiansofeve.com';$old = 'http://bloodlinechronicle.com';$new = 'http://guardiansofeve.otleylogic.com';//$oldpath = '/home1/ikonhost/public_html/guardiansofeve.com';$oldpath = '/home/ikonhost/public_html/bloodlinechronicle.com/';$newpath = '/home/otleylogic/domains/guardiansofeve.otleylogic.com/public_html';/* first, update all the serialized() php data */$lendiff = strlen($new) - strlen($old);$lenpatt = ( $lendiff > 0 ) ? "+ $lendiff" : "- " . abs($lendiff);$oldpatt = str_replace('/', '\/', $old);$newpatt = str_replace('/', '\/', $new);$pattern = '/s:(\d+)(:\\\")([^"]+?|)(' . $oldpatt . ')(.*?)\"/e';$content = file_get_contents($infile);/* then, do a simple find/replace on the rest of the urls */$content = str_replace($old, $new, $content);$content = str_replace($oldpath, $newpath, $content);// fix serialization lengths$content = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $content );file_put_contents("$infile.fixed.sql", $content);?>