diff --git a/README.md b/README.md index 9407c022..65be8ac6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml/badge.svg?branch=master)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml) -[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml/badge.svg?branch=master)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml) +[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml/badge.svg?branch=0.11-dev)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml) +[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml/badge.svg?branch=0.11-dev)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.froxlor.org) # Froxlor diff --git a/admin_admins.php b/admin_admins.php index 5526b37d..67c9d52c 100644 --- a/admin_admins.php +++ b/admin_admins.php @@ -211,10 +211,10 @@ 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', [ + UI::twigBuffer('user/form.html.twig', [ 'formdata' => $admin_add_data['admin_add'] ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } elseif ($action == 'edit' && $id != 0) { try { @@ -258,10 +258,10 @@ 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', [ + UI::twigBuffer('user/form.html.twig', [ 'formdata' => $admin_edit_data['admin_edit'] ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } } diff --git a/admin_customers.php b/admin_customers.php index cea78e2e..21e87aa5 100644 --- a/admin_customers.php +++ b/admin_customers.php @@ -321,10 +321,10 @@ 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', [ + UI::twigBuffer('user/form.html.twig', [ 'formdata' => $customer_add_data['customer_add'] ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } elseif ($action == 'edit' && $id != 0) { @@ -406,10 +406,10 @@ 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', [ + UI::twigBuffer('user/form.html.twig', [ 'formdata' => $customer_edit_data['customer_edit'] ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } } diff --git a/admin_index.php b/admin_index.php index 92eb1dff..416d1669 100644 --- a/admin_index.php +++ b/admin_index.php @@ -180,14 +180,14 @@ if ($page == 'overview') { 'uptime' => $uptime ]; - UI::Twig()->addGlobal('userinfo', $userinfo); - UI::TwigBuffer('user/index.html.twig', [ + UI::twig()->addGlobal('userinfo', $userinfo); + UI::twigBuffer('user/index.html.twig', [ 'sysinfo' => $sysinfo, 'overview' => $overview, 'outstanding_tasks' => $outstanding_tasks, 'cron_last_runs' => $cron_last_runs ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } elseif ($page == 'change_password') { if (isset($_POST['send']) && $_POST['send'] == 'send') { @@ -236,8 +236,8 @@ if ($page == 'overview') { )); } } else { - UI::TwigBuffer('user/change_password.html.twig'); - UI::TwigOutputBuffer(); + UI::twigBuffer('user/change_password.html.twig'); + UI::twigOutputBuffer(); } } elseif ($page == 'change_language') { @@ -277,11 +277,11 @@ if ($page == 'overview') { $default_lang = $userinfo['def_language']; } - UI::TwigBuffer('user/change_language.html.twig', [ + UI::twigBuffer('user/change_language.html.twig', [ 'languages' => $languages, 'default_lang' => $default_lang ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } elseif ($page == 'change_theme') { @@ -321,11 +321,11 @@ if ($page == 'overview') { $themes_avail = \Froxlor\UI\Template::getThemes(); - UI::TwigBuffer('user/change_theme.html.twig', [ + UI::twigBuffer('user/change_theme.html.twig', [ 'themes' => $themes_avail, 'default_theme' => $default_theme ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_admin') == '1') { diff --git a/admin_ipsandports.php b/admin_ipsandports.php index 8b24c72b..38663f02 100644 --- a/admin_ipsandports.php +++ b/admin_ipsandports.php @@ -120,10 +120,10 @@ if ($page == 'ipsandports' || $page == 'overview') { $ipsandports_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_add.php'; - UI::TwigBuffer('user/form.html.twig', [ + UI::twigBuffer('user/form.html.twig', [ 'formdata' => $ipsandports_add_data['ipsandports_add'] ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } elseif ($action == 'edit' && $id != 0) { try { @@ -153,10 +153,10 @@ if ($page == 'ipsandports' || $page == 'overview') { $ipsandports_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php'; - UI::TwigBuffer('user/form.html.twig', [ + UI::twigBuffer('user/form.html.twig', [ 'formdata' => $ipsandports_edit_data['ipsandports_edit'] ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } } elseif ($action == 'jqCheckIP') { diff --git a/api.php b/api.php index 3409a492..a05357bd 100644 --- a/api.php +++ b/api.php @@ -1,88 +1,30 @@ (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package API + * */ -$antiXss = new AntiXSS(); -$request = $antiXss->xss_clean($request); -// validate content +// Return response try { - $decoded_request = stripcslashes_deep($decoded_request); - $request = \Froxlor\Api\FroxlorRPC::validateRequest($decoded_request); - // now actually do it - $cls = "\\Froxlor\\Api\\Commands\\" . $request['command']['class']; - $method = $request['command']['method']; - $apiObj = new $cls($decoded_request['header'], $request['params']); - // call the method with the params if any - echo $apiObj->$method(); + echo (new Api)->handle(@file_get_contents('php://input')); } catch (Exception $e) { - json_response($e->getCode(), $e->getMessage()); -} - -exit(); - -/** - * output json result - * - * @param int $status - * @param string $status_message - * @param mixed $data - * - * @return void - */ -function json_response($status, $status_message = '', $data = null) -{ - if (isset($_SERVER["SERVER_PROTOCOL"]) && ! empty($_SERVER["SERVER_PROTOCOL"])) { - $resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status; - if (! empty($status_message)) { - $resheader .= ' ' . str_replace("\n", " ", $status_message); - } - header($resheader); - } - $response = array(); - $response['status'] = $status; - $response['status_message'] = $status_message; - $response['data'] = $data; - - $json_response = json_encode($response, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); - echo $json_response; - exit(); -} - -function stripcslashes_deep($value) -{ - return is_array($value) ? array_map('stripcslashes_deep', $value) : stripcslashes($value); + echo \Froxlor\Api\Response::jsonErrorResponse($e->getMessage(), $e->getCode()); } diff --git a/css/images/animated-overlay.gif b/css/images/animated-overlay.gif deleted file mode 100644 index d441f75e..00000000 Binary files a/css/images/animated-overlay.gif and /dev/null differ diff --git a/css/images/ui-icons_444444_256x240.png b/css/images/ui-icons_444444_256x240.png deleted file mode 100644 index 19f664d9..00000000 Binary files a/css/images/ui-icons_444444_256x240.png and /dev/null differ diff --git a/css/images/ui-icons_555555_256x240.png b/css/images/ui-icons_555555_256x240.png deleted file mode 100644 index e965f6d9..00000000 Binary files a/css/images/ui-icons_555555_256x240.png and /dev/null differ diff --git a/css/images/ui-icons_777620_256x240.png b/css/images/ui-icons_777620_256x240.png deleted file mode 100644 index 9785948a..00000000 Binary files a/css/images/ui-icons_777620_256x240.png and /dev/null differ diff --git a/css/images/ui-icons_777777_256x240.png b/css/images/ui-icons_777777_256x240.png deleted file mode 100644 index 323c4564..00000000 Binary files a/css/images/ui-icons_777777_256x240.png and /dev/null differ diff --git a/css/images/ui-icons_cc0000_256x240.png b/css/images/ui-icons_cc0000_256x240.png deleted file mode 100644 index 45ac7787..00000000 Binary files a/css/images/ui-icons_cc0000_256x240.png and /dev/null differ diff --git a/css/images/ui-icons_ffffff_256x240.png b/css/images/ui-icons_ffffff_256x240.png deleted file mode 100644 index fe41d2d0..00000000 Binary files a/css/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/css/jquery-ui.min.css b/css/jquery-ui.min.css deleted file mode 100644 index dc84872d..00000000 --- a/css/jquery-ui.min.css +++ /dev/null @@ -1,1893 +0,0 @@ -/*! jQuery UI - v1.12.1 - 2018-06-17 -* http://jqueryui.com -* Includes: draggable.css, core.css, resizable.css, selectable.css, sortable.css, accordion.css, autocomplete.css, menu.css, button.css, controlgroup.css, checkboxradio.css, datepicker.css, dialog.css, progressbar.css, selectmenu.css, slider.css, spinner.css, tabs.css, tooltip.css, theme.css -* To view and modify this theme, visit http://jqueryui.com/themeroller/?scope=&folderName=base&cornerRadiusShadow=8px&offsetLeftShadow=0px&offsetTopShadow=0px&thicknessShadow=5px&opacityShadow=30&bgImgOpacityShadow=0&bgTextureShadow=flat&bgColorShadow=666666&opacityOverlay=30&bgImgOpacityOverlay=0&bgTextureOverlay=flat&bgColorOverlay=aaaaaa&iconColorError=cc0000&fcError=5f3f3f&borderColorError=f1a899&bgTextureError=flat&bgColorError=fddfdf&iconColorHighlight=777620&fcHighlight=777620&borderColorHighlight=dad55e&bgTextureHighlight=flat&bgColorHighlight=fffa90&iconColorActive=ffffff&fcActive=ffffff&borderColorActive=003eff&bgTextureActive=flat&bgColorActive=007fff&iconColorHover=555555&fcHover=2b2b2b&borderColorHover=cccccc&bgTextureHover=flat&bgColorHover=ededed&iconColorDefault=777777&fcDefault=454545&borderColorDefault=c5c5c5&bgTextureDefault=flat&bgColorDefault=f6f6f6&iconColorContent=444444&fcContent=333333&borderColorContent=dddddd&bgTextureContent=flat&bgColorContent=ffffff&iconColorHeader=444444&fcHeader=333333&borderColorHeader=dddddd&bgTextureHeader=flat&bgColorHeader=e9e9e9&cornerRadius=3px&fwDefault=normal&fsDefault=1em&ffDefault=Arial%2CHelvetica%2Csans-serif -* Copyright jQuery Foundation and other contributors; Licensed MIT */ -.ui-draggable-handle { - -ms-touch-action: none; - touch-action: none -} - -.ui-helper-hidden { - display: none -} - -.ui-helper-hidden-accessible { - border: 0; - clip: rect(0, 0, 0, 0); - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px -} - -.ui-helper-reset { - margin: 0; - padding: 0; - border: 0; - outline: 0; - line-height: 1.3; - text-decoration: none; - font-size: 100%; - list-style: none -} - -.ui-helper-clearfix:before, .ui-helper-clearfix:after { - content: ""; - display: table; - border-collapse: collapse -} - -.ui-helper-clearfix:after { - clear: both -} - -.ui-helper-zfix { - width: 100%; - height: 100%; - top: 0; - left: 0; - position: absolute; - opacity: 0; - filter: Alpha(Opacity = 0) -} - -.ui-front { - z-index: 100 -} - -.ui-state-disabled { - cursor: default !important; - pointer-events: none -} - -.ui-icon { - display: inline-block; - vertical-align: middle; - margin-top: -.25em; - position: relative; - text-indent: -99999px; - overflow: hidden; - background-repeat: no-repeat -} - -.ui-widget-icon-block { - left: 50%; - margin-left: -8px; - display: block -} - -.ui-widget-overlay { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100% -} - -.ui-resizable { - position: relative -} - -.ui-resizable-handle { - position: absolute; - font-size: 0.1px; - display: block; - -ms-touch-action: none; - touch-action: none -} - -.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle - { - display: none -} - -.ui-resizable-n { - cursor: n-resize; - height: 7px; - width: 100%; - top: -5px; - left: 0 -} - -.ui-resizable-s { - cursor: s-resize; - height: 7px; - width: 100%; - bottom: -5px; - left: 0 -} - -.ui-resizable-e { - cursor: e-resize; - width: 7px; - right: -5px; - top: 0; - height: 100% -} - -.ui-resizable-w { - cursor: w-resize; - width: 7px; - left: -5px; - top: 0; - height: 100% -} - -.ui-resizable-se { - cursor: se-resize; - width: 12px; - height: 12px; - right: 1px; - bottom: 1px -} - -.ui-resizable-sw { - cursor: sw-resize; - width: 9px; - height: 9px; - left: -5px; - bottom: -5px -} - -.ui-resizable-nw { - cursor: nw-resize; - width: 9px; - height: 9px; - left: -5px; - top: -5px -} - -.ui-resizable-ne { - cursor: ne-resize; - width: 9px; - height: 9px; - right: -5px; - top: -5px -} - -.ui-selectable { - -ms-touch-action: none; - touch-action: none -} - -.ui-selectable-helper { - position: absolute; - z-index: 100; - border: 1px dotted black -} - -.ui-sortable-handle { - -ms-touch-action: none; - touch-action: none -} - -.ui-accordion .ui-accordion-header { - display: block; - cursor: pointer; - position: relative; - margin: 2px 0 0 0; - padding: .5em .5em .5em .7em; - font-size: 100% -} - -.ui-accordion .ui-accordion-content { - padding: 1em 2.2em; - border-top: 0; - overflow: auto -} - -.ui-autocomplete { - position: absolute; - top: 0; - left: 0; - cursor: default -} - -.ui-menu { - list-style: none; - padding: 0; - margin: 0; - display: block; - outline: 0 -} - -.ui-menu .ui-menu { - position: absolute -} - -.ui-menu .ui-menu-item { - margin: 0; - cursor: pointer; - list-style-image: - url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") -} - -.ui-menu .ui-menu-item-wrapper { - position: relative; - padding: 3px 1em 3px .4em -} - -.ui-menu .ui-menu-divider { - margin: 5px 0; - height: 0; - font-size: 0; - line-height: 0; - border-width: 1px 0 0 0 -} - -.ui-menu .ui-state-focus, .ui-menu .ui-state-active { - margin: -1px -} - -.ui-menu-icons { - position: relative -} - -.ui-menu-icons .ui-menu-item-wrapper { - padding-left: 2em -} - -.ui-menu .ui-icon { - position: absolute; - top: 0; - bottom: 0; - left: .2em; - margin: auto 0 -} - -.ui-menu .ui-menu-icon { - left: auto; - right: 0 -} - -.ui-button { - padding: .4em 1em; - display: inline-block; - position: relative; - line-height: normal; - margin-right: .1em; - cursor: pointer; - vertical-align: middle; - text-align: center; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - overflow: visible -} - -.ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, - .ui-button:active { - text-decoration: none -} - -.ui-button-icon-only { - width: 2em; - box-sizing: border-box; - text-indent: -9999px; - white-space: nowrap -} - -input.ui-button.ui-button-icon-only { - text-indent: 0 -} - -.ui-button-icon-only .ui-icon { - position: absolute; - top: 50%; - left: 50%; - margin-top: -8px; - margin-left: -8px -} - -.ui-button.ui-icon-notext .ui-icon { - padding: 0; - width: 2.1em; - height: 2.1em; - text-indent: -9999px; - white-space: nowrap -} - -input.ui-button.ui-icon-notext .ui-icon { - width: auto; - height: auto; - text-indent: 0; - white-space: normal; - padding: .4em 1em -} - -input.ui-button::-moz-focus-inner, button.ui-button::-moz-focus-inner { - border: 0; - padding: 0 -} - -.ui-controlgroup { - vertical-align: middle; - display: inline-block -} - -.ui-controlgroup>.ui-controlgroup-item { - float: left; - margin-left: 0; - margin-right: 0 -} - -.ui-controlgroup>.ui-controlgroup-item:focus, .ui-controlgroup>.ui-controlgroup-item.ui-visual-focus - { - z-index: 9999 -} - -.ui-controlgroup-vertical>.ui-controlgroup-item { - display: block; - float: none; - width: 100%; - margin-top: 0; - margin-bottom: 0; - text-align: left -} - -.ui-controlgroup-vertical .ui-controlgroup-item { - box-sizing: border-box -} - -.ui-controlgroup .ui-controlgroup-label { - padding: .4em 1em -} - -.ui-controlgroup .ui-controlgroup-label span { - font-size: 80% -} - -.ui-controlgroup-horizontal .ui-controlgroup-label+.ui-controlgroup-item - { - border-left: none -} - -.ui-controlgroup-vertical .ui-controlgroup-label+.ui-controlgroup-item { - border-top: none -} - -.ui-controlgroup-horizontal .ui-controlgroup-label.ui-widget-content { - border-right: none -} - -.ui-controlgroup-vertical .ui-controlgroup-label.ui-widget-content { - border-bottom: none -} - -.ui-controlgroup-vertical .ui-spinner-input { - width: 75%; - width: calc(100% - 2.4em) -} - -.ui-controlgroup-vertical .ui-spinner .ui-spinner-up { - border-top-style: solid -} - -.ui-checkboxradio-label .ui-icon-background { - box-shadow: inset 1px 1px 1px #ccc; - border-radius: .12em; - border: none -} - -.ui-checkboxradio-radio-label .ui-icon-background { - width: 16px; - height: 16px; - border-radius: 1em; - overflow: visible; - border: none -} - -.ui-checkboxradio-radio-label.ui-checkboxradio-checked .ui-icon, - .ui-checkboxradio-radio-label.ui-checkboxradio-checked:hover .ui-icon { - background-image: none; - width: 8px; - height: 8px; - border-width: 4px; - border-style: solid -} - -.ui-checkboxradio-disabled { - pointer-events: none -} - -.ui-datepicker { - width: 17em; - padding: .2em .2em 0; - display: none -} - -.ui-datepicker .ui-datepicker-header { - position: relative; - padding: .2em 0 -} - -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { - position: absolute; - top: 2px; - width: 1.8em; - height: 1.8em -} - -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover - { - top: 1px -} - -.ui-datepicker .ui-datepicker-prev { - left: 2px -} - -.ui-datepicker .ui-datepicker-next { - right: 2px -} - -.ui-datepicker .ui-datepicker-prev-hover { - left: 1px -} - -.ui-datepicker .ui-datepicker-next-hover { - right: 1px -} - -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span - { - display: block; - position: absolute; - left: 50%; - margin-left: -8px; - top: 50%; - margin-top: -8px -} - -.ui-datepicker .ui-datepicker-title { - margin: 0 2.3em; - line-height: 1.8em; - text-align: center -} - -.ui-datepicker .ui-datepicker-title select { - font-size: 1em; - margin: 1px 0 -} - -.ui-datepicker select.ui-datepicker-month, .ui-datepicker select.ui-datepicker-year - { - width: 45% -} - -.ui-datepicker table { - width: 100%; - font-size: .9em; - border-collapse: collapse; - margin: 0 0 .4em -} - -.ui-datepicker th { - padding: .7em .3em; - text-align: center; - font-weight: bold; - border: 0 -} - -.ui-datepicker td { - border: 0; - padding: 1px -} - -.ui-datepicker td span, .ui-datepicker td a { - display: block; - padding: .2em; - text-align: right; - text-decoration: none -} - -.ui-datepicker .ui-datepicker-buttonpane { - background-image: none; - margin: .7em 0 0 0; - padding: 0 .2em; - border-left: 0; - border-right: 0; - border-bottom: 0 -} - -.ui-datepicker .ui-datepicker-buttonpane button { - float: right; - margin: .5em .2em .4em; - cursor: pointer; - padding: .2em .6em .3em .6em; - width: auto; - overflow: visible -} - -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { - float: left -} - -.ui-datepicker.ui-datepicker-multi { - width: auto -} - -.ui-datepicker-multi .ui-datepicker-group { - float: left -} - -.ui-datepicker-multi .ui-datepicker-group table { - width: 95%; - margin: 0 auto .4em -} - -.ui-datepicker-multi-2 .ui-datepicker-group { - width: 50% -} - -.ui-datepicker-multi-3 .ui-datepicker-group { - width: 33.3% -} - -.ui-datepicker-multi-4 .ui-datepicker-group { - width: 25% -} - -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header, - .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header - { - border-left-width: 0 -} - -.ui-datepicker-multi .ui-datepicker-buttonpane { - clear: left -} - -.ui-datepicker-row-break { - clear: both; - width: 100%; - font-size: 0 -} - -.ui-datepicker-rtl { - direction: rtl -} - -.ui-datepicker-rtl .ui-datepicker-prev { - right: 2px; - left: auto -} - -.ui-datepicker-rtl .ui-datepicker-next { - left: 2px; - right: auto -} - -.ui-datepicker-rtl .ui-datepicker-prev:hover { - right: 1px; - left: auto -} - -.ui-datepicker-rtl .ui-datepicker-next:hover { - left: 1px; - right: auto -} - -.ui-datepicker-rtl .ui-datepicker-buttonpane { - clear: right -} - -.ui-datepicker-rtl .ui-datepicker-buttonpane button { - float: left -} - -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current, - .ui-datepicker-rtl .ui-datepicker-group { - float: right -} - -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header, - .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { - border-right-width: 0; - border-left-width: 1px -} - -.ui-datepicker .ui-icon { - display: block; - text-indent: -99999px; - overflow: hidden; - background-repeat: no-repeat; - left: .5em; - top: .3em -} - -.ui-dialog { - position: absolute; - top: 0; - left: 0; - padding: .2em; - outline: 0 -} - -.ui-dialog .ui-dialog-titlebar { - padding: .4em 1em; - position: relative -} - -.ui-dialog .ui-dialog-title { - float: left; - margin: .1em 0; - white-space: nowrap; - width: 90%; - overflow: hidden; - text-overflow: ellipsis -} - -.ui-dialog .ui-dialog-titlebar-close { - position: absolute; - right: .3em; - top: 50%; - width: 20px; - margin: -10px 0 0 0; - padding: 1px; - height: 20px -} - -.ui-dialog .ui-dialog-content { - position: relative; - border: 0; - padding: .5em 1em; - background: none; - overflow: auto -} - -.ui-dialog .ui-dialog-buttonpane { - text-align: left; - border-width: 1px 0 0 0; - background-image: none; - margin-top: .5em; - padding: .3em 1em .5em .4em -} - -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { - float: right -} - -.ui-dialog .ui-dialog-buttonpane button { - margin: .5em .4em .5em 0; - cursor: pointer -} - -.ui-dialog .ui-resizable-n { - height: 2px; - top: 0 -} - -.ui-dialog .ui-resizable-e { - width: 2px; - right: 0 -} - -.ui-dialog .ui-resizable-s { - height: 2px; - bottom: 0 -} - -.ui-dialog .ui-resizable-w { - width: 2px; - left: 0 -} - -.ui-dialog .ui-resizable-se, .ui-dialog .ui-resizable-sw, .ui-dialog .ui-resizable-ne, - .ui-dialog .ui-resizable-nw { - width: 7px; - height: 7px -} - -.ui-dialog .ui-resizable-se { - right: 0; - bottom: 0 -} - -.ui-dialog .ui-resizable-sw { - left: 0; - bottom: 0 -} - -.ui-dialog .ui-resizable-ne { - right: 0; - top: 0 -} - -.ui-dialog .ui-resizable-nw { - left: 0; - top: 0 -} - -.ui-draggable .ui-dialog-titlebar { - cursor: move -} - -.ui-progressbar { - height: 2em; - text-align: left; - overflow: hidden -} - -.ui-progressbar .ui-progressbar-value { - margin: -1px; - height: 100% -} - -.ui-progressbar .ui-progressbar-overlay { - background: - url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw=="); - height: 100%; - filter: alpha(opacity = 25); - opacity: 0.25 -} - -.ui-progressbar-indeterminate .ui-progressbar-value { - background-image: none -} - -.ui-selectmenu-menu { - padding: 0; - margin: 0; - position: absolute; - top: 0; - left: 0; - display: none -} - -.ui-selectmenu-menu .ui-menu { - overflow: auto; - overflow-x: hidden; - padding-bottom: 1px -} - -.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup { - font-size: 1em; - font-weight: bold; - line-height: 1.5; - padding: 2px 0.4em; - margin: 0.5em 0 0 0; - height: auto; - border: 0 -} - -.ui-selectmenu-open { - display: block -} - -.ui-selectmenu-text { - display: block; - margin-right: 20px; - overflow: hidden; - text-overflow: ellipsis -} - -.ui-selectmenu-button.ui-button { - text-align: left; - white-space: nowrap; - width: 14em -} - -.ui-selectmenu-icon.ui-icon { - float: right; - margin-top: 0 -} - -.ui-slider { - position: relative; - text-align: left -} - -.ui-slider .ui-slider-handle { - position: absolute; - z-index: 2; - width: 1.2em; - height: 1.2em; - cursor: default; - -ms-touch-action: none; - touch-action: none -} - -.ui-slider .ui-slider-range { - position: absolute; - z-index: 1; - font-size: .7em; - display: block; - border: 0; - background-position: 0 0 -} - -.ui-slider.ui-state-disabled .ui-slider-handle, .ui-slider.ui-state-disabled .ui-slider-range - { - filter: inherit -} - -.ui-slider-horizontal { - height: .8em -} - -.ui-slider-horizontal .ui-slider-handle { - top: -.3em; - margin-left: -.6em -} - -.ui-slider-horizontal .ui-slider-range { - top: 0; - height: 100% -} - -.ui-slider-horizontal .ui-slider-range-min { - left: 0 -} - -.ui-slider-horizontal .ui-slider-range-max { - right: 0 -} - -.ui-slider-vertical { - width: .8em; - height: 100px -} - -.ui-slider-vertical .ui-slider-handle { - left: -.3em; - margin-left: 0; - margin-bottom: -.6em -} - -.ui-slider-vertical .ui-slider-range { - left: 0; - width: 100% -} - -.ui-slider-vertical .ui-slider-range-min { - bottom: 0 -} - -.ui-slider-vertical .ui-slider-range-max { - top: 0 -} - -.ui-spinner { - position: relative; - display: inline-block; - overflow: hidden; - padding: 0; - vertical-align: middle -} - -.ui-spinner-input { - border: none; - background: none; - color: inherit; - padding: .222em 0; - margin: .2em 0; - vertical-align: middle; - margin-left: .4em; - margin-right: 2em -} - -.ui-spinner-button { - width: 1.6em; - height: 50%; - font-size: .5em; - padding: 0; - margin: 0; - text-align: center; - position: absolute; - cursor: default; - display: block; - overflow: hidden; - right: 0 -} - -.ui-spinner a.ui-spinner-button { - border-top-style: none; - border-bottom-style: none; - border-right-style: none -} - -.ui-spinner-up { - top: 0 -} - -.ui-spinner-down { - bottom: 0 -} - -.ui-tabs { - position: relative; - padding: .2em -} - -.ui-tabs .ui-tabs-nav { - margin: 0; - padding: .2em .2em 0 -} - -.ui-tabs .ui-tabs-nav li { - list-style: none; - float: left; - position: relative; - top: 0; - margin: 1px .2em 0 0; - border-bottom-width: 0; - padding: 0; - white-space: nowrap -} - -.ui-tabs .ui-tabs-nav .ui-tabs-anchor { - float: left; - padding: .5em 1em; - text-decoration: none -} - -.ui-tabs .ui-tabs-nav li.ui-tabs-active { - margin-bottom: -1px; - padding-bottom: 1px -} - -.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor, .ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor, - .ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor { - cursor: text -} - -.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor { - cursor: pointer -} - -.ui-tabs .ui-tabs-panel { - display: block; - border-width: 0; - padding: 1em 1.4em; - background: none -} - -.ui-tooltip { - padding: 8px; - position: absolute; - z-index: 9999; - max-width: 300px -} - -body .ui-tooltip { - border-width: 2px -} - -.ui-widget { - font-family: Arial, Helvetica, sans-serif; - font-size: 1em -} - -.ui-widget .ui-widget { - font-size: 1em -} - -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button - { - font-family: Arial, Helvetica, sans-serif; - font-size: 1em -} - -.ui-widget.ui-widget-content { - border: 1px solid #c5c5c5 -} - -.ui-widget-content { - border: 1px solid #ddd; - background: #fff; - color: #333 -} - -.ui-widget-content a { - color: #333 -} - -.ui-widget-header { - border: 1px solid #ddd; - background: #e9e9e9; - color: #333; - font-weight: bold -} - -.ui-widget-header a { - color: #333 -} - -.ui-state-default, .ui-widget-content .ui-state-default, - .ui-widget-header .ui-state-default, .ui-button, html .ui-button.ui-state-disabled:hover, - html .ui-button.ui-state-disabled:active { - border: 1px solid #c5c5c5; - background: #f6f6f6; - font-weight: normal; - color: #454545 -} - -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited, - a.ui-button, a:link.ui-button, a:visited.ui-button, .ui-button { - color: #454545; - text-decoration: none -} - -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, - .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus, - .ui-button:hover, .ui-button:focus { - border: 1px solid #ccc; - background: #ededed; - font-weight: normal; - color: #2b2b2b -} - -.ui-state-hover a, .ui-state-hover a:hover, .ui-state-hover a:link, - .ui-state-hover a:visited, .ui-state-focus a, .ui-state-focus a:hover, - .ui-state-focus a:link, .ui-state-focus a:visited, a.ui-button:hover, a.ui-button:focus - { - color: #2b2b2b; - text-decoration: none -} - -.ui-visual-focus { - box-shadow: 0 0 3px 1px rgb(94, 158, 214) -} - -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active, - a.ui-button:active, .ui-button:active, .ui-button.ui-state-active:hover - { - border: 1px solid #003eff; - background: #007fff; - font-weight: normal; - color: #fff -} - -.ui-icon-background, .ui-state-active .ui-icon-background { - border: #003eff; - background-color: #fff -} - -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited - { - color: #fff; - text-decoration: none -} - -.ui-state-highlight, .ui-widget-content .ui-state-highlight, - .ui-widget-header .ui-state-highlight { - border: 1px solid #dad55e; - background: #fffa90; - color: #777620 -} - -.ui-state-checked { - border: 1px solid #dad55e; - background: #fffa90 -} - -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a, - .ui-widget-header .ui-state-highlight a { - color: #777620 -} - -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error - { - border: 1px solid #f1a899; - background: #fddfdf; - color: #5f3f3f -} - -.ui-state-error a, .ui-widget-content .ui-state-error a, - .ui-widget-header .ui-state-error a { - color: #5f3f3f -} - -.ui-state-error-text, .ui-widget-content .ui-state-error-text, - .ui-widget-header .ui-state-error-text { - color: #5f3f3f -} - -.ui-priority-primary, .ui-widget-content .ui-priority-primary, - .ui-widget-header .ui-priority-primary { - font-weight: bold -} - -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, - .ui-widget-header .ui-priority-secondary { - opacity: .7; - filter: Alpha(Opacity = 70); - font-weight: normal -} - -.ui-state-disabled, .ui-widget-content .ui-state-disabled, - .ui-widget-header .ui-state-disabled { - opacity: .35; - filter: Alpha(Opacity = 35); - background-image: none -} - -.ui-state-disabled .ui-icon { - filter: Alpha(Opacity = 35) -} - -.ui-icon { - width: 16px; - height: 16px -} - -.ui-icon, .ui-widget-content .ui-icon { - background-image: url("images/ui-icons_444444_256x240.png") -} - -.ui-widget-header .ui-icon { - background-image: url("images/ui-icons_444444_256x240.png") -} - -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon, .ui-button:hover .ui-icon, - .ui-button:focus .ui-icon { - background-image: url("images/ui-icons_555555_256x240.png") -} - -.ui-state-active .ui-icon, .ui-button:active .ui-icon { - background-image: url("images/ui-icons_ffffff_256x240.png") -} - -.ui-state-highlight .ui-icon, .ui-button .ui-state-highlight.ui-icon { - background-image: url("images/ui-icons_777620_256x240.png") -} - -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon { - background-image: url("images/ui-icons_cc0000_256x240.png") -} - -.ui-button .ui-icon { - background-image: url("images/ui-icons_777777_256x240.png") -} - -.ui-icon-blank { - background-position: 16px 16px -} - -.ui-icon-caret-1-n { - background-position: 0 0 -} - -.ui-icon-caret-1-ne { - background-position: -16px 0 -} - -.ui-icon-caret-1-e { - background-position: -32px 0 -} - -.ui-icon-caret-1-se { - background-position: -48px 0 -} - -.ui-icon-caret-1-s { - background-position: -65px 0 -} - -.ui-icon-caret-1-sw { - background-position: -80px 0 -} - -.ui-icon-caret-1-w { - background-position: -96px 0 -} - -.ui-icon-caret-1-nw { - background-position: -112px 0 -} - -.ui-icon-caret-2-n-s { - background-position: -128px 0 -} - -.ui-icon-caret-2-e-w { - background-position: -144px 0 -} - -.ui-icon-triangle-1-n { - background-position: 0 -16px -} - -.ui-icon-triangle-1-ne { - background-position: -16px -16px -} - -.ui-icon-triangle-1-e { - background-position: -32px -16px -} - -.ui-icon-triangle-1-se { - background-position: -48px -16px -} - -.ui-icon-triangle-1-s { - background-position: -65px -16px -} - -.ui-icon-triangle-1-sw { - background-position: -80px -16px -} - -.ui-icon-triangle-1-w { - background-position: -96px -16px -} - -.ui-icon-triangle-1-nw { - background-position: -112px -16px -} - -.ui-icon-triangle-2-n-s { - background-position: -128px -16px -} - -.ui-icon-triangle-2-e-w { - background-position: -144px -16px -} - -.ui-icon-arrow-1-n { - background-position: 0 -32px -} - -.ui-icon-arrow-1-ne { - background-position: -16px -32px -} - -.ui-icon-arrow-1-e { - background-position: -32px -32px -} - -.ui-icon-arrow-1-se { - background-position: -48px -32px -} - -.ui-icon-arrow-1-s { - background-position: -65px -32px -} - -.ui-icon-arrow-1-sw { - background-position: -80px -32px -} - -.ui-icon-arrow-1-w { - background-position: -96px -32px -} - -.ui-icon-arrow-1-nw { - background-position: -112px -32px -} - -.ui-icon-arrow-2-n-s { - background-position: -128px -32px -} - -.ui-icon-arrow-2-ne-sw { - background-position: -144px -32px -} - -.ui-icon-arrow-2-e-w { - background-position: -160px -32px -} - -.ui-icon-arrow-2-se-nw { - background-position: -176px -32px -} - -.ui-icon-arrowstop-1-n { - background-position: -192px -32px -} - -.ui-icon-arrowstop-1-e { - background-position: -208px -32px -} - -.ui-icon-arrowstop-1-s { - background-position: -224px -32px -} - -.ui-icon-arrowstop-1-w { - background-position: -240px -32px -} - -.ui-icon-arrowthick-1-n { - background-position: 1px -48px -} - -.ui-icon-arrowthick-1-ne { - background-position: -16px -48px -} - -.ui-icon-arrowthick-1-e { - background-position: -32px -48px -} - -.ui-icon-arrowthick-1-se { - background-position: -48px -48px -} - -.ui-icon-arrowthick-1-s { - background-position: -64px -48px -} - -.ui-icon-arrowthick-1-sw { - background-position: -80px -48px -} - -.ui-icon-arrowthick-1-w { - background-position: -96px -48px -} - -.ui-icon-arrowthick-1-nw { - background-position: -112px -48px -} - -.ui-icon-arrowthick-2-n-s { - background-position: -128px -48px -} - -.ui-icon-arrowthick-2-ne-sw { - background-position: -144px -48px -} - -.ui-icon-arrowthick-2-e-w { - background-position: -160px -48px -} - -.ui-icon-arrowthick-2-se-nw { - background-position: -176px -48px -} - -.ui-icon-arrowthickstop-1-n { - background-position: -192px -48px -} - -.ui-icon-arrowthickstop-1-e { - background-position: -208px -48px -} - -.ui-icon-arrowthickstop-1-s { - background-position: -224px -48px -} - -.ui-icon-arrowthickstop-1-w { - background-position: -240px -48px -} - -.ui-icon-arrowreturnthick-1-w { - background-position: 0 -64px -} - -.ui-icon-arrowreturnthick-1-n { - background-position: -16px -64px -} - -.ui-icon-arrowreturnthick-1-e { - background-position: -32px -64px -} - -.ui-icon-arrowreturnthick-1-s { - background-position: -48px -64px -} - -.ui-icon-arrowreturn-1-w { - background-position: -64px -64px -} - -.ui-icon-arrowreturn-1-n { - background-position: -80px -64px -} - -.ui-icon-arrowreturn-1-e { - background-position: -96px -64px -} - -.ui-icon-arrowreturn-1-s { - background-position: -112px -64px -} - -.ui-icon-arrowrefresh-1-w { - background-position: -128px -64px -} - -.ui-icon-arrowrefresh-1-n { - background-position: -144px -64px -} - -.ui-icon-arrowrefresh-1-e { - background-position: -160px -64px -} - -.ui-icon-arrowrefresh-1-s { - background-position: -176px -64px -} - -.ui-icon-arrow-4 { - background-position: 0 -80px -} - -.ui-icon-arrow-4-diag { - background-position: -16px -80px -} - -.ui-icon-extlink { - background-position: -32px -80px -} - -.ui-icon-newwin { - background-position: -48px -80px -} - -.ui-icon-refresh { - background-position: -64px -80px -} - -.ui-icon-shuffle { - background-position: -80px -80px -} - -.ui-icon-transfer-e-w { - background-position: -96px -80px -} - -.ui-icon-transferthick-e-w { - background-position: -112px -80px -} - -.ui-icon-folder-collapsed { - background-position: 0 -96px -} - -.ui-icon-folder-open { - background-position: -16px -96px -} - -.ui-icon-document { - background-position: -32px -96px -} - -.ui-icon-document-b { - background-position: -48px -96px -} - -.ui-icon-note { - background-position: -64px -96px -} - -.ui-icon-mail-closed { - background-position: -80px -96px -} - -.ui-icon-mail-open { - background-position: -96px -96px -} - -.ui-icon-suitcase { - background-position: -112px -96px -} - -.ui-icon-comment { - background-position: -128px -96px -} - -.ui-icon-person { - background-position: -144px -96px -} - -.ui-icon-print { - background-position: -160px -96px -} - -.ui-icon-trash { - background-position: -176px -96px -} - -.ui-icon-locked { - background-position: -192px -96px -} - -.ui-icon-unlocked { - background-position: -208px -96px -} - -.ui-icon-bookmark { - background-position: -224px -96px -} - -.ui-icon-tag { - background-position: -240px -96px -} - -.ui-icon-home { - background-position: 0 -112px -} - -.ui-icon-flag { - background-position: -16px -112px -} - -.ui-icon-calendar { - background-position: -32px -112px -} - -.ui-icon-cart { - background-position: -48px -112px -} - -.ui-icon-pencil { - background-position: -64px -112px -} - -.ui-icon-clock { - background-position: -80px -112px -} - -.ui-icon-disk { - background-position: -96px -112px -} - -.ui-icon-calculator { - background-position: -112px -112px -} - -.ui-icon-zoomin { - background-position: -128px -112px -} - -.ui-icon-zoomout { - background-position: -144px -112px -} - -.ui-icon-search { - background-position: -160px -112px -} - -.ui-icon-wrench { - background-position: -176px -112px -} - -.ui-icon-gear { - background-position: -192px -112px -} - -.ui-icon-heart { - background-position: -208px -112px -} - -.ui-icon-star { - background-position: -224px -112px -} - -.ui-icon-link { - background-position: -240px -112px -} - -.ui-icon-cancel { - background-position: 0 -128px -} - -.ui-icon-plus { - background-position: -16px -128px -} - -.ui-icon-plusthick { - background-position: -32px -128px -} - -.ui-icon-minus { - background-position: -48px -128px -} - -.ui-icon-minusthick { - background-position: -64px -128px -} - -.ui-icon-close { - background-position: -80px -128px -} - -.ui-icon-closethick { - background-position: -96px -128px -} - -.ui-icon-key { - background-position: -112px -128px -} - -.ui-icon-lightbulb { - background-position: -128px -128px -} - -.ui-icon-scissors { - background-position: -144px -128px -} - -.ui-icon-clipboard { - background-position: -160px -128px -} - -.ui-icon-copy { - background-position: -176px -128px -} - -.ui-icon-contact { - background-position: -192px -128px -} - -.ui-icon-image { - background-position: -208px -128px -} - -.ui-icon-video { - background-position: -224px -128px -} - -.ui-icon-script { - background-position: -240px -128px -} - -.ui-icon-alert { - background-position: 0 -144px -} - -.ui-icon-info { - background-position: -16px -144px -} - -.ui-icon-notice { - background-position: -32px -144px -} - -.ui-icon-help { - background-position: -48px -144px -} - -.ui-icon-check { - background-position: -64px -144px -} - -.ui-icon-bullet { - background-position: -80px -144px -} - -.ui-icon-radio-on { - background-position: -96px -144px -} - -.ui-icon-radio-off { - background-position: -112px -144px -} - -.ui-icon-pin-w { - background-position: -128px -144px -} - -.ui-icon-pin-s { - background-position: -144px -144px -} - -.ui-icon-play { - background-position: 0 -160px -} - -.ui-icon-pause { - background-position: -16px -160px -} - -.ui-icon-seek-next { - background-position: -32px -160px -} - -.ui-icon-seek-prev { - background-position: -48px -160px -} - -.ui-icon-seek-end { - background-position: -64px -160px -} - -.ui-icon-seek-start { - background-position: -80px -160px -} - -.ui-icon-seek-first { - background-position: -80px -160px -} - -.ui-icon-stop { - background-position: -96px -160px -} - -.ui-icon-eject { - background-position: -112px -160px -} - -.ui-icon-volume-off { - background-position: -128px -160px -} - -.ui-icon-volume-on { - background-position: -144px -160px -} - -.ui-icon-power { - background-position: 0 -176px -} - -.ui-icon-signal-diag { - background-position: -16px -176px -} - -.ui-icon-signal { - background-position: -32px -176px -} - -.ui-icon-battery-0 { - background-position: -48px -176px -} - -.ui-icon-battery-1 { - background-position: -64px -176px -} - -.ui-icon-battery-2 { - background-position: -80px -176px -} - -.ui-icon-battery-3 { - background-position: -96px -176px -} - -.ui-icon-circle-plus { - background-position: 0 -192px -} - -.ui-icon-circle-minus { - background-position: -16px -192px -} - -.ui-icon-circle-close { - background-position: -32px -192px -} - -.ui-icon-circle-triangle-e { - background-position: -48px -192px -} - -.ui-icon-circle-triangle-s { - background-position: -64px -192px -} - -.ui-icon-circle-triangle-w { - background-position: -80px -192px -} - -.ui-icon-circle-triangle-n { - background-position: -96px -192px -} - -.ui-icon-circle-arrow-e { - background-position: -112px -192px -} - -.ui-icon-circle-arrow-s { - background-position: -128px -192px -} - -.ui-icon-circle-arrow-w { - background-position: -144px -192px -} - -.ui-icon-circle-arrow-n { - background-position: -160px -192px -} - -.ui-icon-circle-zoomin { - background-position: -176px -192px -} - -.ui-icon-circle-zoomout { - background-position: -192px -192px -} - -.ui-icon-circle-check { - background-position: -208px -192px -} - -.ui-icon-circlesmall-plus { - background-position: 0 -208px -} - -.ui-icon-circlesmall-minus { - background-position: -16px -208px -} - -.ui-icon-circlesmall-close { - background-position: -32px -208px -} - -.ui-icon-squaresmall-plus { - background-position: -48px -208px -} - -.ui-icon-squaresmall-minus { - background-position: -64px -208px -} - -.ui-icon-squaresmall-close { - background-position: -80px -208px -} - -.ui-icon-grip-dotted-vertical { - background-position: 0 -224px -} - -.ui-icon-grip-dotted-horizontal { - background-position: -16px -224px -} - -.ui-icon-grip-solid-vertical { - background-position: -32px -224px -} - -.ui-icon-grip-solid-horizontal { - background-position: -48px -224px -} - -.ui-icon-gripsmall-diagonal-se { - background-position: -64px -224px -} - -.ui-icon-grip-diagonal-se { - background-position: -80px -224px -} - -.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { - border-top-left-radius: 3px -} - -.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { - border-top-right-radius: 3px -} - -.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { - border-bottom-left-radius: 3px -} - -.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { - border-bottom-right-radius: 3px -} - -.ui-widget-overlay { - background: #aaa; - opacity: .3; - filter: Alpha(Opacity = 30) -} - -.ui-widget-shadow { - -webkit-box-shadow: 0 0 5px #666; - box-shadow: 0 0 5px #666 -} \ No newline at end of file diff --git a/customer_index.php b/customer_index.php index 0de20254..c3ea4fb3 100644 --- a/customer_index.php +++ b/customer_index.php @@ -103,12 +103,12 @@ if ($page == 'overview') { $userinfo['total_bytes_used'] = 0; } - UI::Twig()->addGlobal('userinfo', $userinfo); - UI::TwigBuffer('user/index.html.twig', [ + UI::twig()->addGlobal('userinfo', $userinfo); + UI::twigBuffer('user/index.html.twig', [ 'domains' => $domainArray, 'stdsubdomain' => $stdsubdomain ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } elseif ($page == 'change_password') { diff --git a/doc/example/FroxlorAPI.php b/doc/example/FroxlorAPI.php index 9b2ef050..e2f8ff9a 100644 --- a/doc/example/FroxlorAPI.php +++ b/doc/example/FroxlorAPI.php @@ -17,197 +17,43 @@ */ class FroxlorAPI { + private string $url; + private string $key; + private string $secret; + private ?array $lastError = null; + private ?string $lastStatusCode = null; - /** - * URL to api.php of your froxlor installation - * - * @var string - */ - private $host = ""; + public function __construct($url, $key, $secret) + { + $this->url = $url; + $this->key = $key; + $this->secret = $secret; + } - /** - * your api-key - * - * @var string - */ - private $api_key = ""; + public function request($command, array $data = []) + { + $payload = [ + 'command' => $command, + 'params' => $data + ]; - /** - * your api-secret - * - * @var string - */ - private $api_secret = ""; + $ch = curl_init($this->url); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_USERPWD, $this->key . ":" . $this->secret); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($ch); - /** - * last cURL error message - * - * @var string - */ - private $last_error = ""; + $this->lastStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - /** - * last response header received - * - * @var array - */ - private $last_header = array(); + return json_decode($result ?? curl_error($ch), true); + } - /** - * last response data received - * - * @var array - */ - private $last_body = array(); - - /** - * create FroxlorAPI object - * - * @param string $host - * URL to api.php of your froxlor installation - * @param string $api_key - * your api-key - * @param string $api_secret - * your api-secret - * - * @return FroxlorAPI - */ - public function __construct(string $host, string $api_key, string $api_secret) - { - $this->host = $host; - $this->api_key = $api_key; - $this->api_secret = $api_secret; - } - - /** - * send request to froxlor api - * - * @param string $command - * @param array $params - * - * @return FroxlorAPI - */ - public function request(string $command, array $params = array()): FroxlorAPI - { - // build request array - $request = [ - 'header' => [ - 'apikey' => $this->api_key, - 'secret' => $this->api_secret - ], - 'body' => [ - 'command' => $command - ] - ]; - - // add parameter to request-body if any - if (! empty($params)) { - $request['body']['params'] = $params; - } - - // reset last data - $this->last_header = array(); - $this->last_body = array(); - - // send actual request - $response = $this->requestCurl(json_encode($request)); - - // decode response - $resp = json_decode($response[1], true); - // set body to data-part of response - $this->last_body = $resp['data']; - // set header of response - $this->last_header = [ - 'status' => $resp['status'], - 'status_message' => $resp['status_message'] - ]; - - // check for error in api response - if (isset($this->last_header['status']) && $this->last_header['status'] >= 400) { - // set last-error message - $this->last_error .= "[" . $this->last_header['status'] . "] " . $this->last_header['status_message']; - } - - return $this; -} - - /** - * returns last response header - * - * @return array status|status_message - */ - public function getLastHeader(): array - { - return $this->last_header; - } - - /** - * returns last response data - * - * @return array - */ - public function getLastResponse(): array - { - if (!empty($this->getLastError())) { - // nothing is returned when the last call - // was not successful - return []; - } - return $this->last_body; - } - - /** - * return last known error message - * - * @return string - */ - public function getLastError(): string - { - return $this->last_error; - } - - /** - * send cURL request to api - * - * @param string $data - * json array - * - * @return array header|body - */ - private function requestCurl(string $data): array - { - // reset last error message - $this->last_error = ""; - - $ch = curl_init($this->host); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-type: application/json' - )); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt($ch, CURLOPT_VERBOSE, true); - curl_setopt($ch, CURLOPT_HEADER, 1); - $verbose = fopen('php://temp', 'w+'); - curl_setopt($ch, CURLOPT_STDERR, $verbose); - - if (! $data = curl_exec($ch)) { - $this->last_error = 'Curl execution error: ' . curl_error($ch) . "\n"; - rewind($verbose); - $verboseLog = stream_get_contents($verbose); - $this->last_error .= "Verbose information: " . htmlspecialchars($verboseLog) . "\n"; - } - - $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); - $header = substr($data, 0, $header_size); - $body = substr($data, $header_size); - - curl_close($ch); - return array( - $header, - $body - ); - } + public function getLastStatusCode(): ?string + { + return $this->lastStatusCode; + } } diff --git a/doc/example/create_customer.php b/doc/example/create_customer.php index dcd11d3b..8d62cff7 100644 --- a/doc/example/create_customer.php +++ b/doc/example/create_customer.php @@ -4,7 +4,7 @@ require __DIR__ . '/FroxlorAPI.php'; // create object of FroxlorAPI with URL, apikey and apisecret -$fapi = new FroxlorAPI('https://froxlor.your-host.tld/api.php', 'your-api-key', 'your-api-secret'); +$fapi = new FroxlorAPI('http://127.0.0.1/api.php', 'your-api-key', 'your-api-secret'); // customer data $data = [ @@ -16,19 +16,17 @@ $data = [ 'new_customer_password' => 's0mEcRypt1cpassword' . uniqid() ]; // send request -$fapi->request('Customers.add', $data); +$response = $fapi->request('Customers.add', $data); // check for error -if (! empty($fapi->getLastError())) { - echo "Error: " . $fapi->getLastError(); - exit(); +if ($fapi->getLastStatusCode() != 200) { + echo "HTTP-STATUS: " . $fapi->getLastStatusCode() . PHP_EOL; + echo "Description: " . $response['message'] . PHP_EOL; + exit(); } -// get response of request -$request = $fapi->getLastResponse(); - // view response data -var_dump($request); +var_dump($response); /* array(60) { diff --git a/doc/example/list_functions.php b/doc/example/list_functions.php index a691df7c..68be38dc 100644 --- a/doc/example/list_functions.php +++ b/doc/example/list_functions.php @@ -4,19 +4,17 @@ require __DIR__ . '/FroxlorAPI.php'; // create object of FroxlorAPI with URL, apikey and apisecret -$fapi = new FroxlorAPI('https://froxlor.your-host.tld/api.php', 'your-api-key', 'your-api-secret'); +$fapi = new FroxlorAPI('http://localhost/api.php', 'your-api-key', 'your-api-secret'); // send request -$fapi->request('Froxlor.listFunctions'); +$response = $fapi->request('Froxlor.listFunctions'); // check for error -if (! empty($fapi->getLastError())) { - echo "Error: " . $fapi->getLastError(); - exit(); +if ($fapi->getLastStatusCode() != 200) { + echo "HTTP-STATUS: " . $fapi->getLastStatusCode() . PHP_EOL; + echo "Description: " . $response['message'] . PHP_EOL; + exit(); } -// get response of request -$request = $fapi->getLastResponse(); - // view response data -var_dump($request); +var_dump($response); diff --git a/index.php b/index.php index 34cf00d3..db31dc54 100644 --- a/index.php +++ b/index.php @@ -385,7 +385,7 @@ if ($action == '2fa_entercode') { $lastqrystr = htmlspecialchars($_REQUEST['qrystr'], ENT_QUOTES); } - UI::TwigBuffer('login/login.html.twig', [ + UI::twigBuffer('login/login.html.twig', [ 'pagetitle' => 'Login', 'languages' => $languages, 'lastscript' => $lastscript, @@ -394,7 +394,7 @@ if ($action == '2fa_entercode') { 'message' => $message, 'successmsg' => $successmessage ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } } @@ -585,12 +585,12 @@ if ($action == 'forgotpwd') { } } - UI::TwigBuffer('login/fpwd.html.twig', [ + UI::twigBuffer('login/fpwd.html.twig', [ 'pagetitle' => $lng['login']['presend'], 'action' => $action, 'message' => $message, ]); - UI::TwigOutputBuffer(); + UI::twigOutputBuffer(); } if ($action == 'resetpwd') { diff --git a/install/install.php b/install/install.php index 89b33615..de0b92d7 100644 --- a/install/install.php +++ b/install/install.php @@ -53,10 +53,10 @@ require __DIR__ . '/lib/class.FroxlorInstall.php'; use Froxlor\UI\Panel\UI; UI::initTwig(true); -UI::Twig()->addGlobal('install_mode', '1'); -UI::Twig()->addGlobal('basehref', '../'); +UI::twig()->addGlobal('install_mode', '1'); +UI::twig()->addGlobal('basehref', '../'); $frxinstall = new FroxlorInstall(); $frxinstall->run(); -UI::TwigOutputBuffer(); +UI::twigOutputBuffer(); diff --git a/install/lib/class.FroxlorInstall.php b/install/lib/class.FroxlorInstall.php index 95627ba3..dfd186cc 100644 --- a/install/lib/class.FroxlorInstall.php +++ b/install/lib/class.FroxlorInstall.php @@ -133,7 +133,7 @@ class FroxlorInstall $pagecontent = $result['pagecontent']; $pagenavigation = $result['pagenavigation']; - UI::TwigBuffer('/install/index.html.twig', [ + UI::twigBuffer('/install/index.html.twig', [ 'pagetitle' => $pagetitle, 'pagecontent' => $pagecontent, 'pagenavigation' => $pagenavigation diff --git a/lib/Froxlor/Ajax/Ajax.php b/lib/Froxlor/Ajax/Ajax.php new file mode 100644 index 00000000..cc74e529 --- /dev/null +++ b/lib/Froxlor/Ajax/Ajax.php @@ -0,0 +1,176 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package AJAX + * + */ +class Ajax +{ + protected string $session; + protected string $action; + protected string $theme; + + /** + * @throws Exception + */ + public function __construct() + { + $this->session = $_GET['s'] ?? $_POST['s'] ?? null; + $this->action = $_GET['action'] ?? $_POST['action'] ?? null; + $this->theme = $_GET['theme'] ?? 'Froxlor'; + } + + /** + * @throws Exception + */ + public function handle() + { + $session = $this->getValidatedSession(); + + switch ($this->action) { + case 'newsfeed': + return $this->getNewsfeed(); + case 'updatecheck': + return $this->getUpdateCheck($session); + default: + return $this->errorResponse('Action not found!'); + } + } + + public function errorResponse($message, int $response_code = 500) + { + return \Froxlor\Api\Response::jsonErrorResponse($message, $response_code); + } + + public function jsonResponse($value, int $response_code = 200) + { + return \Froxlor\Api\Response::jsonResponse($value, $response_code); + } + + /** + * @throws Exception + */ + private function getValidatedSession(): array + { + $remote_addr = $_SERVER['REMOTE_ADDR']; + if (empty($_SERVER['HTTP_USER_AGENT'])) { + $http_user_agent = 'unknown'; + } else { + $http_user_agent = $_SERVER['HTTP_USER_AGENT']; + } + + $timediff = time() - \Froxlor\Settings::Get('session.sessiontimeout'); + $sel_stmt = \Froxlor\Database\Database::prepare(" + SELECT * FROM `" . TABLE_PANEL_SESSIONS . "` + WHERE `hash` = :hash AND `ipaddress` = :ipaddr AND `useragent` = :ua AND `lastactivity` > :timediff + "); + + $session = \Froxlor\Database\Database::pexecute_first($sel_stmt, [ + 'hash' => $this->session, + 'ipaddr' => $remote_addr, + 'ua' => $http_user_agent, + 'timediff' => $timediff + ]); + + if (!$session) { + throw new Exception('Session is not defined!'); + } + + return $session; + } + + /** + * @throws Exception + */ + private function getNewsfeed() + { + UI::initTwig(); + + $feed = "https://inside.froxlor.org/news/"; + + // Set custom feed if provided + if (isset($_GET['role']) && $_GET['role'] == "customer") { + $custom_feed = Settings::Get("customer.news_feed_url"); + if (!empty(trim($custom_feed))) { + $feed = $custom_feed; + } + } + + // Check for simplexml_load_file + if (!function_exists("simplexml_load_file")) { + return $this->errorResponse( + "Newsfeed not available due to missing php-simplexml extension", + "Please install the php-simplexml extension in order to view our newsfeed." + ); + } + + // Check for curl_version + if (!function_exists('curl_version')) { + return $this->errorResponse( + "Newsfeed not available due to missing php-curl extension", + "Please install the php-curl extension in order to view our newsfeed." + ); + } + + $output = HttpClient::urlGet($feed); + $news = simplexml_load_string(trim($output)); + + // Handle items + if ($news) { + $items = null; + + for ($i = 0; $i < 3; $i++) { + $item = $news->channel->item[$i]; + + $title = (string)$item->title; + $link = (string)$item->link; + $date = date("d.m.Y", strtotime($item->pubDate)); + $content = preg_replace("/[\r\n]+/", " ", strip_tags($item->description)); + $content = substr($content, 0, 150) . "..."; + + $items .= UI::twig()->render($this->theme . '/user/newsfeeditem.html.twig', [ + 'link' => $link, + 'title' => $title, + 'date' => $date, + 'content' => $content + ]); + } + + return $items; + } else { + return $this->errorResponse('No Newsfeeds available at the moment.'); + } + } + + private function getUpdateCheck(array $session) + { + // TODO: set variables from current session + try { + return \Froxlor\Api\Commands\Froxlor::getLocal([ + 'adminid' => 1, + 'adminsession' => 1, + 'change_serversettings' => 1, + 'loginname' => 'updatecheck' + ])->checkUpdate(); + } catch (Exception $e) { + \Froxlor\UI\Response::dynamic_error($e->getMessage()); + } + } +} diff --git a/lib/Froxlor/Api/Api.php b/lib/Froxlor/Api/Api.php new file mode 100644 index 00000000..53655b07 --- /dev/null +++ b/lib/Froxlor/Api/Api.php @@ -0,0 +1,75 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package API + * + */ +class Api +{ + protected array $headers; + + /** + * Api constructor. + * + * @throws Exception + */ + public function __construct() + { + $this->headers = getallheaders(); + + // set header for the response + header("Accept: application/json"); + header("Content-Type: application/json"); + + // check whether API interface is enabled after all + if (\Froxlor\Settings::Get('api.enabled') != 1) { + throw new Exception('API is not enabled. Please contact the administrator if you think this is wrong.', 400); + } + } + + /** + * Handle incoming api request to our backend. + * + * @param mixed $request + * @throws Exception + */ + public function handle($request) + { + // validate content + $request = \Froxlor\Api\FroxlorRPC::validateRequest($request); + $request = (new AntiXSS())->xss_clean( + $this->stripcslashesDeep($request) + ); + + // now actually do it + $cls = "\\Froxlor\\Api\\Commands\\" . $request['command']['class']; + $method = $request['command']['method']; + $apiObj = new $cls([ + 'apikey' => $_SERVER['PHP_AUTH_USER'], + 'secret' => $_SERVER['PHP_AUTH_PW'] + ], $request['params']); + + // call the method with the params if any + return $apiObj->$method(); + } + + private function stripcslashesDeep($value) + { + return is_array($value) ? array_map([$this, 'stripcslashesDeep'], $value) : stripcslashes($value); + } +} diff --git a/lib/Froxlor/Api/ApiCommand.php b/lib/Froxlor/Api/ApiCommand.php index f561ccf8..c2d646e8 100644 --- a/lib/Froxlor/Api/ApiCommand.php +++ b/lib/Froxlor/Api/ApiCommand.php @@ -243,7 +243,7 @@ abstract class ApiCommand extends ApiParameter */ protected function getUserDetail($detail = null) { - return (isset($this->user_data[$detail]) ? $this->user_data[$detail] : null); + return ($this->user_data[$detail] ?? null); } /** @@ -463,32 +463,16 @@ abstract class ApiCommand extends ApiParameter return json_decode($json_result, true)['data']; } - /** - * return api-compatible response in JSON format and send corresponding http-header - * - * @param int $status - * @param string $status_message - * @param mixed $data - * - * @return string json-encoded response message - */ - protected function response($status, $status_message, $data = null) + /** + * return api-compatible response in JSON format and send corresponding http-header + * + * @param mixed $data + * @param int $response_code + * @return string json-encoded response message + */ + protected function response($data = null, int $response_code = 200) { - if (isset($_SERVER["SERVER_PROTOCOL"]) && ! empty($_SERVER["SERVER_PROTOCOL"])) { - $resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status; - if (! empty($status_message)) { - $resheader .= ' ' . str_replace("\n", " ", $status_message); - } - header($resheader); - } - - $response = array(); - $response['status'] = $status; - $response['status_message'] = $status_message; - $response['data'] = $data; - - $json_response = json_encode($response, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); - return $json_response; + return \Froxlor\Api\Response::jsonDataResponse($data, $response_code); } /** diff --git a/lib/Froxlor/Api/Commands/Admins.php b/lib/Froxlor/Api/Commands/Admins.php index 747edfc9..96311b06 100644 --- a/lib/Froxlor/Api/Commands/Admins.php +++ b/lib/Froxlor/Api/Commands/Admins.php @@ -51,7 +51,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -75,7 +75,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_admins']); + return $this->response($result['num_admins']); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -109,7 +109,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get admin '" . $result['loginname'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'"); throw new \Exception("Admin with " . $key . " could not be found", 404); @@ -364,7 +364,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = $this->apiCall('Admins.get', array( 'id' => $adminid )); - return $this->response(200, "successful", $result); + return $this->response($result); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -677,7 +677,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = $this->apiCall('Admins.get', array( 'id' => $result['adminid'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } } } @@ -775,7 +775,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted admin '" . $result['loginname'] . "'"); \Froxlor\User::updateCounters(); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -817,7 +817,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result['loginfail_count'] = 0; $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] unlocked admin '" . $result['loginname'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } diff --git a/lib/Froxlor/Api/Commands/ApiKeys.php b/lib/Froxlor/Api/Commands/ApiKeys.php index 971d92d3..eb25045e 100644 --- a/lib/Froxlor/Api/Commands/ApiKeys.php +++ b/lib/Froxlor/Api/Commands/ApiKeys.php @@ -23,8 +23,12 @@ class ApiKeys extends \Froxlor\Api\ApiCommand { public function listing() - {} + { + // + } public function listingCount() - {} + { + // + } } \ No newline at end of file diff --git a/lib/Froxlor/Api/Commands/Certificates.php b/lib/Froxlor/Api/Commands/Certificates.php index a611eedf..960a1a02 100644 --- a/lib/Froxlor/Api/Commands/Certificates.php +++ b/lib/Froxlor/Api/Commands/Certificates.php @@ -81,7 +81,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou $result = $this->apiCall('Certificates.get', array( 'id' => $domain['id'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Domain '" . $domain['domain'] . "' already has a certificate. Did you mean to call update?", 406); } @@ -122,7 +122,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou if (! $result) { throw new \Exception("Domain '" . $domain['domain'] . "' does not have a certificate.", 412); } - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -168,7 +168,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou $result = $this->apiCall('Certificates.get', array( 'id' => $domain['id'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -222,7 +222,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou } $result[] = $cert; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -258,7 +258,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou $certs_stmt = Database::prepare($certs_stmt_query); $result = Database::pexecute_first($certs_stmt, $qry_params, true, true); if ($result) { - return $this->response(200, "successful", $result['num_certs']); + return $this->response($result['num_certs']); } } @@ -326,7 +326,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::DELETE_DOMAIN_SSL, $chk['domain']); } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] removed ssl-certificate for '" . $chk['domain'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Unable to determine SSL certificate. Maybe no access?", 406); } diff --git a/lib/Froxlor/Api/Commands/Cronjobs.php b/lib/Froxlor/Api/Commands/Cronjobs.php index 34c0f218..0285483f 100644 --- a/lib/Froxlor/Api/Commands/Cronjobs.php +++ b/lib/Froxlor/Api/Commands/Cronjobs.php @@ -51,7 +51,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE 'id' => $id ), true, true); if ($result) { - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("cronjob with id #" . $id . " could not be found", 404); } @@ -119,7 +119,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE $result = $this->apiCall('Cronjobs.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -152,7 +152,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -175,7 +175,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_crons']); + return $this->response($result['num_crons']); } } throw new \Exception("Not allowed to execute given command.", 403); diff --git a/lib/Froxlor/Api/Commands/CustomerBackups.php b/lib/Froxlor/Api/Commands/CustomerBackups.php index f899b6ca..a5675a3c 100644 --- a/lib/Froxlor/Api/Commands/CustomerBackups.php +++ b/lib/Froxlor/Api/Commands/CustomerBackups.php @@ -111,7 +111,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::CREATE_CUSTOMER_BACKUP, $task_data); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] added customer-backup job for '" . $customer['loginname'] . "'. Target directory: " . $userpath); - return $this->response(200, "successful", $task_data); + return $this->response($task_data); } /** @@ -170,7 +170,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re } } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list customer-backups"); - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -204,7 +204,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re $result_count ++; } } - return $this->response(200, "successful", $result_count); + return $this->response($result_count); } /** @@ -239,7 +239,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re 'tid' => $entry ), true, true); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] deleted planned customer-backup #" . $entry); - return $this->response(200, "successful", true); + return $this->response(true); } } } diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index b1dd1034..c2e03e14 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -103,7 +103,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource } $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -133,7 +133,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource } $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { - return $this->response(200, "successful", $result['num_customers']); + return $this->response($result['num_customers']); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -223,7 +223,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource } } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get customer '" . $result['loginname'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'"); throw new \Exception("Customer with " . $key . " could not be found", 404); @@ -823,7 +823,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $result = $this->apiCall('Customers.get', array( 'loginname' => $loginname )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("No more resources available", 406); } @@ -1420,7 +1420,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $result = $this->apiCall('Customers.get', array( 'id' => $result['customerid'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -1657,7 +1657,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::CREATE_QUOTA); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted customer '" . $result['loginname'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -1699,7 +1699,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $result['loginfail_count'] = 0; $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] unlocked customer '" . $result['loginname'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -1769,7 +1769,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $result = $this->apiCall('Customers.get', array( 'id' => $c_result['customerid'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } diff --git a/lib/Froxlor/Api/Commands/DirOptions.php b/lib/Froxlor/Api/Commands/DirOptions.php index d5c0c010..40aeec2d 100644 --- a/lib/Froxlor/Api/Commands/DirOptions.php +++ b/lib/Froxlor/Api/Commands/DirOptions.php @@ -128,7 +128,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = $this->apiCall('DirOptions.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -186,7 +186,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get directory options for '" . $result['path'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = "id #" . $id; throw new \Exception("Directory option with " . $key . " could not be found", 404); @@ -275,7 +275,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = $this->apiCall('DirOptions.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -315,7 +315,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result[] = $row; } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list directory-options"); - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -347,7 +347,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_htaccess']); + return $this->response($result['num_htaccess']); } } @@ -414,7 +414,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc ), true, true); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted directory-option for '" . str_replace($customer_data['documentroot'], '/', $result['path']) . "'"); \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); - return $this->response(200, "successful", $result); + return $this->response($result); } /** diff --git a/lib/Froxlor/Api/Commands/DirProtections.php b/lib/Froxlor/Api/Commands/DirProtections.php index 8137b93e..38491f14 100644 --- a/lib/Froxlor/Api/Commands/DirProtections.php +++ b/lib/Froxlor/Api/Commands/DirProtections.php @@ -111,7 +111,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res $result = $this->apiCall('DirProtections.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -173,7 +173,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get directory protection for '" . $result['path'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "username '" . $username . "'"); throw new \Exception("Directory protection with " . $key . " could not be found", 404); @@ -258,7 +258,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res $result = $this->apiCall('DirProtections.get', array( 'id' => $result['id'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -298,7 +298,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res $result[] = $row; } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list directory-protections"); - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -330,7 +330,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_htpasswd']); + return $this->response($result['num_htpasswd']); } } @@ -386,6 +386,6 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'"); \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); - return $this->response(200, "successful", $result); + return $this->response($result); } } diff --git a/lib/Froxlor/Api/Commands/DomainZones.php b/lib/Froxlor/Api/Commands/DomainZones.php index 7c0b385b..c5b29296 100644 --- a/lib/Froxlor/Api/Commands/DomainZones.php +++ b/lib/Froxlor/Api/Commands/DomainZones.php @@ -341,7 +341,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $result = $this->apiCall('DomainZones.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } // return $errors throw new \Exception(implode("\n", $errors), 406); @@ -392,7 +392,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $zonefile = (string) $zone; $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get dns-zone for '" . $result['domain'] . "'"); - return $this->response(200, "successful", explode("\n", $zonefile)); + return $this->response(explode("\n", $zonefile)); } /** @@ -452,7 +452,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour while ($row = $sel_stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -496,7 +496,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour 'did' => $id ), true, true); if ($result) { - return $this->response(200, "successful", $result['num_dns']); + return $this->response($result['num_dns']); } } @@ -543,8 +543,8 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour if ($del_stmt->rowCount() > 0) { // re-generate bind configs \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS); - return $this->response(200, "successful", true); + return $this->response(true); } - return $this->response(304, "successful", true); + return $this->response(null, 204); } } diff --git a/lib/Froxlor/Api/Commands/Domains.php b/lib/Froxlor/Api/Commands/Domains.php index 3113f528..3511e393 100644 --- a/lib/Froxlor/Api/Commands/Domains.php +++ b/lib/Froxlor/Api/Commands/Domains.php @@ -68,7 +68,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -100,7 +100,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { - return $this->response(200, "successful", $result['num_domains']); + return $this->response($result['num_domains']); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -156,7 +156,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $result['ipsandports'] = $this->getIpsForDomain($result['id']); } $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get domain '" . $result['domain'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "domainname '" . $domainname . "'"); throw new \Exception("Domain with " . $key . " could not be found", 404); @@ -866,7 +866,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $result = $this->apiCall('Domains.get', array( 'domainname' => $domain )); - return $this->response(200, "successful", $result); + return $this->response($result); } } throw new \Exception("No more resources available", 406); @@ -1833,7 +1833,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $result = $this->apiCall('Domains.get', array( 'domainname' => $result['domain'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -1994,7 +1994,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); // Using nameserver, insert a task which rebuilds the server config \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } diff --git a/lib/Froxlor/Api/Commands/EmailAccounts.php b/lib/Froxlor/Api/Commands/EmailAccounts.php index 9ee1d16c..414e81ab 100644 --- a/lib/Froxlor/Api/Commands/EmailAccounts.php +++ b/lib/Froxlor/Api/Commands/EmailAccounts.php @@ -273,7 +273,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso $result = $this->apiCall('Emails.get', array( 'emailaddr' => $result['email_full'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("No more resources available", 406); } @@ -404,7 +404,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso $result = $this->apiCall('Emails.get', array( 'emailaddr' => $result['email_full'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -507,6 +507,6 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso Customers::decreaseUsage($customer['customerid'], 'email_quota_used', '', $quota); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email account for '" . $result['email_full'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } } diff --git a/lib/Froxlor/Api/Commands/EmailForwarders.php b/lib/Froxlor/Api/Commands/EmailForwarders.php index 847bf9f6..54542b2f 100644 --- a/lib/Froxlor/Api/Commands/EmailForwarders.php +++ b/lib/Froxlor/Api/Commands/EmailForwarders.php @@ -102,7 +102,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re $result = $this->apiCall('Emails.get', array( 'emailaddr' => $result['email_full'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("No more resources available", 406); } @@ -168,7 +168,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re ]; } - return $this->response(200, "successful", [ + return $this->response([ 'count' => count($destination), 'list' => $destination ]); @@ -210,7 +210,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re $result['destination'] = explode(' ', $result['destination']); - return $this->response(200, "successful", count($result['destination'])); + return $this->response(count($result['destination'])); } /** @@ -280,7 +280,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re $result = $this->apiCall('Emails.get', array( 'emailaddr' => $result['email_full'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Unknown forwarder id", 404); } diff --git a/lib/Froxlor/Api/Commands/Emails.php b/lib/Froxlor/Api/Commands/Emails.php index 699533c7..d3850ae9 100644 --- a/lib/Froxlor/Api/Commands/Emails.php +++ b/lib/Froxlor/Api/Commands/Emails.php @@ -145,7 +145,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = $this->apiCall('Emails.get', array( 'emailaddr' => $email_full )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("No more resources available", 406); } @@ -181,7 +181,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get email address '" . $result['email_full'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "emailaddr '" . $emailaddr . "'"); throw new \Exception("Email address with " . $key . " could not be found", 404); @@ -280,7 +280,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = $this->apiCall('Emails.get', array( 'emailaddr' => $result['email_full'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -319,7 +319,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result[] = $row; } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list email-addresses"); - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -349,7 +349,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_emails']); + return $this->response($result['num_emails']); } } @@ -423,6 +423,6 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt Customers::decreaseUsage($customer['customerid'], 'emails_used'); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email address '" . $result['email_full'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } } diff --git a/lib/Froxlor/Api/Commands/FpmDaemons.php b/lib/Froxlor/Api/Commands/FpmDaemons.php index b443798b..3490b8f9 100644 --- a/lib/Froxlor/Api/Commands/FpmDaemons.php +++ b/lib/Froxlor/Api/Commands/FpmDaemons.php @@ -70,7 +70,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $fpmdaemons[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($fpmdaemons), 'list' => $fpmdaemons )); @@ -93,7 +93,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_fpms']); + return $this->response($result['num_fpms']); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -121,7 +121,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc 'id' => $id ), true, true); if ($result) { - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("fpm-daemon with id #" . $id . " could not be found", 404); } @@ -234,7 +234,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = $this->apiCall('FpmDaemons.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -356,7 +356,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = $this->apiCall('FpmDaemons.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -402,7 +402,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] fpm-daemon setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index 7aecb886..31cde236 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -74,7 +74,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand // zum update schritt #1 -> download if ($isnewerversion == 1) { $text = 'There is a newer version available: "' . $_version . '" (Your current version is: ' . $this->version . ')'; - return $this->response(200, "successful", array( + return $this->response(array( 'isnewerversion' => $isnewerversion, 'version' => $_version, 'message' => $text, @@ -83,7 +83,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand )); } elseif ($isnewerversion == 0) { // all good - return $this->response(200, "successful", array( + return $this->response(array( 'isnewerversion' => $isnewerversion, 'version' => $version_label, 'message' => "", @@ -95,13 +95,13 @@ class Froxlor extends \Froxlor\Api\ApiCommand } } } - return $this->response(300, "successful", array( + return $this->response(array( 'isnewerversion' => 0, 'version' => $this->version . $this->branding, 'message' => 'Version-check not available due to missing php-curl extension', 'link' => UPDATE_URI . '/pretty', 'additional_info' => "" - )); + ), 502); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -129,7 +129,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS); // cron.d file \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_CRON); - return $this->response(200, "successful", true); + return $this->response(true); } catch (\Exception $e) { throw new \Exception($e->getMessage(), 406); } @@ -149,7 +149,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "User " . $this->getUserDetail('loginname') . " exported settings"); $json_export = \Froxlor\SImExporter::export(); - return $this->response(200, "successful", $json_export); + return $this->response($json_export); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -175,7 +175,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand 'value' => $row['value'] ); } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -197,7 +197,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { $setting = $this->getParam('key'); - return $this->response(200, "successful", Settings::Get($setting)); + return $this->response(Settings::Get($setting)); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -227,7 +227,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand throw new \Exception("Setting '" . $setting . "' could not be found"); } $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] Changing setting '" . $setting . "' from '" . $oldvalue . "' to '" . $value . "'"); - return $this->response(200, "successful", Settings::Set($setting, $value, true)); + return $this->response(Settings::Set($setting, $value, true)); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -240,7 +240,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand */ public function generatePassword() { - return $this->response(200, "successful", \Froxlor\System\Crypt::generatePassword()); + return $this->response(\Froxlor\System\Crypt::generatePassword()); } /** @@ -256,7 +256,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand $integrity = new \Froxlor\Database\IntegrityCheck(); $result = $integrity->checkAll(); if ($result) { - return $this->response(200, "successful", "OK"); + return $this->response("OK"); } throw new \Exception("Some checks failed.", 406); } @@ -333,7 +333,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand } // return the list - return $this->response(200, "successful", $functions); + return $this->response($functions); } /** diff --git a/lib/Froxlor/Api/Commands/Ftps.php b/lib/Froxlor/Api/Commands/Ftps.php index 5b05cf13..748a62a9 100644 --- a/lib/Froxlor/Api/Commands/Ftps.php +++ b/lib/Froxlor/Api/Commands/Ftps.php @@ -281,7 +281,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit $result = $this->apiCall('Ftps.get', array( 'username' => $username )); - return $this->response(200, "successful", $result); + return $this->response($result); } } throw new \Exception("No more resources available", 406); @@ -342,7 +342,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get ftp-user '" . $result['username'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "username '" . $username . "'"); throw new \Exception("FTP user with " . $key . " could not be found", 404); @@ -469,7 +469,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit 'username' => $result['username'] )); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] updated ftp-user '" . $result['username'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -505,7 +505,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit $result[] = $row; } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list ftp-users"); - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -533,7 +533,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_ftps']); + return $this->response($result['num_ftps']); } } @@ -641,6 +641,6 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit Customers::decreaseUsage($customer_data['customerid'], 'ftps_used', $resetaccnumber); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted ftp-user '" . $result['username'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } } diff --git a/lib/Froxlor/Api/Commands/HostingPlans.php b/lib/Froxlor/Api/Commands/HostingPlans.php index dbaade04..6a23ad39 100644 --- a/lib/Froxlor/Api/Commands/HostingPlans.php +++ b/lib/Froxlor/Api/Commands/HostingPlans.php @@ -57,7 +57,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -85,7 +85,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou } $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { - return $this->response(200, "successful", $result['num_plans']); + return $this->response($result['num_plans']); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -120,7 +120,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get hosting-plan '" . $result['name'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "planname '" . $planname . "'"); throw new \Exception("Hosting-plan with " . $key . " could not be found", 404); @@ -246,7 +246,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou $result = $this->apiCall('HostingPlans.get', array( 'planname' => $name )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -393,7 +393,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou ); Database::pexecute($upd_stmt, $update_data, true, true); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] updated hosting-plan '" . $result['name'] . "'"); - return $this->response(200, "successful", $update_data); + return $this->response($update_data); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -431,7 +431,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou 'id' => $id ), true, true); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted hosting-plan '" . $result['name'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } diff --git a/lib/Froxlor/Api/Commands/IpsAndPorts.php b/lib/Froxlor/Api/Commands/IpsAndPorts.php index 71d836fb..c49ebf85 100644 --- a/lib/Froxlor/Api/Commands/IpsAndPorts.php +++ b/lib/Froxlor/Api/Commands/IpsAndPorts.php @@ -56,7 +56,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -82,7 +82,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour SELECT COUNT(*) as num_ips FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $ip_where); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_ips']); + return $this->response($result['num_ips']); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -116,7 +116,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour ), true, true); if ($result) { $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get ip " . $result['ip'] . " " . $result['port']); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("IP/port with id #" . $id . " could not be found", 404); } @@ -310,7 +310,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $result = $this->apiCall('IpsAndPorts.get', array( 'id' => $ins_data['id'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -520,7 +520,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $result = $this->apiCall('IpsAndPorts.get', array( 'id' => $result['id'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -589,7 +589,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } else { \Froxlor\UI\Response::standard_error('cantdeletesystemip', '', true); } diff --git a/lib/Froxlor/Api/Commands/Mysqls.php b/lib/Froxlor/Api/Commands/Mysqls.php index e759ede2..a8ee343e 100644 --- a/lib/Froxlor/Api/Commands/Mysqls.php +++ b/lib/Froxlor/Api/Commands/Mysqls.php @@ -182,7 +182,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = $this->apiCall('Mysqls.get', array( 'dbname' => $username )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("No more resources available", 406); } @@ -273,7 +273,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt Database::needRoot(false); $result['size'] = $mbdata['MB'] ?? 0; $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get database '" . $result['databasename'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "dbname '" . $dbname . "'"); throw new \Exception("MySQL database with " . $key . " could not be found", 404); @@ -365,7 +365,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = $this->apiCall('Mysqls.get', array( 'dbname' => $result['databasename'] )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -436,7 +436,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt Database::needRoot(false); } } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -463,7 +463,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_dbs']); + return $this->response($result['num_dbs']); } } @@ -525,6 +525,6 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt Customers::decreaseUsage($customer['customerid'], 'mysqls_used', $resetaccnumber); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted database '" . $result['databasename'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } } diff --git a/lib/Froxlor/Api/Commands/PhpSettings.php b/lib/Froxlor/Api/Commands/PhpSettings.php index ae59726f..4a5df145 100644 --- a/lib/Froxlor/Api/Commands/PhpSettings.php +++ b/lib/Froxlor/Api/Commands/PhpSettings.php @@ -113,7 +113,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $phpconfigs[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($phpconfigs), 'list' => $phpconfigs )); @@ -137,7 +137,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour "); $result = Database::pexecute_first($result_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_phps']); + return $this->response($result['num_phps']); } } throw new \Exception("Not allowed to execute given command.", 403); @@ -165,7 +165,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour 'id' => $id ), true, true); if ($result) { - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("php-config with id #" . $id . " could not be found", 404); } @@ -372,7 +372,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour )); $this->addForAllCustomers($allow_all_customers, $ins_data['id']); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -573,7 +573,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour )); $this->addForAllCustomers($allow_all_customers, $id); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } @@ -624,7 +624,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] php setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("Not allowed to execute given command.", 403); } diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index 16717ea5..7aa2ed5d 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -370,7 +370,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = $this->apiCall('SubDomains.get', array( 'id' => $subdomain_id )); - return $this->response(200, "successful", $result); + return $this->response($result); } throw new \Exception("No more resources available", 406); } @@ -451,7 +451,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get subdomain '" . $result['domain'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } $key = ($id > 0 ? "id #" . $id : "domainname '" . $domainname . "'"); throw new \Exception("Subdomain with " . $key . " could not be found", 404); @@ -744,7 +744,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $result = $this->apiCall('SubDomains.get', array( 'id' => $id )); - return $this->response(200, "successful", $result); + return $this->response($result); } /** @@ -848,7 +848,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc while ($row = $domains_stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row; } - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -913,7 +913,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc "); $result = Database::pexecute_first($domains_stmt, null, true, true); if ($result) { - return $this->response(200, "successful", $result['num_subdom']); + return $this->response($result['num_subdom']); } } @@ -1031,7 +1031,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc Customers::decreaseUsage($customer['customerid'], 'subdomains_used'); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted subdomain '" . $result['domain'] . "'"); - return $this->response(200, "successful", $result); + return $this->response($result); } /** diff --git a/lib/Froxlor/Api/Commands/SysLog.php b/lib/Froxlor/Api/Commands/SysLog.php index 9e744827..cebcffcb 100644 --- a/lib/Froxlor/Api/Commands/SysLog.php +++ b/lib/Froxlor/Api/Commands/SysLog.php @@ -74,7 +74,7 @@ class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result[] = $row; } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list log-entries"); - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); @@ -129,7 +129,7 @@ class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $result = Database::pexecute_first($result_stmt, $params, true, true); if ($result) { - return $this->response(200, "successful", $result['num_logs']); + return $this->response($result['num_logs']); } } @@ -204,7 +204,7 @@ class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $params['trunc'] = $truncatedate; Database::pexecute($result_stmt, $params, true, true); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] truncated the froxlor syslog"); - return $this->response(200, "successful", true); + return $this->response(true); } throw new \Exception("Not allowed to execute given command.", 403); } diff --git a/lib/Froxlor/Api/Commands/Traffic.php b/lib/Froxlor/Api/Commands/Traffic.php index caa5c670..178ef379 100644 --- a/lib/Froxlor/Api/Commands/Traffic.php +++ b/lib/Froxlor/Api/Commands/Traffic.php @@ -144,7 +144,7 @@ class Traffic extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $result[] = $row; } $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list traffic"); - return $this->response(200, "successful", array( + return $this->response(array( 'count' => count($result), 'list' => $result )); diff --git a/lib/Froxlor/Api/FroxlorRPC.php b/lib/Froxlor/Api/FroxlorRPC.php index 3a21f330..56dfe43c 100644 --- a/lib/Froxlor/Api/FroxlorRPC.php +++ b/lib/Froxlor/Api/FroxlorRPC.php @@ -1,6 +1,10 @@ (2010-) + * @author Maurice Preuß * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package API * @since 0.10.0 - * + * */ class FroxlorRPC { + /** + * validate a given request + * + * @param $request + * @return array + * @throws Exception + */ + public static function validateRequest($request): array + { + // make basic authentication + if (!isset($_SERVER['PHP_AUTH_USER']) || !self::validateAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { + header('WWW-Authenticate: Basic realm="API"'); + throw new Exception('Unauthenticated. Please provide api user credentials.', 401); + } - /** - * validate a given request - * - * @param array $request - * - * @throws \Exception - * @return array - */ - public static function validateRequest($request) - { - // check header - if (! isset($request['header']) || empty($request['header'])) { - throw new \Exception("Invalid request header", 400); - } + // check if present + if (empty($request)) { + throw new Exception('Empty request body.', 400); + } - // check authorization - if (! isset($request['header']['apikey']) || empty($request['header']['apikey']) || ! isset($request['header']['secret']) || empty($request['header']['secret'])) { - throw new \Exception("No authorization credentials given", 400); - } - self::validateAuth($request['header']['apikey'], $request['header']['secret']); + // decode json request + $decoded_request = json_decode($request, true); - // check command - return self::validateBody($request); - } + // is it valid? + if (is_null($decoded_request)) { + throw new Exception('Invalid JSON Format.', 400); + } - /** - * validates the given api credentials - * - * @param string $key - * @param string $secret - * - * @throws \Exception - * @return boolean - */ - private static function validateAuth($key, $secret) - { - $sel_stmt = \Froxlor\Database\Database::prepare(" + return self::validateBody($decoded_request); + } + + /** + * validates the given api credentials + * + * @param string $key + * @param string $secret + * @return boolean + */ + private static function validateAuth(string $key, string $secret): bool + { + $sel_stmt = \Froxlor\Database\Database::prepare( + " SELECT ak.*, a.api_allowed as admin_api_allowed, c.api_allowed as cust_api_allowed, c.deactivated FROM `api_keys` ak LEFT JOIN `panel_admins` a ON a.adminid = ak.adminid LEFT JOIN `panel_customers` c ON c.customerid = ak.customerid WHERE `apikey` = :ak AND `secret` = :as - "); - $result = \Froxlor\Database\Database::pexecute_first($sel_stmt, array( - 'ak' => $key, - 'as' => $secret - ), true, true); - if ($result) { - if ($result['apikey'] == $key && $result['secret'] == $secret && ($result['valid_until'] == - 1 || $result['valid_until'] >= time()) && (($result['customerid'] == 0 && $result['admin_api_allowed'] == 1) || ($result['customerid'] > 0 && $result['cust_api_allowed'] == 1 && $result['deactivated'] == 0))) { - // get user to check whether api call is allowed - if (! empty($result['allowed_from'])) { - // @todo allow specification and validating of whole subnets later - $ip_list = explode(",", $result['allowed_from']); - $access_ip = inet_ntop(inet_pton($_SERVER['REMOTE_ADDR'])); - if (in_array($access_ip, $ip_list)) { - return true; - } - } else { - return true; - } - } - } - throw new \Exception("Invalid authorization credentials", 403); - } + " + ); + $result = \Froxlor\Database\Database::pexecute_first($sel_stmt, array( + 'ak' => $key, + 'as' => $secret + ), true, true); + if ($result) { + if ($result['apikey'] == $key && $result['secret'] == $secret && ($result['valid_until'] == -1 || $result['valid_until'] >= time( + )) && (($result['customerid'] == 0 && $result['admin_api_allowed'] == 1) || ($result['customerid'] > 0 && $result['cust_api_allowed'] == 1 && $result['deactivated'] == 0))) { + // get user to check whether api call is allowed + if (!empty($result['allowed_from'])) { + // @todo allow specification and validating of whole subnets later + $ip_list = explode(",", $result['allowed_from']); + $access_ip = inet_ntop(inet_pton($_SERVER['REMOTE_ADDR'])); + if (in_array($access_ip, $ip_list)) { + return true; + } + } else { + return true; + } + } + } + return false; + } - /** - * validates the given command - * - * @param array $request - * - * @return array - * @throws \Exception - */ - private static function validateBody($request) - { - // check body - if (! isset($request['body']) || empty($request['body'])) { - throw new \Exception("Invalid request body", 400); - } + /** + * validates the given command + * + * @param array $request + * + * @return array + * @throws Exception + */ + private static function validateBody($request) + { + // check command exists + if (empty($request['command'])) { + throw new Exception("Please provide a command.", 400); + } - // check command exists - if (! isset($request['body']['command']) || empty($request['body']['command'])) { - throw new \Exception("No command given", 400); - } + $command = explode(".", $request['command']); - $command = explode(".", $request['body']['command']); - - if (count($command) != 2) { - throw new \Exception("Invalid command", 400); - } - // simply check for file-existance, as we do not want to use our autoloader because this way - // it will recognize non-api classes+methods as valid commands - $apiclass = '\\Froxlor\\Api\\Commands\\' . $command[0]; - if (! class_exists($apiclass) || ! @method_exists($apiclass, $command[1])) { - throw new \Exception("Unknown command", 400); - } - return array( - 'command' => array( - 'class' => $command[0], - 'method' => $command[1] - ), - 'params' => isset($request['body']['params']) ? $request['body']['params'] : null - ); - } + if (count($command) != 2) { + throw new Exception("The given command is invalid.", 400); + } + // simply check for file-existance, as we do not want to use our autoloader because this way + // it will recognize non-api classes+methods as valid commands + $apiclass = '\\Froxlor\\Api\\Commands\\' . $command[0]; + if (!class_exists($apiclass) || !@method_exists($apiclass, $command[1])) { + throw new Exception("Unknown command", 400); + } + return array( + 'command' => array( + 'class' => $command[0], + 'method' => $command[1] + ), + 'params' => $request['params'] ?? null + ); + } } diff --git a/lib/Froxlor/Api/Response.php b/lib/Froxlor/Api/Response.php new file mode 100644 index 00000000..219fcdab --- /dev/null +++ b/lib/Froxlor/Api/Response.php @@ -0,0 +1,37 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package API + * + */ +class Response +{ + public static function jsonResponse($data = null, int $response_code = 200) + { + http_response_code($response_code); + + return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); + } + + public static function jsonDataResponse($data = null, int $response_code = 200) + { + return self::jsonResponse(['data' => $data], $response_code); + } + + public static function jsonErrorResponse($message = null, int $response_code = 200) + { + return self::jsonResponse(['message' => $message], $response_code); + } +} diff --git a/lib/Froxlor/Database/Database.php b/lib/Froxlor/Database/Database.php index 85c09b0f..4c22a3f1 100644 --- a/lib/Froxlor/Database/Database.php +++ b/lib/Froxlor/Database/Database.php @@ -470,14 +470,14 @@ class Database } // show \Froxlor\UI\Panel\UI::initTwig(true); - \Froxlor\UI\Panel\UI::Twig()->addGlobal('install_mode', '1'); - \Froxlor\UI\Panel\UI::TwigBuffer('misc/dberrornice.html.twig', [ + \Froxlor\UI\Panel\UI::twig()->addGlobal('install_mode', '1'); + \Froxlor\UI\Panel\UI::twigBuffer('misc/dberrornice.html.twig', [ 'page_title' => 'Database error', 'message' => $error_message, 'debug' => $error_trace, 'report' => $err_report_link ]); - echo \Froxlor\UI\Panel\UI::TwigOutputBuffer(); + echo \Froxlor\UI\Panel\UI::twigOutputBuffer(); die(); } die("We are sorry, but a MySQL - error occurred. The administrator may find more information in the syslog"); diff --git a/lib/Froxlor/Http/HttpClient.php b/lib/Froxlor/Http/HttpClient.php index 5b0e764a..45d4fd54 100644 --- a/lib/Froxlor/Http/HttpClient.php +++ b/lib/Froxlor/Http/HttpClient.php @@ -1,17 +1,17 @@ '; // check for more existing errors - $errors = isset(\Froxlor\UI\Panel\UI::Twig()->getGlobals()['global_errors']) ? \Froxlor\UI\Panel\UI::Twig()->getGlobals()['global_errors'] : ""; - \Froxlor\UI\Panel\UI::Twig()->addGlobal('global_errors', $errors . $err_display); + $errors = isset(\Froxlor\UI\Panel\UI::twig()->getGlobals()['global_errors']) ? \Froxlor\UI\Panel\UI::twig()->getGlobals()['global_errors'] : ""; + \Froxlor\UI\Panel\UI::twig()->addGlobal('global_errors', $errors . $err_display); // return true to ignore php standard error-handler return true; } @@ -157,15 +157,15 @@ class PhpHelper if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) { // show \Froxlor\UI\Panel\UI::initTwig(true); - \Froxlor\UI\Panel\UI::Twig()->addGlobal('install_mode', '1'); - \Froxlor\UI\Panel\UI::TwigBuffer('misc/alert_nosession.html.twig', [ + \Froxlor\UI\Panel\UI::twig()->addGlobal('install_mode', '1'); + \Froxlor\UI\Panel\UI::twigBuffer('misc/alert_nosession.html.twig', [ 'page_title' => 'Uncaught exception', 'heading' => 'Uncaught exception', 'type' => 'danger', 'alert_msg' => $exception->getCode() . ' ' . $exception->getMessage(), 'alert_info' => $exception->getTraceAsString() ]); - echo \Froxlor\UI\Panel\UI::TwigOutputBuffer(); + echo \Froxlor\UI\Panel\UI::twigOutputBuffer(); die(); } } diff --git a/lib/Froxlor/UI/Panel/UI.php b/lib/Froxlor/UI/Panel/UI.php index b99f7aec..28eaa0a1 100644 --- a/lib/Froxlor/UI/Panel/UI.php +++ b/lib/Froxlor/UI/Panel/UI.php @@ -128,8 +128,8 @@ class UI * * @return \Twig\Environment */ - public static function Twig() - { + public static function twig(): ?\Twig\Environment + { return self::$twig; } @@ -138,7 +138,7 @@ class UI * * @see \Twig\Environment::render() */ - public static function TwigBuffer($name, array $context = []) + public static function twigBuffer($name, array $context = []) { self::$twigbuf[] = [ self::getTheme() . '/' . $name => $context @@ -172,7 +172,7 @@ class UI /** * echo output buffer and empty buffer-content */ - public static function TwigOutputBuffer() + public static function twigOutputBuffer() { $output = ""; foreach (self::$twigbuf as $buf) { @@ -250,13 +250,14 @@ class UI } } - /** - * returns an array of available themes - * - * @return array - */ - public static function getThemes() - { + /** + * returns an array of available themes + * + * @return array + * @throws \Exception + */ + public static function getThemes(): array + { $themespath = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/templates/'); $themes_available = array(); diff --git a/lib/Froxlor/UI/Response.php b/lib/Froxlor/UI/Response.php index 6ef20d47..63450b39 100644 --- a/lib/Froxlor/UI/Response.php +++ b/lib/Froxlor/UI/Response.php @@ -119,14 +119,14 @@ class Response if ($throw_exception) { throw new \Exception(strip_tags($error), 400); } - \Froxlor\UI\Panel\UI::TwigBuffer('misc/alert.html.twig', [ + \Froxlor\UI\Panel\UI::twigBuffer('misc/alert.html.twig', [ 'type' => 'danger', 'btntype' => 'light', 'heading' => $lng['error']['error'], 'alert_msg' => $error, 'redirect_link' => $link_ref ]); - \Froxlor\UI\Panel\UI::TwigOutputBuffer(); + \Froxlor\UI\Panel\UI::twigOutputBuffer(); exit; } diff --git a/lib/ajax.php b/lib/ajax.php index 539fc220..d4b81660 100644 --- a/lib/ajax.php +++ b/lib/ajax.php @@ -1,143 +1,40 @@ * @author Froxlor team (2010-) + * @author Maurice Preuß * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package AJAX * */ + require_once dirname(__DIR__) . '/vendor/autoload.php'; // Load the user settings if (!file_exists('./userdata.inc.php')) { - die(); + die(); } require './userdata.inc.php'; require './tables.inc.php'; -use Froxlor\UI\Panel\UI; - -if (isset($_POST['s'])) { - $s = $_POST['s']; -} elseif (isset($_GET['s'])) { - $s = $_GET['s']; -} else { - $s = ''; -} - -if (isset($_POST['action'])) { - $action = $_POST['action']; -} elseif (isset($_GET['action'])) { - $action = $_GET['action']; -} else { - $action = ""; -} - -$theme = $_GET['theme'] ?? 'Froxlor'; - -UI::sendHeaders(); -UI::initTwig(); -UI::sendSslHeaders(); - -ini_set("session.name", "s"); -ini_set("url_rewriter.tags", ""); -ini_set("session.use_cookies", false); -ini_set("session.cookie_httponly", true); -ini_set("session.cookie_secure", UI::$SSL_REQ); -session_id($s); -session_start(); - -if (empty($s)) { - die(); -} - -$remote_addr = $_SERVER['REMOTE_ADDR']; -if (empty($_SERVER['HTTP_USER_AGENT'])) { - $http_user_agent = 'unknown'; -} else { - $http_user_agent = $_SERVER['HTTP_USER_AGENT']; -} -$timediff = time() - \Froxlor\Settings::Get('session.sessiontimeout'); -$sel_stmt = \Froxlor\Database\Database::prepare(" - SELECT * FROM `" . TABLE_PANEL_SESSIONS . "` - WHERE `hash` = :hash AND `ipaddress` = :ipaddr AND `useragent` = :ua AND `lastactivity` > :timediff -"); -$sinfo = \Froxlor\Database\Database::pexecute_first($sel_stmt, [ - 'hash' => $s, - 'ipaddr' => $remote_addr, - 'ua' => $http_user_agent, - 'timediff' => $timediff -]); - -if ($sinfo == false) { - die(); -} - -if ($action == "newsfeed") { - - if (isset($_GET['role']) && $_GET['role'] == "customer") { - $feed = \Froxlor\Settings::Get("customer.news_feed_url"); - if (empty(trim($feed))) { - $feed = "https://inside.froxlor.org/news/"; - } - } else { - $feed = "https://inside.froxlor.org/news/"; - } - - if (function_exists("simplexml_load_file") == false) { - outputItem("Newsfeed not available due to missing php-simplexml extension", "Please install the php-simplexml extension in order to view our newsfeed."); - exit(); - } - - if (function_exists('curl_version')) { - $output = \Froxlor\Http\HttpClient::urlGet($feed); - $news = simplexml_load_string(trim($output)); - } else { - outputItem("Newsfeed not available due to missing php-curl extension", "Please install the php-curl extension in order to view our newsfeed."); - exit(); - } - - if ($news !== false) { - for ($i = 0; $i < 3; $i++) { - $item = $news->channel->item[$i]; - - $title = (string) $item->title; - $link = (string) $item->link; - $date = date("d.m.Y", strtotime($item->pubDate)); - $content = preg_replace("/[\r\n]+/", " ", strip_tags($item->description)); - $content = substr($content, 0, 150) . "..."; - - echo UI::Twig()->render($theme . '/user/newsfeeditem.html.twig', [ - 'link' => $link, - 'title' => $title, - 'date' => $date, - 'content' => $content - ]); - } - } else { - echo ""; - } -} elseif ($action == "updatecheck") { - try { - $json_result = \Froxlor\Api\Commands\Froxlor::getLocal([ - 'adminid' => 1, - 'adminsession' => 1, - 'change_serversettings' => 1, - 'loginname' => 'updatecheck' - ])->checkUpdate(); - } catch (Exception $e) { - \Froxlor\UI\Response::dynamic_error($e->getMessage()); - } - echo $result; -} else { - echo "No action set."; +// Return response +try { + echo (new Ajax)->handle(); +} catch (Exception $e) { + echo \Froxlor\Api\Response::jsonErrorResponse($e->getMessage(), 500); } diff --git a/lib/init.php b/lib/init.php index 5c1fbe8f..42e2d24a 100644 --- a/lib/init.php +++ b/lib/init.php @@ -93,8 +93,8 @@ $filename = htmlentities(basename($_SERVER['SCRIPT_NAME'])); // check whether the userdata file exists if (!file_exists(\Froxlor\Froxlor::getInstallDir() . '/lib/userdata.inc.php')) { - UI::Twig()->addGlobal('install_mode', '1'); - echo UI::Twig()->render($_deftheme . '/misc/configurehint.html.twig'); + UI::twig()->addGlobal('install_mode', '1'); + echo UI::twig()->render($_deftheme . '/misc/configurehint.html.twig'); die(); } @@ -103,8 +103,8 @@ if (!is_readable(\Froxlor\Froxlor::getInstallDir() . '/lib/userdata.inc.php')) { // get possible owner $posixusername = posix_getpwuid(posix_getuid()); $posixgroup = posix_getgrgid(posix_getgid()); - UI::Twig()->addGlobal('install_mode', '1'); - echo UI::Twig()->render($_deftheme . '/misc/ownershiphint.html.twig', [ + UI::twig()->addGlobal('install_mode', '1'); + echo UI::twig()->render($_deftheme . '/misc/ownershiphint.html.twig', [ 'user' => $posixusername['name'], 'group' => $posixgroup['name'], 'installdir' => \Froxlor\Froxlor::getInstallDir() @@ -115,8 +115,8 @@ if (!is_readable(\Froxlor\Froxlor::getInstallDir() . '/lib/userdata.inc.php')) { // include MySQL-Username/Passwort etc. require \Froxlor\Froxlor::getInstallDir() . '/lib/userdata.inc.php'; if (!isset($sql) || !is_array($sql)) { - UI::Twig()->addGlobal('install_mode', '1'); - echo UI::Twig()->render($_deftheme . '/misc/configurehint.html.twig'); + UI::twig()->addGlobal('install_mode', '1'); + echo UI::twig()->render($_deftheme . '/misc/configurehint.html.twig'); die(); } @@ -361,8 +361,8 @@ if (Settings::Get('panel.logo_overridecustom') == 0 && file_exists($hl_path . '/ } } -UI::Twig()->addGlobal('header_logo_login', $header_logo_login); -UI::Twig()->addGlobal('header_logo', $header_logo); +UI::twig()->addGlobal('header_logo_login', $header_logo_login); +UI::twig()->addGlobal('header_logo', $header_logo); /** * Redirects to index.php (login page) if no session exists @@ -377,7 +377,7 @@ if ($nosession == 1 && AREA != 'login') { exit(); } -UI::Twig()->addGlobal('userinfo', ($userinfo ?? [])); +UI::twig()->addGlobal('userinfo', ($userinfo ?? [])); /** * Logic moved out of lng-file @@ -433,7 +433,7 @@ if (AREA == 'admin' || AREA == 'customer') { $navigation = \Froxlor\UI\HTML::buildNavigation($navigation_data[AREA], $userinfo); } } -UI::Twig()->addGlobal('nav_entries', $navigation); +UI::twig()->addGlobal('nav_entries', $navigation); $js = ""; $css = ""; @@ -454,8 +454,8 @@ if (is_array($_themeoptions) && array_key_exists('js', $_themeoptions['variants' } } -UI::Twig()->addGlobal('theme_js', $js); -UI::Twig()->addGlobal('theme_css', $css); +UI::twig()->addGlobal('theme_js', $js); +UI::twig()->addGlobal('theme_css', $css); unset($js); unset($css); @@ -500,9 +500,9 @@ if ($page == '') { $page = 'overview'; } -UI::Twig()->addGlobal('action', $action); -UI::Twig()->addGlobal('page', $page); -UI::Twig()->addGlobal('s', $s); +UI::twig()->addGlobal('action', $action); +UI::twig()->addGlobal('page', $page); +UI::twig()->addGlobal('s', $s); /** * Initialize the mailingsystem diff --git a/lib/tables.inc.php b/lib/tables.inc.php index 94aa7eeb..3c819da5 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -16,39 +16,40 @@ * @package System * */ -define('TABLE_FTP_GROUPS', 'ftp_groups'); -define('TABLE_FTP_USERS', 'ftp_users'); -define('TABLE_FTP_QUOTALIMITS', 'ftp_quotalimits'); -define('TABLE_FTP_QUOTATALLIES', 'ftp_quotatallies'); -define('TABLE_MAIL_AUTORESPONDER', 'mail_autoresponder'); -define('TABLE_MAIL_USERS', 'mail_users'); -define('TABLE_MAIL_VIRTUAL', 'mail_virtual'); -define('TABLE_PANEL_ACTIVATION', 'panel_activation'); -define('TABLE_PANEL_ADMINS', 'panel_admins'); -define('TABLE_PANEL_CUSTOMERS', 'panel_customers'); -define('TABLE_PANEL_DATABASES', 'panel_databases'); -define('TABLE_PANEL_DOMAINS', 'panel_domains'); -define('TABLE_PANEL_HTACCESS', 'panel_htaccess'); -define('TABLE_PANEL_HTPASSWDS', 'panel_htpasswds'); -define('TABLE_PANEL_SESSIONS', 'panel_sessions'); -define('TABLE_PANEL_SETTINGS', 'panel_settings'); -define('TABLE_PANEL_TASKS', 'panel_tasks'); -define('TABLE_PANEL_TEMPLATES', 'panel_templates'); -define('TABLE_PANEL_TRAFFIC', 'panel_traffic'); -define('TABLE_PANEL_TRAFFIC_ADMINS', 'panel_traffic_admins'); -define('TABLE_PANEL_DISKSPACE', 'panel_diskspace'); -define('TABLE_PANEL_LANGUAGE', 'panel_languages'); -define('TABLE_PANEL_IPSANDPORTS', 'panel_ipsandports'); -define('TABLE_PANEL_LOG', 'panel_syslog'); -define('TABLE_PANEL_PHPCONFIGS', 'panel_phpconfigs'); -define('TABLE_PANEL_CRONRUNS', 'cronjobs_run'); -define('TABLE_PANEL_REDIRECTCODES', 'redirect_codes'); -define('TABLE_PANEL_DOMAINREDIRECTS', 'domain_redirect_codes'); -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'); -define('TABLE_API_KEYS', 'api_keys'); + +const TABLE_FTP_GROUPS = 'ftp_groups'; +const TABLE_FTP_USERS = 'ftp_users'; +const TABLE_FTP_QUOTALIMITS = 'ftp_quotalimits'; +const TABLE_FTP_QUOTATALLIES = 'ftp_quotatallies'; +const TABLE_MAIL_AUTORESPONDER = 'mail_autoresponder'; +const TABLE_MAIL_USERS = 'mail_users'; +const TABLE_MAIL_VIRTUAL = 'mail_virtual'; +const TABLE_PANEL_ACTIVATION = 'panel_activation'; +const TABLE_PANEL_ADMINS = 'panel_admins'; +const TABLE_PANEL_CUSTOMERS = 'panel_customers'; +const TABLE_PANEL_DATABASES = 'panel_databases'; +const TABLE_PANEL_DOMAINS = 'panel_domains'; +const TABLE_PANEL_HTACCESS = 'panel_htaccess'; +const TABLE_PANEL_HTPASSWDS = 'panel_htpasswds'; +const TABLE_PANEL_SESSIONS = 'panel_sessions'; +const TABLE_PANEL_SETTINGS = 'panel_settings'; +const TABLE_PANEL_TASKS = 'panel_tasks'; +const TABLE_PANEL_TEMPLATES = 'panel_templates'; +const TABLE_PANEL_TRAFFIC = 'panel_traffic'; +const TABLE_PANEL_TRAFFIC_ADMINS = 'panel_traffic_admins'; +const TABLE_PANEL_DISKSPACE = 'panel_diskspace'; +const TABLE_PANEL_LANGUAGE = 'panel_languages'; +const TABLE_PANEL_IPSANDPORTS = 'panel_ipsandports'; +const TABLE_PANEL_LOG = 'panel_syslog'; +const TABLE_PANEL_PHPCONFIGS = 'panel_phpconfigs'; +const TABLE_PANEL_CRONRUNS = 'cronjobs_run'; +const TABLE_PANEL_REDIRECTCODES = 'redirect_codes'; +const TABLE_PANEL_DOMAINREDIRECTS = 'domain_redirect_codes'; +const TABLE_PANEL_DOMAIN_SSL_SETTINGS = 'domain_ssl_settings'; +const TABLE_DOMAINTOIP = 'panel_domaintoip'; +const TABLE_DOMAIN_DNS = 'domain_dns_entries'; +const TABLE_PANEL_FPMDAEMONS = 'panel_fpmdaemons'; +const TABLE_PANEL_PLANS = 'panel_plans'; +const TABLE_API_KEYS = 'api_keys'; require dirname(__FILE__) . '/version.inc.php'; diff --git a/templates/Froxlor/assets/js/main.js b/templates/Froxlor/assets/js/main.js index b2c66f98..e8f05b38 100644 --- a/templates/Froxlor/assets/js/main.js +++ b/templates/Froxlor/assets/js/main.js @@ -3198,10 +3198,76 @@ function withinMaxClamp(min, value, max) { /***/ }), -/***/ "./templates/Froxlor/src/main.js": -/*!***************************************!*\ - !*** ./templates/Froxlor/src/main.js ***! - \***************************************/ +/***/ "./templates/Froxlor/src/js/components/newsfeed.js": +/*!*********************************************************!*\ + !*** ./templates/Froxlor/src/js/components/newsfeed.js ***! + \*********************************************************/ +/***/ (() => { + +$(document).ready(function () { + /* + * newsfeed + */ + if (document.getElementById('newsfeed')) { + var role = ""; + + if (typeof $("#newsfeed").data("role") !== "undefined") { + role = "&role=" + $("#newsfeed").data("role"); + } + + $.ajax({ + url: "lib/ajax.php?action=newsfeed" + role + "&theme=" + window.$theme + "&s=" + window.$session, + type: "GET", + success: function success(data) { + $("#newsfeeditems").html(data); + }, + error: function error(request, status, _error) { + console.log(request, status, _error); + $("#newsfeeditems").html(''); + } + }); + } +}); + +/***/ }), + +/***/ "./templates/Froxlor/src/js/components/updatecheck.js": +/*!************************************************************!*\ + !*** ./templates/Froxlor/src/js/components/updatecheck.js ***! + \************************************************************/ +/***/ (() => { + +$(document).ready(function () { + /* + * updatecheck + */ + if (document.getElementById('updatecheck')) { + var role = ""; + + if (typeof $("#updatecheck").data("role") !== "undefined") { + role = "&role=" + $("#newsfeed").data("role"); + } + + $.ajax({ + url: "lib/ajax.php?action=updatecheck" + role + "&theme=" + window.$theme + "&s=" + window.$session, + type: "GET", + success: function success(data) { + $("#newsfeeditems").html(data); + }, + error: function error(request, status, _error) { + console.log(request, status, _error); + $("#newsfeeditems").html(''); + } + }); + } +}); + +/***/ }), + +/***/ "./templates/Froxlor/src/js/main.js": +/*!******************************************!*\ + !*** ./templates/Froxlor/src/js/main.js ***! + \******************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; @@ -3212,30 +3278,13 @@ __webpack_require__.r(__webpack_exports__); window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); $(document).ready(function () { - var mytheme = 'Froxlor'; - /* - * newsfeed - */ + window.$theme = 'Froxlor'; + window.$session = $('meta[name="froxlor-session"]').attr('content'); +}); // Load components - if (document.getElementById('newsfeed')) { - var role = ""; +__webpack_require__(/*! ./components/newsfeed */ "./templates/Froxlor/src/js/components/newsfeed.js"); - if (typeof $("#newsfeed").data("role") !== "undefined") { - role = "&role=" + $("#newsfeed").data("role"); - } - - $.ajax({ - url: "lib/ajax.php?action=newsfeed" + role + "&theme=" + mytheme, - type: "GET", - success: function success(data) { - $("#newsfeeditems").html(data); - }, - error: function error(a, b) { - $("#newsfeeditems").html(''); - } - }); - } -}); +__webpack_require__(/*! ./components/updatecheck */ "./templates/Froxlor/src/js/components/updatecheck.js"); /***/ }), @@ -19334,7 +19383,7 @@ __webpack_require__.r(__webpack_exports__); /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module depends on other loaded chunks and execution need to be delayed -/******/ __webpack_require__.O(undefined, ["templates/Froxlor/assets/css/dark","templates/Froxlor/assets/css/main"], () => (__webpack_require__("./templates/Froxlor/src/main.js"))) +/******/ __webpack_require__.O(undefined, ["templates/Froxlor/assets/css/dark","templates/Froxlor/assets/css/main"], () => (__webpack_require__("./templates/Froxlor/src/js/main.js"))) /******/ __webpack_require__.O(undefined, ["templates/Froxlor/assets/css/dark","templates/Froxlor/assets/css/main"], () => (__webpack_require__("./templates/Froxlor/src/scss/main.scss"))) /******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["templates/Froxlor/assets/css/dark","templates/Froxlor/assets/css/main"], () => (__webpack_require__("./templates/Froxlor/src/scss/dark.scss"))) /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); diff --git a/templates/Froxlor/base.html.twig b/templates/Froxlor/base.html.twig index cdb7e312..5f0ae6a1 100644 --- a/templates/Froxlor/base.html.twig +++ b/templates/Froxlor/base.html.twig @@ -7,6 +7,9 @@ + + + {% if theme_css is empty %} diff --git a/templates/Froxlor/src/js/components/newsfeed.js b/templates/Froxlor/src/js/components/newsfeed.js new file mode 100644 index 00000000..bd81490a --- /dev/null +++ b/templates/Froxlor/src/js/components/newsfeed.js @@ -0,0 +1,24 @@ +$(document).ready(function () { + /* + * newsfeed + */ + if (document.getElementById('newsfeed')) { + let role = ""; + + if (typeof $("#newsfeed").data("role") !== "undefined") { + role = "&role=" + $("#newsfeed").data("role"); + } + + $.ajax({ + url: "lib/ajax.php?action=newsfeed" + role + "&theme=" + window.$theme + "&s=" + window.$session, + type: "GET", + success: function (data) { + $("#newsfeeditems").html(data); + }, + error: function (request, status, error) { + console.log(request, status, error) + $("#newsfeeditems").html(''); + } + }); + } +}); \ No newline at end of file diff --git a/templates/Froxlor/src/js/components/updatecheck.js b/templates/Froxlor/src/js/components/updatecheck.js new file mode 100644 index 00000000..0b0d2d72 --- /dev/null +++ b/templates/Froxlor/src/js/components/updatecheck.js @@ -0,0 +1,24 @@ +$(document).ready(function () { + /* + * updatecheck + */ + if (document.getElementById('updatecheck')) { + let role = ""; + + if (typeof $("#updatecheck").data("role") !== "undefined") { + role = "&role=" + $("#newsfeed").data("role"); + } + + $.ajax({ + url: "lib/ajax.php?action=updatecheck" + role + "&theme=" + window.$theme + "&s=" + window.$session, + type: "GET", + success: function (data) { + $("#newsfeeditems").html(data); + }, + error: function (request, status, error) { + console.log(request, status, error) + $("#newsfeeditems").html(''); + } + }); + } +}); \ No newline at end of file diff --git a/templates/Froxlor/src/js/main.js b/templates/Froxlor/src/js/main.js new file mode 100644 index 00000000..c5224015 --- /dev/null +++ b/templates/Froxlor/src/js/main.js @@ -0,0 +1,14 @@ +// load bootstrap +import 'bootstrap'; + +// load jquery +window.$ = window.jQuery = require('jquery'); + +$(document).ready(function () { + window.$theme = 'Froxlor'; + window.$session = $('meta[name="froxlor-session"]').attr('content'); +}); + +// Load components +require('./components/newsfeed') +require('./components/updatecheck') diff --git a/templates/Froxlor/src/main.js b/templates/Froxlor/src/main.js deleted file mode 100644 index 8f68d384..00000000 --- a/templates/Froxlor/src/main.js +++ /dev/null @@ -1,43 +0,0 @@ -// load bootstrap -import 'bootstrap'; - -// load jquery -window.$ = window.jQuery = require('jquery'); - -function getUrlVars() { - var vars = [], hash; - var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); - for (var i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - return vars; -} - -$(document).ready(function () { - - const mytheme = 'Froxlor'; - /* - * newsfeed - */ - if (document.getElementById('newsfeed')) { - var role = ""; - if (typeof $("#newsfeed").data("role") !== "undefined") { - role = "&role=" + $("#newsfeed").data("role"); - } - var s = getUrlVars()["s"]; - - $.ajax({ - url: "lib/ajax.php?action=newsfeed" + role + "&theme=" + mytheme + "&s=" + s, - type: "GET", - success: function (data) { - $("#newsfeeditems").html(data); - }, - error: function (a, b) { - $("#newsfeeditems").html(''); - } - }); - } - -}); diff --git a/templates/Froxlor/userarea.html.twig b/templates/Froxlor/userarea.html.twig index d1f46b21..6f934a32 100644 --- a/templates/Froxlor/userarea.html.twig +++ b/templates/Froxlor/userarea.html.twig @@ -32,6 +32,11 @@