blob: 246d44772456145c876144d963b3f8b6c744280c (
plain) (
blame)
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
|
<?php
class Page_InternetAccess extends Page
{
protected function doPreprocess()
{
User::load();
if (!User::hasPermission('superadmin')) {
Message::addError('main.no-permission');
Util::redirect('?do=Main');
}
if (isset($_POST['PROXY_CONF'])) {
$data = array();
foreach (array('PROXY_CONF', 'PROXY_ADDR', 'PROXY_PORT', 'PROXY_USERNAME', 'PROXY_PASSWORD') as $key) {
$data[$key] = Request::post($key, '');
}
if (!FileUtil::arrayToFile(CONFIG_PROXY_CONF, $data)) {
Message::addError('main.error-write', CONFIG_PROXY_CONF);
Util::redirect();
} else {
Message::addSuccess('settings-updated');
Taskmanager::release(Taskmanager::submit('ReloadProxy'));
$taskids = array();
Trigger::stopDaemons(NULL, $taskids);
$taskids = array();
Trigger::startDaemons(NULL, $taskids);
Session::set('ia-restart', $taskids);
Util::redirect('?do=InternetAccess&show=update');
}
}
}
protected function doRender()
{
if (Request::any('show') === 'update') {
$taskids = Session::get('ia-restart');
if (is_array($taskids)) {
Render::addTemplate('restart', $taskids);
} else {
Message::addError('invalid-action', 'Restart');
}
}
$data = FileUtil::fileToArray(CONFIG_PROXY_CONF);
if (!isset($data['PROXY_CONF']))
$data['PROXY_CONF'] = 'AUTO';
$data['selected_' . $data['PROXY_CONF']] = 'selected';
Render::addTemplate('_page', $data);
}
}
|