1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Apps\Controller\Admin; |
4
|
|
|
|
5
|
|
|
use Apps\Model\Admin\Main\EntityDeleteRoute; |
6
|
|
|
use Apps\Model\Admin\Main\FormAddRoute; |
7
|
|
|
use Apps\Model\Admin\Main\FormSettings; |
8
|
|
|
use Extend\Core\Arch\AdminController; |
9
|
|
|
use Ffcms\Core\App; |
10
|
|
|
use Ffcms\Core\Exception\SyntaxException; |
11
|
|
|
use Ffcms\Core\Helper\Environment; |
12
|
|
|
use Ffcms\Core\Helper\FileSystem\Directory; |
13
|
|
|
use Ffcms\Core\Helper\FileSystem\File; |
14
|
|
|
use Ffcms\Core\Helper\Type\Arr; |
15
|
|
|
use Ffcms\Core\Helper\Type\Integer; |
16
|
|
|
use Ffcms\Core\Helper\Type\Str; |
17
|
|
|
|
18
|
|
|
class Main extends AdminController |
19
|
|
|
{ |
20
|
|
|
public $type = 'app'; |
21
|
|
|
|
22
|
|
|
public function __construct() |
23
|
|
|
{ |
24
|
|
|
parent::__construct(false); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Index page of admin dashboard |
29
|
|
|
*/ |
30
|
|
|
public function actionIndex() |
31
|
|
|
{ |
32
|
|
|
// cache some data |
33
|
|
|
$rootSize = App::$Cache->get('root.size'); |
34
|
|
|
if ($rootSize === null) { |
35
|
|
|
$rootSize = round(Directory::getSize('/') / (1024*1000), 2) . ' mb'; |
|
|
|
|
36
|
|
|
App::$Cache->set('root.size', $rootSize, 60 * 60 * 24); // 24 hours caching |
37
|
|
|
} |
38
|
|
|
$loadAvg = App::$Cache->get('load.average'); |
39
|
|
|
if ($loadAvg === null) { |
40
|
|
|
$loadAvg = Environment::loadAverage(); |
41
|
|
|
App::$Cache->set('load.average', $loadAvg, 60*2); // 2 min cache |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$stats = [ |
45
|
|
|
'ff_version' => App::$Properties->version['num'] . ' (' . App::$Properties->version['date'] . ')', |
46
|
|
|
'php_version' => Environment::phpVersion() . ' (' . Environment::phpSAPI() . ')', |
47
|
|
|
'os_name' => Environment::osName(), |
48
|
|
|
'database_name' => App::$Database->connection()->getDatabaseName() . ' (' . App::$Database->connection()->getDriverName() . ')', |
49
|
|
|
'file_size' => $rootSize, |
50
|
|
|
'load_avg' => $loadAvg |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
return App::$View->render('index', [ |
54
|
|
|
'stats' => $stats |
55
|
|
|
]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Manage settings in web |
60
|
|
|
*/ |
61
|
|
View Code Duplication |
public function actionSettings() |
|
|
|
|
62
|
|
|
{ |
63
|
|
|
$model = new FormSettings(); |
64
|
|
|
|
65
|
|
|
if ($model->send()) { |
66
|
|
|
if ($model->validate()) { |
67
|
|
|
if ($model->makeSave()) { |
68
|
|
|
// show message about successful save and take system some time ;) |
69
|
|
|
return App::$View->render('settings_save'); |
70
|
|
|
} else { |
71
|
|
|
App::$Session->getFlashBag()->add('error', __('Configuration file is not writable! Check /Private/Config/ dir and files')); |
72
|
|
|
} |
73
|
|
|
} else { |
74
|
|
|
App::$Session->getFlashBag()->add('error', __('Validation of form data is failed!')); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return App::$View->render('settings', [ |
79
|
|
|
'model' => $model // no $model->export() there |
|
|
|
|
80
|
|
|
]); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Manage files via elFinder |
85
|
|
|
*/ |
86
|
|
|
public function actionFiles() |
87
|
|
|
{ |
88
|
|
|
return App::$View->render('files', [ |
89
|
|
|
'connector' => App::$Alias->scriptUrl . '/api/main/files?lang=' . App::$Request->getLanguage() |
90
|
|
|
]); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Show antivirus |
95
|
|
|
*/ |
96
|
|
|
public function actionAntivirus() |
97
|
|
|
{ |
98
|
|
|
return App::$View->render('antivirus'); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function actionDebugcookie() |
102
|
|
|
{ |
103
|
|
|
$cookieProperty = App::$Properties->get('debug'); |
104
|
|
|
//App::$Request->cookies->add([$cookieProperty['cookie']['key'] => $cookieProperty['cookie']['value']]); todo: fix me |
|
|
|
|
105
|
|
|
setcookie($cookieProperty['cookie']['key'], $cookieProperty['cookie']['value'], Integer::MAX, '/', null, null, true); |
106
|
|
|
App::$Response->redirect('/'); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* List available routes |
111
|
|
|
* @throws \Ffcms\Core\Exception\SyntaxException |
112
|
|
|
*/ |
113
|
|
|
public function actionRouting() |
114
|
|
|
{ |
115
|
|
|
$routingMap = App::$Properties->getAll('Routing'); |
116
|
|
|
|
117
|
|
|
return App::$View->render('routing', [ |
118
|
|
|
'routes' => $routingMap |
119
|
|
|
]); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Show add form for routing |
124
|
|
|
* @throws \Ffcms\Core\Exception\SyntaxException |
125
|
|
|
*/ |
126
|
|
|
public function actionAddroute() |
127
|
|
|
{ |
128
|
|
|
$model = new FormAddRoute(); |
129
|
|
|
|
130
|
|
|
if (!File::exist('/Private/Config/Routing.php') || !File::writable('/Private/Config/Routing.php')) { |
131
|
|
|
App::$Session->getFlashBag()->add('error', __('Routing configuration file is not allowed to write: /Private/Config/Routing.php')); |
132
|
|
|
} elseif ($model->send() && $model->validate()) { |
133
|
|
|
$model->save(); |
134
|
|
|
App::$Response->redirect('main/routing'); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return App::$View->render('add_route', [ |
138
|
|
|
'model' => $model |
139
|
|
|
]); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Delete scheme route |
144
|
|
|
* @throws SyntaxException |
145
|
|
|
*/ |
146
|
|
|
public function actionDeleteroute() |
147
|
|
|
{ |
148
|
|
|
$type = (string)App::$Request->query->get('type'); |
149
|
|
|
$loader = (string)App::$Request->query->get('loader'); |
150
|
|
|
$source = Str::lowerCase((string)App::$Request->query->get('path')); |
151
|
|
|
|
152
|
|
|
$model = new EntityDeleteRoute($type, $loader, $source); |
153
|
|
|
if ($model->send()) { |
154
|
|
|
$model->make(); |
155
|
|
|
App::$Response->redirect('main/routing'); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
return App::$View->render('delete_route', [ |
159
|
|
|
'model' => $model |
160
|
|
|
]); |
161
|
|
|
} |
162
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.