]> git.mxchange.org Git - admin.git/commitdiff
Added find-bad-php.sh
authorRoland Haeder <roland@mxchange.org>
Tue, 12 May 2015 00:05:57 +0000 (02:05 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 12 May 2015 00:05:57 +0000 (02:05 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
find-bad-php.sh [new file with mode: 0755]

diff --git a/find-bad-php.sh b/find-bad-php.sh
new file mode 100755 (executable)
index 0000000..2fdfecf
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+echo "$0: Searching for PHP scripts (except 3rd party) ..."
+PHP=`find -type f -name "*.php" | grep -v "third_party"`
+
+for SCRIPT in ${PHP};
+do
+       HEADER=`cat ${SCRIPT} | head -n 1 | grep -v "<?"`
+
+       FOOTER=`cat ${SCRIPT} | tail -n 1 | grep -v "?>"`
+
+       if [ -n "${HEADER}" ];
+       then
+               echo "$0: Script '${SCRIPT}' has non-typical header."
+       fi
+
+       if [ -n "${FOOTER}" ];
+       then
+               echo "$0: Script '${SCRIPT}' has non-typical footer."
+       fi
+
+       LINT=`php -l "${SCRIPT}" 2>&1 | grep -v "No syntax errors detected in"`
+
+       if [ -n "${LINT}" ]
+       then
+               echo "$0: ${LINT}"
+       fi
+done
+
+echo "$0: All done."
+exit 0