Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c30961d3c | ||
|
|
edd5ef0ca0 | ||
|
|
6befe85656 | ||
|
|
27f8c8b438 | ||
|
|
fc0c796b68 | ||
|
|
482e8c9a11 | ||
|
|
7a664a9990 | ||
|
|
372ab5d9c8 | ||
|
|
de70dbb888 | ||
|
|
4d7ceb9efe | ||
|
|
bb792f228f | ||
|
|
017396197e | ||
|
|
216f013c96 | ||
|
|
05f1bf0a1f | ||
|
|
295fbae6f5 | ||
|
|
ca4c93ac92 |
@@ -170,6 +170,11 @@ if ($page == 'admins'
|
||||
");
|
||||
Database::pexecute($del_stmt, array('adminid' => $id));
|
||||
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_DISKSPACE_ADMINS . "` WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($del_stmt, array('adminid' => $id));
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
||||
`adminid` = :userid WHERE `adminid` = :adminid
|
||||
|
||||
@@ -307,6 +307,8 @@ if ($page == 'customers'
|
||||
Database::pexecute($stmt, array('id' => $id));
|
||||
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `customerid` = :id");
|
||||
Database::pexecute($stmt, array('id' => $id));
|
||||
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DISKSPACE . "` WHERE `customerid` = :id");
|
||||
Database::pexecute($stmt, array('id' => $id));
|
||||
$stmt = Database::prepare("DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = :id");
|
||||
Database::pexecute($stmt, array('id' => $id));
|
||||
$stmt = Database::prepare("DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :id");
|
||||
@@ -1073,6 +1075,20 @@ if ($page == 'customers'
|
||||
}
|
||||
}
|
||||
|
||||
// hosting plans
|
||||
$hosting_plans = "";
|
||||
$plans = Database::query("
|
||||
SELECT *
|
||||
FROM `" . TABLE_PANEL_PLANS . "`
|
||||
ORDER BY name ASC
|
||||
");
|
||||
if (Database::num_rows() > 0){
|
||||
$hosting_plans .= makeoption("---", 0, 0, true, true);
|
||||
}
|
||||
while ($row = $plans->fetch(PDO::FETCH_ASSOC)) {
|
||||
$hosting_plans .= makeoption($row['name'], $row['id'], 0, true, true);
|
||||
}
|
||||
|
||||
$customer_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_add.php';
|
||||
$customer_add_form = htmlform::genHTMLForm($customer_add_data);
|
||||
|
||||
@@ -1755,6 +1771,20 @@ if ($page == 'customers'
|
||||
}
|
||||
}
|
||||
|
||||
// hosting plans
|
||||
$hosting_plans = "";
|
||||
$plans = Database::query("
|
||||
SELECT *
|
||||
FROM `" . TABLE_PANEL_PLANS . "`
|
||||
ORDER BY name ASC
|
||||
");
|
||||
if (Database::num_rows() > 0){
|
||||
$hosting_plans .= makeoption("---", 0, 0, true, true);
|
||||
}
|
||||
while ($row = $plans->fetch(PDO::FETCH_ASSOC)) {
|
||||
$hosting_plans .= makeoption($row['name'], $row['id'], 0, true, true);
|
||||
}
|
||||
|
||||
$customer_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_edit.php';
|
||||
$customer_edit_form = htmlform::genHTMLForm($customer_edit_data);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
$syshostname = "AND `d`.`id` <> " . Settings::Get('system.hostname_id');
|
||||
}
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `d`.*, `c`.`loginname`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`
|
||||
SELECT `d`.*, `c`.`loginname`, `c`.`deactivated`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`
|
||||
FROM `" . TABLE_PANEL_DOMAINS . "` `d`
|
||||
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`)
|
||||
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `ad` ON `d`.`aliasdomain`=`ad`.`id`
|
||||
@@ -429,6 +429,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
}
|
||||
|
||||
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
|
||||
$notryfiles = isset($_POST['notryfiles']) && (int)$_POST['notryfiles'] == 1 ? 1 : 0;
|
||||
validate($_POST['documentroot'], 'documentroot');
|
||||
|
||||
// If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
|
||||
@@ -451,6 +452,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
$zonefile = '';
|
||||
$dkim = '1';
|
||||
$specialsettings = '';
|
||||
$notryfiles = '0';
|
||||
}
|
||||
|
||||
if ($userinfo['caneditphpsettings'] == '1' || $userinfo['change_serversettings'] == '1') {
|
||||
@@ -801,6 +803,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
'mod_fcgid_starter' => $mod_fcgid_starter,
|
||||
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests,
|
||||
'specialsettings' => $specialsettings,
|
||||
'notryfiles' => $notryfiles,
|
||||
'registration_date' => $registration_date,
|
||||
'termination_date' => $termination_date,
|
||||
'issubof' => $issubof,
|
||||
@@ -850,6 +853,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
'openbasedir' => $openbasedir,
|
||||
'speciallogfile' => $speciallogfile,
|
||||
'specialsettings' => $specialsettings,
|
||||
'notryfiles' => $notryfiles,
|
||||
'ssl_redirect' => $ssl_redirect,
|
||||
'add_date' => time(),
|
||||
'registration_date' => $registration_date,
|
||||
@@ -889,6 +893,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
`openbasedir` = :openbasedir,
|
||||
`speciallogfile` = :speciallogfile,
|
||||
`specialsettings` = :specialsettings,
|
||||
`notryfiles` = :notryfiles,
|
||||
`ssl_redirect` = :ssl_redirect,
|
||||
`add_date` = :add_date,
|
||||
`registration_date` = :registration_date,
|
||||
@@ -1338,6 +1343,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
|
||||
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
|
||||
$ssfs = (isset($_POST['specialsettingsforsubdomains']) && intval($_POST['specialsettingsforsubdomains']) == 1) ? 1 : 0;
|
||||
$notryfiles = isset($_POST['notryfiles']) && (int)$_POST['notryfiles'] == 1 ? 1 : 0;
|
||||
$documentroot = validate($_POST['documentroot'], 'documentroot');
|
||||
|
||||
if ($documentroot == '') {
|
||||
@@ -1359,6 +1365,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
$dkim = $result['dkim'];
|
||||
$specialsettings = $result['specialsettings'];
|
||||
$ssfs = (empty($specialsettings) ? 0 : 1);
|
||||
$notryfiles = $result['notryfiles'];
|
||||
$documentroot = $result['documentroot'];
|
||||
}
|
||||
|
||||
@@ -1655,6 +1662,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests,
|
||||
'specialsettings' => $specialsettings,
|
||||
'specialsettingsforsubdomains' => $ssfs,
|
||||
'notryfiles' => $notryfiles,
|
||||
'registration_date' => $registration_date,
|
||||
'termination_date' => $termination_date,
|
||||
'issubof' => $issubof,
|
||||
@@ -1697,6 +1705,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
$mod_fcgid_starter != $result['mod_fcgid_starter'] ||
|
||||
$mod_fcgid_maxrequests != $result['mod_fcgid_maxrequests'] ||
|
||||
$specialsettings != $result['specialsettings'] ||
|
||||
$notryfiles != $result['notryfiles'] ||
|
||||
$aliasdomain != $result['aliasdomain'] ||
|
||||
$issubof != $result['ismainbutsubto'] ||
|
||||
$email_only != $result['email_only'] ||
|
||||
@@ -1855,6 +1864,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
$update_data['mod_fcgid_starter'] = $mod_fcgid_starter;
|
||||
$update_data['mod_fcgid_maxrequests'] = $mod_fcgid_maxrequests;
|
||||
$update_data['specialsettings'] = $specialsettings;
|
||||
$update_data['notryfiles'] = $notryfiles;
|
||||
$update_data['registration_date'] = $registration_date;
|
||||
$update_data['termination_date'] = $termination_date;
|
||||
$update_data['ismainbutsubto'] = $issubof;
|
||||
@@ -1889,6 +1899,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
`mod_fcgid_starter` = :mod_fcgid_starter,
|
||||
`mod_fcgid_maxrequests` = :mod_fcgid_maxrequests,
|
||||
`specialsettings` = :specialsettings,
|
||||
`notryfiles` = :notryfiles,
|
||||
`registration_date` = :registration_date,
|
||||
`termination_date` = :termination_date,
|
||||
`ismainbutsubto` = :ismainbutsubto,
|
||||
|
||||
522
admin_plans.php
Normal file
522
admin_plans.php
Normal file
@@ -0,0 +1,522 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
define('AREA', 'admin');
|
||||
require './lib/init.php';
|
||||
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
} elseif (isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']);
|
||||
}
|
||||
|
||||
if ($page == '' || $page == 'overview') {
|
||||
|
||||
if ($action == '') {
|
||||
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
|
||||
$fields = array(
|
||||
'p.name' => $lng['admin']['plans']['name'],
|
||||
'p.description' => $lng['admin']['plans']['description'],
|
||||
'adminname' => $lng['admin']['admin'],
|
||||
'p.ts' => $lng['admin']['plans']['last_update']
|
||||
);
|
||||
$paging = new paging($userinfo, TABLE_PANEL_PLANS, $fields);
|
||||
$plans = '';
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT p.*, a.loginname as adminname
|
||||
FROM `" . TABLE_PANEL_PLANS . "` p, `" . TABLE_PANEL_ADMINS . "` a
|
||||
WHERE " . ($userinfo['customers_see_all'] ? '' : " `p`.`adminid` = :adminid AND ") . "
|
||||
`p`.`adminid` = `a`.`adminid` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
'adminid' => $userinfo['adminid']
|
||||
));
|
||||
$paging->setEntries(Database::num_rows());
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = htmlentities_array($row);
|
||||
$row['ts_format'] = date("d.m.Y H:i", $row['ts']);
|
||||
eval("\$plans.=\"" . getTemplate("plans/plans_plan") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("plans/plans") . "\";");
|
||||
} elseif ($action == 'delete' && $id != 0) {
|
||||
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
|
||||
$result = Database::pexecute_first($result_stmt, array(
|
||||
'id' => $id
|
||||
));
|
||||
|
||||
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['adminid'] == $result['adminid']) {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
|
||||
Database::pexecute($del_stmt, array(
|
||||
'id' => $id
|
||||
));
|
||||
|
||||
$log->logAction(ADM_ACTION, LOG_INFO, "Plan '" . $result['name'] . "' has been deleted by '" . $userinfo['loginname'] . "'");
|
||||
redirectTo($filename, array(
|
||||
'page' => $page,
|
||||
's' => $s
|
||||
));
|
||||
} else {
|
||||
ask_yesno('plan_reallydelete', $filename, array(
|
||||
'id' => $id,
|
||||
'page' => $page,
|
||||
'action' => $action
|
||||
), $result['name']);
|
||||
}
|
||||
} else {
|
||||
standard_error('nopermissionsorinvalidid');
|
||||
}
|
||||
} elseif ($action == 'add') {
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$name = validate($_POST['name'], 'name');
|
||||
$description = validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/');
|
||||
|
||||
$value_arr = array();
|
||||
|
||||
$value_arr['diskspace'] = intval_ressource($_POST['diskspace']);
|
||||
if (isset($_POST['diskspace_ul'])) {
|
||||
$value_arr['diskspace'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['traffic'] = doubleval_ressource($_POST['traffic']);
|
||||
if (isset($_POST['traffic_ul'])) {
|
||||
$value_arr['traffic'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['subdomains'] = intval_ressource($_POST['subdomains']);
|
||||
if (isset($_POST['subdomains_ul'])) {
|
||||
$value_arr['subdomains'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['emails'] = intval_ressource($_POST['emails']);
|
||||
if (isset($_POST['emails_ul'])) {
|
||||
$value_arr['emails'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['email_accounts'] = intval_ressource($_POST['email_accounts']);
|
||||
if (isset($_POST['email_accounts_ul'])) {
|
||||
$value_arr['email_accounts'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['email_forwarders'] = intval_ressource($_POST['email_forwarders']);
|
||||
if (isset($_POST['email_forwarders_ul'])) {
|
||||
$value_arr['email_forwarders'] = - 1;
|
||||
}
|
||||
|
||||
if (Settings::Get('system.mail_quota_enabled') == '1') {
|
||||
$value_arr['email_quota'] = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array(
|
||||
'0',
|
||||
''
|
||||
));
|
||||
if (isset($_POST['email_quota_ul'])) {
|
||||
$value_arr['email_quota'] = - 1;
|
||||
}
|
||||
} else {
|
||||
$value_arr['email_quota'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['email_imap'] = 0;
|
||||
if (isset($_POST['email_imap'])) {
|
||||
$value_arr['email_imap'] = intval_ressource($_POST['email_imap']);
|
||||
}
|
||||
|
||||
$value_arr['email_pop3'] = 0;
|
||||
if (isset($_POST['email_pop3'])) {
|
||||
$value_arr['email_pop3'] = intval_ressource($_POST['email_pop3']);
|
||||
}
|
||||
|
||||
$value_arr['ftps'] = intval_ressource($_POST['ftps']);
|
||||
if (isset($_POST['ftps_ul'])) {
|
||||
$value_arr['ftps'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['tickets'] = (Settings::Get('ticket.enabled') == 1 ? intval_ressource($_POST['tickets']) : 0);
|
||||
if (isset($_POST['tickets_ul']) && Settings::Get('ticket.enabled') == '1') {
|
||||
$value_arr['tickets'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['mysqls'] = intval_ressource($_POST['mysqls']);
|
||||
if (isset($_POST['mysqls_ul'])) {
|
||||
$value_arr['mysqls'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['phpenabled'] = 0;
|
||||
if (isset($_POST['phpenabled'])) {
|
||||
$value_arr['phpenabled'] = intval($_POST['phpenabled']);
|
||||
}
|
||||
|
||||
$value_arr['allowed_phpconfigs'] = array();
|
||||
if (isset($_POST['allowed_phpconfigs']) && is_array($_POST['allowed_phpconfigs'])) {
|
||||
foreach ($_POST['allowed_phpconfigs'] as $allowed_phpconfig) {
|
||||
$allowed_phpconfig = intval($allowed_phpconfig);
|
||||
$value_arr['allowed_phpconfigs'][] = $allowed_phpconfig;
|
||||
}
|
||||
}
|
||||
|
||||
$value_arr['perlenabled'] = 0;
|
||||
if (isset($_POST['perlenabled'])) {
|
||||
$value_arr['perlenabled'] = intval($_POST['perlenabled']);
|
||||
}
|
||||
|
||||
$value_arr['dnsenabled'] = 0;
|
||||
if (isset($_POST['dnsenabled'])) {
|
||||
$value_arr['dnsenabled'] = intval($_POST['dnsenabled']);
|
||||
}
|
||||
|
||||
$ins_stmt = Database::prepare("
|
||||
INSERT INTO `" . TABLE_PANEL_PLANS . "`
|
||||
SET `adminid` = :adminid, `name` = :name, `description` = :desc, `value` = :valuearr, `ts` = UNIX_TIMESTAMP();
|
||||
");
|
||||
$ins_data = array(
|
||||
'adminid' => $userinfo['adminid'],
|
||||
'name' => $name,
|
||||
'desc' => $description,
|
||||
'valuearr' => json_encode($value_arr)
|
||||
);
|
||||
Database::pexecute($ins_stmt, $ins_data);
|
||||
|
||||
$log->logAction(ADM_ACTION, LOG_WARNING, "added plan '" . $name . "'");
|
||||
redirectTo($filename, array(
|
||||
'page' => $page,
|
||||
's' => $s
|
||||
));
|
||||
} else {
|
||||
|
||||
$diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$tickets_ul = makecheckbox('tickets_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
$mysqls_ul = makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
||||
|
||||
$phpconfigs = array();
|
||||
$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(
|
||||
'label' => $row['description'] . " [" . $row['interpreter'] . "]<br />",
|
||||
'value' => $row['id']
|
||||
);
|
||||
} else {
|
||||
$phpconfigs[] = array(
|
||||
'label' => $row['description'] . "<br />",
|
||||
'value' => $row['id']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// dummy to avoid unknown variables
|
||||
$language_options = null;
|
||||
$gender_options = null;
|
||||
$hosting_plans = null;
|
||||
|
||||
$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']);
|
||||
$plans_add_form = htmlform::genHTMLForm($plans_add_data);
|
||||
|
||||
$title = $plans_add_data['plans_add']['title'];
|
||||
$image = $plans_add_data['plans_add']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("plans/plans_add") . "\";");
|
||||
}
|
||||
} elseif ($action == 'edit' && $id != 0) {
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
|
||||
$result = Database::pexecute_first($result_stmt, array(
|
||||
'id' => $id
|
||||
));
|
||||
|
||||
if ($result['name'] != '') {
|
||||
|
||||
$result['value'] = json_decode($result['value'], true);
|
||||
$result = htmlentities_array($result);
|
||||
|
||||
foreach ($result['value'] as $index => $value) {
|
||||
$result[$index] = $value;
|
||||
}
|
||||
$result['allowed_phpconfigs'] = json_encode($result['allowed_phpconfigs']);
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
|
||||
$name = validate($_POST['name'], 'name');
|
||||
$description = validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/');
|
||||
|
||||
$value_arr = array();
|
||||
|
||||
$value_arr['diskspace'] = intval_ressource($_POST['diskspace']);
|
||||
if (isset($_POST['diskspace_ul'])) {
|
||||
$value_arr['diskspace'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['traffic'] = doubleval_ressource($_POST['traffic']);
|
||||
if (isset($_POST['traffic_ul'])) {
|
||||
$value_arr['traffic'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['subdomains'] = intval_ressource($_POST['subdomains']);
|
||||
if (isset($_POST['subdomains_ul'])) {
|
||||
$value_arr['subdomains'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['emails'] = intval_ressource($_POST['emails']);
|
||||
if (isset($_POST['emails_ul'])) {
|
||||
$value_arr['emails'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['email_accounts'] = intval_ressource($_POST['email_accounts']);
|
||||
if (isset($_POST['email_accounts_ul'])) {
|
||||
$value_arr['email_accounts'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['email_forwarders'] = intval_ressource($_POST['email_forwarders']);
|
||||
if (isset($_POST['email_forwarders_ul'])) {
|
||||
$value_arr['email_forwarders'] = - 1;
|
||||
}
|
||||
|
||||
if (Settings::Get('system.mail_quota_enabled') == '1') {
|
||||
$value_arr['email_quota'] = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array(
|
||||
'0',
|
||||
''
|
||||
));
|
||||
if (isset($_POST['email_quota_ul'])) {
|
||||
$value_arr['email_quota'] = - 1;
|
||||
}
|
||||
} else {
|
||||
$value_arr['email_quota'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['email_imap'] = 0;
|
||||
if (isset($_POST['email_imap'])) {
|
||||
$value_arr['email_imap'] = intval_ressource($_POST['email_imap']);
|
||||
}
|
||||
|
||||
$value_arr['email_pop3'] = 0;
|
||||
if (isset($_POST['email_pop3'])) {
|
||||
$value_arr['email_pop3'] = intval_ressource($_POST['email_pop3']);
|
||||
}
|
||||
|
||||
$value_arr['ftps'] = intval_ressource($_POST['ftps']);
|
||||
if (isset($_POST['ftps_ul'])) {
|
||||
$value_arr['ftps'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['tickets'] = (Settings::Get('ticket.enabled') == 1 ? intval_ressource($_POST['tickets']) : 0);
|
||||
if (isset($_POST['tickets_ul']) && Settings::Get('ticket.enabled') == '1') {
|
||||
$value_arr['tickets'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['mysqls'] = intval_ressource($_POST['mysqls']);
|
||||
if (isset($_POST['mysqls_ul'])) {
|
||||
$value_arr['mysqls'] = - 1;
|
||||
}
|
||||
|
||||
$value_arr['phpenabled'] = 0;
|
||||
if (isset($_POST['phpenabled'])) {
|
||||
$value_arr['phpenabled'] = intval($_POST['phpenabled']);
|
||||
}
|
||||
|
||||
$value_arr['allowed_phpconfigs'] = array();
|
||||
if (isset($_POST['allowed_phpconfigs']) && is_array($_POST['allowed_phpconfigs'])) {
|
||||
foreach ($_POST['allowed_phpconfigs'] as $allowed_phpconfig) {
|
||||
$allowed_phpconfig = intval($allowed_phpconfig);
|
||||
$value_arr['allowed_phpconfigs'][] = $allowed_phpconfig;
|
||||
}
|
||||
}
|
||||
|
||||
$value_arr['perlenabled'] = 0;
|
||||
if (isset($_POST['perlenabled'])) {
|
||||
$value_arr['perlenabled'] = intval($_POST['perlenabled']);
|
||||
}
|
||||
|
||||
$value_arr['dnsenabled'] = 0;
|
||||
if (isset($_POST['dnsenabled'])) {
|
||||
$value_arr['dnsenabled'] = intval($_POST['dnsenabled']);
|
||||
}
|
||||
|
||||
$ins_stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_PLANS . "`
|
||||
SET `name` = :name, `description` = :desc, `value` = :valuearr, `ts` = UNIX_TIMESTAMP()
|
||||
WHERE `id` = :id
|
||||
");
|
||||
$ins_data = array(
|
||||
'name' => $name,
|
||||
'desc' => $description,
|
||||
'valuearr' => json_encode($value_arr),
|
||||
'id' => $id
|
||||
);
|
||||
Database::pexecute($ins_stmt, $ins_data);
|
||||
|
||||
$log->logAction(ADM_ACTION, LOG_WARNING, "updated plan '" . $name . "'");
|
||||
redirectTo($filename, array(
|
||||
'page' => $page,
|
||||
's' => $s
|
||||
));
|
||||
} else {
|
||||
|
||||
$diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
|
||||
if ($result['diskspace'] == '-1') {
|
||||
$result['diskspace'] = '';
|
||||
}
|
||||
|
||||
$traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
|
||||
if ($result['traffic'] == '-1') {
|
||||
$result['traffic'] = '';
|
||||
}
|
||||
|
||||
$subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
|
||||
if ($result['subdomains'] == '-1') {
|
||||
$result['subdomains'] = '';
|
||||
}
|
||||
|
||||
$emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
|
||||
if ($result['emails'] == '-1') {
|
||||
$result['emails'] = '';
|
||||
}
|
||||
|
||||
$email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
|
||||
if ($result['email_accounts'] == '-1') {
|
||||
$result['email_accounts'] = '';
|
||||
}
|
||||
|
||||
$email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
|
||||
if ($result['email_forwarders'] == '-1') {
|
||||
$result['email_forwarders'] = '';
|
||||
}
|
||||
|
||||
$email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
|
||||
if ($result['email_quota'] == '-1') {
|
||||
$result['email_quota'] = '';
|
||||
}
|
||||
|
||||
$ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
|
||||
if ($result['ftps'] == '-1') {
|
||||
$result['ftps'] = '';
|
||||
}
|
||||
|
||||
$tickets_ul = makecheckbox('tickets_ul', $lng['customer']['unlimited'], '-1', false, $result['tickets'], true, true);
|
||||
if ($result['tickets'] == '-1') {
|
||||
$result['tickets'] = '';
|
||||
}
|
||||
|
||||
$mysqls_ul = makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true);
|
||||
if ($result['mysqls'] == '-1') {
|
||||
$result['mysqls'] = '';
|
||||
}
|
||||
|
||||
$phpconfigs = array();
|
||||
$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(
|
||||
'label' => $row['description'] . " [" . $row['interpreter'] . "]<br />",
|
||||
'value' => $row['id']
|
||||
);
|
||||
} else {
|
||||
$phpconfigs[] = array(
|
||||
'label' => $row['description'] . "<br />",
|
||||
'value' => $row['id']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$result['imap'] = $result['email_imap'];
|
||||
$result['pop3'] = $result['email_pop3'];
|
||||
|
||||
// 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;
|
||||
$hosting_plans = null;
|
||||
$admin_select_cnt = null;
|
||||
$admin_select = null;
|
||||
|
||||
$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']);
|
||||
$plans_edit_form = htmlform::genHTMLForm($plans_edit_data);
|
||||
|
||||
$title = $plans_edit_data['plans_edit']['title'];
|
||||
$image = $plans_edit_data['plans_edit']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("plans/plans_edit") . "\";");
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'jqGetPlanValues') {
|
||||
$planid = isset($_POST['planid']) ? (int)$_POST['planid'] : 0;
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
|
||||
$result = Database::pexecute_first($result_stmt, array(
|
||||
'id' => $planid
|
||||
));
|
||||
echo $result['value'];
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -260,6 +260,7 @@ CREATE TABLE `panel_domains` (
|
||||
`hsts_preload` tinyint(1) NOT NULL default '0',
|
||||
`ocsp_stapling` tinyint(1) DEFAULT '0',
|
||||
`http2` tinyint(1) DEFAULT '0',
|
||||
`notryfiles` tinyint(1) DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `customerid` (`customerid`),
|
||||
KEY `parentdomain` (`parentdomainid`),
|
||||
@@ -686,8 +687,8 @@ opcache.interned_strings_buffer'),
|
||||
('panel', 'password_special_char_required', '0'),
|
||||
('panel', 'password_special_char', '!?<>§$%+#=@'),
|
||||
('panel', 'customer_hide_options', ''),
|
||||
('panel', 'version', '0.9.39.1'),
|
||||
('panel', 'db_version', '201801260');
|
||||
('panel', 'version', '0.9.39.5'),
|
||||
('panel', 'db_version', '201802130');
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `panel_tasks`;
|
||||
@@ -1028,3 +1029,16 @@ CREATE TABLE `domain_dns_entries` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `panel_plans`;
|
||||
CREATE TABLE `panel_plans` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`adminid` int(11) NOT NULL default '0',
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`description` text NOT NULL,
|
||||
`value` longtext NOT NULL,
|
||||
`ts` int(15) NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
KEY adminid (adminid)
|
||||
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
|
||||
|
||||
427
install/scripts/config-services.php
Executable file
427
install/scripts/config-services.php
Executable file
@@ -0,0 +1,427 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2018 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> (2018-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Cron
|
||||
*
|
||||
*/
|
||||
|
||||
// Check if we're in the CLI
|
||||
if (@php_sapi_name() !== 'cli') {
|
||||
die('This script will only work in the shell.');
|
||||
}
|
||||
|
||||
require dirname(dirname(__DIR__)) . '/lib/classes/output/class.CmdLineHandler.php';
|
||||
|
||||
class ConfigServicesCmd extends CmdLineHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* list of valid switches
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $switches = array(
|
||||
'h'
|
||||
);
|
||||
|
||||
/**
|
||||
* list of valid parameters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $params = array(
|
||||
'create',
|
||||
'apply',
|
||||
'daemon',
|
||||
'list-daemons',
|
||||
'froxlor-dir',
|
||||
'help'
|
||||
);
|
||||
|
||||
public static $action_class = 'Action';
|
||||
|
||||
public static function printHelp()
|
||||
{
|
||||
self::println("");
|
||||
self::println("Help / command line parameters:");
|
||||
self::println("");
|
||||
// commands
|
||||
self::println("--create\t\tlets you create a services list configuration for the 'apply' command");
|
||||
self::println("");
|
||||
self::println("--apply\t\t\tconfigure your services by given configuration file. To create one run the --create command");
|
||||
self::println("\t\t\tExample: --apply=/path/to/my-config.json");
|
||||
self::println("");
|
||||
self::println("--list-daemons\t\tOutput the services that are going to be configured using a given config file. No services will be configured.");
|
||||
self::println("\t\t\tExample: --apply=/path/to/my-config.json --list-daemons");
|
||||
self::println("");
|
||||
self::println("--daemon\t\tWhen running --apply you can specify a daemon. This will be the only service that gets configured");
|
||||
self::println("\t\t\tExample: --apply=/path/to/my-config.json --daemon=apache24");
|
||||
self::println("");
|
||||
self::println("--froxlor-dir\t\tpath to froxlor installation");
|
||||
self::println("\t\t\tExample: --froxlor-dir=/var/www/froxlor/");
|
||||
self::println("");
|
||||
self::println("--help\t\t\tshow help screen (this)");
|
||||
self::println("");
|
||||
// switches
|
||||
// self::println("-d\t\t\tenable debug output");
|
||||
self::println("-h\t\t\tsame as --help");
|
||||
self::println("");
|
||||
|
||||
die(); // end of execution
|
||||
}
|
||||
}
|
||||
|
||||
class Action
|
||||
{
|
||||
|
||||
private $_args = null;
|
||||
|
||||
private $_name = null;
|
||||
|
||||
private $_db = null;
|
||||
|
||||
public function __construct($args)
|
||||
{
|
||||
$this->_args = $args;
|
||||
$this->_validate();
|
||||
}
|
||||
|
||||
public function getActionName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* validates the parsed command line parameters
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _validate()
|
||||
{
|
||||
$this->_checkConfigParam(true);
|
||||
$this->_parseConfig();
|
||||
|
||||
require FROXLOR_INSTALL_DIR . '/lib/tables.inc.php';
|
||||
require FROXLOR_INSTALL_DIR . '/lib/functions.php';
|
||||
require FROXLOR_INSTALL_DIR . '/lib/classes/settings/class.Settings.php';
|
||||
require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigParser.php';
|
||||
require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigService.php';
|
||||
require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigDaemon.php';
|
||||
|
||||
if (array_key_exists("create", $this->_args)) {
|
||||
$this->_createConfig();
|
||||
} elseif (array_key_exists("apply", $this->_args)) {
|
||||
$this->_applyConfig();
|
||||
} elseif (array_key_exists("list-daemons", $this->_args) || array_key_exists("daemon", $this->_args)) {
|
||||
CmdLineHandler::printwarn("--list-daemons and --daemon only work together with --apply");
|
||||
}
|
||||
}
|
||||
|
||||
private function _createConfig()
|
||||
{
|
||||
$_daemons_config = array(
|
||||
'distro' => ""
|
||||
);
|
||||
|
||||
$config_dir = FROXLOR_INSTALL_DIR . '/lib/configfiles/';
|
||||
// show list of available distro's
|
||||
$distros = glob($config_dir . '*.xml');
|
||||
// tmp array
|
||||
$distributions_select_data = array();
|
||||
// read in all the distros
|
||||
foreach ($distros as $_distribution) {
|
||||
// get configparser object
|
||||
$dist = new ConfigParser($_distribution);
|
||||
// get distro-info
|
||||
$dist_display = $this->getCompleteDistroName($dist);
|
||||
// store in tmp array
|
||||
$distributions_select_data[$dist_display] = str_replace(".xml", "", strtolower(basename($_distribution)));
|
||||
}
|
||||
|
||||
// sort by distribution name
|
||||
ksort($distributions_select_data);
|
||||
|
||||
// list all distributions
|
||||
$mask = "|%-50.50s |%-50.50s |\n";
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
printf($mask, 'dist', 'name');
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
foreach ($distributions_select_data as $name => $filename) {
|
||||
printf($mask, $filename, $name);
|
||||
}
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
echo PHP_EOL;
|
||||
|
||||
while (! in_array($_daemons_config['distro'], $distributions_select_data)) {
|
||||
$_daemons_config['distro'] = CmdLineHandler::getInput("choose distribution", "stretch");
|
||||
}
|
||||
|
||||
// go through all services and let user check whether to include it or not
|
||||
$configfiles = new ConfigParser($config_dir . '/' . $_daemons_config['distro'] . ".xml");
|
||||
$services = $configfiles->getServices();
|
||||
|
||||
foreach ($services as $si => $service) {
|
||||
echo PHP_EOL . "--- " . strtoupper($si) . " ---" . PHP_EOL . PHP_EOL;
|
||||
$_daemons_config[$si] = "";
|
||||
|
||||
$daemons = $service->getDaemons();
|
||||
$mask = "|%-50.50s |%-50.50s |\n";
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
printf($mask, 'value', 'name');
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
$default_daemon = "";
|
||||
foreach ($daemons as $di => $dd) {
|
||||
$title = $dd->title;
|
||||
if ($dd->default) {
|
||||
$default_daemon = $di;
|
||||
$title = $title . " (default)";
|
||||
}
|
||||
printf($mask, $di, $title);
|
||||
}
|
||||
printf($mask, "x", "No " . $si);
|
||||
$daemons['x'] = 'x';
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
echo PHP_EOL;
|
||||
if ($si == 'system') {
|
||||
$_daemons_config[$si] = array();
|
||||
// for the system/other services we need a multiple choice possibility
|
||||
CmdLineHandler::println("Select every service you need. Enter empty value when done");
|
||||
$sysservice = "";
|
||||
do {
|
||||
$sysservice = CmdLineHandler::getInput("choose service");
|
||||
if (! empty($sysservice)) {
|
||||
$_daemons_config[$si][] = $sysservice;
|
||||
}
|
||||
} while (! empty($sysservice));
|
||||
} else {
|
||||
// for all others -> only one value
|
||||
while (! array_key_exists($_daemons_config[$si], $daemons)) {
|
||||
$_daemons_config[$si] = CmdLineHandler::getInput("choose service", $default_daemon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo PHP_EOL . PHP_EOL;
|
||||
$daemons_config = json_encode($_daemons_config);
|
||||
$output = CmdLineHandler::getInput("choose output-filename", "/tmp/froxlor-config-" . date('Ymd') . ".json");
|
||||
file_put_contents($output, $daemons_config);
|
||||
CmdLineHandler::printsucc("Successfully generated service-configfile '" . $output . "'");
|
||||
}
|
||||
|
||||
private function getCompleteDistroName($cparser)
|
||||
{
|
||||
// get distro-info
|
||||
$dist_display = $cparser->distributionName;
|
||||
if ($cparser->distributionCodename != '') {
|
||||
$dist_display .= " " . $cparser->distributionCodename;
|
||||
}
|
||||
if ($cparser->distributionVersion != '') {
|
||||
$dist_display .= " (" . $cparser->distributionVersion . ")";
|
||||
}
|
||||
if ($cparser->deprecated) {
|
||||
$dist_display .= " [deprecated]";
|
||||
}
|
||||
return $dist_display;
|
||||
}
|
||||
|
||||
private function _applyConfig()
|
||||
{
|
||||
if (! is_file($this->_args["apply"])) {
|
||||
throw new Exception("Given config file is not a file");
|
||||
} elseif (! file_exists($this->_args["apply"])) {
|
||||
throw new Exception("Given config file cannot be found ('" . $this->_args["apply"] . "')");
|
||||
} elseif (! is_readable($this->_args["apply"])) {
|
||||
throw new Exception("Given config file cannot be read ('" . $this->_args["apply"] . "')");
|
||||
}
|
||||
|
||||
$config = file_get_contents($this->_args["apply"]);
|
||||
$decoded_config = json_decode($config, true);
|
||||
|
||||
if (array_key_exists("list-daemons", $this->_args)) {
|
||||
$mask = "|%-50.50s |%-50.50s |\n";
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
printf($mask, 'service', 'daemon');
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
foreach ($decoded_config as $service => $daemon) {
|
||||
if (is_array($daemon) && count($daemon) > 0) {
|
||||
foreach ($daemon as $sysdaemon) {
|
||||
printf($mask, $service, $sysdaemon);
|
||||
}
|
||||
} else {
|
||||
if ($daemon == 'x') {
|
||||
$daemon = '--- skipped ---';
|
||||
}
|
||||
printf($mask, $service, $daemon);
|
||||
}
|
||||
}
|
||||
printf($mask, str_repeat("-", 50), str_repeat("-", 50));
|
||||
echo PHP_EOL;
|
||||
exit();
|
||||
}
|
||||
|
||||
$only_daemon = null;
|
||||
if (array_key_exists("daemon", $this->_args)) {
|
||||
$only_daemon = $this->_args['daemon'];
|
||||
}
|
||||
|
||||
if (! empty($decoded_config)) {
|
||||
$config_dir = FROXLOR_INSTALL_DIR . '/lib/configfiles/';
|
||||
$configfiles = new ConfigParser($config_dir . '/' . $decoded_config['distro'] . ".xml");
|
||||
$services = $configfiles->getServices();
|
||||
$replace_arr = $this->_getReplacerArray();
|
||||
|
||||
foreach ($services as $si => $service) {
|
||||
echo PHP_EOL . "--- Configuring: " . strtoupper($si) . " ---" . PHP_EOL . PHP_EOL;
|
||||
if (! isset($decoded_config[$si]) || $decoded_config[$si] == 'x') {
|
||||
CmdLineHandler::printwarn("Skipping " . strtoupper($si) . " configuration as desired");
|
||||
continue;
|
||||
}
|
||||
$daemons = $service->getDaemons();
|
||||
foreach ($daemons as $di => $dd) {
|
||||
// check for desired service
|
||||
if (($si != 'system' && $decoded_config[$si] != $di) || (is_array($decoded_config[$si]) && ! in_array($di, $decoded_config[$si]))) {
|
||||
continue;
|
||||
}
|
||||
CmdLineHandler::println("Configuring '" . $di . "'");
|
||||
|
||||
if (! empty($only_daemon) && $only_daemon != $di) {
|
||||
CmdLineHandler::printwarn("Skipping " . $di . " configuration as desired");
|
||||
continue;
|
||||
}
|
||||
// run all cmds
|
||||
$confarr = $dd->getConfig();
|
||||
foreach ($confarr as $idx => $action) {
|
||||
switch ($action['type']) {
|
||||
case "install":
|
||||
CmdLineHandler::println("Installing required packages");
|
||||
passthru(strtr($action['content'], $replace_arr), $result);
|
||||
if (strlen($result) > 1) {
|
||||
echo $result;
|
||||
}
|
||||
break;
|
||||
case "command":
|
||||
exec(strtr($action['content'], $replace_arr));
|
||||
break;
|
||||
case "file":
|
||||
if (array_key_exists('content', $action)) {
|
||||
CmdLineHandler::printwarn("Creating file '" . $action['name'] . "'");
|
||||
file_put_contents($action['name'], strtr($action['content'], $replace_arr));
|
||||
} elseif (array_key_exists('subcommands', $action)) {
|
||||
foreach ($action['subcommands'] as $fileaction) {
|
||||
if (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "pre") {
|
||||
exec(strtr($fileaction['content'], $replace_arr));
|
||||
} elseif (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "post") {
|
||||
exec(strtr($fileaction['content'], $replace_arr));
|
||||
} elseif ($fileaction['type'] == 'file') {
|
||||
CmdLineHandler::printwarn("Creating file '" . $fileaction['name'] . "'");
|
||||
file_put_contents($fileaction['name'], strtr($fileaction['content'], $replace_arr));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CmdLineHandler::printsucc("All services have been configured");
|
||||
} else {
|
||||
CmdLineHandler::printerr("Unable to decode given JSON file");
|
||||
}
|
||||
}
|
||||
|
||||
private function _getReplacerArray()
|
||||
{
|
||||
$customer_tmpdir = '/tmp/';
|
||||
if (Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_tmpdir') != '') {
|
||||
$customer_tmpdir = Settings::Get('system.mod_fcgid_tmpdir');
|
||||
} elseif (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.tmpdir') != '') {
|
||||
$customer_tmpdir = Settings::Get('phpfpm.tmpdir');
|
||||
}
|
||||
|
||||
// try to convert namserver hosts to ip's
|
||||
$ns_ips = "";
|
||||
if (Settings::Get('system.nameservers') != '') {
|
||||
$nameservers = explode(',', Settings::Get('system.nameservers'));
|
||||
foreach ($nameservers as $nameserver) {
|
||||
$nameserver = trim($nameserver);
|
||||
$nameserver_ips = gethostbynamel($nameserver);
|
||||
if (is_array($nameserver_ips) && count($nameserver_ips) > 0) {
|
||||
$ns_ips .= implode(",", $nameserver_ips);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Database::needSqlData();
|
||||
$sql = Database::getSqlData();
|
||||
|
||||
$replace_arr = array(
|
||||
'<SQL_UNPRIVILEGED_USER>' => $sql['user'],
|
||||
'<SQL_UNPRIVILEGED_PASSWORD>' => $sql['passwd'],
|
||||
'<SQL_DB>' => $sql['db'],
|
||||
'<SQL_HOST>' => $sql['host'],
|
||||
'<SQL_SOCKET>' => isset($sql['socket']) ? $sql['socket'] : null,
|
||||
'<SERVERNAME>' => Settings::Get('system.hostname'),
|
||||
'<SERVERIP>' => Settings::Get('system.ipaddress'),
|
||||
'<NAMESERVERS>' => Settings::Get('system.nameservers'),
|
||||
'<NAMESERVERS_IP>' => $ns_ips,
|
||||
'<AXFRSERVERS>' => Settings::Get('system.axfrservers'),
|
||||
'<VIRTUAL_MAILBOX_BASE>' => Settings::Get('system.vmail_homedir'),
|
||||
'<VIRTUAL_UID_MAPS>' => Settings::Get('system.vmail_uid'),
|
||||
'<VIRTUAL_GID_MAPS>' => Settings::Get('system.vmail_gid'),
|
||||
'<SSLPROTOCOLS>' => (Settings::Get('system.use_ssl') == '1') ? 'imaps pop3s' : '',
|
||||
'<CUSTOMER_TMP>' => makeCorrectDir($customer_tmpdir),
|
||||
'<BASE_PATH>' => makeCorrectDir(FROXLOR_INSTALL_DIR),
|
||||
'<BIND_CONFIG_PATH>' => makeCorrectDir(Settings::Get('system.bindconf_directory')),
|
||||
'<WEBSERVER_RELOAD_CMD>' => Settings::Get('system.apachereload_command'),
|
||||
'<CUSTOMER_LOGS>' => makeCorrectDir(Settings::Get('system.logfiles_directory')),
|
||||
'<FPM_IPCDIR>' => makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir')),
|
||||
'<WEBSERVER_GROUP>' => Settings::Get('system.httpgroup')
|
||||
);
|
||||
return $replace_arr;
|
||||
}
|
||||
|
||||
private function _parseConfig()
|
||||
{
|
||||
define('FROXLOR_INSTALL_DIR', $this->_args['froxlor-dir']);
|
||||
if (! file_exists(FROXLOR_INSTALL_DIR . '/lib/classes/database/class.Database.php')) {
|
||||
throw new Exception("Could not find froxlor's Database class. Is froxlor really installed to '" . FROXLOR_INSTALL_DIR . "'?");
|
||||
}
|
||||
if (! file_exists(FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php')) {
|
||||
throw new Exception("Could not find froxlor's userdata.inc.php file. You should use this script only with a fully installed and setup froxlor system.");
|
||||
}
|
||||
require FROXLOR_INSTALL_DIR . '/lib/classes/database/class.Database.php';
|
||||
}
|
||||
|
||||
private function _checkConfigParam($needed = false)
|
||||
{
|
||||
if ($needed) {
|
||||
if (! isset($this->_args["froxlor-dir"])) {
|
||||
throw new Exception("No configuration given (missing --froxlor-dir parameter?)");
|
||||
} elseif (! is_dir($this->_args["froxlor-dir"])) {
|
||||
throw new Exception("Given --froxlor-dir parameter is not a directory");
|
||||
} elseif (! file_exists($this->_args["froxlor-dir"])) {
|
||||
throw new Exception("Given froxlor directory cannot be found ('" . $this->_args["froxlor-dir"] . "')");
|
||||
} elseif (! is_readable($this->_args["froxlor-dir"])) {
|
||||
throw new Exception("Given froxlor direcotry cannot be read ('" . $this->_args["froxlor-dir"] . "')");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// give control to command line handler
|
||||
try {
|
||||
ConfigServicesCmd::processParameters($argc, $argv);
|
||||
} catch (Exception $e) {
|
||||
ConfigServicesCmd::printerr($e->getMessage());
|
||||
}
|
||||
231
install/scripts/switch-server-ip.php
Normal file → Executable file
231
install/scripts/switch-server-ip.php
Normal file → Executable file
@@ -13,46 +13,33 @@
|
||||
* @author Froxlor team <team@froxlor.org> (2016-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Cron
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Check if we're in the CLI
|
||||
if(@php_sapi_name() !== 'cli') {
|
||||
if (@php_sapi_name() !== 'cli') {
|
||||
die('This script will only work in the shell.');
|
||||
}
|
||||
|
||||
// give control to command line handler
|
||||
try {
|
||||
CmdLineHandler::processParameters($argc, $argv);
|
||||
} catch (Exception $e) {
|
||||
CmdLineHandler::printerr($e->getMessage());
|
||||
}
|
||||
require dirname(dirname(__DIR__)) . '/lib/classes/output/class.CmdLineHandler.php';
|
||||
|
||||
class CmdLineHandler
|
||||
class SwitchServerIp extends CmdLineHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* internal variable for passed arguments
|
||||
* list of valid switches
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $args = null;
|
||||
|
||||
/**
|
||||
* Action object read from commandline/config
|
||||
*
|
||||
* @var Action
|
||||
*/
|
||||
private $_action = null;
|
||||
|
||||
/**
|
||||
* list of valid parameters/switches
|
||||
*/
|
||||
public static $switches = array(
|
||||
/* 'd', // debug / output information for everything */
|
||||
'h'
|
||||
);
|
||||
// same as --help
|
||||
|
||||
/**
|
||||
* list of valid parameters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $params = array(
|
||||
'switch',
|
||||
'list',
|
||||
@@ -60,131 +47,7 @@ class CmdLineHandler
|
||||
'help'
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns a CmdLineHandler object with given
|
||||
* arguments from command line
|
||||
*
|
||||
* @param int $argc
|
||||
* @param array $argv
|
||||
*
|
||||
* @return CmdLineHandler
|
||||
*/
|
||||
public static function processParameters($argc, $argv)
|
||||
{
|
||||
return new CmdLineHandler($argc, $argv);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the Action object generated in
|
||||
* the class constructor
|
||||
*
|
||||
* @return Action
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* class constructor, validates the command line parameters
|
||||
* and sets the Action-object if valid
|
||||
*
|
||||
* @param int $argc
|
||||
* @param string[] $argv
|
||||
*
|
||||
* @return null
|
||||
* @throws Exception
|
||||
*/
|
||||
private function __construct($argc, $argv)
|
||||
{
|
||||
self::$args = $this->_parseArgs($argv);
|
||||
$this->_action = $this->_createAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the arguments given via the command line;
|
||||
* three types are supported:
|
||||
* 1.
|
||||
* --parm1 or --parm2=value
|
||||
* 2. -xyz (multiple switches in one) or -a=value
|
||||
* 3. parm1 parm2
|
||||
*
|
||||
* The 1. will be mapped as
|
||||
* ["parm1"] => true, ["parm2"] => "value"
|
||||
* The 2. as
|
||||
* ["x"] => true, ["y"] => true, ["z"] => true, ["a"] => "value"
|
||||
* And the 3. as
|
||||
* [0] => "parm1", [1] => "parm2"
|
||||
*
|
||||
* @param array $argv
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _parseArgs($argv)
|
||||
{
|
||||
array_shift($argv);
|
||||
$o = array();
|
||||
foreach ($argv as $a) {
|
||||
if (substr($a, 0, 2) == '--') {
|
||||
$eq = strpos($a, '=');
|
||||
if ($eq !== false) {
|
||||
$o[substr($a, 2, $eq - 2)] = substr($a, $eq + 1);
|
||||
} else {
|
||||
$k = substr($a, 2);
|
||||
if (! isset($o[$k])) {
|
||||
$o[$k] = true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (substr($a, 0, 1) == '-') {
|
||||
if (substr($a, 2, 1) == '=') {
|
||||
$o[substr($a, 1, 1)] = substr($a, 3);
|
||||
} else {
|
||||
foreach (str_split(substr($a, 1)) as $k) {
|
||||
if (! isset($o[$k])) {
|
||||
$o[$k] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$o[] = $a;
|
||||
}
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Action-Object for the Action-Handler
|
||||
*
|
||||
* @return Action
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _createAction()
|
||||
{
|
||||
|
||||
// Test for help-switch
|
||||
if (empty(self::$args) || array_key_exists("help", self::$args) || array_key_exists("h", self::$args)) {
|
||||
self::printHelp();
|
||||
// end of execution
|
||||
}
|
||||
// check if no unknown parameters are present
|
||||
foreach (self::$args as $arg => $value) {
|
||||
|
||||
if (is_numeric($arg)) {
|
||||
throw new Exception("Unknown parameter '" . $value . "' in argument list");
|
||||
} elseif (! in_array($arg, self::$params) && ! in_array($arg, self::$switches)) {
|
||||
throw new Exception("Unknown parameter '" . $arg . "' in argument list");
|
||||
}
|
||||
}
|
||||
|
||||
// set debugger switch
|
||||
if (isset(self::$args["d"]) && self::$args["d"] == true) {
|
||||
// Debugger::getInstance()->setEnabled(true);
|
||||
// Debugger::getInstance()->debug("debug output enabled");
|
||||
}
|
||||
|
||||
return new Action(self::$args);
|
||||
}
|
||||
public static $action_class = 'Action';
|
||||
|
||||
public static function printHelp()
|
||||
{
|
||||
@@ -207,34 +70,9 @@ class CmdLineHandler
|
||||
// self::println("-d\t\t\tenable debug output");
|
||||
self::println("-h\t\t\tsame as --help");
|
||||
self::println("");
|
||||
|
||||
|
||||
die(); // end of execution
|
||||
}
|
||||
|
||||
public static function println($msg = "")
|
||||
{
|
||||
print $msg . PHP_EOL;
|
||||
}
|
||||
|
||||
private static function _printcolor($msg = "", $color = "0")
|
||||
{
|
||||
print "\033[" . $color . "m" . $msg . "\033[0m" . PHP_EOL;
|
||||
}
|
||||
|
||||
public static function printerr($msg = "")
|
||||
{
|
||||
self::_printcolor($msg, "31");
|
||||
}
|
||||
|
||||
public static function printsucc($msg = "")
|
||||
{
|
||||
self::_printcolor($msg, "32");
|
||||
}
|
||||
|
||||
public static function printwarn($msg = "")
|
||||
{
|
||||
self::_printcolor($msg, "33");
|
||||
}
|
||||
}
|
||||
|
||||
class Action
|
||||
@@ -268,11 +106,11 @@ class Action
|
||||
if (array_key_exists("list", $this->_args) || array_key_exists("switch", $this->_args)) {
|
||||
$need_config = true;
|
||||
}
|
||||
|
||||
|
||||
$this->_checkConfigParam($need_config);
|
||||
|
||||
|
||||
$this->_parseConfig();
|
||||
|
||||
|
||||
if (array_key_exists("list", $this->_args)) {
|
||||
$this->_listIPs();
|
||||
}
|
||||
@@ -300,11 +138,11 @@ class Action
|
||||
private function _switchIPs()
|
||||
{
|
||||
$ip_list = $this->_args['switch'];
|
||||
|
||||
|
||||
if (empty($ip_list) || is_bool($ip_list)) {
|
||||
throw new Exception("No paramters given for --switch action.");
|
||||
}
|
||||
|
||||
|
||||
$ips_to_switch = array();
|
||||
$ip_list = explode(" ", $ip_list);
|
||||
foreach ($ip_list as $ips_combo) {
|
||||
@@ -324,22 +162,22 @@ class Action
|
||||
}
|
||||
$ips_to_switch[] = $ip_pair;
|
||||
}
|
||||
|
||||
|
||||
if (count($ips_to_switch) > 0) {
|
||||
$upd_stmt = Database::prepare("UPDATE panel_ipsandports SET `ip` = :newip WHERE `ip` = :oldip");
|
||||
|
||||
|
||||
// system.ipaddress
|
||||
$check_sysip_stmt = Database::prepare("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'system' and `varname` = 'ipaddress'");
|
||||
$check_sysip = Database::pexecute_first($check_sysip_stmt);
|
||||
|
||||
|
||||
// system.mysql_access_host
|
||||
$check_mysqlip_stmt = Database::prepare("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'system' and `varname` = 'mysql_access_host'");
|
||||
$check_mysqlip = Database::pexecute_first($check_mysqlip_stmt);
|
||||
|
||||
|
||||
// system.axfrservers
|
||||
$check_axfrip_stmt = Database::prepare("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'system' and `varname` = 'axfrservers'");
|
||||
$check_axfrip = Database::pexecute_first($check_axfrip_stmt);
|
||||
|
||||
|
||||
foreach ($ips_to_switch as $ip_pair) {
|
||||
echo "Switching IP \033[1m" . $ip_pair[0] . "\033[0m to IP \033[1m" . $ip_pair[1] . "\033[0m" . PHP_EOL;
|
||||
Database::pexecute($upd_stmt, array(
|
||||
@@ -347,11 +185,11 @@ class Action
|
||||
'oldip' => $ip_pair[0]
|
||||
));
|
||||
$rows_updated = $upd_stmt->rowCount();
|
||||
|
||||
|
||||
if ($rows_updated == 0) {
|
||||
CmdLineHandler::printwarn("Note: " . $ip_pair[0] . " not updated to " . $ip_pair[1] . " (possibly no entry found in froxlor database. Use --list to see what IP addresses are added in froxlor");
|
||||
}
|
||||
|
||||
|
||||
// check whether the system.ipaddress needs updating
|
||||
if ($check_sysip['value'] == $ip_pair[0]) {
|
||||
$upd2_stmt = Database::prepare("UPDATE `panel_settings` SET `value` = :newip WHERE `settinggroup` = 'system' and `varname` = 'ipaddress'");
|
||||
@@ -360,7 +198,7 @@ class Action
|
||||
));
|
||||
CmdLineHandler::printsucc("Updated system-ipaddress from '" . $ip_pair[0] . "' to '" . $ip_pair[1] . "'");
|
||||
}
|
||||
|
||||
|
||||
// check whether the system.mysql_access_host needs updating
|
||||
if (strstr($check_mysqlip['value'], $ip_pair[0]) !== false) {
|
||||
$new_mysqlip = str_replace($ip_pair[0], $ip_pair[1], $check_mysqlip['value']);
|
||||
@@ -370,7 +208,7 @@ class Action
|
||||
));
|
||||
CmdLineHandler::printsucc("Updated mysql_access_host from '" . $check_mysqlip['value'] . "' to '" . $new_mysqlip . "'");
|
||||
}
|
||||
|
||||
|
||||
// check whether the system.axfrservers needs updating
|
||||
if (strstr($check_axfrip['value'], $ip_pair[0]) !== false) {
|
||||
$new_axfrip = str_replace($ip_pair[0], $ip_pair[1], $check_axfrip['value']);
|
||||
@@ -382,7 +220,7 @@ class Action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo PHP_EOL;
|
||||
CmdLineHandler::printwarn("*** ATTENTION *** Remember to replace IP addresses in configuration files if used anywhere.");
|
||||
CmdLineHandler::printsucc("IP addresses updated");
|
||||
@@ -391,10 +229,10 @@ class Action
|
||||
private function _parseConfig()
|
||||
{
|
||||
define('FROXLOR_INSTALL_DIR', $this->_args['froxlor-dir']);
|
||||
if (!file_exists(FROXLOR_INSTALL_DIR . '/lib/classes/database/class.Database.php')) {
|
||||
throw new Exception("Could not find froxlor's Database class. Is froxlor really installed to '".FROXLOR_INSTALL_DIR."'?");
|
||||
if (! file_exists(FROXLOR_INSTALL_DIR . '/lib/classes/database/class.Database.php')) {
|
||||
throw new Exception("Could not find froxlor's Database class. Is froxlor really installed to '" . FROXLOR_INSTALL_DIR . "'?");
|
||||
}
|
||||
if (!file_exists(FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php')) {
|
||||
if (! file_exists(FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php')) {
|
||||
throw new Exception("Could not find froxlor's userdata.inc.php file. You should use this script only with a fully installed and setup froxlor system.");
|
||||
}
|
||||
require FROXLOR_INSTALL_DIR . '/lib/classes/database/class.Database.php';
|
||||
@@ -415,3 +253,10 @@ class Action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// give control to command line handler
|
||||
try {
|
||||
SwitchServerIp::processParameters($argc, $argv);
|
||||
} catch (Exception $e) {
|
||||
SwitchServerIp::printerr($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -3886,3 +3886,56 @@ if (isFroxlorVersion('0.9.39')) {
|
||||
showUpdateStep("Updating from 0.9.39 to 0.9.39.1", false);
|
||||
updateToVersion('0.9.39.1');
|
||||
}
|
||||
|
||||
if (isFroxlorVersion('0.9.39.1')) {
|
||||
|
||||
showUpdateStep("Updating from 0.9.39.1 to 0.9.39.2", false);
|
||||
updateToVersion('0.9.39.2');
|
||||
}
|
||||
|
||||
if (isDatabaseVersion('201801260')) {
|
||||
|
||||
showUpdateStep("Adding new plans table");
|
||||
Database::query("DROP TABLE IF EXISTS `panel_plans`;");
|
||||
$sql = "CREATE TABLE `panel_plans` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`adminid` int(11) NOT NULL default '0',
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`description` text NOT NULL,
|
||||
`value` longtext NOT NULL,
|
||||
`ts` int(15) NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
KEY adminid (adminid)
|
||||
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci;";
|
||||
Database::query($sql);
|
||||
lastStepStatus(0);
|
||||
|
||||
updateToDbVersion('201802120');
|
||||
}
|
||||
|
||||
if (isDatabaseVersion('201802120')) {
|
||||
|
||||
showUpdateStep("Adding domain field for try_files flag");
|
||||
Database::query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` ADD `notryfiles` tinyint(1) DEFAULT '0';");
|
||||
lastStepStatus(0);
|
||||
|
||||
updateToDbVersion('201802130');
|
||||
}
|
||||
|
||||
if (isFroxlorVersion('0.9.39.2')) {
|
||||
|
||||
showUpdateStep("Updating from 0.9.39.2 to 0.9.39.3", false);
|
||||
updateToVersion('0.9.39.3');
|
||||
}
|
||||
|
||||
if (isFroxlorVersion('0.9.39.3')) {
|
||||
|
||||
showUpdateStep("Updating from 0.9.39.3 to 0.9.39.4", false);
|
||||
updateToVersion('0.9.39.4');
|
||||
}
|
||||
|
||||
if (isFroxlorVersion('0.9.39.4')) {
|
||||
|
||||
showUpdateStep("Updating from 0.9.39.4 to 0.9.39.5", false);
|
||||
updateToVersion('0.9.39.5');
|
||||
}
|
||||
|
||||
196
lib/classes/output/class.CmdLineHandler.php
Normal file
196
lib/classes/output/class.CmdLineHandler.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2018 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> (2018-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Cron
|
||||
*
|
||||
*/
|
||||
abstract class CmdLineHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* internal variable for passed arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $args = null;
|
||||
|
||||
/**
|
||||
* Action object read from commandline/config
|
||||
*
|
||||
* @var Action
|
||||
*/
|
||||
private $_action = null;
|
||||
|
||||
/**
|
||||
* Returns a CmdLineHandler object with given
|
||||
* arguments from command line
|
||||
*
|
||||
* @param int $argc
|
||||
* @param array $argv
|
||||
*
|
||||
* @return CmdLineHandler
|
||||
*/
|
||||
public static function processParameters($argc, $argv)
|
||||
{
|
||||
$me = get_called_class();
|
||||
return new $me($argc, $argv);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the Action object generated in
|
||||
* the class constructor
|
||||
*
|
||||
* @return Action
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* class constructor, validates the command line parameters
|
||||
* and sets the Action-object if valid
|
||||
*
|
||||
* @param int $argc
|
||||
* @param string[] $argv
|
||||
*
|
||||
* @return null
|
||||
* @throws Exception
|
||||
*/
|
||||
private function __construct($argc, $argv)
|
||||
{
|
||||
self::$args = $this->_parseArgs($argv);
|
||||
$this->_action = $this->_createAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the arguments given via the command line;
|
||||
* three types are supported:
|
||||
* 1.
|
||||
* --parm1 or --parm2=value
|
||||
* 2. -xyz (multiple switches in one) or -a=value
|
||||
* 3. parm1 parm2
|
||||
*
|
||||
* The 1. will be mapped as
|
||||
* ["parm1"] => true, ["parm2"] => "value"
|
||||
* The 2. as
|
||||
* ["x"] => true, ["y"] => true, ["z"] => true, ["a"] => "value"
|
||||
* And the 3. as
|
||||
* [0] => "parm1", [1] => "parm2"
|
||||
*
|
||||
* @param array $argv
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _parseArgs($argv)
|
||||
{
|
||||
array_shift($argv);
|
||||
$o = array();
|
||||
foreach ($argv as $a) {
|
||||
if (substr($a, 0, 2) == '--') {
|
||||
$eq = strpos($a, '=');
|
||||
if ($eq !== false) {
|
||||
$o[substr($a, 2, $eq - 2)] = substr($a, $eq + 1);
|
||||
} else {
|
||||
$k = substr($a, 2);
|
||||
if (! isset($o[$k])) {
|
||||
$o[$k] = true;
|
||||
}
|
||||
}
|
||||
} else if (substr($a, 0, 1) == '-') {
|
||||
if (substr($a, 2, 1) == '=') {
|
||||
$o[substr($a, 1, 1)] = substr($a, 3);
|
||||
} else {
|
||||
foreach (str_split(substr($a, 1)) as $k) {
|
||||
if (! isset($o[$k])) {
|
||||
$o[$k] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$o[] = $a;
|
||||
}
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Action-Object for the Action-Handler
|
||||
*
|
||||
* @return Action
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _createAction()
|
||||
{
|
||||
|
||||
// Test for help-switch
|
||||
if (empty(self::$args) || array_key_exists("help", self::$args) || array_key_exists("h", self::$args)) {
|
||||
static::printHelp();
|
||||
// end of execution
|
||||
}
|
||||
// check if no unknown parameters are present
|
||||
foreach (self::$args as $arg => $value) {
|
||||
|
||||
if (is_numeric($arg)) {
|
||||
throw new Exception("Unknown parameter '" . $value . "' in argument list");
|
||||
} elseif (! in_array($arg, static::$params) && ! in_array($arg, static::$switches)) {
|
||||
throw new Exception("Unknown parameter '" . $arg . "' in argument list");
|
||||
}
|
||||
}
|
||||
|
||||
// set debugger switch
|
||||
if (isset(self::$args["d"]) && self::$args["d"] == true) {
|
||||
// Debugger::getInstance()->setEnabled(true);
|
||||
// Debugger::getInstance()->debug("debug output enabled");
|
||||
}
|
||||
|
||||
return new static::$action_class(self::$args);
|
||||
}
|
||||
|
||||
public static function getInput($prompt = "#", $default = "")
|
||||
{
|
||||
if (! empty($default)) {
|
||||
$prompt .= " [" . $default . "]";
|
||||
}
|
||||
$result = readline($prompt . ":");
|
||||
if (empty($result) && ! empty($default)) {
|
||||
$result = $default;
|
||||
}
|
||||
return mb_strtolower($result);
|
||||
}
|
||||
|
||||
public static function println($msg = "")
|
||||
{
|
||||
print $msg . PHP_EOL;
|
||||
}
|
||||
|
||||
private static function _printcolor($msg = "", $color = "0")
|
||||
{
|
||||
print "\033[" . $color . "m" . $msg . "\033[0m" . PHP_EOL;
|
||||
}
|
||||
|
||||
public static function printerr($msg = "")
|
||||
{
|
||||
self::_printcolor($msg, "31");
|
||||
}
|
||||
|
||||
public static function printsucc($msg = "")
|
||||
{
|
||||
self::_printcolor($msg, "32");
|
||||
}
|
||||
|
||||
public static function printwarn($msg = "")
|
||||
{
|
||||
self::_printcolor($msg, "33");
|
||||
}
|
||||
}
|
||||
@@ -98,14 +98,14 @@ class SImExporter
|
||||
// when there were changes in the variable-name or similar
|
||||
unset($_data['panel.version']);
|
||||
unset($_data['panel.db_version']);
|
||||
/*
|
||||
|
||||
// store new data
|
||||
foreach ($_data as $index => $value) {
|
||||
Settings::Set($index, $value);
|
||||
}
|
||||
// save to DB
|
||||
Settings::Flush();
|
||||
*/
|
||||
|
||||
// all good
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ exit "$RETVAL"
|
||||
<!--DNS -->
|
||||
<service type="dns" title="{{lng.admin.configfiles.dns}}">
|
||||
<!--Bind9 -->
|
||||
<daemon name="bind" title="Bind9 nameserver">
|
||||
<daemon name="bind" title="Bind9 nameserver" default="true">
|
||||
<install><![CDATA[emerge net-dns/bind]]></install>
|
||||
<file name="/etc/bind/default.zone">
|
||||
<content><![CDATA[
|
||||
@@ -3422,10 +3422,17 @@ MAILDIRPATH=.maildir
|
||||
<daemon name="proftpd" title="ProFTPd" default="true">
|
||||
<command><![CDATA[echo "net-ftp/proftpd mysql" >> /etc/portage/package.use]]></command>
|
||||
<install><![CDATA[emerge net-ftp/proftpd]]></install>
|
||||
<commands>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key]]></command>
|
||||
<file name="/etc/proftpd/create-cert.sh" chown="root:0" chmod="0700">
|
||||
<content><![CDATA[#!/bin/bash
|
||||
[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key
|
||||
]]>
|
||||
</content>
|
||||
</file>
|
||||
<commands index="1">
|
||||
<command><![CDATA[/etc/proftpd/create-cert.sh]]></command>
|
||||
<command><![CDATA[rm -f /etc/proftpd/create-cert.sh]]></command>
|
||||
</commands>
|
||||
<file name="/etc/proftpd/proftpd.conf" chown="root:0" chmod="0600"
|
||||
backup="true">
|
||||
|
||||
@@ -365,7 +365,7 @@ exit "$RETVAL"
|
||||
<!--DNS -->
|
||||
<service type="dns" title="{{lng.admin.configfiles.dns}}">
|
||||
<!--Bind9 -->
|
||||
<daemon name="bind" title="Bind9 nameserver">
|
||||
<daemon name="bind" title="Bind9 nameserver" default="true">
|
||||
<install><![CDATA[apt-get install bind9]]></install>
|
||||
<command><![CDATA[echo "include \"{{settings.system.bindconf_directory}}froxlor_bind.conf\";" >> /etc/bind/named.conf.local]]></command>
|
||||
<command><![CDATA[touch {{settings.system.bindconf_directory}}froxlor_bind.conf]]></command>
|
||||
@@ -3814,10 +3814,17 @@ plugin {
|
||||
<!-- Proftpd -->
|
||||
<daemon name="proftpd" title="ProFTPd" default="true">
|
||||
<install><![CDATA[apt-get install proftpd-basic proftpd-mod-mysql]]></install>
|
||||
<commands>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key]]></command>
|
||||
<file name="/etc/proftpd/create-cert.sh" chown="root:0" chmod="0700">
|
||||
<content><![CDATA[#!/bin/bash
|
||||
[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key
|
||||
]]>
|
||||
</content>
|
||||
</file>
|
||||
<commands index="1">
|
||||
<command><![CDATA[/etc/proftpd/create-cert.sh]]></command>
|
||||
<command><![CDATA[rm -f /etc/proftpd/create-cert.sh]]></command>
|
||||
</commands>
|
||||
<file name="/etc/proftpd/proftpd.conf" chown="root:0" chmod="0600"
|
||||
backup="true">
|
||||
|
||||
@@ -334,7 +334,7 @@ exit "$RETVAL"
|
||||
<!--DNS -->
|
||||
<service type="dns" title="{{lng.admin.configfiles.dns}}">
|
||||
<!--Bind9 -->
|
||||
<daemon name="bind" title="Bind9 nameserver">
|
||||
<daemon name="bind" title="Bind9 nameserver" default="true">
|
||||
<install><![CDATA[apt-get install bind9]]></install>
|
||||
<command><![CDATA[echo "include \"{{settings.system.bindconf_directory}}froxlor_bind.conf\";" >> /etc/bind/named.conf]]></command>
|
||||
<command><![CDATA[touch {{settings.system.bindconf_directory}}froxlor_bind.conf]]></command>
|
||||
@@ -1143,10 +1143,17 @@ MYSQL_AUXOPTIONS_FIELD CONCAT("allowimap=",imap,",allowpop3=",pop3)
|
||||
<!-- Proftpd -->
|
||||
<daemon name="proftpd" title="ProFTPd" default="true">
|
||||
<install><![CDATA[apt-get install proftpd-basic proftpd-mod-mysql]]></install>
|
||||
<commands>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key]]></command>
|
||||
<file name="/etc/proftpd/create-cert.sh" chown="root:0" chmod="0700">
|
||||
<content><![CDATA[#!/bin/bash
|
||||
[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key
|
||||
]]>
|
||||
</content>
|
||||
</file>
|
||||
<commands index="1">
|
||||
<command><![CDATA[/etc/proftpd/create-cert.sh]]></command>
|
||||
<command><![CDATA[rm -f /etc/proftpd/create-cert.sh]]></command>
|
||||
</commands>
|
||||
<file name="/etc/proftpd/proftpd.conf" chown="root:0" chmod="0600"
|
||||
backup="true">
|
||||
|
||||
@@ -354,7 +354,7 @@ exit "$RETVAL"
|
||||
<!--DNS -->
|
||||
<service type="dns" title="{{lng.admin.configfiles.dns}}">
|
||||
<!--Bind9 -->
|
||||
<daemon name="bind" title="Bind9 nameserver">
|
||||
<daemon name="bind" title="Bind9 nameserver" default="true">
|
||||
<install><![CDATA[apt-get install bind9]]></install>
|
||||
<command><![CDATA[echo "include \"{{settings.system.bindconf_directory}}froxlor_bind.conf\";" >> /etc/bind/named.conf.local]]></command>
|
||||
<command><![CDATA[touch {{settings.system.bindconf_directory}}froxlor_bind.conf]]></command>
|
||||
@@ -3882,10 +3882,17 @@ plugin {
|
||||
<!-- Proftpd -->
|
||||
<daemon name="proftpd" title="ProFTPd" default="true">
|
||||
<install><![CDATA[apt-get install proftpd-basic proftpd-mod-mysql]]></install>
|
||||
<commands>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key]]></command>
|
||||
<file name="/etc/proftpd/create-cert.sh" chown="root:0" chmod="0700">
|
||||
<content><![CDATA[#!/bin/bash
|
||||
[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key
|
||||
]]>
|
||||
</content>
|
||||
</file>
|
||||
<commands index="1">
|
||||
<command><![CDATA[/etc/proftpd/create-cert.sh]]></command>
|
||||
<command><![CDATA[rm -f /etc/proftpd/create-cert.sh]]></command>
|
||||
</commands>
|
||||
<file name="/etc/proftpd/proftpd.conf" chown="root:0" chmod="0600"
|
||||
backup="true">
|
||||
|
||||
@@ -367,7 +367,7 @@ exit "$RETVAL"
|
||||
<!--DNS -->
|
||||
<service type="dns" title="{{lng.admin.configfiles.dns}}">
|
||||
<!--Bind9 -->
|
||||
<daemon name="bind" title="Bind9 nameserver">
|
||||
<daemon name="bind" title="Bind9 nameserver" default="true">
|
||||
<install><![CDATA[apt-get install bind9]]></install>
|
||||
<command><![CDATA[echo "include \"{{settings.system.bindconf_directory}}froxlor_bind.conf\";" >> /etc/bind/named.conf]]></command>
|
||||
<command><![CDATA[touch {{settings.system.bindconf_directory}}froxlor_bind.conf]]></command>
|
||||
@@ -1152,10 +1152,17 @@ MYSQL_AUXOPTIONS_FIELD CONCAT("allowimap=",imap,",allowpop3=",pop3)
|
||||
<!-- Proftpd -->
|
||||
<daemon name="proftpd" title="ProFTPd" default="true">
|
||||
<install><![CDATA[apt-get install proftpd-basic proftpd-mod-mysql]]></install>
|
||||
<commands>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key]]></command>
|
||||
<file name="/etc/proftpd/create-cert.sh" chown="root:0" chmod="0700">
|
||||
<content><![CDATA[#!/bin/bash
|
||||
[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key
|
||||
]]>
|
||||
</content>
|
||||
</file>
|
||||
<commands index="1">
|
||||
<command><![CDATA[/etc/proftpd/create-cert.sh]]></command>
|
||||
<command><![CDATA[rm -f /etc/proftpd/create-cert.sh]]></command>
|
||||
</commands>
|
||||
<file name="/etc/proftpd/proftpd.conf" chown="root:0" chmod="0600"
|
||||
backup="true">
|
||||
|
||||
@@ -407,7 +407,7 @@ exit "$RETVAL"
|
||||
<!--DNS -->
|
||||
<service type="dns" title="{{lng.admin.configfiles.dns}}">
|
||||
<!--Bind9 -->
|
||||
<daemon name="bind" title="Bind9 nameserver">
|
||||
<daemon name="bind" title="Bind9 nameserver" default="true">
|
||||
<install><![CDATA[apt-get install bind9]]></install>
|
||||
<command><![CDATA[echo "include \"{{settings.system.bindconf_directory}}froxlor_bind.conf\";" >> /etc/bind/named.conf.local]]></command>
|
||||
<command><![CDATA[touch {{settings.system.bindconf_directory}}froxlor_bind.conf]]></command>
|
||||
@@ -4716,10 +4716,17 @@ MYSQL_AUXOPTIONS_FIELD CONCAT("allowimap=",imap,",allowpop3=",pop3)
|
||||
<!-- Proftpd -->
|
||||
<daemon name="proftpd" title="ProFTPd" default="true">
|
||||
<install><![CDATA[apt-get install proftpd-basic proftpd-mod-mysql]]></install>
|
||||
<commands>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"]]></command>
|
||||
<command><![CDATA[chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key]]></command>
|
||||
<file name="/etc/proftpd/create-cert.sh" chown="root:0" chmod="0700">
|
||||
<content><![CDATA[#!/bin/bash
|
||||
[ -f /etc/ssl/certs/proftpd.crt ] || openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out /etc/ssl/certs/proftpd.crt -keyout /etc/ssl/private/proftpd.key -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
[ -f /etc/ssl/certs/proftpd_ec.crt ] || openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name secp521r1) -keyout /etc/ssl/private/proftpd_ec.key -out /etc/ssl/certs/proftpd_ec.crt -days 3650 -subj "/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=<SERVERNAME>"
|
||||
chmod 0600 /etc/ssl/private/proftpd.key /etc/ssl/private/proftpd_ec.key
|
||||
]]>
|
||||
</content>
|
||||
</file>
|
||||
<commands index="1">
|
||||
<command><![CDATA[/etc/proftpd/create-cert.sh]]></command>
|
||||
<command><![CDATA[rm -f /etc/proftpd/create-cert.sh]]></command>
|
||||
</commands>
|
||||
<file name="/etc/proftpd/proftpd.conf" chown="root:0" chmod="0600"
|
||||
backup="true">
|
||||
|
||||
@@ -158,6 +158,18 @@ return array(
|
||||
)
|
||||
)
|
||||
),
|
||||
'section_cpre' => array(
|
||||
'visible' => !empty($hosting_plans),
|
||||
'title' => $lng['admin']['plans']['use_plan'],
|
||||
'image' => 'icons/user_add.png',
|
||||
'fields' => array(
|
||||
'use_plan' => array(
|
||||
'label' => $lng['admin']['plans']['use_plan'],
|
||||
'type' => 'select',
|
||||
'select_var' => $hosting_plans
|
||||
)
|
||||
)
|
||||
),
|
||||
'section_c' => array(
|
||||
'title' => $lng['admin']['servicedata'],
|
||||
'image' => 'icons/user_add.png',
|
||||
@@ -290,9 +302,9 @@ return array(
|
||||
'values' => $phpconfigs,
|
||||
'value' => ((int) Settings::Get('system.mod_fcgid') == 1 ? array(
|
||||
Settings::Get('system.mod_fcgid_defaultini')
|
||||
) : (int) Settings::Get('phpfpm.enabled') == 1) ? array(
|
||||
) : (int) Settings::Get('phpfpm.enabled') == 1 ? array(
|
||||
Settings::Get('phpfpm.defaultini')
|
||||
) : array(),
|
||||
) : array()),
|
||||
'is_array' => 1
|
||||
),
|
||||
'perlenabled' => array(
|
||||
|
||||
@@ -150,6 +150,18 @@ return array(
|
||||
)
|
||||
)
|
||||
),
|
||||
'section_cpre' => array(
|
||||
'visible' => !empty($hosting_plans),
|
||||
'title' => $lng['admin']['plans']['use_plan'],
|
||||
'image' => 'icons/user_add.png',
|
||||
'fields' => array(
|
||||
'use_plan' => array(
|
||||
'label' => $lng['admin']['plans']['use_plan'],
|
||||
'type' => 'select',
|
||||
'select_var' => $hosting_plans
|
||||
)
|
||||
)
|
||||
),
|
||||
'section_c' => array(
|
||||
'title' => $lng['admin']['servicedata'],
|
||||
'image' => 'icons/user_edit.png',
|
||||
|
||||
@@ -131,6 +131,19 @@ return array(
|
||||
'type' => 'textarea',
|
||||
'cols' => 60,
|
||||
'rows' => 12
|
||||
),
|
||||
'notryfiles' => array(
|
||||
'visible' => (Settings::Get('system.webserver') == 'nginx' && $userinfo['change_serversettings'] == '1'),
|
||||
'label' => $lng['admin']['notryfiles']['title'],
|
||||
'desc' => $lng['admin']['notryfiles']['description'],
|
||||
'type' => 'checkbox',
|
||||
'values' => array(
|
||||
array(
|
||||
'label' => $lng['panel']['yes'],
|
||||
'value' => '1'
|
||||
)
|
||||
),
|
||||
'value' => array()
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
@@ -161,6 +161,21 @@ return array(
|
||||
'value' => array(
|
||||
'1'
|
||||
)
|
||||
),
|
||||
'notryfiles' => array(
|
||||
'visible' => (Settings::Get('system.webserver') == 'nginx' && $userinfo['change_serversettings'] == '1'),
|
||||
'label' => $lng['admin']['notryfiles']['title'],
|
||||
'desc' => $lng['admin']['notryfiles']['description'],
|
||||
'type' => 'checkbox',
|
||||
'values' => array(
|
||||
array(
|
||||
'label' => $lng['panel']['yes'],
|
||||
'value' => '1'
|
||||
)
|
||||
),
|
||||
'value' => array(
|
||||
$result['notryfiles']
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
41
lib/formfields/admin/plans/formfield.plans_add.php
Normal file
41
lib/formfields/admin/plans/formfield.plans_add.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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 Formfields
|
||||
*
|
||||
*/
|
||||
|
||||
return array(
|
||||
'plans_add' => array(
|
||||
'title' => $lng['admin']['plans']['add'],
|
||||
'image' => 'icons/templates_add_big.png',
|
||||
'sections' => array(
|
||||
'section_a' => array(
|
||||
'title' => $lng['admin']['plans']['plan_details'],
|
||||
'image' => 'icons/templates_add_big.png',
|
||||
'fields' => array(
|
||||
'name' => array(
|
||||
'label' => $lng['admin']['plans']['name'],
|
||||
'type' => 'text'
|
||||
),
|
||||
'description' => array(
|
||||
'label' => $lng['admin']['plans']['description'],
|
||||
'type' => 'textarea',
|
||||
'cols' => 60,
|
||||
'rows' => 12
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
43
lib/formfields/admin/plans/formfield.plans_edit.php
Normal file
43
lib/formfields/admin/plans/formfield.plans_edit.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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 Formfields
|
||||
*
|
||||
*/
|
||||
|
||||
return array(
|
||||
'plans_edit' => array(
|
||||
'title' => $lng['admin']['plans']['edit'],
|
||||
'image' => 'icons/templates_edit_big.png',
|
||||
'sections' => array(
|
||||
'section_a' => array(
|
||||
'title' => $lng['admin']['plans']['plan_details'],
|
||||
'image' => 'icons/templates_edit_big.png',
|
||||
'fields' => array(
|
||||
'name' => array(
|
||||
'label' => $lng['admin']['plans']['name'],
|
||||
'type' => 'text',
|
||||
'value' => $result['name']
|
||||
),
|
||||
'description' => array(
|
||||
'label' => $lng['admin']['plans']['description'],
|
||||
'type' => 'textarea',
|
||||
'cols' => 60,
|
||||
'rows' => 12,
|
||||
'value' => $result['description']
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -214,6 +214,11 @@ return array(
|
||||
'label' => $lng['admin']['ipsandports']['ipsandports'],
|
||||
'required_resources' => 'change_serversettings'
|
||||
),
|
||||
array(
|
||||
'url' => 'admin_plans.php?page=overview',
|
||||
'label' => $lng['admin']['plans']['plans'],
|
||||
'required_resources' => 'customers'
|
||||
),
|
||||
array(
|
||||
'url' => 'admin_settings.php?page=updatecounters',
|
||||
'label' => $lng['admin']['updatecounters'],
|
||||
|
||||
@@ -52,5 +52,6 @@ define('TABLE_PANEL_DOMAIN_SSL_SETTINGS', 'domain_ssl_settings');
|
||||
define('TABLE_DOMAINTOIP', 'panel_domaintoip');
|
||||
define('TABLE_DOMAIN_DNS', 'domain_dns_entries');
|
||||
define('TABLE_PANEL_FPMDAEMONS', 'panel_fpmdaemons');
|
||||
define('TABLE_PANEL_PLANS', 'panel_plans');
|
||||
|
||||
require dirname(__FILE__).'/version.inc.php';
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
*/
|
||||
|
||||
// Main version variable
|
||||
$version = '0.9.39.1';
|
||||
$version = '0.9.39.5';
|
||||
|
||||
// Database version (YYYYMMDDC where C is a daily counter)
|
||||
$dbversion = '201801260';
|
||||
$dbversion = '201802130';
|
||||
|
||||
// Distribution branding-tag (used for Debian etc.)
|
||||
$branding = '';
|
||||
|
||||
@@ -2104,3 +2104,16 @@ $lng['serversettings']['phpfpm_settings']['envpath'] = 'Paths to add to the PATH
|
||||
$lng['admin']['configfiles']['importexport'] = 'Import/Export';
|
||||
$lng['success']['settingsimported'] = 'Settings imported successfully';
|
||||
$lng['error']['jsonextensionnotfound'] = 'This feature requires the php json-extension.';
|
||||
|
||||
// added in froxlor 0.9.39
|
||||
$lng['admin']['plans']['name'] = 'Plan name';
|
||||
$lng['admin']['plans']['description'] = 'Description';
|
||||
$lng['admin']['plans']['last_update'] = 'Last updated';
|
||||
$lng['admin']['plans']['plans'] = 'Hosting plans';
|
||||
$lng['admin']['plans']['plan_details'] = 'Plan details';
|
||||
$lng['admin']['plans']['add'] = 'Add new plan';
|
||||
$lng['admin']['plans']['edit'] = 'Edit plan';
|
||||
$lng['admin']['plans']['use_plan'] = 'Apply plan';
|
||||
$lng['question']['plan_reallydelete'] = 'Do you really want to delete the hosting plan %s?';
|
||||
$lng['admin']['notryfiles']['title'] = 'No autogenerated try_files';
|
||||
$lng['admin']['notryfiles']['description'] = 'Say yes here if you want to specify a custom try_files directive in specialsettings (needed for some wordpress plugins for example).';
|
||||
|
||||
@@ -1754,3 +1754,16 @@ $lng['phpfpm']['ini_admin_values'] = 'Mögliche <strong>php_admin_value</strong>
|
||||
$lng['serversettings']['phpfpm_settings']['envpath'] = 'Pfade für die PATH Umgebungsvariable. Leerlassen, um keine PATH Umgebungsvariable zu setzen.';
|
||||
$lng['success']['settingsimported'] = 'Einstellungnen erfolgreich importiert';
|
||||
$lng['error']['jsonextensionnotfound'] = 'Diese Funktion benötigt die PHP json-Erweiterung.';
|
||||
|
||||
// added in froxlor 0.9.39
|
||||
$lng['admin']['plans']['name'] = 'Plan Name';
|
||||
$lng['admin']['plans']['description'] = 'Beschreibung';
|
||||
$lng['admin']['plans']['last_update'] = 'Zuletzt aktualisiert';
|
||||
$lng['admin']['plans']['plans'] = 'Hosting Pläne';
|
||||
$lng['admin']['plans']['plan_details'] = 'Plan Details';
|
||||
$lng['admin']['plans']['add'] = 'Neuen Plan anlegen';
|
||||
$lng['admin']['plans']['edit'] = 'Plan editieren';
|
||||
$lng['admin']['plans']['use_plan'] = 'Plan übernehmen';
|
||||
$lng['question']['plan_reallydelete'] = 'Wollen Sie den Hosting-Plan "%s" wirklich löschen?';
|
||||
$lng['admin']['notryfiles']['title'] = 'Keine generierte try_files Anweisung';
|
||||
$lng['admin']['notryfiles']['description'] = 'Wähle "Ja", wenn eine eigene try_files Direktive in den "eigenen Vhost Einstellungen" angegeben werden soll (z.B. nötig für manche Wordpress Plugins).';
|
||||
|
||||
@@ -916,7 +916,9 @@ class nginx extends HttpConfigBase
|
||||
|
||||
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1') {
|
||||
$webroot_text .= "\t" . 'index index.php index.html index.htm;' . "\n";
|
||||
$webroot_text .= "\t\t" . 'try_files $uri $uri/ @rewrites;' . "\n";
|
||||
if ($domain['notryfiles'] != 1) {
|
||||
$webroot_text .= "\t\t" . 'try_files $uri $uri/ @rewrites;' . "\n";
|
||||
}
|
||||
} else {
|
||||
$webroot_text .= "\t" . 'index index.html index.htm;' . "\n";
|
||||
}
|
||||
@@ -927,7 +929,7 @@ class nginx extends HttpConfigBase
|
||||
}
|
||||
|
||||
$webroot_text .= "\t" . '}' . "\n\n";
|
||||
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1') {
|
||||
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1' && $domain['notryfiles'] != 1) {
|
||||
$webroot_text .= "\tlocation @rewrites {\n";
|
||||
$webroot_text .= "\t\trewrite ^ /index.php last;\n";
|
||||
$webroot_text .= "\t}\n\n";
|
||||
|
||||
@@ -6,6 +6,7 @@ $header
|
||||
{$title}
|
||||
</h2>
|
||||
</header>
|
||||
<script type="text/javascript" src="templates/{$theme}/assets/js/customers.js"></script>
|
||||
|
||||
<section>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ $header
|
||||
{$title}
|
||||
</h2>
|
||||
</header>
|
||||
<script type="text/javascript" src="templates/{$theme}/assets/js/customers.js"></script>
|
||||
|
||||
<section>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<if $row['termination_css'] != ''>
|
||||
<tr class="{$row['termination_css']}">
|
||||
<tr class="{$row['termination_css']}<if $row['deactivated'] == 1> disabled</if>">
|
||||
</if>
|
||||
<if $row['termination_css'] == ''>
|
||||
<tr>
|
||||
<tr <if $row['deactivated'] == 1>class="disabled"</if>>
|
||||
</if>
|
||||
<td>{$row['domain']}
|
||||
<if (isset($row['standardsubdomain']) && $row['standardsubdomain'] == $row['id'])>
|
||||
|
||||
59
templates/Sparkle/admin/plans/plans.tpl
vendored
Normal file
59
templates/Sparkle/admin/plans/plans.tpl
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
$header
|
||||
<article>
|
||||
<header>
|
||||
<h2>
|
||||
<img src="templates/{$theme}/assets/img/icons/templates_big.png" alt="" />
|
||||
{$lng['admin']['plans']['plans']}
|
||||
</h2>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
|
||||
<form action="{$linker->getLink(array('section' => 'plans'))}" method="post" enctype="application/x-www-form-urlencoded">
|
||||
<input type="hidden" name="s" value="$s"/>
|
||||
<input type="hidden" name="page" value="$page"/>
|
||||
<div class="overviewsearch">
|
||||
{$searchcode}
|
||||
</div>
|
||||
|
||||
<div class="overviewadd">
|
||||
<img src="templates/{$theme}/assets/img/icons/add.png" alt="" />
|
||||
<a href="{$linker->getLink(array('section' => 'plans', 'page' => $page, 'action' => 'add'))}">{$lng['admin']['plans']['add']}</a>
|
||||
</div>
|
||||
|
||||
<table class="full hl">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{$lng['admin']['plans']['name']} {$arrowcode['p.name']}</th>
|
||||
<th>{$lng['admin']['plans']['description']} {$arrowcode['p.description']}</th>
|
||||
<th>{$lng['admin']['admin']} {$arrowcode['adminname']}</th>
|
||||
<th>{$lng['admin']['plans']['last_update']} {$arrowcode['p.ts']}</th>
|
||||
<th>{$lng['panel']['options']}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<if $pagingcode != ''>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5">{$pagingcode}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</if>
|
||||
|
||||
<tbody>
|
||||
$plans
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<if 15 < $count>
|
||||
<div class="overviewadd">
|
||||
<img src="templates/{$theme}/assets/img/icons/add.png" alt="" />
|
||||
<a href="{$linker->getLink(array('section' => 'plans', 'page' => $page, 'action' => 'add'))}">{$lng['admin']['plans']['add']}</a>
|
||||
</div>
|
||||
</if>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
$footer
|
||||
26
templates/Sparkle/admin/plans/plans_add.tpl
vendored
Normal file
26
templates/Sparkle/admin/plans/plans_add.tpl
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
$header
|
||||
<article>
|
||||
<header>
|
||||
<h2>
|
||||
<img src="templates/{$theme}/assets/img/{$image}" alt="{$title}" />
|
||||
{$title}
|
||||
</h2>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
|
||||
<form action="{$linker->getLink(array('section' => 'plans'))}" method="post" enctype="application/x-www-form-urlencoded">
|
||||
<input type="hidden" name="s" value="$s" />
|
||||
<input type="hidden" name="page" value="$page" />
|
||||
<input type="hidden" name="action" value="$action" />
|
||||
<input type="hidden" name="send" value="send" />
|
||||
|
||||
<table class="full">
|
||||
{$plans_add_form}
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
$footer
|
||||
27
templates/Sparkle/admin/plans/plans_edit.tpl
vendored
Normal file
27
templates/Sparkle/admin/plans/plans_edit.tpl
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
$header
|
||||
<article>
|
||||
<header>
|
||||
<h2>
|
||||
<img src="templates/{$theme}/assets/img/{$image}" alt="{$title}" />
|
||||
{$title}
|
||||
</h2>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
|
||||
<form action="{$linker->getLink(array('section' => 'plans'))}" method="post" enctype="application/x-www-form-urlencoded">
|
||||
<input type="hidden" name="s" value="$s" />
|
||||
<input type="hidden" name="page" value="$page" />
|
||||
<input type="hidden" name="action" value="$action" />
|
||||
<input type="hidden" name="id" value="$id" />
|
||||
<input type="hidden" name="send" value="send" />
|
||||
|
||||
<table class="full">
|
||||
{$plans_edit_form}
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
$footer
|
||||
14
templates/Sparkle/admin/plans/plans_plan.tpl
vendored
Normal file
14
templates/Sparkle/admin/plans/plans_plan.tpl
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<tr>
|
||||
<td>{$row['name']}</td>
|
||||
<td>{$row['description']}</td>
|
||||
<td>{$row['adminname']}</td>
|
||||
<td>{$row['ts_format']}</td>
|
||||
<td>
|
||||
<a href="{$linker->getLink(array('section' => 'plans', 'page' => $page, 'action' => 'edit', 'id' => $row['id']))}">
|
||||
<img src="templates/{$theme}/assets/img/icons/edit.png" alt="{$lng['panel']['edit']}" title="{$lng['panel']['edit']}" />
|
||||
</a>
|
||||
<a href="{$linker->getLink(array('section' => 'plans', 'page' => $page, 'action' => 'delete', 'id' => $row['id']))}">
|
||||
<img src="templates/{$theme}/assets/img/icons/delete.png" alt="{$lng['panel']['delete']}" title="{$lng['panel']['delete']}" />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
75
templates/Sparkle/assets/js/customers.js
vendored
Normal file
75
templates/Sparkle/assets/js/customers.js
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
var getUrlParameter = function getUrlParameter(sParam) {
|
||||
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
|
||||
sURLVariables = sPageURL.split('&'),
|
||||
sParameterName,
|
||||
i;
|
||||
|
||||
for (i = 0; i < sURLVariables.length; i++) {
|
||||
sParameterName = sURLVariables[i].split('=');
|
||||
|
||||
if (sParameterName[0] === sParam) {
|
||||
return sParameterName[1] === undefined ? true : sParameterName[1];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* disable unusable php-configuration by customer settings
|
||||
*/
|
||||
$('#use_plan').change(function() {
|
||||
var pid = $(this).val();
|
||||
if (pid > 0) {
|
||||
var sid = getUrlParameter('s');
|
||||
$.ajax({
|
||||
url: "admin_plans.php?s="+sid+"&page=overview&action=jqGetPlanValues",
|
||||
type: "POST",
|
||||
data: {
|
||||
planid: pid
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
for (i in json) {
|
||||
if (i == 'email_imap' || i == 'email_pop3' || i == 'perlenabled' || i == 'phpenabled' || i == 'dnsenabled') {
|
||||
/** handle checkboxes **/
|
||||
if (json[i] == 1) {
|
||||
$("input[name='"+i+"']").prop('checked', true);
|
||||
} else {
|
||||
$("input[name='"+i+"']").prop('checked', false);
|
||||
}
|
||||
} else if (i == 'allowed_phpconfigs') {
|
||||
/** handle array of values **/
|
||||
$("input[name='allowed_phpconfigs[]']").each(function(index) {
|
||||
$(this).prop('checked', false);
|
||||
for (j in json[i]) {
|
||||
if ($(this).val() == json[i][j]) {
|
||||
$(this).prop('checked', true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (json[i] == -1) {
|
||||
/** handle unlimited checkboxes **/
|
||||
$("input[name='" + i + "_ul']").attr('checked', 'checked');
|
||||
$("input[name='"+i+"']").prop({
|
||||
readonly: true
|
||||
});
|
||||
} else {
|
||||
/** handle normal value **/
|
||||
$("input[name='"+i+"']").val(json[i]);
|
||||
$("input[name='"+i+"']").prop({
|
||||
readonly: false
|
||||
});
|
||||
$("input[name='" + i + "_ul']").prop('checked', false);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(a, b) {
|
||||
console.log(a, b);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user