-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.php
91 lines (50 loc) · 1.43 KB
/
boot.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
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
83
84
85
86
87
88
89
90
<?php
function app(){
return array(
'environment' => 'local',
'debug' => true,
'TZD' => '+01:00',
'root' => realpath( dirname( __FILE__ ) ).'/',
'config' => 'app/config/',
'libs' => 'app/libs/',
'public' => 'public/',
'cronjobs' => 'cronjobs/',
'cronjobs_storage' => 'storage/'
);
};
function get_config($file){
$env = app()['root'].app()['config'].app()['environment'].'/';
$fileName = $file.'.php';
if(!file_exists($env.$fileName)){
$env = app()['root'].app()['config'];
}
return include $env.$fileName;
}
function get_logs($path,$order = 0){
$logs = scandir($path,$order);
foreach($logs as $k => $log){
if(substr( $log, 0, 1 ) === "."){
unset($logs[$k]);
}
}
return $logs;
}
function cj_proccess($pid,$method){
$proccess_path = app()['root'].app()['cronjobs_storage'].'_PID/';
if($method == 'add'){
if(!is_dir($proccess_path)) mkdir($proccess_path, 0777, true);
$pid = (!file_exists($proccess_path.$pid))? touch($proccess_path.$pid): false;
}elseif($method == 'kill'){
unlink($proccess_path.$pid);
}
return $pid;
}
function cj_runtime($date,$time){
// ISO 8601 datetime standard
$TZD = app('TZD');
$date = ($date)? $date: date('Y-m-d');
return (strtotime($date.'T'.$time.$TZD) == strtotime(date('Y-m-dTH:i'.$TZD)))? true : false;
}
spl_autoload_register(function ($class) {
include app()['libs'].'/'.$class . '.php';
});