Created
May 17, 2014 18:53
-
-
Save detain/0826d315d2a6096b2498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = explode(' ', './scripts/map_sql_to_api.php ./scripts/whmcs_import.php ./scripts/map_everything_to_my.php ./scripts/whmcs_import2.php ./phpunit/class_tests/db_mdb2Test.php ./phpunit/class_tests/db_PDOTest.php ./phpunit/class_tests/db_mysqlTest.php ./phpunit/class_tests/db_mysqliTest.php ./include/preconfig.functions.inc.php ./include/accounts/accounts.inc.php ./include/dns/pdns.functions.inc.php ./include/db/class.db_mdb2.functions.inc.php ./include/functions.inc.php ./monitord.php ./monitord_new.php'); | |
foreach ($files as $file) | |
{ | |
echo "Working on file $file\n"; | |
$txt = file_get_contents($file); | |
$regex = '/([\s]+)(\$[\w\[\]\'_]+) = new db;\n[\s]+\$[\w\[\]\'_]+->Host = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->Database = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->User = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->Password = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->Type = ([^;]+);/m'; | |
if (preg_match($regex, $txt)) | |
{ | |
$txt = preg_replace($regex, '\1\2 = new db(\4, \5, \6, \3);\1\2->Type = \7;', $txt); | |
} | |
$regex = '/([\s]+)(\$[\w\[\]\'_]+) = new db;\n[\s]+\$[\w\[\]\'_]+->Database = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->User = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->Password = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->Host = ([^;]+);\n[\s]+\$[\w\[\]\'_]+->Type = ([^;]+);/m'; | |
if (preg_match($regex, $txt)) | |
{ | |
$txt = preg_replace($regex, '\1\2 = new db(\3, \4, \5, \6);\1\2->Type = \7;', $txt); | |
} | |
file_put_contents($file, $txt); | |
//file_put_contents($file.'.new', $txt); | |
//echo `diff -wu $file $file.new;`; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment