major refactoring of almost all files
This commit is contained in:
137
admin_plans.php
137
admin_plans.php
@@ -4,15 +4,23 @@
|
||||
* This file is part of the Froxlor project.
|
||||
* 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 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';
|
||||
@@ -20,81 +28,83 @@ require __DIR__ . '/lib/init.php';
|
||||
|
||||
use Froxlor\Api\Commands\HostingPlans;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\PhpHelper;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\UI\Collection;
|
||||
use Froxlor\UI\HTML;
|
||||
use Froxlor\UI\Listing;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
|
||||
$id = (int) Request::get('id');
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
if ($page == '' || $page == 'overview') {
|
||||
|
||||
if ($action == '') {
|
||||
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
|
||||
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
|
||||
|
||||
try {
|
||||
$plan_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.plans.php';
|
||||
$collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\HostingPlans::class, $userinfo))
|
||||
->withPagination($plan_list_data['plan_list']['columns']);
|
||||
$plan_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.plans.php';
|
||||
$collection = (new Collection(HostingPlans::class, $userinfo))
|
||||
->withPagination($plan_list_data['plan_list']['columns']);
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
|
||||
UI::view('user/table.html.twig', [
|
||||
'listing' => \Froxlor\UI\Listing::format($collection, $plan_list_data, 'plan_list') ,
|
||||
'actions_links' => [[
|
||||
'href' => $linker->getLink(['section' => 'plans', 'page' => $page, 'action' => 'add']),
|
||||
'label' => $lng['admin']['plans']['add']
|
||||
]]
|
||||
'listing' => Listing::format($collection, $plan_list_data, 'plan_list'),
|
||||
'actions_links' => [
|
||||
[
|
||||
'href' => $linker->getLink(['section' => 'plans', 'page' => $page, 'action' => 'add']),
|
||||
'label' => lng('admin.plans.add')
|
||||
]
|
||||
]
|
||||
]);
|
||||
} elseif ($action == 'delete' && $id != 0) {
|
||||
|
||||
try {
|
||||
$json_result = HostingPlans::getLocal($userinfo, array(
|
||||
$json_result = HostingPlans::getLocal($userinfo, [
|
||||
'id' => $id
|
||||
))->get();
|
||||
])->get();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['adminid'] == $result['adminid']) {
|
||||
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['adminid'] == $result['adminid']) {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
|
||||
try {
|
||||
HostingPlans::getLocal($userinfo, array(
|
||||
HostingPlans::getLocal($userinfo, [
|
||||
'id' => $id
|
||||
))->delete();
|
||||
])->delete();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
|
||||
\Froxlor\UI\Response::redirectTo($filename, array(
|
||||
Response::redirectTo($filename, [
|
||||
'page' => $page
|
||||
));
|
||||
]);
|
||||
} else {
|
||||
\Froxlor\UI\HTML::askYesNo('plan_reallydelete', $filename, array(
|
||||
HTML::askYesNo('plan_reallydelete', $filename, [
|
||||
'id' => $id,
|
||||
'page' => $page,
|
||||
'action' => $action
|
||||
), $result['name']);
|
||||
], $result['name']);
|
||||
}
|
||||
} else {
|
||||
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
|
||||
Response::standardError('nopermissionsorinvalidid');
|
||||
}
|
||||
} elseif ($action == 'add') {
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
try {
|
||||
HostingPlans::getLocal($userinfo, $_POST)->add();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
\Froxlor\UI\Response::redirectTo($filename, array(
|
||||
Response::redirectTo($filename, [
|
||||
'page' => $page
|
||||
));
|
||||
]);
|
||||
} else {
|
||||
|
||||
$phpconfigs = [];
|
||||
$configs = Database::query("
|
||||
SELECT c.*, fc.description as interpreter
|
||||
@@ -102,16 +112,16 @@ if ($page == '' || $page == 'overview') {
|
||||
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
|
||||
");
|
||||
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
||||
$phpconfigs[] = array(
|
||||
if ((int)Settings::Get('phpfpm.enabled') == 1) {
|
||||
$phpconfigs[] = [
|
||||
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
|
||||
'value' => $row['id']
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$phpconfigs[] = array(
|
||||
$phpconfigs[] = [
|
||||
'label' => $row['description'],
|
||||
'value' => $row['id']
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,24 +138,23 @@ if ($page == '' || $page == 'overview') {
|
||||
$plans_add_data['plans_add']['sections'] = array_merge($plans_add_data['plans_add']['sections'], $cust_add_data['customer_add']['sections']);
|
||||
|
||||
UI::view('user/form.html.twig', [
|
||||
'formaction' => $linker->getLink(array('section' => 'plans')),
|
||||
'formaction' => $linker->getLink(['section' => 'plans']),
|
||||
'formdata' => $plans_add_data['plans_add']
|
||||
]);
|
||||
}
|
||||
} elseif ($action == 'edit' && $id != 0) {
|
||||
try {
|
||||
$json_result = HostingPlans::getLocal($userinfo, array(
|
||||
$json_result = HostingPlans::getLocal($userinfo, [
|
||||
'id' => $id
|
||||
))->get();
|
||||
])->get();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
if ($result['name'] != '') {
|
||||
|
||||
$result['value'] = json_decode($result['value'], true);
|
||||
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
|
||||
$result = PhpHelper::htmlentitiesArray($result);
|
||||
|
||||
foreach ($result['value'] as $index => $value) {
|
||||
$result[$index] = $value;
|
||||
@@ -153,17 +162,15 @@ if ($page == '' || $page == 'overview') {
|
||||
$result['allowed_phpconfigs'] = json_encode($result['allowed_phpconfigs']);
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
|
||||
try {
|
||||
HostingPlans::getLocal($userinfo, $_POST)->update();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
\Froxlor\UI\Response::redirectTo($filename, array(
|
||||
Response::redirectTo($filename, [
|
||||
'page' => $page
|
||||
));
|
||||
]);
|
||||
} else {
|
||||
|
||||
$phpconfigs = [];
|
||||
$configs = Database::query("
|
||||
SELECT c.*, fc.description as interpreter
|
||||
@@ -171,16 +178,16 @@ if ($page == '' || $page == 'overview') {
|
||||
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
|
||||
");
|
||||
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
||||
$phpconfigs[] = array(
|
||||
if ((int)Settings::Get('phpfpm.enabled') == 1) {
|
||||
$phpconfigs[] = [
|
||||
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
|
||||
'value' => $row['id']
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$phpconfigs[] = array(
|
||||
$phpconfigs[] = [
|
||||
'label' => $row['description'],
|
||||
'value' => $row['id']
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,20 +227,20 @@ if ($page == '' || $page == 'overview') {
|
||||
$plans_edit_data['plans_edit']['sections'] = array_merge($plans_edit_data['plans_edit']['sections'], $cust_edit_data['customer_edit']['sections']);
|
||||
|
||||
UI::view('user/form.html.twig', [
|
||||
'formaction' => $linker->getLink(array('section' => 'plans', 'id' => $id)),
|
||||
'formaction' => $linker->getLink(['section' => 'plans', 'id' => $id]),
|
||||
'formdata' => $plans_edit_data['plans_edit'],
|
||||
'editid' => $id
|
||||
]);
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'jqGetPlanValues') {
|
||||
$planid = isset($_POST['planid']) ? (int) $_POST['planid'] : 0;
|
||||
$planid = isset($_POST['planid']) ? (int)$_POST['planid'] : 0;
|
||||
try {
|
||||
$json_result = HostingPlans::getLocal($userinfo, array(
|
||||
$json_result = HostingPlans::getLocal($userinfo, [
|
||||
'id' => $planid
|
||||
))->get();
|
||||
])->get();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
echo $result['value'];
|
||||
|
||||
Reference in New Issue
Block a user