forked from billm/pfsense-tools-centipede-slbd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lintcheck.php
executable file
·55 lines (49 loc) · 1.06 KB
/
lintcheck.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env php
<?php
/*
* A simple recursive syntax checker for PHP
* Colin Smith
* Whipped up for pfSense
*/
if($argc == 1) exit;
$tocheck = array(
'.php',
'.inc'
);
$dirs = glob($argv[1]);
if(!is_array($dirs)) $dirs = array($dirs);
function check_dir($dir) {
global $tocheck, $exitabnormal;
if(is_dir($dir)) {
if($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if(($file == '.') or ($file == '..') or ($file == 'CVS')) continue;
if(is_dir($dir . '/' . $file . '/')) {
check_dir($dir . '/' . $file . '/');
} else {
if(in_array(strrchr($file, '.'), $tocheck)) {
$phpout = "";
exec("/usr/bin/env php -l {$dir}/{$file} 2>&1", $phpout);
if(!stristr($phpout[0], "No syntax errors detected in")) {
$exitabnormal = true;
print "{$dir}{$file}\n-----";
foreach($phpout as $errline) {
print "{$errline}\n";
}
print "\n";
}
}
}
}
}
}
return;
}
foreach($dirs as $todo) {
check_dir($todo);
}
if($exitabnormal) {
exit(-1);
} else {
exit(0);
}