Created
April 5, 2021 16:38
-
-
Save DNTech/7b9448c2dffa66b444f3a81897ee2e68 to your computer and use it in GitHub Desktop.
Replace mysql to mysqli within a directory hierarchy
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 | |
$folders = [ | |
'*.php', | |
'*/*.php', | |
'*/*/*.php' | |
]; | |
foreach ($folders as $f){ | |
$res = shell_exec("ls $f"); | |
$files = explode("\n", $res); | |
echo("\n"); | |
foreach ($files as $fl){ | |
if(is_file($fl)){ | |
echo "working on $fl\n"; | |
$content = file_get_contents($fl); | |
$content = str_replace('mysqli_query($conn, $query)', 'mysqli_query($conn, $query)', $content); | |
file_put_contents($fl, $content); | |
echo "Corrected $fl\n\n"; | |
} | |
} | |
} | |
echo 'done'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment