-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathengine.php
More file actions
82 lines (65 loc) · 2.4 KB
/
Copy pathengine.php
File metadata and controls
82 lines (65 loc) · 2.4 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @file engine.php
* @author zhonghuali241@163.com
* @date 2015-1-21
* @desc
*/
require('lnmpcheck.php');
require('lib/utils.php');
require('config.php');
class Engine {
private $allclass = array();
private $allparentclass = array();
private $objset =array();
public function runCheck($print_reason = false,$print_data = false){
if ($handle = opendir(dirname(__FILE_).'/checkitems')) {
while (false !== ($entry = readdir($handle))) {
if($entry == '.' || $entry == '..') continue;
if(substr($entry, -4) == '.php'){
include './checkitems/'.$entry;
}
}
$define_class = get_declared_classes();
foreach ($define_class as $val){
if(is_subclass_of($val, 'LnmpCheck')){
$this->allclass[$val] = $val;
$parent_class = get_parent_class($val);
if($parent_class != 'LnmpCheck') {
$this->allparentclass[$parent_class] = $parent_class;
}
}
}
foreach ($this->allparentclass as $val){
unset($this->allclass[$val]);
}
foreach ($this->allclass as $val){
$this->objset[$val] = new $val;
}
usort($this->objset, array($this,'cmp'));
echo "checking......\n\n";
foreach ($this->objset as $obj){
if(method_exists($obj, 'check')) {
$res = $obj->check();
if($res === false) {
if($print_reason && method_exists($obj, 'printReason')){
$obj->printReason();
}
if($print_data && method_exists($obj, 'printData')){
$obj->printData();
}
}
if($res === false && !$obj->fall) break;
}
}
echo "\n*****************\ncheck completed\n*****************\n";
closedir($handle);
}
}
public function cmp($a, $b) {
if ($a->priority == $b->priority) {
return 0;
}
return ($a->priority < $b->priority) ? -1 : 1;
}
}