Last active
August 12, 2019 04:52
-
-
Save adibdz/98d21aaabe112ef24ab32511079b4cd1 to your computer and use it in GitHub Desktop.
A simple bash script to update (mysql_connect, mysql_query, msyql_fetch_array, mysql_error, mysql_close & mysql_num_row) sql-files on bWAPP using php7-mysqli module.
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
#!/bin/bash | |
## This is simple bash script to update sql* files on bWAPP. | |
## Which using one of following APIs: | |
## mysql_query, msyql_fetch_array, mysql_error, mysql_close & mysql_num_rows. | |
## All of them are deprecated to PHP 7 and produce this error: | |
## "PHP Fatal error: Uncaught Error: Call to undefined function mysql_query() ..." | |
## This script update them to adapt with PHP 7 API's. | |
## How to run: | |
## - Place this file inside bWAPP folder. | |
## - # chmod 755 to_php7 | |
## - # ./to_php7 | |
## Happy Hunting :) | |
## @adib_dz | |
cp connect.php connect.php.backup | |
cp connect_i.php connect.php | |
echo "[+] Copying connect.php to connect.php.backup ... done" | |
sleep 1 | |
echo "[+] Copying connect_i.php to connect.php ... done" | |
sleep 1 | |
echo | |
a=`ls | grep "^sql"` | |
n=`echo $a | awk '{print NF}'` | |
i=0 | |
while [ $i -lt $n ] | |
do | |
x=`echo $a | awk -v x=$i -F ' ' '{print $(1+x)}'` | |
echo $x | |
sed -i 's/mysql_query.*;/mysqli_query($link, $sql);/' $x | |
sed -i 's/mysql_fetch_array/mysqli_fetch_array/' $x | |
sed -i 's/mysql_error.*;/mysqli_error($link));/' $x | |
sed -i 's/mysql_num_rows/mysqli_num_rows/' $x | |
sed -i 's/mysql_close/mysqli_close/' $x | |
i=$(( $i + 1 )) | |
done | |
echo | |
echo "[+] Updating mysql_query to mysqli_query(\$link, \$sql) ... done" | |
sleep 1 | |
echo "[+] Updating mysql_fetch_array to mysqli_fetch_array ... done" | |
sleep 1 | |
echo "[+] Updating mysql_error to mysqli_error(\$link) ... done" | |
sleep 1 | |
echo "[+] Updating mysql_num_rows to mysqli_num_rows ... done" | |
sleep 1 | |
echo "[+] Updating mysql_close to mysqli_close ... done" | |
sleep 1 | |
echo | |
echo "[?] If you get some error, please let me know. Thank you." | |
sleep 2 | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment