major refactoring of almost all files
This commit is contained in:
127
admin_index.php
127
admin_index.php
@@ -2,19 +2,25 @@
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Panel
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you can also view it online at
|
||||
* https://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright the authors
|
||||
* @author Froxlor team <team@froxlor.org>
|
||||
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||
*/
|
||||
|
||||
const AREA = 'admin';
|
||||
@@ -22,40 +28,44 @@ require __DIR__ . '/lib/init.php';
|
||||
|
||||
use Froxlor\Api\Commands\Admins as Admins;
|
||||
use Froxlor\Api\Commands\Froxlor as Froxlor;
|
||||
use Froxlor\CurrentUser;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\System\Cronjob;
|
||||
use Froxlor\System\Crypt;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
use Froxlor\Validate\Validate;
|
||||
|
||||
$id = (int) Request::get('id');
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
if ($action == 'logout') {
|
||||
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "logged out");
|
||||
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "logged out");
|
||||
unset($_SESSION['userinfo']);
|
||||
\Froxlor\CurrentUser::setData();
|
||||
CurrentUser::setData();
|
||||
session_destroy();
|
||||
|
||||
\Froxlor\UI\Response::redirectTo('index.php');
|
||||
Response::redirectTo('index.php');
|
||||
} elseif ($action == 'suback') {
|
||||
if (is_array(\Froxlor\CurrentUser::getField('switched_user'))) {
|
||||
$result = \Froxlor\CurrentUser::getData();
|
||||
if (is_array(CurrentUser::getField('switched_user'))) {
|
||||
$result = CurrentUser::getData();
|
||||
$result = $result['switched_user'];
|
||||
\Froxlor\CurrentUser::setData($result);
|
||||
CurrentUser::setData($result);
|
||||
$target = (isset($_GET['target']) ? $_GET['target'] : 'index');
|
||||
$redirect = "admin_" . $target . ".php";
|
||||
if (!file_exists(\Froxlor\Froxlor::getInstallDir() . "/" . $redirect)) {
|
||||
$redirect = "admin_index.php";
|
||||
}
|
||||
\Froxlor\UI\Response::redirectTo($redirect, null, true);
|
||||
Response::redirectTo($redirect, null, true);
|
||||
} else {
|
||||
\Froxlor\UI\Response::dynamic_error("Cannot change back - You've never switched to another user :-)");
|
||||
Response::dynamicError("Cannot change back - You've never switched to another user :-)");
|
||||
}
|
||||
}
|
||||
|
||||
if ($page == 'overview') {
|
||||
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_index");
|
||||
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_index");
|
||||
$params = [];
|
||||
if ($userinfo['customers_see_all'] == '0') {
|
||||
$params = [
|
||||
@@ -103,7 +113,7 @@ if ($page == 'overview') {
|
||||
try {
|
||||
$json_result = Froxlor::getLocal($userinfo)->checkUpdate();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
@@ -113,15 +123,15 @@ if ($page == 'overview') {
|
||||
$lookfornewversion_addinfo = $result['additional_info'];
|
||||
$isnewerversion = $result['isnewerversion'];
|
||||
} else {
|
||||
$lookfornewversion_lable = $lng['admin']['lookfornewversion']['clickhere'];
|
||||
$lookfornewversion_lable = lng('admin.lookfornewversion.clickhere');
|
||||
$lookfornewversion_link = htmlspecialchars($filename . '?page=' . urlencode($page) . '&lookfornewversion=yes');
|
||||
$lookfornewversion_message = '';
|
||||
$lookfornewversion_addinfo = '';
|
||||
$isnewerversion = 0;
|
||||
}
|
||||
|
||||
$cron_last_runs = \Froxlor\System\Cronjob::getCronjobsLastRun();
|
||||
$outstanding_tasks = \Froxlor\System\Cronjob::getOutstandingTasks();
|
||||
$cron_last_runs = Cronjob::getCronjobsLastRun();
|
||||
$outstanding_tasks = Cronjob::getOutstandingTasks();
|
||||
|
||||
// additional sys-infos
|
||||
$meminfo = explode("\n", @file_get_contents("/proc/meminfo"));
|
||||
@@ -138,7 +148,7 @@ if ($page == 'overview') {
|
||||
} else {
|
||||
$load = @file_get_contents('/proc/loadavg');
|
||||
if (!$load) {
|
||||
$load = $lng['admin']['noloadavailable'];
|
||||
$load = lng('admin.noloadavailable');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,72 +196,69 @@ if ($page == 'overview') {
|
||||
'cron_last_runs' => $cron_last_runs
|
||||
]);
|
||||
} elseif ($page == 'change_password') {
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password');
|
||||
$old_password = Validate::validate($_POST['old_password'], 'old password');
|
||||
|
||||
if (!\Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_ADMINS, 'adminid')) {
|
||||
\Froxlor\UI\Response::standard_error('oldpasswordnotcorrect');
|
||||
if (!Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_ADMINS, 'adminid')) {
|
||||
Response::standardError('oldpasswordnotcorrect');
|
||||
}
|
||||
|
||||
try {
|
||||
$new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password');
|
||||
$new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
|
||||
$new_password = Crypt::validatePassword($_POST['new_password'], 'new password');
|
||||
$new_password_confirm = Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
|
||||
if ($old_password == '') {
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
Response::standardError([
|
||||
'stringisempty',
|
||||
'oldpassword'
|
||||
));
|
||||
]);
|
||||
} elseif ($new_password == '') {
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
Response::standardError([
|
||||
'stringisempty',
|
||||
'newpassword'
|
||||
));
|
||||
]);
|
||||
} elseif ($new_password_confirm == '') {
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
Response::standardError([
|
||||
'stringisempty',
|
||||
'newpasswordconfirm'
|
||||
));
|
||||
]);
|
||||
} elseif ($new_password != $new_password_confirm) {
|
||||
\Froxlor\UI\Response::standard_error('newpasswordconfirmerror');
|
||||
Response::standardError('newpasswordconfirmerror');
|
||||
} else {
|
||||
try {
|
||||
Admins::getLocal($userinfo, array(
|
||||
Admins::getLocal($userinfo, [
|
||||
'id' => $userinfo['adminid'],
|
||||
'admin_password' => $new_password
|
||||
))->update();
|
||||
])->update();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'changed password');
|
||||
\Froxlor\UI\Response::redirectTo($filename);
|
||||
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'changed password');
|
||||
Response::redirectTo($filename);
|
||||
}
|
||||
} else {
|
||||
UI::view('user/change_password.html.twig');
|
||||
}
|
||||
} elseif ($page == 'change_language') {
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$def_language = \Froxlor\Validate\Validate::validate($_POST['def_language'], 'default language');
|
||||
$def_language = Validate::validate($_POST['def_language'], 'default language');
|
||||
|
||||
if (isset($languages[$def_language])) {
|
||||
try {
|
||||
Admins::getLocal($userinfo, array(
|
||||
Admins::getLocal($userinfo, [
|
||||
'id' => $userinfo['adminid'],
|
||||
'def_language' => $def_language
|
||||
))->update();
|
||||
])->update();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
}
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
|
||||
\Froxlor\UI\Response::redirectTo($filename);
|
||||
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
|
||||
Response::redirectTo($filename);
|
||||
} else {
|
||||
|
||||
$default_lang = Settings::Get('panel.standardlanguage');
|
||||
if ($userinfo['def_language'] != '') {
|
||||
$default_lang = $userinfo['def_language'];
|
||||
@@ -263,22 +270,20 @@ if ($page == 'overview') {
|
||||
]);
|
||||
}
|
||||
} elseif ($page == 'change_theme') {
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$theme = \Froxlor\Validate\Validate::validate($_POST['theme'], 'theme');
|
||||
$theme = Validate::validate($_POST['theme'], 'theme');
|
||||
try {
|
||||
Admins::getLocal($userinfo, array(
|
||||
Admins::getLocal($userinfo, [
|
||||
'id' => $userinfo['adminid'],
|
||||
'theme' => $theme
|
||||
))->update();
|
||||
])->update();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her theme to '" . $theme . "'");
|
||||
\Froxlor\UI\Response::redirectTo($filename);
|
||||
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her theme to '" . $theme . "'");
|
||||
Response::redirectTo($filename);
|
||||
} else {
|
||||
|
||||
$default_theme = Settings::Get('panel.default_theme');
|
||||
if ($userinfo['theme'] != '') {
|
||||
$default_theme = $userinfo['theme'];
|
||||
|
||||
Reference in New Issue
Block a user