-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScope.php
More file actions
57 lines (51 loc) · 1.68 KB
/
Scope.php
File metadata and controls
57 lines (51 loc) · 1.68 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
<?php
namespace Yonna\Log;
use Yonna\IO\Request;
use Yonna\Scope\Config;
use Yonna\Log\Config as LogConf;
class Scope
{
private static function myScanDir($dir)
{
$file_arr = scandir($dir);
$new_arr = [];
foreach ($file_arr as $f) {
if ($f != ".." && $f != ".") {
if (is_dir($dir . DIRECTORY_SEPARATOR . $f)) {
array_unshift($new_arr, [
'path' => $f,
'children' => self::myScanDir($dir . DIRECTORY_SEPARATOR . $f)
]);
} else {
$new_arr[] = [
'path' => $f,
];
}
}
}
return $new_arr;
}
public static function conf()
{
Config::group(['log'], function () {
Config::post('dir', function () {
$dir = realpath(LogConf::getDir() . LogConf::getFile());
$dir = self::myScanDir($dir);
return $dir;
});
Config::post('file', function (Request $request) {
$file = realpath(LogConf::getDir() . LogConf::getFile() . DIRECTORY_SEPARATOR . $request->getInput()['file']);
if (!is_file($file)) {
return '';
}
$content = file_get_contents($file);
$content = str_replace(["\r\n", "\r", "\n", "\t"], '<br/>', $content);
return $content;
});
Config::post('db', function (Request $request) {
$input = $request->getInput();
return Log::db()->page($input);
});
});
}
}