diff --git a/admin_admins.php b/admin_admins.php index 3c8031d8..5526b37d 100644 --- a/admin_admins.php +++ b/admin_admins.php @@ -22,6 +22,7 @@ require './lib/init.php'; use Froxlor\Database\Database; use Froxlor\Settings; use Froxlor\Api\Commands\Admins as Admins; +use Froxlor\UI\Panel\UI; if (isset($_POST['id'])) { $id = intval($_POST['id']); @@ -104,7 +105,7 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') { $row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : ''; eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("admins/admins_admin") . "\";"); - $count ++; + $count++; } $admincount = $result['count'] . " / " . $paging->getEntries(); @@ -199,39 +200,21 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') { )); } else { - $language_options = ''; - foreach ($languages as $language_file => $language_name) { - $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $userinfo['language'], true); - } - - $ipaddress = \Froxlor\UI\HTML::makeoption($lng['admin']['allips'], "-1"); + $ipaddress = []; + $ipaddress[-1] = $lng['admin']['allips']; $ipsandports_stmt = Database::query(" SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC "); - while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { - $ipaddress .= \Froxlor\UI\HTML::makeoption($row['ip'], $row['id']); + $ipaddress[$row['id']] = $row['ip']; } - $customers_ul = \Froxlor\UI\HTML::makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $domains_ul = \Froxlor\UI\HTML::makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); - $admin_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_add.php'; - $admin_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($admin_add_data); - $title = $admin_add_data['admin_add']['title']; - $image = $admin_add_data['admin_add']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins_add") . "\";"); + UI::TwigBuffer('user/form.html.twig', [ + 'formdata' => $admin_add_data['admin_add'] + ]); + UI::TwigOutputBuffer(); } } elseif ($action == 'edit' && $id != 0) { try { @@ -262,84 +245,23 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') { $result['diskspace'] = round($result['diskspace'] / 1024, $dec_places); $result['email'] = $idna_convert->decode($result['email']); - $customers_ul = \Froxlor\UI\HTML::makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, $result['customers'], true, true); - if ($result['customers'] == '-1') { - $result['customers'] = ''; - } - - $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true); - if ($result['diskspace'] == '-1') { - $result['diskspace'] = ''; - } - - $traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true); - if ($result['traffic'] == '-1') { - $result['traffic'] = ''; - } - - $domains_ul = \Froxlor\UI\HTML::makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, $result['domains'], true, true); - if ($result['domains'] == '-1') { - $result['domains'] = ''; - } - - $subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true); - if ($result['subdomains'] == '-1') { - $result['subdomains'] = ''; - } - - $emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true); - if ($result['emails'] == '-1') { - $result['emails'] = ''; - } - - $email_accounts_ul = \Froxlor\UI\HTML::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 = \Froxlor\UI\HTML::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 = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true); - if ($result['email_quota'] == '-1') { - $result['email_quota'] = ''; - } - - $ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true); - if ($result['ftps'] == '-1') { - $result['ftps'] = ''; - } - - $mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true); - if ($result['mysqls'] == '-1') { - $result['mysqls'] = ''; - } - - $language_options = ''; - foreach ($languages as $language_file => $language_name) { - $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $result['def_language'], true); - } - - $ipaddress = \Froxlor\UI\HTML::makeoption($lng['admin']['allips'], "-1", $result['ip']); + $ipaddress = []; + $ipaddress[-1] = $lng['admin']['allips']; $ipsandports_stmt = Database::query(" - SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `id`, `ip` ORDER BY `ip`, `port` ASC + SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC "); - while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { - $ipaddress .= \Froxlor\UI\HTML::makeoption($row['ip'], $row['id'], $result['ip']); + $ipaddress[$row['id']] = $row['ip']; } $result = \Froxlor\PhpHelper::htmlentitiesArray($result); $admin_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_edit.php'; - $admin_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($admin_edit_data); - $title = $admin_edit_data['admin_edit']['title']; - $image = $admin_edit_data['admin_edit']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins_edit") . "\";"); + UI::TwigBuffer('user/form.html.twig', [ + 'formdata' => $admin_edit_data['admin_edit'] + ]); + UI::TwigOutputBuffer(); } } } diff --git a/lib/formfields/admin/admin/formfield.admin_add.php b/lib/formfields/admin/admin/formfield.admin_add.php index 710d634f..5c108a14 100644 --- a/lib/formfields/admin/admin/formfield.admin_add.php +++ b/lib/formfields/admin/admin/formfield.admin_add.php @@ -17,7 +17,7 @@ return array( 'admin_add' => array( 'title' => $lng['admin']['admin_add'], - 'image' => 'icons/user_add.png', + 'image' => 'fa-solid fa-user-plus', 'sections' => array( 'section_a' => array( 'title' => $lng['admin']['accountdata'], @@ -43,21 +43,16 @@ return array( 'def_language' => array( 'label' => $lng['login']['language'], 'type' => 'select', - 'select_var' => $language_options + 'select_var' => $languages, + 'selected' => $userinfo['language'] + ), 'api_allowed' => array( 'label' => $lng['usersettings']['api_allowed']['title'], 'desc' => $lng['usersettings']['api_allowed']['description'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - '1' - ), + 'value' => '1', + 'checked' => (\Froxlor\Settings::Get('api.enabled') == '1' ? true : false), 'visible' => (\Froxlor\Settings::Get('api.enabled') == '1' ? true : false) ) ) @@ -77,7 +72,6 @@ return array( 'mandatory' => true ), 'custom_notes' => array( - 'style' => 'align-top', 'label' => $lng['usersettings']['custom_notes']['title'], 'desc' => $lng['usersettings']['custom_notes']['description'], 'type' => 'textarea', @@ -87,13 +81,8 @@ return array( 'custom_notes_show' => array( 'label' => $lng['usersettings']['custom_notes']['show'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ) ) ), @@ -109,110 +98,82 @@ return array( 'change_serversettings' => array( 'label' => $lng['admin']['change_serversettings'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ), 'customers' => array( 'label' => $lng['admin']['customers'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $customers_ul + 'mandatory' => true ), 'customers_see_all' => array( 'label' => $lng['admin']['customers_see_all'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ), 'domains' => array( 'label' => $lng['admin']['domains'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $domains_ul + 'mandatory' => true ), 'domains_see_all' => array( 'label' => $lng['admin']['domains_see_all'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ), 'caneditphpsettings' => array( 'label' => $lng['admin']['caneditphpsettings'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array() + 'value' => '1', + 'checked' => false ), 'diskspace' => array( 'label' => $lng['customer']['diskspace'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 6, - 'mandatory' => true, - 'ul_field' => $diskspace_ul + 'mandatory' => true ), 'traffic' => array( 'label' => $lng['customer']['traffic'] . ' (' . $lng['customer']['gib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 4, - 'mandatory' => true, - 'ul_field' => $traffic_ul + 'mandatory' => true ), 'subdomains' => array( 'label' => $lng['customer']['subdomains'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $subdomains_ul + 'mandatory' => true ), 'emails' => array( 'label' => $lng['customer']['emails'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $emails_ul + 'mandatory' => true ), 'email_accounts' => array( 'label' => $lng['customer']['accounts'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $email_accounts_ul + 'mandatory' => true ), 'email_forwarders' => array( 'label' => $lng['customer']['forwarders'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $email_forwarders_ul + 'mandatory' => true ), 'email_quota' => array( 'label' => $lng['customer']['email_quota'] . ' (' . $lng['customer']['mib'] . ')', @@ -220,23 +181,20 @@ return array( 'value' => 0, 'maxlength' => 9, 'visible' => (\Froxlor\Settings::Get('system.mail_quota_enabled') == '1' ? true : false), - 'mandatory' => true, - 'ul_field' => $email_quota_ul + 'mandatory' => true ), 'ftps' => array( 'label' => $lng['customer']['ftps'], 'type' => 'textul', 'value' => 0, - 'maxlength' => 9, - 'ul_field' => $ftps_ul + 'maxlength' => 9 ), 'mysqls' => array( 'label' => $lng['customer']['mysqls'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $mysqls_ul + 'mandatory' => true ) ) ) diff --git a/lib/formfields/admin/admin/formfield.admin_edit.php b/lib/formfields/admin/admin/formfield.admin_edit.php index 5e4eac5d..852c0067 100644 --- a/lib/formfields/admin/admin/formfield.admin_edit.php +++ b/lib/formfields/admin/admin/formfield.admin_edit.php @@ -17,7 +17,7 @@ return array( 'admin_edit' => array( 'title' => $lng['admin']['admin_edit'], - 'image' => 'icons/user_edit.png', + 'image' => 'fa-solid fa-user-pen', 'sections' => array( 'section_a' => array( 'title' => $lng['admin']['accountdata'], @@ -31,15 +31,8 @@ return array( 'deactivated' => array( 'label' => $lng['admin']['deactivated_user'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['deactivated'] - ), + 'value' => '1', + 'checked' => $result['deactivated'], 'visible' => ($result['adminid'] == $userinfo['userid'] ? false : true) ), 'admin_password' => array( @@ -57,22 +50,16 @@ return array( 'def_language' => array( 'label' => $lng['login']['language'], 'type' => 'select', - 'select_var' => $language_options, + 'select_var' => $languages, + 'selected' => $result['def_language'], 'visible' => ($result['adminid'] == $userinfo['userid'] ? false : true) ), 'api_allowed' => array( 'label' => $lng['usersettings']['api_allowed']['title'], 'desc' => $lng['usersettings']['api_allowed']['description'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['api_allowed'] - ), + 'value' => '1', + 'checked' => $result['api_allowed'], 'visible' => (\Froxlor\Settings::Get('api.enabled') == '1' ? true : false) ) ) @@ -94,7 +81,6 @@ return array( 'value' => $result['email'] ), 'custom_notes' => array( - 'style' => 'align-top', 'label' => $lng['usersettings']['custom_notes']['title'], 'desc' => $lng['usersettings']['custom_notes']['description'], 'type' => 'textarea', @@ -105,15 +91,8 @@ return array( 'custom_notes_show' => array( 'label' => $lng['usersettings']['custom_notes']['show'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['custom_notes_show'] - ) + 'value' => '1', + 'checked' => $result['custom_notes_show'] ) ) ), @@ -125,123 +104,88 @@ return array( 'ipaddress' => array( 'label' => $lng['serversettings']['ipaddress']['title'], 'type' => 'select', - 'select_var' => $ipaddress + 'select_var' => $ipaddress, + 'selected' => $result['ip'] ), 'change_serversettings' => array( 'label' => $lng['admin']['change_serversettings'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['change_serversettings'] - ) + 'value' => '1', + 'checked' => $result['change_serversettings'] ), 'customers' => array( 'label' => $lng['admin']['customers'], 'type' => 'textul', 'value' => $result['customers'], 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $customers_ul + 'mandatory' => true ), 'customers_see_all' => array( 'label' => $lng['admin']['customers_see_all'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['customers_see_all'] - ) + 'value' => '1', + 'checked' => $result['customers_see_all'] ), 'domains' => array( 'label' => $lng['admin']['domains'], 'type' => 'textul', 'value' => $result['domains'], 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $domains_ul + 'mandatory' => true ), 'domains_see_all' => array( 'label' => $lng['admin']['domains_see_all'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['domains_see_all'] - ) + 'value' => '1', + 'checked' => $result['domains_see_all'] ), 'caneditphpsettings' => array( 'label' => $lng['admin']['caneditphpsettings'], 'type' => 'checkbox', - 'values' => array( - array( - 'label' => $lng['panel']['yes'], - 'value' => '1' - ) - ), - 'value' => array( - $result['caneditphpsettings'] - ) + 'value' => '1', + 'checked' => $result['caneditphpsettings'] ), 'diskspace' => array( 'label' => $lng['customer']['diskspace'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => $result['diskspace'], 'maxlength' => 6, - 'mandatory' => true, - 'ul_field' => $diskspace_ul + 'mandatory' => true ), 'traffic' => array( 'label' => $lng['customer']['traffic'] . ' (' . $lng['customer']['gib'] . ')', 'type' => 'textul', 'value' => $result['traffic'], 'maxlength' => 4, - 'mandatory' => true, - 'ul_field' => $traffic_ul + 'mandatory' => true ), 'subdomains' => array( 'label' => $lng['customer']['subdomains'], 'type' => 'textul', 'value' => $result['subdomains'], 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $subdomains_ul + 'mandatory' => true ), 'emails' => array( 'label' => $lng['customer']['emails'], 'type' => 'textul', 'value' => $result['emails'], 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $emails_ul + 'mandatory' => true ), 'email_accounts' => array( 'label' => $lng['customer']['accounts'], 'type' => 'textul', 'value' => $result['email_accounts'], 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $email_accounts_ul + 'mandatory' => true ), 'email_forwarders' => array( 'label' => $lng['customer']['forwarders'], 'type' => 'textul', 'value' => $result['email_forwarders'], 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $email_forwarders_ul + 'mandatory' => true ), 'email_quota' => array( 'label' => $lng['customer']['email_quota'] . ' (' . $lng['customer']['mib'] . ')', @@ -249,23 +193,20 @@ return array( 'value' => $result['email_quota'], 'maxlength' => 9, 'visible' => (\Froxlor\Settings::Get('system.mail_quota_enabled') == '1' ? true : false), - 'mandatory' => true, - 'ul_field' => $email_quota_ul + 'mandatory' => true ), 'ftps' => array( 'label' => $lng['customer']['ftps'], 'type' => 'textul', 'value' => $result['ftps'], - 'maxlength' => 9, - 'ul_field' => $ftps_ul + 'maxlength' => 9 ), 'mysqls' => array( 'label' => $lng['customer']['mysqls'], 'type' => 'textul', 'value' => $result['mysqls'], 'maxlength' => 9, - 'mandatory' => true, - 'ul_field' => $mysqls_ul + 'mandatory' => true ) ) )