From 13edefb8c6fb8cfc8bcdf83fad08e7bf179f9327 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 25 May 2015 18:05:52 -0400 Subject: [PATCH] Modernise some of the new admin section. Roll hoplite to 2dbb698f2da9339190cc1e3d2e8bfb1f803ebc84. --- admin/fields.php | 6 ++---- admin/home.php | 2 +- admin/index.php | 2 +- admin/settings.php | 40 ++++++++++++++++++++-------------------- includes/hoplite | 2 +- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/admin/fields.php b/admin/fields.php index 39c60da..9467d7f 100644 --- a/admin/fields.php +++ b/admin/fields.php @@ -48,7 +48,7 @@ class FieldsAction extends http\ActionController implements TemplatePreCaching public function ActionEdit(http\Request $request, http\Response $response) { - $field = new bugdar\Field(bugdar::$input->InputClean('g', 'field', http\Input::TYPE_STR)); + $field = new bugdar\Field(filter_input(INPUT_GET, 'field', FILTER_SANITIZE_STRING)); $response->data['field'] = $field->Fetch(); $response->context['template'] = 'admin_fields_edit'; } @@ -65,8 +65,6 @@ class FieldsAction extends http\ActionController implements TemplatePreCaching protected function _GetActionMethod(http\Request $request) { $method = parent::_GetActionMethod($request); - if ($method === NULL) - return 'ActionList'; - return $method; + return $method ? $method : 'ActionList'; } } diff --git a/admin/home.php b/admin/home.php index 3c4f877..8e8c4f0 100644 --- a/admin/home.php +++ b/admin/home.php @@ -30,7 +30,7 @@ class HomeAction extends http\Action implements TemplatePreCaching { public function TemplateSet() { - return array('admin_index'); + return ['admin_index']; } public function Invoke(http\Request $request, http\Response $response) diff --git a/admin/index.php b/admin/index.php index 8a69dc0..db34f86 100644 --- a/admin/index.php +++ b/admin/index.php @@ -94,7 +94,7 @@ class FrontController implements http\RootControllerDelegate if (can_perform('canadminpanel')) { $stmt = bugdar::$db->Prepare("SELECT * FROM ". TABLE_PREFIX . "adminsession WHERE sessionid = ?"); - $stmt->Execute(array(bugdar::$input->InputClean('c', $cookie, http\Input::TYPE_STR))); + $stmt->Execute([ filter_input(INPUT_COOKIE, $cookie, FILTER_SANITIZE_STRING) ]); $session = $stmt->FetchObject(); if ($session && $session->userid == bugdar::$user['userid'] && $session->dateline >= TIMENOW - 3600) { diff --git a/admin/settings.php b/admin/settings.php index fab1a8b..eb35178 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -24,17 +24,17 @@ namespace bugdar\admin; use \bugdar; use \hoplite\http; -require_once HOPLITE_ROOT . '/http/action.php'; +require_once HOPLITE_ROOT . '/http/rest_action.php'; require_once BUGDAR_ROOT . '/includes/functions_datastore.php'; -class SettingsAction extends http\Action implements TemplatePreCaching +class SettingsAction extends http\RestAction implements TemplatePreCaching { public function TemplateSet() { - return array('admin_settings'); + return ['admin_settings']; } - public function Invoke(http\Request $request, http\Response $response) + public function DoGet(http\Request $request, http\Response $response) { // TODO(port): global. global $bugsys; @@ -43,25 +43,25 @@ class SettingsAction extends http\Action implements TemplatePreCaching $response->context['template'] = 'admin_settings'; $response->data['timezone_list'] = $bugsys->datef->fetch_timezone_list(); + } - // Save settings on POST. - if ($request->http_method == 'POST') { - $query_bits = array(); - $values = array(); - foreach ($request->data['_POST']['settings'] AS $varname => $value) { - $query_bits[] = '(?,?)'; - array_push($values, $varname, $value); - } + public function DoPost(http\Request $request, http\Response $response) + { + $query_bits = array(); + $values = array(); + foreach ($request->data['_POST']['settings'] AS $varname => $value) { + $query_bits[] = '(?,?)'; + array_push($values, $varname, $value); + } - $query = bugdar::$db->Prepare(" - REPLACE into " . TABLE_PREFIX . "setting - (varname, value) - VALUES " . implode(', ', $query_bits)); - $query->Execute($values); + $query = bugdar::$db->Prepare(" + REPLACE into " . TABLE_PREFIX . "setting + (varname, value) + VALUES " . implode(', ', $query_bits)); + $query->Execute($values); - build_settings(); + build_settings(); - $this->controller()->StopWithRedirect($this->controller()->MakeURL('/settings')); - } + $this->controller()->StopWithRedirect($this->controller()->MakeURL('/settings')); } } diff --git a/includes/hoplite b/includes/hoplite index 38d8c89..2dbb698 160000 --- a/includes/hoplite +++ b/includes/hoplite @@ -1 +1 @@ -Subproject commit 38d8c893ebfb727e6f70ee86a155431e8d9fd571 +Subproject commit 2dbb698f2da9339190cc1e3d2e8bfb1f803ebc84 -- 2.43.5