2018-02-12 12:28:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of the Froxlor project.
|
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* 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.
|
2018-02-12 12:28:13 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* 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.
|
2018-02-12 12:28:13 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* 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
|
2018-02-12 12:28:13 +00:00
|
|
|
*/
|
2022-02-20 17:00:44 +00:00
|
|
|
|
|
|
|
const AREA = 'admin';
|
|
|
|
require __DIR__ . '/lib/init.php';
|
2018-02-12 12:28:13 +00:00
|
|
|
|
2019-09-16 10:31:02 +00:00
|
|
|
use Froxlor\Api\Commands\HostingPlans;
|
2022-08-26 07:06:42 +00:00
|
|
|
use Froxlor\Api\Commands\MysqlServer;
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Database\Database;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\FroxlorLogger;
|
|
|
|
use Froxlor\PhpHelper;
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Settings;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\UI\Collection;
|
|
|
|
use Froxlor\UI\HTML;
|
|
|
|
use Froxlor\UI\Listing;
|
2022-02-22 18:31:28 +00:00
|
|
|
use Froxlor\UI\Panel\UI;
|
2022-02-20 17:00:44 +00:00
|
|
|
use Froxlor\UI\Request;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\UI\Response;
|
2018-12-18 12:45:05 +00:00
|
|
|
|
2022-12-30 20:43:27 +00:00
|
|
|
$id = (int)Request::any('id');
|
2018-02-12 12:28:13 +00:00
|
|
|
|
|
|
|
if ($page == '' || $page == 'overview') {
|
|
|
|
if ($action == '') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
|
2022-02-24 20:39:31 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$plan_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.plans.php';
|
|
|
|
$collection = (new Collection(HostingPlans::class, $userinfo))
|
2022-09-30 07:44:11 +00:00
|
|
|
->withPagination($plan_list_data['plan_list']['columns'], $plan_list_data['plan_list']['default_sorting']);
|
2019-11-10 17:35:32 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2019-11-10 17:35:32 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/table.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'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')
|
|
|
|
]
|
|
|
|
]
|
2022-02-25 19:41:06 +00:00
|
|
|
]);
|
2018-02-12 12:28:13 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = HostingPlans::getLocal($userinfo, [
|
2019-09-16 10:31:02 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2019-09-16 10:31:02 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2019-09-16 10:31:02 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['adminid'] == $result['adminid']) {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
HostingPlans::getLocal($userinfo, [
|
2019-09-16 10:31:02 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->delete();
|
2019-09-16 10:31:02 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2019-09-16 10:31:02 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-02-12 12:28:13 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('plan_reallydelete', $filename, [
|
2018-02-12 12:28:13 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
2022-04-28 18:48:00 +00:00
|
|
|
], $result['name']);
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardError('nopermissionsorinvalidid');
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
} elseif ($action == 'add') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
HostingPlans::getLocal($userinfo, Request::postAll())->add();
|
2019-09-16 10:31:02 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-02-12 12:28:13 +00:00
|
|
|
} else {
|
2022-08-26 07:06:42 +00:00
|
|
|
$mysql_servers = [];
|
|
|
|
try {
|
|
|
|
$result_json = MysqlServer::getLocal($userinfo)->listing();
|
|
|
|
$result_decoded = json_decode($result_json, true)['data']['list'];
|
|
|
|
foreach ($result_decoded as $dbserver => $dbdata) {
|
|
|
|
$mysql_servers[] = [
|
|
|
|
'label' => $dbdata['caption'],
|
|
|
|
'value' => $dbserver
|
|
|
|
];
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
|
|
/* just none */
|
|
|
|
}
|
|
|
|
|
2022-02-22 18:31:28 +00:00
|
|
|
$phpconfigs = [];
|
2018-02-12 12:28:13 +00:00
|
|
|
$configs = Database::query("
|
|
|
|
SELECT c.*, fc.description as interpreter
|
|
|
|
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
|
|
|
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
|
|
|
|
");
|
|
|
|
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
|
2022-04-28 18:48:00 +00:00
|
|
|
if ((int)Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpconfigs[] = [
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2018-02-12 12:28:13 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
$phpconfigs[] = [
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'],
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-13 09:58:06 +00:00
|
|
|
// dummy to avoid unknown variables
|
|
|
|
$hosting_plans = null;
|
|
|
|
|
2022-08-26 07:06:42 +00:00
|
|
|
$plans_add_data = include_once __DIR__ . '/lib/formfields/admin/plans/formfield.plans_add.php';
|
|
|
|
$cust_add_data = include_once __DIR__ . '/lib/formfields/admin/customer/formfield.customer_add.php';
|
2018-02-12 12:28:13 +00:00
|
|
|
// unset unneeded stuff
|
|
|
|
unset($cust_add_data['customer_add']['sections']['section_a']);
|
|
|
|
unset($cust_add_data['customer_add']['sections']['section_b']);
|
|
|
|
unset($cust_add_data['customer_add']['sections']['section_cpre']);
|
|
|
|
// merge
|
|
|
|
$plans_add_data['plans_add']['sections'] = array_merge($plans_add_data['plans_add']['sections'], $cust_add_data['customer_add']['sections']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'plans']),
|
2022-02-22 18:31:28 +00:00
|
|
|
'formdata' => $plans_add_data['plans_add']
|
|
|
|
]);
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = HostingPlans::getLocal($userinfo, [
|
2019-09-16 10:31:02 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2019-09-16 10:31:02 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2019-09-16 10:31:02 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
if ($result['name'] != '') {
|
|
|
|
$result['value'] = json_decode($result['value'], true);
|
2022-04-28 18:48:00 +00:00
|
|
|
$result = PhpHelper::htmlentitiesArray($result);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
foreach ($result['value'] as $index => $value) {
|
|
|
|
$result[$index] = $value;
|
|
|
|
}
|
|
|
|
$result['allowed_phpconfigs'] = json_encode($result['allowed_phpconfigs']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
HostingPlans::getLocal($userinfo, Request::postAll())->update();
|
2019-09-16 10:31:02 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-02-12 12:28:13 +00:00
|
|
|
} else {
|
2022-08-26 07:06:42 +00:00
|
|
|
$mysql_servers = [];
|
|
|
|
try {
|
|
|
|
$result_json = MysqlServer::getLocal($userinfo)->listing();
|
|
|
|
$result_decoded = json_decode($result_json, true)['data']['list'];
|
|
|
|
foreach ($result_decoded as $dbserver => $dbdata) {
|
|
|
|
$mysql_servers[] = [
|
|
|
|
'label' => $dbdata['caption'],
|
|
|
|
'value' => $dbserver
|
|
|
|
];
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
|
|
/* just none */
|
|
|
|
}
|
|
|
|
|
2022-02-22 18:31:28 +00:00
|
|
|
$phpconfigs = [];
|
2018-02-12 12:28:13 +00:00
|
|
|
$configs = Database::query("
|
|
|
|
SELECT c.*, fc.description as interpreter
|
|
|
|
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
|
|
|
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
|
|
|
|
");
|
|
|
|
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
|
2022-04-28 18:48:00 +00:00
|
|
|
if ((int)Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpconfigs[] = [
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2018-02-12 12:28:13 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
$phpconfigs[] = [
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'],
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-13 09:58:06 +00:00
|
|
|
|
2018-02-14 06:40:39 +00:00
|
|
|
$result['imap'] = $result['email_imap'];
|
|
|
|
$result['pop3'] = $result['email_pop3'];
|
|
|
|
|
2018-02-13 09:58:06 +00:00
|
|
|
// dummy to avoid unknown variables
|
|
|
|
$result['loginname'] = null;
|
|
|
|
$result['documentroot'] = null;
|
|
|
|
$result['standardsubdomain'] = null;
|
|
|
|
$result['deactivated'] = null;
|
2022-03-13 11:16:42 +00:00
|
|
|
$result['def_language'] = null;
|
2018-02-13 09:58:06 +00:00
|
|
|
$result['firstname'] = null;
|
2022-03-13 11:16:42 +00:00
|
|
|
$result['gender'] = null;
|
2018-02-13 09:58:06 +00:00
|
|
|
$result['company'] = null;
|
|
|
|
$result['street'] = null;
|
|
|
|
$result['zipcode'] = null;
|
|
|
|
$result['city'] = null;
|
|
|
|
$result['phone'] = null;
|
|
|
|
$result['fax'] = null;
|
|
|
|
$result['email'] = null;
|
|
|
|
$result['customernumber'] = null;
|
|
|
|
$result['custom_notes'] = null;
|
|
|
|
$result['custom_notes_show'] = null;
|
2019-10-28 19:06:14 +00:00
|
|
|
$result['api_allowed'] = null;
|
2018-02-13 09:58:06 +00:00
|
|
|
$hosting_plans = null;
|
2022-03-13 11:16:42 +00:00
|
|
|
$admin_select = [];
|
2018-02-13 09:58:06 +00:00
|
|
|
|
2022-08-26 07:06:42 +00:00
|
|
|
$plans_edit_data = include_once __DIR__ . '/lib/formfields/admin/plans/formfield.plans_edit.php';
|
|
|
|
$cust_edit_data = include_once __DIR__ . '/lib/formfields/admin/customer/formfield.customer_edit.php';
|
2018-02-12 12:28:13 +00:00
|
|
|
// unset unneeded stuff
|
|
|
|
unset($cust_edit_data['customer_edit']['sections']['section_a']);
|
|
|
|
unset($cust_edit_data['customer_edit']['sections']['section_b']);
|
|
|
|
unset($cust_edit_data['customer_edit']['sections']['section_cpre']);
|
2022-03-13 11:16:42 +00:00
|
|
|
unset($cust_edit_data['customer_edit']['sections']['section_d']);
|
2018-02-12 12:28:13 +00:00
|
|
|
// merge
|
|
|
|
$plans_edit_data['plans_edit']['sections'] = array_merge($plans_edit_data['plans_edit']['sections'], $cust_edit_data['customer_edit']['sections']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'plans', 'id' => $id]),
|
2022-02-28 09:51:19 +00:00
|
|
|
'formdata' => $plans_edit_data['plans_edit'],
|
|
|
|
'editid' => $id
|
2022-02-22 18:31:28 +00:00
|
|
|
]);
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} elseif ($action == 'jqGetPlanValues') {
|
2022-12-30 20:43:27 +00:00
|
|
|
$planid = (int)Request::any('planid', 0);
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = HostingPlans::getLocal($userinfo, [
|
2019-09-16 10:31:02 +00:00
|
|
|
'id' => $planid
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2019-09-16 10:31:02 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2019-09-16 10:31:02 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-02-12 12:28:13 +00:00
|
|
|
echo $result['value'];
|
2018-12-19 15:57:03 +00:00
|
|
|
exit();
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
}
|