diff --git a/admin_admins.php b/admin_admins.php index 39b4d0d3..2e5b0407 100644 --- a/admin_admins.php +++ b/admin_admins.php @@ -153,6 +153,7 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') { $admin_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_add.php'; UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'admins')), 'formdata' => $admin_add_data['admin_add'] ]); UI::twigOutputBuffer(); @@ -200,6 +201,7 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') { $admin_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_edit.php'; UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'admins', 'id' => $id)), 'formdata' => $admin_edit_data['admin_edit'] ]); UI::twigOutputBuffer(); diff --git a/admin_customers.php b/admin_customers.php index 915d37a3..aeeff0fb 100644 --- a/admin_customers.php +++ b/admin_customers.php @@ -317,6 +317,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') { $customer_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_add.php'; UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'customers')), 'formdata' => $customer_add_data['customer_add'] ]); UI::twigOutputBuffer(); @@ -402,6 +403,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') { $customer_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_edit.php'; UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'customers', 'id' => $id)), 'formdata' => $customer_edit_data['customer_edit'] ]); UI::twigOutputBuffer(); diff --git a/api.php b/api.php index a05357bd..ff12c21a 100644 --- a/api.php +++ b/api.php @@ -1,7 +1,6 @@ $userinfo['customerid'] )); - $domains = ''; - + $domains = []; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row['domain']), $row['domain']); + $domains[$row['domain']] = $idna_convert->decode($row['domain']); } - $aliasdomains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, NULL, true); + $aliasdomains[0] = $lng['domains']['noaliasdomain']; $domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`id` <> `c`.`standardsubdomain` @@ -179,19 +179,19 @@ if ($page == 'overview') { )); while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $aliasdomains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id']); + $aliasdomains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']); } - $redirectcode = ''; + $redirectcode = []; if (Settings::Get('customredirect.enabled') == '1') { $codes = \Froxlor\Domain\Domain::getRedirectCodesArray(); foreach ($codes as $rc) { - $redirectcode .= \Froxlor\UI\HTML::makeoption($rc['code'] . ' (' . $lng['redirect_desc'][$rc['desc']] . ')', $rc['id']); + $redirectcode[$rc['id']] = $rc['code'] . ' (' . $lng['redirect_desc'][$rc['desc']] . ')'; } } // check if we at least have one ssl-ip/port, #1179 - $ssl_ipsandports = ''; + $ssl_ipsandports = false; $ssl_ip_stmt = Database::prepare(" SELECT COUNT(*) as countSSL FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip @@ -201,16 +201,17 @@ if ($page == 'overview') { Database::pexecute($ssl_ip_stmt); $resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC); if (isset($resultX['countSSL']) && (int) $resultX['countSSL'] > 0) { - $ssl_ipsandports = 'notempty'; + $ssl_ipsandports = true; } - $openbasedir = \Froxlor\UI\HTML::makeoption($lng['domain']['docroot'], 0, NULL, true) . \Froxlor\UI\HTML::makeoption($lng['domain']['homedir'], 1, NULL, true); + $openbasedir = [ + 0 => $lng['domain']['docroot'], + 1 => $lng['domain']['homedir'] + ]; $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); - $phpconfigs = ''; - $has_phpconfigs = false; - if (isset($userinfo['allowed_phpconfigs']) && ! empty($userinfo['allowed_phpconfigs'])) { - $has_phpconfigs = true; + $phpconfigs = []; + if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs'])) { $allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY); $phpconfigs_result_stmt = Database::query(" SELECT c.*, fc.description as interpreter @@ -220,20 +221,20 @@ if ($page == 'overview') { "); while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) { if ((int) Settings::Get('phpfpm.enabled') == 1) { - $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]", $phpconfigs_row['id'], Settings::Get('phpfpm.defaultini'), true, true); + $phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]"; } else { - $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true); + $phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description']; } } } $subdomain_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_add.php'; - $subdomain_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($subdomain_add_data); - $title = $subdomain_add_data['domain_add']['title']; - $image = $subdomain_add_data['domain_add']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_add") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'domains')), + 'formdata' => $subdomain_add_data['domain_add'] + ]); + UI::twigOutputBuffer(); } } } elseif ($action == 'edit' && $id != 0) { @@ -261,7 +262,7 @@ if ($page == 'overview') { } else { $result['domain'] = $idna_convert->decode($result['domain']); - $domains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, $result['aliasdomain'], true); + $domains[0] = $lng['domains']['noaliasdomain']; // also check ip/port combination to be the same, #176 $domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d` , `" . TABLE_PANEL_CUSTOMERS . "` `c` , `" . TABLE_DOMAINTOIP . "` `dip` WHERE `d`.`aliasdomain` IS NULL @@ -282,7 +283,7 @@ if ($page == 'overview') { )); while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']); + $domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']); } if (preg_match('/^https?\:\/\//', $result['documentroot']) && \Froxlor\Validate\Validate::validateUrl($result['documentroot'])) { @@ -298,17 +299,17 @@ if ($page == 'overview') { $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot']); } - $redirectcode = ''; + $redirectcode = []; if (Settings::Get('customredirect.enabled') == '1') { $def_code = \Froxlor\Domain\Domain::getDomainRedirectId($id); $codes = \Froxlor\Domain\Domain::getRedirectCodesArray(); foreach ($codes as $rc) { - $redirectcode .= \Froxlor\UI\HTML::makeoption($rc['code'] . ' (' . $lng['redirect_desc'][$rc['desc']] . ')', $rc['id'], $def_code); + $redirectcode[$rc['id']] = $rc['code'] . ' (' . $lng['redirect_desc'][$rc['desc']] . ')'; } } // check if we at least have one ssl-ip/port, #1179 - $ssl_ipsandports = ''; + $ssl_ipsandports = false; $ssl_ip_stmt = Database::prepare(" SELECT COUNT(*) as countSSL FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip @@ -320,26 +321,29 @@ if ($page == 'overview') { )); $resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC); if (isset($resultX['countSSL']) && (int) $resultX['countSSL'] > 0) { - $ssl_ipsandports = 'notempty'; + $ssl_ipsandports = true; } // Fudge the result for ssl_redirect to hide the Let's Encrypt steps $result['temporary_ssl_redirect'] = $result['ssl_redirect']; $result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1); - $openbasedir = \Froxlor\UI\HTML::makeoption($lng['domain']['docroot'], 0, $result['openbasedir_path'], true) . \Froxlor\UI\HTML::makeoption($lng['domain']['homedir'], 1, $result['openbasedir_path'], true); + $openbasedir = [ + 0 => $lng['domain']['docroot'], + 1 => $lng['domain']['homedir'] + ]; // create serveralias options - $serveraliasoptions = ""; - $_value = '2'; + $serveraliasoptions = []; + $serveraliasoptions_selected = '2'; if ($result['iswildcarddomain'] == '1') { - $_value = '0'; + $serveraliasoptions_selected = '0'; } elseif ($result['wwwserveralias'] == '1') { - $_value = '1'; + $serveraliasoptions_selected = '1'; } - $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', $_value, true, true); - $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', $_value, true, true); - $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', $_value, true, true); + $serveraliasoptions[0] = $lng['domains']['serveraliasoption_wildcard']; + $serveraliasoptions[1] = $lng['domains']['serveraliasoption_www']; + $serveraliasoptions[2] = $lng['domains']['serveraliasoption_none']; $ips_stmt = Database::prepare("SELECT `p`.`ip` AS `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` `p` LEFT JOIN `" . TABLE_DOMAINTOIP . "` `dip` @@ -349,15 +353,13 @@ if ($page == 'overview') { Database::pexecute($ips_stmt, array( "id_domain" => $result['id'] )); - $result_ipandport['ip'] = ''; + $domainips = []; while ($rowip = $ips_stmt->fetch(PDO::FETCH_ASSOC)) { - $result_ipandport['ip'] .= $rowip['ip'] . "
"; + $domainips[] = ['item' => $rowip['ip']]; } - $phpconfigs = ''; - $has_phpconfigs = false; - if (isset($userinfo['allowed_phpconfigs']) && ! empty($userinfo['allowed_phpconfigs'])) { - $has_phpconfigs = true; + $phpconfigs = []; + if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs'])) { $allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY); $phpconfigs_result_stmt = Database::query(" SELECT c.*, fc.description as interpreter @@ -367,9 +369,9 @@ if ($page == 'overview') { "); while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) { if ((int) Settings::Get('phpfpm.enabled') == 1) { - $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]", $phpconfigs_row['id'], $result['phpsettingid'], true, true); + $phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]"; } else { - $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true); + $phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description']; } } } @@ -380,16 +382,15 @@ if ($page == 'overview') { )); $alias_check = $alias_check['count']; - $domainip = $result_ipandport['ip']; $result = \Froxlor\PhpHelper::htmlentitiesArray($result); $subdomain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_edit.php'; - $subdomain_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($subdomain_edit_data); - $title = $subdomain_edit_data['domain_edit']['title']; - $image = $subdomain_edit_data['domain_edit']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_edit") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'domains', 'id' => $id)), + 'formdata' => $subdomain_edit_data['domain_edit'] + ]); + UI::twigOutputBuffer(); } } else { \Froxlor\UI\Response::standard_error('domains_canteditdomain'); @@ -435,7 +436,7 @@ if ($page == 'overview') { $do_insert = false; // if no entry can be found, behave like we have empty values - if (! is_array($result) || ! isset($result['ssl_cert_file'])) { + if (!is_array($result) || !isset($result['ssl_cert_file'])) { $result = array( 'ssl_cert_file' => '', 'ssl_key_file' => '', @@ -514,4 +515,3 @@ function formatDomainEntry(&$row, &$idna_convert) } } } - diff --git a/customer_email.php b/customer_email.php index 3f0bee0e..93f9da5c 100644 --- a/customer_email.php +++ b/customer_email.php @@ -211,6 +211,7 @@ if ($page == 'overview') { unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']); } UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'email')), 'formdata' => $email_add_data['emails_add'] ]); UI::twigOutputBuffer(); @@ -260,6 +261,7 @@ if ($page == 'overview') { } UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'email')), 'formdata' => $email_edit_data['emails_edit'] ]); UI::twigOutputBuffer(); @@ -328,6 +330,7 @@ if ($page == 'overview') { $account_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addaccount.php'; UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'email', 'id' => $id)), 'formdata' => $account_add_data['emails_addaccount'] ]); UI::twigOutputBuffer(); @@ -366,12 +369,12 @@ if ($page == 'overview') { $result = \Froxlor\PhpHelper::htmlentitiesArray($result); $account_changepw_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangepasswd.php'; - $account_changepw_form = \Froxlor\UI\HtmlForm::genHTMLForm($account_changepw_data); - $title = $account_changepw_data['emails_accountchangepasswd']['title']; - $image = $account_changepw_data['emails_accountchangepasswd']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_changepw") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'email', 'id' => $id)), + 'formdata' => $account_changepw_data['emails_accountchangepasswd'] + ]); + UI::twigOutputBuffer(); } } } elseif ($action == 'changequota' && Settings::Get('system.mail_quota_enabled') == '1' && $id != 0) { @@ -402,12 +405,12 @@ if ($page == 'overview') { $result = \Froxlor\PhpHelper::htmlentitiesArray($result); $quota_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangequota.php'; - $quota_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($quota_edit_data); - $title = $quota_edit_data['emails_accountchangequota']['title']; - $image = $quota_edit_data['emails_accountchangequota']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_changequota") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'email', 'id' => $id)), + 'formdata' => $quota_edit_data['emails_accountchangequota'] + ]); + UI::twigOutputBuffer(); } } } elseif ($action == 'delete' && $id != 0) { @@ -474,6 +477,7 @@ if ($page == 'overview') { $forwarder_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addforwarder.php'; UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'email', 'id' => $id)), 'formdata' => $forwarder_add_data['emails_addforwarder'] ]); UI::twigOutputBuffer(); diff --git a/customer_extras.php b/customer_extras.php index 294cb01c..59427300 100644 --- a/customer_extras.php +++ b/customer_extras.php @@ -23,6 +23,7 @@ use Froxlor\Api\Commands\CustomerBackups as CustomerBackups; use Froxlor\Api\Commands\DirOptions as DirOptions; use Froxlor\Api\Commands\DirProtections as DirProtections; use Froxlor\Settings; +use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; // redirect if this customer page is hidden via settings @@ -127,12 +128,12 @@ if ($page == 'overview') { $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php'; - $htpasswd_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($htpasswd_add_data); - $title = $htpasswd_add_data['htpasswd_add']['title']; - $image = $htpasswd_add_data['htpasswd_add']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_add") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'extras')), + 'formdata' => $htpasswd_add_data['htpasswd_add'] + ]); + UI::twigOutputBuffer(); } } elseif ($action == 'edit' && $id != 0) { try { @@ -159,16 +160,15 @@ if ($page == 'overview') { if (strpos($result['path'], $userinfo['documentroot']) === 0) { $result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']); } - $result = \Froxlor\PhpHelper::htmlentitiesArray($result); $htpasswd_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_edit.php'; - $htpasswd_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($htpasswd_edit_data); - $title = $htpasswd_edit_data['htpasswd_edit']['title']; - $image = $htpasswd_edit_data['htpasswd_edit']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_edit") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'extras', 'id' => $id)), + 'formdata' => $htpasswd_edit_data['htpasswd_edit'] + ]); + UI::twigOutputBuffer(); } } } @@ -271,12 +271,12 @@ if ($page == 'overview') { $cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']); $htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php'; - $htaccess_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($htaccess_add_data); - $title = $htaccess_add_data['htaccess_add']['title']; - $image = $htaccess_add_data['htaccess_add']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_add") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'extras')), + 'formdata' => $htaccess_add_data['htaccess_add'] + ]); + UI::twigOutputBuffer(); } } elseif (($action == 'edit') && ($id != 0)) { try { @@ -303,24 +303,17 @@ if ($page == 'overview') { if (strpos($result['path'], $userinfo['documentroot']) === 0) { $result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']); } - - $result['error404path'] = $result['error404path']; - $result['error403path'] = $result['error403path']; - $result['error500path'] = $result['error500path']; $cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']); - /* - * $options_indexes = \Froxlor\UI\HTML::makeyesno('options_indexes', '1', '0', $result['options_indexes']); - * $options_cgi = \Froxlor\UI\HTML::makeyesno('options_cgi', '1', '0', $result['options_cgi']); - */ + $result = \Froxlor\PhpHelper::htmlentitiesArray($result); $htaccess_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_edit.php'; - $htaccess_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($htaccess_edit_data); - $title = $htaccess_edit_data['htaccess_edit']['title']; - $image = $htaccess_edit_data['htaccess_edit']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_edit") . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'extras', 'id' => $id)), + 'formdata' => $htaccess_edit_data['htaccess_edit'] + ]); + UI::twigOutputBuffer(); } } } diff --git a/customer_ftp.php b/customer_ftp.php index 43b0d9c2..99743677 100644 --- a/customer_ftp.php +++ b/customer_ftp.php @@ -22,6 +22,7 @@ require __DIR__ . '/lib/init.php'; use Froxlor\Api\Commands\Ftps as Ftps; use Froxlor\Database\Database; use Froxlor\Settings; +use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; // redirect if this customer page is hidden via settings @@ -71,7 +72,7 @@ if ($page == 'overview') { $row['documentroot'] = \Froxlor\FileDir::makeCorrectDir($row['documentroot']); $row = \Froxlor\PhpHelper::htmlentitiesArray($row); eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_account') . "\";"); - $count ++; + $count++; } eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts') . "\";"); @@ -122,9 +123,7 @@ if ($page == 'overview') { $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/'); if (Settings::Get('customer.ftpatdomain') == '1') { - $domainlist = array(); - $domains = ''; - + $domainlist = []; $result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`= :customerid"); Database::pexecute($result_domains_stmt, array( @@ -132,39 +131,27 @@ if ($page == 'overview') { )); while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $domainlist[] = $row_domain['domain']; + $domainlist[$row_domain['domain']] = $idna_convert->decode($row_domain['domain']); } - sort($domainlist); - - if (isset($domainlist[0]) && $domainlist[0] != '') { - foreach ($domainlist as $dom) { - $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($dom), $dom); - } - } } if (Settings::Get('system.allow_customer_shell') == '1') { - $shells = \Froxlor\UI\HTML::makeoption("/bin/false", "/bin/false", "/bin/false"); + $shells['/bin/false'] = "/bin/false"; $shells_avail = Settings::Get('system.available_shells'); - if (! empty($shells_avail)) { + if (!empty($shells_avail)) { $shells_avail = explode(",", $shells_avail); $shells_avail = array_map("trim", $shells_avail); - foreach ($shells_avail as $_shell) { - $shells .= \Froxlor\UI\HTML::makeoption($_shell, $_shell, "/bin/false"); - } } } - // $sendinfomail = \Froxlor\UI\HTML::makeyesno('sendinfomail', '1', '0', '0'); - $ftp_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_add.php'; - $ftp_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($ftp_add_data); - $title = $ftp_add_data['ftp_add']['title']; - $image = $ftp_add_data['ftp_add']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_add') . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'ftp')), + 'formdata' => $ftp_add_data['ftp_add'] + ]); + UI::twigOutputBuffer(); } } } elseif ($action == 'edit' && $id != 0) { @@ -198,39 +185,22 @@ if ($page == 'overview') { $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir); - if (Settings::Get('customer.ftpatdomain') == '1') { - $domains = ''; - - $result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` - WHERE `customerid` = :customerid"); - Database::pexecute($result_domains_stmt, array( - "customerid" => $userinfo['customerid'] - )); - - while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']); - } - } - if (Settings::Get('system.allow_customer_shell') == '1') { - $shells = \Froxlor\UI\HTML::makeoption("/bin/false", "/bin/false", $result['shell']); + $shells['/bin/false'] = "/bin/false"; $shells_avail = Settings::Get('system.available_shells'); - if (! empty($shells_avail)) { + if (!empty($shells_avail)) { $shells_avail = explode(",", $shells_avail); $shells_avail = array_map("trim", $shells_avail); - foreach ($shells_avail as $_shell) { - $shells .= \Froxlor\UI\HTML::makeoption($_shell, $_shell, $result['shell']); - } } } $ftp_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_edit.php'; - $ftp_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($ftp_edit_data); - $title = $ftp_edit_data['ftp_edit']['title']; - $image = $ftp_edit_data['ftp_edit']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_edit') . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'ftp', 'id' => $id)), + 'formdata' => $ftp_edit_data['ftp_edit'] + ]); + UI::twigOutputBuffer(); } } } diff --git a/customer_logger.php b/customer_logger.php index d718e335..89cfb21f 100644 --- a/customer_logger.php +++ b/customer_logger.php @@ -22,6 +22,7 @@ require __DIR__ . '/lib/init.php'; use Froxlor\Api\Commands\SysLog; use Froxlor\Database\Database; use Froxlor\Settings; +use Froxlor\UI\Panel\UI; // redirect if this customer page is hidden via settings if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) { diff --git a/customer_mysql.php b/customer_mysql.php index a57569de..895841e0 100644 --- a/customer_mysql.php +++ b/customer_mysql.php @@ -22,6 +22,7 @@ require __DIR__ . '/lib/init.php'; use Froxlor\Api\Commands\Mysqls as Mysqls; use Froxlor\Database\Database; use Froxlor\Settings; +use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; // redirect if this customer page is hidden via settings @@ -90,7 +91,7 @@ if ($page == 'overview') { } $row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";"); - $count ++; + $count++; } Database::needRoot(false); // End root-session @@ -114,7 +115,7 @@ if ($page == 'overview') { $sql_root = Database::getSqlData(); Database::needRoot(false); - if (! isset($sql_root[$result['dbserver']]) || ! is_array($sql_root[$result['dbserver']])) { + if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) { $result['dbserver'] = 0; } @@ -155,24 +156,22 @@ if ($page == 'overview') { } else { $dbservers_stmt = Database::query("SELECT DISTINCT `dbserver` FROM `" . TABLE_PANEL_DATABASES . "`"); - $mysql_servers = ''; - $count_mysqlservers = 0; + $mysql_servers = []; while ($dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC)) { Database::needRoot(true, $dbserver['dbserver']); Database::needSqlData(); $sql_root = Database::getSqlData(); - $mysql_servers .= \Froxlor\UI\HTML::makeoption($sql_root['caption'], $dbserver['dbserver']); - $count_mysqlservers ++; + $mysql_servers[$dbserver['dbserver']] = $sql_root['caption']; } Database::needRoot(false); $mysql_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_add.php'; - $mysql_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($mysql_add_data); - $title = $mysql_add_data['mysql_add']['title']; - $image = $mysql_add_data['mysql_add']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_add') . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'mysql')), + 'formdata' => $mysql_add_data['mysql_add'] + ]); + UI::twigOutputBuffer(); } } } elseif ($action == 'edit' && $id != 0) { @@ -200,7 +199,7 @@ if ($page == 'overview') { $dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `" . TABLE_PANEL_DATABASES . "`"); $dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC); - $count_mysqlservers = $dbserver['numservers']; + $count_mysql_servers = $dbserver['numservers']; Database::needRoot(true, $result['dbserver']); Database::needSqlData(); @@ -208,12 +207,12 @@ if ($page == 'overview') { Database::needRoot(false); $mysql_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_edit.php'; - $mysql_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($mysql_edit_data); - $title = $mysql_edit_data['mysql_edit']['title']; - $image = $mysql_edit_data['mysql_edit']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_edit') . "\";"); + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'mysql', 'id' => $id)), + 'formdata' => $mysql_edit_data['mysql_edit'] + ]); + UI::twigOutputBuffer(); } } } diff --git a/customer_traffic.php b/customer_traffic.php index 588defe5..1a98f97a 100644 --- a/customer_traffic.php +++ b/customer_traffic.php @@ -22,6 +22,7 @@ require __DIR__ . '/lib/init.php'; use Froxlor\Database\Database; use Froxlor\Settings; +use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; // redirect if this customer page is hidden via settings diff --git a/lib/Froxlor/FileDir.php b/lib/Froxlor/FileDir.php index f19a4271..ae334bf6 100644 --- a/lib/Froxlor/FileDir.php +++ b/lib/Froxlor/FileDir.php @@ -394,22 +394,23 @@ class FileDir $value = '/' . $value; } - $fieldType = \Froxlor\Settings::Get('panel.pathedit'); + $fieldType = strtolower(\Froxlor\Settings::Get('panel.pathedit')); - if ($fieldType == 'Manual') { + if ($fieldType == 'manual') { $field = array( 'type' => 'text', 'value' => htmlspecialchars($value) ); - } elseif ($fieldType == 'Dropdown') { + + } elseif ($fieldType == 'dropdown') { $dirList = self::findDirs($path, $uid, $gid); natcasesort($dirList); if (sizeof($dirList) > 0) { if (sizeof($dirList) <= 100) { - $_field = ''; + $_field = []; foreach ($dirList as $dir) { if (strpos($dir, $path) === 0) { $dir = substr($dir, strlen($path)); @@ -419,11 +420,12 @@ class FileDir } $dir = self::makeCorrectDir($dir); } - $_field .= \Froxlor\UI\HTML::makeoption($dir, $dir, $value); + $_field[$dir] = $dir; } $field = array( 'type' => 'select', - 'value' => $_field + 'select_var' => $_field, + 'selected' => $value ); } else { // remove starting slash we added diff --git a/lib/Froxlor/UI/HTML.php b/lib/Froxlor/UI/HTML.php index 26f68ab1..b4bcf227 100644 --- a/lib/Froxlor/UI/HTML.php +++ b/lib/Froxlor/UI/HTML.php @@ -2,6 +2,19 @@ namespace Froxlor\UI; +/** + * 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 (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package UI + */ class HTML { @@ -12,11 +25,9 @@ class HTML * array navigation data * @param * array userinfo the userinfo of the user - * @return array the content of the navigation bar - * - * @author Florian Lippert + * @return array the content of the navigation bar according to user-permissions */ - public static function buildNavigation($navigation, $userinfo) + public static function buildNavigation(array $navigation, array $userinfo) { $returnvalue = []; @@ -64,7 +75,7 @@ class HTML $icon = $element['icon'] ?? null; } else { $navlabel = $element['label']; - $icon = $element['icon'] ?? null; + $icon = $element['icon'] ?? null; } $navigation_links[] = [ @@ -138,6 +149,8 @@ class HTML * Whether the value may contain html or not * * @return string HTML Code + * + * @deprecated */ public static function makecheckbox($name, $title, $value, $break = false, $selvalue = null, $title_trusted = false, $value_trusted = false) { @@ -183,6 +196,8 @@ class HTML * @param bool $disabled * * @return string HTML Code + * + * @deprecated */ public static function makeoption($title, $value, $selvalue = null, $title_trusted = false, $value_trusted = false, $id = null, $disabled = false) { @@ -229,6 +244,8 @@ class HTML * @return string HTML Code * @author Florian Lippert (2003-2009) * @author Froxlor team (2010-) + * + * @deprecated */ public static function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '', $disabled = false) { @@ -249,7 +266,7 @@ class HTML } /** - * Prints Question on screen + * Output boolean confirm-dialog * * @param string $text * The question @@ -257,69 +274,59 @@ class HTML * File which will be called with POST if user clicks yes * @param array $params * Values which will be given to $yesfile. Format: array(variable1=>value1, variable2=>value2, variable3=>value3) - * @param string $targetname - * Name of the target eg Domain or eMail address etc. - * @param int $back_nr - * Number of steps to go back when "No" is pressed + * @param string $replacer + * value of a possible existing string-replacer in the question * - * @author Florian Lippert * @author Froxlor team (2010-) * - * @return string outputs parsed question_yesno template + * @return string */ - public static function askYesNo($text, $yesfile, $params = array(), $targetname = '', $back_nr = 1) + public static function askYesNo(string $text, string $yesfile, array $params = [], string $replacer = '') { - global $userinfo, $s, $header, $footer, $lng, $theme; - - $hiddenparams = ''; - - if (is_array($params)) { - foreach ($params as $field => $value) { - $hiddenparams .= '' . "\n"; - } - } + global $lng; if (isset($lng['question'][$text])) { $text = $lng['question'][$text]; } $text = strtr($text, array( - '%s' => htmlspecialchars($targetname) + '%s' => htmlspecialchars($replacer) )); - eval("echo \"" . Template::getTemplate('misc/question_yesno', '1') . "\";"); + + Panel\UI::twigBuffer('form/yesnoquestion.html.twig', [ + 'action' => $yesfile, + 'url_params' => $params, + 'question' => $text + ]); + Panel\UI::twigOutputBuffer(); exit(); } - public static function askYesNoWithCheckbox($text, $chk_text, $yesfile, $params = array(), $targetname = '', $show_checkbox = true) + public static function askYesNoWithCheckbox(string $text, string $chk_text, string $yesfile, array $params = [], string $replacer = '', bool $show_checkbox = true) { - global $userinfo, $s, $header, $footer, $lng, $theme; - - $hiddenparams = ''; - - if (is_array($params)) { - foreach ($params as $field => $value) { - $hiddenparams .= '' . "\n"; - } - } + global $lng; if (isset($lng['question'][$text])) { $text = $lng['question'][$text]; } + $text = strtr($text, array( + '%s' => htmlspecialchars($replacer) + )); if (isset($lng['question'][$chk_text])) { $chk_text = $lng['question'][$chk_text]; } - if ($show_checkbox) { - $checkbox = self::makecheckbox('delete_userfiles', $chk_text, '1', false, '0', true, true); - } else { - $checkbox = '' . "\n"; - } - - $text = strtr($text, array( - '%s' => htmlspecialchars($targetname) - )); - eval("echo \"" . Template::getTemplate('misc/question_yesno_checkbox', '1') . "\";"); + Panel\UI::twigBuffer('form/yesnoquestion.html.twig', [ + 'action' => $yesfile, + 'url_params' => $params, + 'question' => $text, + 'with_checkbox' => [ + 'chk_text' => $chk_text, + 'show' => $show_checkbox + ] + ]); + Panel\UI::twigOutputBuffer(); exit(); } } diff --git a/lib/Froxlor/UI/HtmlForm.php b/lib/Froxlor/UI/HtmlForm.php deleted file mode 100644 index 99273b9a..00000000 --- a/lib/Froxlor/UI/HtmlForm.php +++ /dev/null @@ -1,351 +0,0 @@ - (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Classes - * - */ -class HtmlForm -{ - - /** - * internal tmp-variable to store form - * - * @var string - */ - private static $form = ''; - - private static $filename = ''; - - public static function genHTMLForm($data = array()) - { - global $lng, $theme; - $nob = false; - - self::$form = ''; - - foreach ($data as $fdata) { - $sections = $fdata['sections']; - - foreach ($sections as $section) { - /* - * here be section title & image - */ - $title = $section['title']; - $image = $section['image']; - - if (isset($section['visible']) && $section['visible'] === false) { - continue; - } - - if (! isset($section['nobuttons']) || $section['nobuttons'] == false) { - eval("self::\$form .= \"" . Template::getTemplate("misc/form/table_section", "1") . "\";"); - } else { - $nob = true; - } - - $nexto = false; - foreach ($section['fields'] as $fieldname => $fielddata) { - if (isset($fielddata['visible']) && $fielddata['visible'] === false) { - continue; - } - - if ($nexto === false || (isset($fielddata['next_to']) && $nexto['field'] != $fielddata['next_to'])) { - $label = $fielddata['label']; - $desc = (isset($fielddata['desc']) ? $fielddata['desc'] : ''); - $style = (isset($fielddata['style']) ? ' class="' . $fielddata['style'] . '"' : ''); - $mandatory = self::getMandatoryFlag($fielddata); - $data_field = self::parseDataField($fieldname, $fielddata); - if (isset($fielddata['has_nextto'])) { - $nexto = array( - 'field' => $fieldname - ); - $data_field .= '{NEXTTOFIELD_' . $fieldname . '}'; - } else { - $nexto = false; - } - eval("self::\$form .= \"" . Template::getTemplate("misc/form/table_row", "1") . "\";"); - } else { - $data_field = self::parseDataField($fieldname, $fielddata); - $data_field = str_replace("\t", "", $data_field); - $data_field = $fielddata['next_to_prefix'] . $data_field; - self::$form = str_replace('{NEXTTOFIELD_' . $fielddata['next_to'] . '}', $data_field, self::$form); - $nexto = false; - } - } - } - } - - // add save/reset buttons at the end of the form - if (! $nob) { - eval("self::\$form .= \"" . Template::getTemplate("misc/form/table_end", "1") . "\";"); - } - - return self::$form; - } - - private static function parseDataField($fieldname, $data = array()) - { - switch ($data['type']) { - case 'text': - return self::textBox($fieldname, $data); - break; - case 'textul': - return self::textBox($fieldname, $data, 'text', true); - break; - case 'password': - return self::textBox($fieldname, $data, 'password'); - break; - case 'hidden': - return self::textBox($fieldname, $data, 'hidden'); - break; - case 'yesno': - return self::yesnoBox($data); - break; - case 'select': - return self::selectBox($fieldname, $data); - break; - case 'label': - return self::labelField($data); - break; - case 'textarea': - return self::textArea($fieldname, $data); - break; - case 'checkbox': - return self::checkbox($fieldname, $data); - break; - case 'file': - return self::file($fieldname, $data); - break; - case 'int': - return self::int($fieldname, $data); - break; - } - } - - private static function getMandatoryFlag($data = array()) - { - if (isset($data['mandatory'])) { - return ' *'; - } elseif (isset($data['mandatory_ex'])) { - return ' **'; - } - return ''; - } - - private static function textBox($fieldname = '', $data = array(), $type = 'text', $unlimited = false) - { - $return = ''; - $extras = ''; - if (isset($data['maxlength'])) { - $extras .= ' maxlength="' . $data['maxlength'] . '"'; - } - if (isset($data['size'])) { - $extras .= ' size="' . $data['size'] . '"'; - } - if (isset($data['autocomplete'])) { - $extras .= ' autocomplete="' . $data['autocomplete'] . '"'; - } - - // add support to save reloaded forms - if (isset($data['value'])) { - $value = $data['value']; - } elseif (isset($_SESSION['requestData'][$fieldname])) { - $value = $_SESSION['requestData'][$fieldname]; - } else { - $value = ''; - } - - $ulfield = ($unlimited == true ? ' ' . $data['ul_field'] : ''); - if (isset($data['display']) && $data['display'] != '') { - $ulfield = '' . $data['display'] . ''; - } - - eval("\$return = \"" . Template::getTemplate("misc/form/input_text", "1") . "\";"); - return $return; - } - - private static function textArea($fieldname = '', $data = array()) - { - $return = ''; - $extras = ''; - if (isset($data['cols'])) { - $extras .= ' cols="' . $data['cols'] . '"'; - } - if (isset($data['rows'])) { - $extras .= ' rows="' . $data['rows'] . '"'; - } - - // add support to save reloaded forms - if (isset($data['value'])) { - $value = $data['value']; - } elseif (isset($_SESSION['requestData'][$fieldname])) { - $value = $_SESSION['requestData'][$fieldname]; - } else { - $value = ''; - } - trim($value); - - eval("\$return = \"" . Template::getTemplate("misc/form/input_textarea", "1") . "\";"); - return $return; - } - - private static function yesnoBox($data = array()) - { - return $data['yesno_var']; - } - - private static function labelField($data = array()) - { - return $data['value']; - } - - private static function selectBox($fieldname = '', $data = array()) - { - // add support to save reloaded forms - if (isset($data['select_var'])) { - $select_var = $data['select_var']; - } elseif (isset($_SESSION['requestData'][$fieldname])) { - $select_var = $_SESSION['requestData'][$fieldname]; - } else { - $select_var = ''; - } - - return ''; - } - - /** - * Function to generate checkboxes. - * - * - * $data = array( - * 'label' => $lng['customer']['email_imap'], - * 'type' => 'checkbox', - * 'values' => array( - * array( 'label' => 'active', - * 'value' => '1' - * ) - * ), - * 'value' => array('1'), - * 'mandatory' => true - * ) - * - * - * @param string $fieldname - * contains the fieldname - * @param array $data - * contains the data array - */ - private static function checkbox($fieldname = '', $data = array()) - { - // $data['value'] contains checked items - $checked = array(); - if (isset($data['value'])) { - $checked = $data['value']; - } - - if (isset($_SESSION['requestData'])) { - if (isset($_SESSION['requestData'][$fieldname])) { - $checked = array( - $_SESSION['requestData'][$fieldname] - ); - } - } - - // default value is none, so the checkbox isn't an array - $isArray = ''; - - if (count($data['values']) > 1 || (isset($data['is_array']) && $data['is_array'] == 1)) { - $isArray = '[]'; - } - - // will contain the output - $output = ""; - foreach ($data['values'] as $val) { - $key = $val['label']; - // is this box checked? - $isChecked = ''; - if (is_array($checked) && count($checked) > 0) { - foreach ($checked as $tmp) { - if ($tmp == $val['value']) { - $isChecked = ' checked="checked" '; - break; - } - } - } - $output .= ''; - } - - return $output; - } - - private static function file($fieldname = '', $data = array()) - { - $return = ''; - $extras = ''; - if (isset($data['maxlength'])) { - $extras .= ' maxlength="' . $data['maxlength'] . '"'; - } - - // add support to save reloaded forms - if (isset($data['value'])) { - $value = $data['value']; - } elseif (isset($_SESSION['requestData'][$fieldname])) { - $value = $_SESSION['requestData'][$fieldname]; - } else { - $value = ''; - } - - if (isset($data['display']) && $data['display'] != '') { - $ulfield = '' . $data['display'] . ''; - } - - eval("\$return = \"" . Template::getTemplate("misc/form/input_file", "1") . "\";"); - return $return; - } - - private static function int($fieldname = '', $data = array()) - { - $return = ''; - $extras = ''; - if (isset($data['int_min'])) { - $extras .= ' min="' . $data['int_min'] . '"'; - } - if (isset($data['int_max'])) { - $extras .= ' max="' . $data['int_max'] . '"'; - } - - // add support to save reloaded forms - if (isset($data['value'])) { - $value = $data['value']; - } elseif (isset($_SESSION['requestData'][$fieldname])) { - $value = $_SESSION['requestData'][$fieldname]; - } else { - $value = ''; - } - - $type = 'number'; - $ulfield = ''; - eval("\$return = \"" . Template::getTemplate("misc/form/input_text", "1") . "\";"); - return $return; - } -} diff --git a/lib/formfields/customer/domains/formfield.domains_add.php b/lib/formfields/customer/domains/formfield.domains_add.php index 93dd85c3..937975e6 100644 --- a/lib/formfields/customer/domains/formfield.domains_add.php +++ b/lib/formfields/customer/domains/formfield.domains_add.php @@ -41,10 +41,11 @@ return array( ), 'path' => array( 'label' => $lng['panel']['path'], - 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescriptionSubdomain'] : null) . (isset($pathSelect['note']) ? $pathSelect['note'] . '
' . $pathSelect['value'] : ''), + 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescriptionSubdomain'] : null), 'type' => $pathSelect['type'], - 'select_var' => $pathSelect['value'], - 'selected' => $pathSelect['value'] + 'select_var' => $pathSelect['select_var'] ?? '', + 'value' => $pathSelect['value'], + 'note' => $pathSelect['note'] ?? '', ), 'url' => array( 'visible' => (\Froxlor\Settings::Get('panel.pathedit') == 'Dropdown' ? true : false), @@ -70,17 +71,18 @@ return array( 'select_var' => $openbasedir ), 'phpsettingid' => array( - 'visible' => (((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 || (int) \Froxlor\Settings::Get('phpfpm.enabled') == 1) && $has_phpconfigs ? true : false), + 'visible' => (((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 || (int) \Froxlor\Settings::Get('phpfpm.enabled') == 1) && count($phpconfigs) > 0 ? true : false), 'label' => $lng['admin']['phpsettings']['title'], 'type' => 'select', - 'select_var' => $phpconfigs + 'select_var' => $phpconfigs, + 'selected' => (int) Settings::Get('phpfpm.enabled') == 1) ? Settings::Get('phpfpm.defaultini') : Settings::Get('system.mod_fcgid_defaultini') ) ) ), 'section_bssl' => array( 'title' => $lng['admin']['webserversettings_ssl'], 'image' => 'icons/domain_add.png', - 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? true : false) : false, + 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports ? true : false) : false, 'fields' => array( 'sslenabled' => array( 'label' => $lng['admin']['domain_sslenabled'], @@ -104,7 +106,7 @@ return array( 'checked' => false ), 'http2' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', + 'visible' => ($ssl_ipsandports ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', 'label' => $lng['admin']['domain_http2']['title'], 'desc' => $lng['admin']['domain_http2']['description'], 'type' => 'checkbox', diff --git a/lib/formfields/customer/domains/formfield.domains_edit.php b/lib/formfields/customer/domains/formfield.domains_edit.php index b3624b46..7b0085b0 100644 --- a/lib/formfields/customer/domains/formfield.domains_edit.php +++ b/lib/formfields/customer/domains/formfield.domains_edit.php @@ -30,14 +30,15 @@ return array( ), 'dns' => array( 'label' => $lng['dns']['destinationip'], - 'type' => 'label', - 'value' => $domainip + 'type' => 'itemlist', + 'values' => $domainips ), 'alias' => array( 'visible' => ($alias_check == '0' ? true : false), 'label' => $lng['domains']['aliasdomain'], 'type' => 'select', - 'select_var' => $domains + 'select_var' => $domains, + 'selected' => $result['aliasdomain'] ), 'path' => array( 'label' => $lng['panel']['path'], @@ -57,14 +58,16 @@ return array( 'label' => $lng['domains']['redirectifpathisurl'], 'desc' => $lng['domains']['redirectifpathisurlinfo'], 'type' => 'select', - 'select_var' => $redirectcode + 'select_var' => $redirectcode, + 'selected' => $def_code ), 'selectserveralias' => array( 'visible' => ((($result['parentdomainid'] == '0' && $userinfo['subdomains'] != '0') || $result['parentdomainid'] != '0') ? true : false), 'label' => $lng['admin']['selectserveralias'], 'desc' => $lng['admin']['selectserveralias_desc'], 'type' => 'select', - 'select_var' => $serveraliasoptions + 'select_var' => $serveraliasoptions, + 'selected' => $serveraliasoptions_selected ), 'isemaildomain' => array( 'visible' => ((($result['subcanemaildomain'] == '1' || $result['subcanemaildomain'] == '2') && $result['parentdomainid'] != '0') ? true : false), @@ -77,20 +80,22 @@ return array( 'visible' => ($result['openbasedir'] == '1') ? true : false, 'label' => $lng['domain']['openbasedirpath'], 'type' => 'select', - 'select_var' => $openbasedir + 'select_var' => $openbasedir, + 'selected' => $result['openbasedir_path'] ), 'phpsettingid' => array( - 'visible' => (((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 || (int) \Froxlor\Settings::Get('phpfpm.enabled') == 1) && $has_phpconfigs ? true : false), + 'visible' => (((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 || (int) \Froxlor\Settings::Get('phpfpm.enabled') == 1) && count($phpconfigs) > 0 ? true : false), 'label' => $lng['admin']['phpsettings']['title'], 'type' => 'select', - 'select_var' => $phpconfigs + 'select_var' => $phpconfigs, + 'selected' => $result['phpsettingid'] ) ) ), 'section_bssl' => array( 'title' => $lng['admin']['webserversettings_ssl'], 'image' => 'icons/domain_edit.png', - 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? (\Froxlor\Domain\Domain::domainHasSslIpPort($result['id']) ? true : false) : false) : false, + 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports ? (\Froxlor\Domain\Domain::domainHasSslIpPort($result['id']) ? true : false) : false) : false, 'fields' => array( 'sslenabled' => array( 'label' => $lng['admin']['domain_sslenabled'], @@ -114,7 +119,7 @@ return array( 'checked' => $result['letsencrypt'] ), 'http2' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', + 'visible' => ($ssl_ipsandports ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', 'label' => $lng['admin']['domain_http2']['title'], 'desc' => $lng['admin']['domain_http2']['description'], 'type' => 'checkbox', diff --git a/lib/formfields/customer/extras/formfield.backup.php b/lib/formfields/customer/extras/formfield.backup.php index 4a756613..13de0341 100644 --- a/lib/formfields/customer/extras/formfield.backup.php +++ b/lib/formfields/customer/extras/formfield.backup.php @@ -25,10 +25,11 @@ return array( 'fields' => array( 'path' => array( 'label' => $lng['panel']['backuppath']['title'], - 'desc' => $lng['panel']['backuppath']['description'] . '
' . (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null) . (isset($pathSelect['note']) ? '
' . $pathSelect['value'] : ''), + 'desc' => $lng['panel']['backuppath']['description'] . '
' . (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'type' => $pathSelect['type'], - 'select_var' => $pathSelect['value'], - 'value' => $pathSelect['value'] + 'select_var' => $pathSelect['select_var'] ?? '', + 'value' => $pathSelect['value'], + 'note' => $pathSelect['note'] ?? '', ), 'path_protection_info' => array( 'label' => $lng['extras']['path_protection_label'], @@ -38,41 +39,20 @@ return array( 'backup_web' => array( 'label' => $lng['extras']['backup_web'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - '1' - ) + 'value' => '1', + 'checked' => true ), 'backup_mail' => array( 'label' => $lng['extras']['backup_mail'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - '1' - ) + 'value' => '1', + 'checked' => true ), 'backup_dbs' => array( 'label' => $lng['extras']['backup_dbs'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - '1' - ) + 'value' => '1', + 'checked' => true ) ) ) diff --git a/lib/formfields/customer/extras/formfield.htaccess_add.php b/lib/formfields/customer/extras/formfield.htaccess_add.php index 87ee8b66..7d44f488 100644 --- a/lib/formfields/customer/extras/formfield.htaccess_add.php +++ b/lib/formfields/customer/extras/formfield.htaccess_add.php @@ -25,21 +25,17 @@ return array( 'fields' => array( 'path' => array( 'label' => $lng['panel']['path'], - 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null) . (isset($pathSelect['note']) ? '
' . $pathSelect['value'] : ''), + 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'type' => $pathSelect['type'], - 'select_var' => $pathSelect['value'], - 'value' => $pathSelect['value'] + 'select_var' => $pathSelect['select_var'] ?? '', + 'value' => $pathSelect['value'], + 'note' => $pathSelect['note'] ?? '', ), 'options_indexes' => array( 'label' => $lng['extras']['directory_browsing'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ), 'error404path' => array( 'label' => $lng['extras']['errordocument404path'], @@ -62,13 +58,8 @@ return array( 'visible' => ($cperlenabled == 1), 'label' => $lng['extras']['execute_perl'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ) ) ) diff --git a/lib/formfields/customer/extras/formfield.htaccess_edit.php b/lib/formfields/customer/extras/formfield.htaccess_edit.php index f73f7d93..bcf0879e 100644 --- a/lib/formfields/customer/extras/formfield.htaccess_edit.php +++ b/lib/formfields/customer/extras/formfield.htaccess_edit.php @@ -31,15 +31,8 @@ return array( 'options_indexes' => array( 'label' => $lng['extras']['directory_browsing'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['options_indexes'] - ) + 'value' => '1', + 'checked' => $result['options_indexes'] ), 'error404path' => array( 'label' => $lng['extras']['errordocument404path'], @@ -65,15 +58,8 @@ return array( 'visible' => ($cperlenabled == 1), 'label' => $lng['extras']['execute_perl'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['options_cgi'] - ) + 'value' => '1', + 'checked' => $result['options_cgi'] ) ) ) diff --git a/lib/formfields/customer/extras/formfield.htpasswd_add.php b/lib/formfields/customer/extras/formfield.htpasswd_add.php index 87a6e5d8..6b4bce20 100644 --- a/lib/formfields/customer/extras/formfield.htpasswd_add.php +++ b/lib/formfields/customer/extras/formfield.htpasswd_add.php @@ -25,10 +25,11 @@ return array( 'fields' => array( 'path' => array( 'label' => $lng['panel']['path'], - 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null) . (isset($pathSelect['note']) ? '
' . $pathSelect['value'] : ''), + 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'type' => $pathSelect['type'], - 'select_var' => $pathSelect['value'], - 'value' => $pathSelect['value'] + 'select_var' => $pathSelect['select_var'] ?? '', + 'value' => $pathSelect['value'], + 'note' => $pathSelect['note'] ?? '', ), 'username' => array( 'label' => $lng['login']['username'], diff --git a/lib/formfields/customer/ftp/formfield.ftp_add.php b/lib/formfields/customer/ftp/formfield.ftp_add.php index ded4d0c6..78b7ce4e 100644 --- a/lib/formfields/customer/ftp/formfield.ftp_add.php +++ b/lib/formfields/customer/ftp/formfield.ftp_add.php @@ -25,24 +25,28 @@ return array( 'ftp_username' => array( 'visible' => (\Froxlor\Settings::Get('customer.ftpatdomain') == '1' ? true : false), 'label' => $lng['login']['username'], - 'type' => 'text' - ), - 'ftp_domain' => array( - 'visible' => (\Froxlor\Settings::Get('customer.ftpatdomain') == '1' ? true : false), - 'label' => $lng['domains']['domainname'], - 'type' => 'select', - 'select_var' => (isset($domains) ? $domains : "") + 'type' => 'text', + 'next_to' => (\Froxlor\Settings::Get('customer.ftpatdomain') == '1' && count($domainlist) > 0 ? [ + 'ftp_domain' => array( + 'next_to_prefix' => '@', + 'label' => $lng['domains']['domainname'], + 'type' => 'select', + 'select_var' => $domainlist + ), + ] + : []) ), 'ftp_description' => array( - 'label' => $lng['panel']['ftpdesc'] = 'FTP description', + 'label' => $lng['panel']['ftpdesc'], 'type' => 'text' ), 'path' => array( 'label' => $lng['panel']['path'], - 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null) . (isset($pathSelect['note']) ? '
' . $pathSelect['value'] : ''), + 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'type' => $pathSelect['type'], - 'select_var' => $pathSelect['value'], - 'value' => $pathSelect['value'] + 'select_var' => $pathSelect['select_var'] ?? '', + 'value' => $pathSelect['value'], + 'note' => $pathSelect['note'] ?? '', ), 'ftp_password' => array( 'label' => $lng['login']['password'], @@ -58,19 +62,15 @@ return array( 'sendinfomail' => array( 'label' => $lng['customer']['sendinfomail'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ), 'shell' => array( 'visible' => (\Froxlor\Settings::Get('system.allow_customer_shell') == '1' ? true : false), 'label' => $lng['panel']['shell'], 'type' => 'select', - 'select_var' => (isset($shells) ? $shells : "") + 'select_var' => $shells_avail, + 'selected' => '/bin/false' ) ) ) diff --git a/lib/formfields/customer/ftp/formfield.ftp_edit.php b/lib/formfields/customer/ftp/formfield.ftp_edit.php index 727bd7a7..411e9cb5 100644 --- a/lib/formfields/customer/ftp/formfield.ftp_edit.php +++ b/lib/formfields/customer/ftp/formfield.ftp_edit.php @@ -28,16 +28,17 @@ return array( 'value' => $result['username'] ), 'ftp_description' => array( - 'label' => $lng['panel']['ftpdesc'] = 'FTP description', + 'label' => $lng['panel']['ftpdesc'], 'type' => 'text', 'value' => $result['description'] ), 'path' => array( 'label' => $lng['panel']['path'], - 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null) . (isset($pathSelect['note']) ? '
' . $pathSelect['value'] : ''), + 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'type' => $pathSelect['type'], - 'select_var' => $pathSelect['value'], - 'value' => $pathSelect['value'] + 'select_var' => $pathSelect['select_var'] ?? '', + 'value' => $pathSelect['value'], + 'note' => $pathSelect['note'] ?? '', ), 'ftp_password' => array( 'label' => $lng['login']['password'], @@ -55,7 +56,8 @@ return array( 'visible' => (\Froxlor\Settings::Get('system.allow_customer_shell') == '1' ? true : false), 'label' => $lng['panel']['shell'], 'type' => 'select', - 'select_var' => (isset($shells) ? $shells : "") + 'select_var' => $shells_avail, + 'selected' => $result['shell'] ?? '/bin/false' ) ) ) diff --git a/lib/formfields/customer/mysql/formfield.mysql_add.php b/lib/formfields/customer/mysql/formfield.mysql_add.php index f6c9eb75..3975bf92 100644 --- a/lib/formfields/customer/mysql/formfield.mysql_add.php +++ b/lib/formfields/customer/mysql/formfield.mysql_add.php @@ -34,7 +34,7 @@ return array( 'type' => 'text' ), 'mysql_server' => array( - 'visible' => (1 < $count_mysqlservers ? true : false), + 'visible' => (count($mysql_servers) > 1 ? true : false), 'label' => $lng['mysql']['mysql_server'], 'type' => 'select', 'select_var' => $mysql_servers @@ -53,13 +53,8 @@ return array( 'sendinfomail' => array( 'label' => $lng['customer']['sendinfomail'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ) ) ) diff --git a/lib/formfields/customer/mysql/formfield.mysql_edit.php b/lib/formfields/customer/mysql/formfield.mysql_edit.php index 4748fa84..b79dbc62 100644 --- a/lib/formfields/customer/mysql/formfield.mysql_edit.php +++ b/lib/formfields/customer/mysql/formfield.mysql_edit.php @@ -33,7 +33,7 @@ return array( 'value' => $result['description'] ), 'mysql_server' => array( - 'visible' => (1 < $count_mysqlservers ? true : false), + 'visible' => ($count_mysql_servers > 1 ? true : false), 'label' => $lng['mysql']['mysql_server'], 'type' => 'label', 'value' => $sql_root['caption'] diff --git a/lng/english.lng.php b/lng/english.lng.php index f280ea70..0bed80e1 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -2141,3 +2141,4 @@ $lng['serversettings']['acmeshpath']['title'] = 'Path to acme.sh'; $lng['serversettings']['acmeshpath']['description'] = 'Set this to where acme.sh is installed to, including the acme.sh script
Default is /root/.acme.sh/acme.sh'; $lng['panel']['usage_statistics'] = 'Resource usage'; +$lng['panel']['security_question'] = 'Security question'; diff --git a/lng/german.lng.php b/lng/german.lng.php index 7ac4bd15..bd3898d4 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1787,3 +1787,4 @@ $lng['serversettings']['acmeshpath']['title'] = 'Pfad zu acme.sh'; $lng['serversettings']['acmeshpath']['description'] = 'Installationspfad zu acme.sh, inklusive acme.sh Script
Standard ist /root/.acme.sh/acme.sh'; $lng['panel']['usage_statistics'] = 'Resourcen-Verbrauch'; +$lng['panel']['security_question'] = 'Sicherheitsabfrage'; diff --git a/templates/Froxlor/form/form.html.twig b/templates/Froxlor/form/form.html.twig index 331f0ef7..8f836129 100644 --- a/templates/Froxlor/form/form.html.twig +++ b/templates/Froxlor/form/form.html.twig @@ -1,8 +1,8 @@ -{% macro form(form_data, action, title = "") %} +{% macro form(form_data, formaction, title = "") %} {% import "Froxlor/form/formfields.html.twig" as formfields %} -
+ {% if title is not empty %}