forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_php.sh
More file actions
executable file
·40 lines (32 loc) · 864 Bytes
/
check_php.sh
File metadata and controls
executable file
·40 lines (32 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Original code: @jroman00 (https://gist.github.com/mathiasverraes/3096500#gistcomment-1575416)
error=false
current=$1
if [ -z "$current" ]; then
current="/usr/local/hestia/web/"
fi
if [ ! -d $current ] && [ ! -f $current ]; then
echo "Invalid directory or file: $current"
error=true
fi
echo "Checking PHP files..."
for file in $(find $current -type f -name "*.php" -not -path "${current}fm/*"); do
RESULTS=$(php -l -n $file)
if [ "$RESULTS" != "No syntax errors detected in $file" ]; then
echo $RESULTS
error=true
fi
done
echo "Checking HTML/PHP combined files..."
for file in $(find $current -type f -name "*.html" -not -path "${current}fm/*"); do
RESULTS=$(php -l -n $file)
if [ "$RESULTS" != "No syntax errors detected in $file" ]; then
echo $RESULTS
error=true
fi
done
if [ "$error" = true ]; then
exit 1
else
exit 0
fi