Последняя активность 6 months ago

php54_deprecated_functions Исходник
1#!/bin/bash
2#
3# PHP 5.4 Deprecated function checker
4#
5# Version: 0.0.3
6#
7# Original Author: Michiel Roos <michiel@donationbasedhosting.org>
8#
9# http://www.php.net/manual/de/migration54.incompatible.php
10# http://www.php.net/manual/en/migration54.deprecated.php
11#
12# Please note that there will be some false positives. Some PHP code is mixed
13# with JS code. In JS 'split' is still a valid function.
14#
15
16PWD="/tmp"
17FIND_PHP54_DEPRECATED_LOGLOCATION="php54_deprecated_functions.log"
18OUTPUT=${PWD}/${FIND_PHP54_DEPRECATED_LOGLOCATION}
19
20deprecatedFunctions54=(
21# php 5.4 removed
22 define_syslog_variables
23 import_request_variables
24 session_is_registered
25 session_register
26 session_unregister
27 mysqli_bind_param
28 mysqli_bind_result
29 mysqli_client_encoding
30 mysqli_fetch
31 mysqli_param_count
32 mysqli_get_metadata
33 mysqli_send_long_data
34 mysqli::client_encoding
35 mysqli_stmt::stmt
36# php 5.4 changed behavior
37 get_magic_quotes_gpc
38 get_magic_quotes_runtime
39 set_magic_quotes_runtime
40 array_combine
41 htmlspecialchars
42 htmlentities
43 ob_start
44# php 5.4 deprecated
45 mcrypt_generic_end
46 mysql_list_dbs
47)
48
49deprecatedIniDirectives54=(
50# php 5.4
51 register_globals
52 register_long_arrays
53)
54
55len=${#deprecatedFunctions54[*]}
56i=0
57
58echo "Checking for deprectated functions in PHP 5.4 ______________________________________" > ${OUTPUT}
59echo "" >> ${OUTPUT}
60
61while [ $i -lt $len ]; do
62 echo " // checking for '${deprecatedFunctions54[$i]}()'" >> ${OUTPUT}
63 grep -rn --color --include=*.php "^[^#]*[^a-zA-Z_]${deprecatedFunctions54[$i]}[[:space:]]*(" . >> ${OUTPUT};
64 echo "" >> ${OUTPUT}
65 let i++
66done
67
68len=${#deprecatedIniDirectives54[*]}
69i=0
70
71echo "Checking for deprectated ini directives in PHP 5.4 _________________________________" >> ${OUTPUT}
72echo "" >> ${OUTPUT}
73
74while [ $i -lt $len ]; do
75 echo " // checking for '${deprecatedIniDirectives54[$i]}()'" >> ${OUTPUT}
76 grep -rn --color --include=*.php "ini_set[[:space:]]*(['|\"]${deprecatedIniDirectives54[$i]}" . >> ${OUTPUT};
77 echo "" >> ${OUTPUT}
78 let i++
79done
80