Created
April 1, 2013 17:20
-
-
Save edgarsandi/5286310 to your computer and use it in GitHub Desktop.
Script to find deprecated functions and directives
This file contains hidden or 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 | |
# | |
# PHP 5.3 Deprecated function checker | |
# | |
# Version: 0.0.3 | |
# | |
# Author: Michiel Roos <[email protected]> | |
# | |
# www.php.net/manual/en/migration53.deprecated.php | |
# | |
# Please note that there will be some false positives. Some PHP code is mixed | |
# with JS code. In JS 'split' is still a valid function. | |
# | |
# mcrypt_generic_end | |
# mysql_list_dbs | |
# mcrypt_cbc | |
# mcrypt_cfb | |
# mcrypt_ecb | |
# mcrypt_ofb | |
deprecatedFunctions=( | |
call_user_method | |
call_user_method_array | |
define_syslog_variables | |
dl | |
ereg | |
ereg_replace | |
eregi | |
eregi_replace | |
set_magic_quotes_runtime | |
session_register | |
session_unregister | |
session_is_registered | |
set_socket_blocking | |
split | |
spliti | |
sql_regcase | |
mysql_db_query | |
mysql_escape_string | |
mcrypt_generic_end | |
mysql_list_dbs | |
mcrypt_cbc | |
mcrypt_cfb | |
mcrypt_ecb | |
mcrypt_ofb | |
) | |
deprecatedIniDirectives=( | |
define_syslog_variables | |
register_globals | |
register_long_arrays | |
safe_mode | |
magic_quotes_gpc | |
magic_quotes_runtime | |
magic_quotes_sybase | |
) | |
len=${#deprecatedFunctions[*]} | |
i=0 | |
echo "Checking for deprectated functions ______________________________________" | |
echo "" | |
while [ $i -lt $len ]; do | |
echo " // checking for '${deprecatedFunctions[$i]}()'" | |
grep -rn --color --include=*.php "^[^#]*[^a-zA-Z_]${deprecatedFunctions[$i]}[[:space:]]*(" * > "deprecated_${deprecatedFunctions[$i]}_function.txt" | |
grep -rn --color --include=*.php "^[^#]*[^a-zA-Z_]${deprecatedFunctions[$i]}[[:space:]]*(" *; | |
echo "" | |
let i++ | |
done | |
len=${#deprecatedIniDirectives[*]} | |
i=0 | |
echo "Checking for deprectated ini directives _________________________________" | |
echo "" | |
while [ $i -lt $len ]; do | |
echo " // checking for '${deprecatedIniDirectives[$i]}()'" | |
grep -rn --color --include=*.php "ini_set[[:space:]]*(['|\"]${deprecatedIniDirectives[$i]}" * > deprecated_directives.txt | |
grep -rn --color --include=*.php "ini_set[[:space:]]*(['|\"]${deprecatedIniDirectives[$i]}" *; | |
echo "" | |
let i++ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment