From 3e55043625a1900c759838547556acdf557f5a41 Mon Sep 17 00:00:00 2001 From: geekwright Date: Wed, 17 May 2017 16:12:43 -0500 Subject: [PATCH 1/2] Add token processing --- admin/item.php | 13 +++---- admin/mimetypes.php | 76 ++++++++++++++++++++++++++----------- class/item.php | 10 ++--- language/english/admin.php | 5 +++ language/english/common.php | 2 + submit.php | 13 ++++++- 6 files changed, 84 insertions(+), 35 deletions(-) diff --git a/admin/item.php b/admin/item.php index 780a71e2..3167057f 100644 --- a/admin/item.php +++ b/admin/item.php @@ -23,18 +23,17 @@ require_once __DIR__ . '/admin_header.php'; +// all post requests should have a valid token +if ('POST' === Request::getMethod() && !$GLOBALS['xoopsSecurity']->check()) { + redirect_header('item.php', 2, _CO_PUBLISHER_BAD_TOKEN); +} + $itemid = Request::getInt('itemid', Request::getInt('itemid', 0, 'POST'), 'GET'); $op = ($itemid > 0 || Request::getString('editor', '', 'POST')) ? 'mod' : ''; //$op = Request::getString('op', $op, 'GET'); $op = Request::getString('op', Request::getString('op', $op, 'POST'), 'GET'); -//if (!empty(Request::getString('additem', '', 'POST'))) { -// $op = 'additem'; -//} elseif (!empty(Request::getString('del', '', 'POST'))) { -// $op = 'del'; -//} - $op = Request::getString('additem', '', 'POST') ? 'additem' : (Request::getString('del', '', 'POST') ? 'del' : $op); // Where shall we start ? @@ -146,7 +145,7 @@ case 'del': $itemObj = $publisher->getHandler('item')->get($itemid); - $confirm = Request::getInt('confirm', '', 'POST'); + $confirm = Request::getInt('confirm', 0, 'POST'); if ($confirm) { if (!$publisher->getHandler('item')->delete($itemObj)) { diff --git a/admin/mimetypes.php b/admin/mimetypes.php index e4daa2e5..0acf417a 100644 --- a/admin/mimetypes.php +++ b/admin/mimetypes.php @@ -24,15 +24,6 @@ require_once __DIR__ . '/admin_header.php'; xoops_load('XoopsPagenav'); -//$start = $limit = 0; -//if (isset($_GET['limit'])) { -// $limit = Request::getInt('limit', 0, 'GET'); -//} elseif (isset($_POST['limit'])) { -// $limit = Request::getInt('limit', 0, 'POST'); -//} else { -// $limit = 15; -//} - $start = Request::getInt('start', 0, 'GET'); $limit = Request::getInt('limit', Request::getInt('limit', 15, 'GET'), 'POST'); @@ -51,6 +42,11 @@ $op = Request::getString('op', 'default', 'GET'); +// all post requests should have a valid token +if ('POST' === Request::getMethod() && !$GLOBALS['xoopsSecurity']->check()) { + redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?op=manage", 3, _CO_PUBLISHER_BAD_TOKEN); +} + switch ($op) { case 'add': PublisherMimetypesUtility::add(); @@ -72,6 +68,10 @@ PublisherMimetypesUtility::updateMimeValue(); break; + case 'confirmUpdateMimeValue': + PublisherMimetypesUtility::confirmUpdateMimeValue(); + break; + case 'clearAddSession': PublisherMimetypesUtility::clearAddSession(); break; @@ -127,6 +127,7 @@ public static function add() // Display add form echo "
"; + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); echo ""; echo "'; echo " @@ -296,6 +297,7 @@ public static function edit() // Display edit form echo ""; + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); echo ""; echo ""; echo "
" . _AM_PUBLISHER_MIME_CREATEF . '
"; @@ -437,6 +439,7 @@ public static function manage() echo "
"; echo "
"; echo ""; + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); echo ''; echo ''; echo "'; @@ -454,6 +457,7 @@ public static function manage() echo "
" . _AM_PUBLISHER_TEXT_SEARCH_BY . '
"; echo ""; + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); echo ""; echo "
" . _AM_PUBLISHER_TEXT_SORT_BY . " "; echo "'; echo " @@ -641,9 +646,10 @@ public static function search() echo '
" . _AM_PUBLISHER_TEXT_SEARCH_MIME . '
" . _AM_PUBLISHER_TEXT_SEARCH_BY . "
'; } else { $searchField = Request::getString('search_by', ''); + $searchField = isset($aSearchBy[$searchField]) ? $searchField : 'mime_ext' ; $searchText = Request::getString('search_text', ''); - $crit = new Criteria($searchField, "%$searchText%", 'LIKE'); + $crit = new Criteria($searchField, '%' . $GLOBALS['xoopsDB']->escape($searchText) . '%', 'LIKE'); $crit->setSort($sort); $crit->setOrder($order); $crit->setLimit($limit); @@ -659,6 +665,7 @@ public static function search() echo ""; echo "
"; echo "
"; + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); echo ''; echo ''; echo "'; @@ -676,6 +683,7 @@ public static function search() echo "
" . _AM_PUBLISHER_TEXT_SEARCH_BY . '
"; echo ""; + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); echo ""; echo "
" . _AM_PUBLISHER_TEXT_SORT_BY . "