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).
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
* @package Panel
|
|
|
|
*
|
|
|
|
*/
|
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;
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Database\Database;
|
|
|
|
use Froxlor\Settings;
|
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;
|
2018-12-18 12:45:05 +00:00
|
|
|
|
2022-02-20 17:00:44 +00:00
|
|
|
$id = (int) Request::get('id');
|
2018-02-12 12:28:13 +00:00
|
|
|
|
|
|
|
if ($page == '' || $page == 'overview') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
if ($action == '') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-26 14:51:26 +00:00
|
|
|
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
|
2018-02-12 12:28:13 +00:00
|
|
|
$fields = array(
|
2018-12-22 07:15:31 +00:00
|
|
|
'p.name' => $lng['admin']['plans']['name'],
|
|
|
|
'p.description' => $lng['admin']['plans']['description'],
|
|
|
|
'adminname' => $lng['admin']['admin'],
|
|
|
|
'p.ts' => $lng['admin']['plans']['last_update']
|
2018-02-12 12:28:13 +00:00
|
|
|
);
|
2019-11-10 17:35:32 +00:00
|
|
|
try {
|
|
|
|
// get total count
|
|
|
|
$json_result = HostingPlans::getLocal($userinfo)->listingCount();
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
// initialize pagination and filtering
|
|
|
|
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
|
|
|
// get list
|
|
|
|
$json_result = HostingPlans::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
$plans = '';
|
|
|
|
$sortcode = $paging->getHtmlSortCode($lng);
|
|
|
|
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$searchcode = $paging->getHtmlSearchCode($lng);
|
|
|
|
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$count = 0;
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
foreach ($result['list'] as $row) {
|
|
|
|
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
|
|
|
$row['ts_format'] = date("d.m.Y H:i", $row['ts']);
|
|
|
|
eval("\$plans.=\"" . \Froxlor\UI\Template::getTemplate("plans/plans_plan") . "\";");
|
2022-02-22 18:31:28 +00:00
|
|
|
$count++;
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans") . "\";");
|
2018-02-12 12:28:13 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
|
|
|
$json_result = HostingPlans::getLocal($userinfo, array(
|
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['adminid'] == $result['adminid']) {
|
2018-02-12 12:28:13 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
|
|
|
HostingPlans::getLocal($userinfo, array(
|
|
|
|
'id' => $id
|
|
|
|
))->delete();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
2018-02-12 12:28:13 +00:00
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
|
|
|
} else {
|
2018-12-24 12:50:45 +00:00
|
|
|
\Froxlor\UI\HTML::askYesNo('plan_reallydelete', $filename, array(
|
2018-02-12 12:28:13 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
|
|
|
), $result['name']);
|
|
|
|
}
|
|
|
|
} else {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
} elseif ($action == 'add') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
|
|
|
HostingPlans::getLocal($userinfo, $_POST)->add();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
2018-02-12 12:28:13 +00:00
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
|
|
|
} else {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
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)) {
|
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpconfigs[] = array(
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$phpconfigs[] = array(
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'],
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-13 09:58:06 +00:00
|
|
|
// dummy to avoid unknown variables
|
|
|
|
$language_options = null;
|
|
|
|
$gender_options = null;
|
|
|
|
$hosting_plans = null;
|
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
$plans_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/plans/formfield.plans_add.php';
|
|
|
|
$cust_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_add.php';
|
|
|
|
// 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-02-22 18:31:28 +00:00
|
|
|
UI::twigBuffer('user/form.html.twig', [
|
|
|
|
'formaction' => $linker->getLink(array('section' => 'plans')),
|
|
|
|
'formdata' => $plans_add_data['plans_add']
|
|
|
|
]);
|
|
|
|
UI::twigOutputBuffer();
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
|
|
|
$json_result = HostingPlans::getLocal($userinfo, array(
|
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
|
|
}
|
|
|
|
$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'] != '') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
$result['value'] = json_decode($result['value'], true);
|
2018-12-24 12:50:45 +00:00
|
|
|
$result = \Froxlor\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
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
2019-11-13 14:28:08 +00:00
|
|
|
HostingPlans::getLocal($userinfo, $_POST)->update();
|
2019-09-16 10:31:02 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
2018-02-12 12:28:13 +00:00
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
|
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)) {
|
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpconfigs[] = array(
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$phpconfigs[] = array(
|
2022-02-22 18:31:28 +00:00
|
|
|
'label' => $row['description'],
|
2018-02-12 12:28:13 +00:00
|
|
|
'value' => $row['id']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
$language_options = null;
|
|
|
|
$result['firstname'] = null;
|
|
|
|
$gender_options = null;
|
|
|
|
$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;
|
|
|
|
$admin_select_cnt = null;
|
|
|
|
$admin_select = null;
|
|
|
|
|
2018-02-12 12:28:13 +00:00
|
|
|
$plans_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/plans/formfield.plans_edit.php';
|
|
|
|
$cust_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_edit.php';
|
|
|
|
// 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']);
|
|
|
|
// 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-02-22 18:31:28 +00:00
|
|
|
UI::twigBuffer('user/form.html.twig', [
|
|
|
|
'formaction' => $linker->getLink(array('section' => 'plans', 'id' => $id)),
|
|
|
|
'formdata' => $plans_add_data['plans_add']
|
|
|
|
]);
|
|
|
|
UI::twigOutputBuffer();
|
2018-02-12 12:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} elseif ($action == 'jqGetPlanValues') {
|
2018-12-19 15:57:03 +00:00
|
|
|
$planid = isset($_POST['planid']) ? (int) $_POST['planid'] : 0;
|
2019-09-16 10:31:02 +00:00
|
|
|
try {
|
|
|
|
$json_result = HostingPlans::getLocal($userinfo, array(
|
|
|
|
'id' => $planid
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
|
|
}
|
|
|
|
$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
|
|
|
}
|
|
|
|
}
|