mambax7 /
publisher
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||||
| 2 | /* |
||||
| 3 | You may not change or alter any portion of this comment or credits |
||||
| 4 | of supporting developers from this source code or any supporting source code |
||||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 6 | |||||
| 7 | This program is distributed in the hope that it will be useful, |
||||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 10 | */ |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * @copyright XOOPS Project (https://xoops.org) |
||||
| 14 | * @license https://www.fsf.org/copyleft/gpl.html GNU public license |
||||
| 15 | * @since 1.0 |
||||
| 16 | * @author trabis <[email protected]> |
||||
| 17 | * @author phppp |
||||
| 18 | */ |
||||
| 19 | |||||
| 20 | use Xmf\Request; |
||||
| 21 | use XoopsModules\Publisher\CategoryHandler; |
||||
| 22 | use XoopsModules\Publisher\Helper; |
||||
| 23 | |||||
| 24 | require_once \dirname(__DIR__) . '/include/common.php'; |
||||
| 25 | |||||
| 26 | /** |
||||
| 27 | * @param $options |
||||
| 28 | * |
||||
| 29 | * @return array |
||||
| 30 | */ |
||||
| 31 | function publisher_search_show($options) |
||||
|
0 ignored issues
–
show
|
|||||
| 32 | { |
||||
| 33 | $block = []; |
||||
| 34 | $helper = Helper::getInstance(); |
||||
| 35 | /** @var CategoryHandler $categoryHandler */ |
||||
| 36 | $categoryHandler = $helper->getHandler('Category'); |
||||
| 37 | $categories = $categoryHandler->getCategoriesForSearch(); |
||||
| 38 | if (0 === count($categories)) { |
||||
| 39 | return $block; |
||||
| 40 | } |
||||
| 41 | |||||
| 42 | xoops_loadLanguage('search'); |
||||
| 43 | |||||
| 44 | $andor = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST'); |
||||
| 45 | $username = Request::getString('uname', Request::getString('uname', null, 'GET'), 'POST'); |
||||
| 46 | // $searchin = isset($_POST["searchin"]) ? $_POST["searchin"] : (isset($_GET["searchin"]) ? explode("|", $_GET["searchin"]) : array()); |
||||
| 47 | // $searchin = Request::getArray('searchin', (explode("|", Request::getString('searchin', array(), 'GET'))), 'POST'); |
||||
| 48 | |||||
| 49 | $searchin = Request::getArray('searchin', '', 'POST'); |
||||
| 50 | if (!isset($searchin)) { |
||||
| 51 | $searchin = Request::getString('searchin', [], 'GET'); |
||||
|
0 ignored issues
–
show
array() of type array is incompatible with the type string expected by parameter $default of Xmf\Request::getString().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 52 | $searchin = isset($searchin) ? explode('|', $searchin) : []; |
||||
| 53 | } |
||||
| 54 | |||||
| 55 | $sortby = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST'); |
||||
| 56 | $term = Request::getString('term', Request::getString('term', '', 'GET')); |
||||
| 57 | |||||
| 58 | //mb TODO simplify next lines with category |
||||
| 59 | $category = Request::getArray('category', [], 'POST') ?: Request::getArray('category', null, 'GET'); |
||||
| 60 | if (empty($category) || (is_array($category) && in_array('all', $category, true))) { |
||||
| 61 | $category = []; |
||||
| 62 | } else { |
||||
| 63 | $category = (!is_array($category)) ? explode(',', $category) : $category; |
||||
| 64 | $category = array_map('\intval', $category); |
||||
| 65 | } |
||||
| 66 | |||||
| 67 | $andor = in_array(mb_strtoupper($andor), ['OR', 'AND', 'EXACT'], true) ? \mb_strtoupper($andor) : 'OR'; |
||||
| 68 | $sortby = in_array(mb_strtolower($sortby), ['itemid', 'datesub', 'title', 'categoryid'], true) ? \mb_strtolower($sortby) : 'itemid'; |
||||
| 69 | |||||
| 70 | /* type */ |
||||
| 71 | $typeSelect = '<select name="andor">'; |
||||
| 72 | $typeSelect .= '<option value="OR"'; |
||||
| 73 | if ('OR' === $andor) { |
||||
| 74 | $typeSelect .= ' selected="selected"'; |
||||
| 75 | } |
||||
| 76 | $typeSelect .= '>' . _SR_ANY . '</option>'; |
||||
| 77 | $typeSelect .= '<option value="AND"'; |
||||
| 78 | if ('AND' === $andor) { |
||||
| 79 | $typeSelect .= ' selected="selected"'; |
||||
| 80 | } |
||||
| 81 | $typeSelect .= '>' . _SR_ALL . '</option>'; |
||||
| 82 | $typeSelect .= '<option value="EXACT"'; |
||||
| 83 | if ('exact' === $andor) { |
||||
| 84 | $typeSelect .= ' selected="selected"'; |
||||
| 85 | } |
||||
| 86 | $typeSelect .= '>' . _SR_EXACT . '</option>'; |
||||
| 87 | $typeSelect .= '</select>'; |
||||
| 88 | |||||
| 89 | /* category */ |
||||
| 90 | |||||
| 91 | $categorySelect = '<select name="category[]" size="5" multiple="multiple" width="150" style="width:150px;">'; |
||||
| 92 | $categorySelect .= '<option value="all"'; |
||||
| 93 | if (empty($category) || 0 === count($category)) { |
||||
| 94 | $categorySelect .= 'selected="selected"'; |
||||
| 95 | } |
||||
| 96 | $categorySelect .= '>' . _ALL . '</option>'; |
||||
| 97 | foreach ($categories as $id => $cat) { |
||||
| 98 | $categorySelect .= '<option value="' . $id . '"'; |
||||
| 99 | if (in_array($id, $category, true)) { |
||||
| 100 | $categorySelect .= 'selected="selected"'; |
||||
| 101 | } |
||||
| 102 | $categorySelect .= '>' . $cat . '</option>'; |
||||
| 103 | } |
||||
| 104 | unset($id); |
||||
| 105 | $categorySelect .= '</select>'; |
||||
| 106 | |||||
| 107 | /* scope */ |
||||
| 108 | $searchSelect = '<input type="checkbox" name="searchin[]" value="title"'; |
||||
| 109 | if (is_array($searchin) && in_array('title', $searchin, true)) { |
||||
| 110 | $searchSelect .= ' checked'; |
||||
| 111 | } |
||||
| 112 | $searchSelect .= '>' . _CO_PUBLISHER_TITLE . ' '; |
||||
| 113 | $searchSelect .= '<input type="checkbox" name="searchin[]" value="subtitle"'; |
||||
| 114 | if (is_array($searchin) && in_array('subtitle', $searchin, true)) { |
||||
| 115 | $searchSelect .= ' checked'; |
||||
| 116 | } |
||||
| 117 | $searchSelect .= '>' . _CO_PUBLISHER_SUBTITLE . ' '; |
||||
| 118 | $searchSelect .= '<input type="checkbox" name="searchin[]" value="summary"'; |
||||
| 119 | if (is_array($searchin) && in_array('summary', $searchin, true)) { |
||||
| 120 | $searchSelect .= ' checked'; |
||||
| 121 | } |
||||
| 122 | $searchSelect .= '>' . _CO_PUBLISHER_SUMMARY . ' '; |
||||
| 123 | $searchSelect .= '<input type="checkbox" name="searchin[]" value="text"'; |
||||
| 124 | if (is_array($searchin) && in_array('body', $searchin, true)) { |
||||
| 125 | $searchSelect .= ' checked'; |
||||
| 126 | } |
||||
| 127 | $searchSelect .= '>' . _CO_PUBLISHER_BODY . ' '; |
||||
| 128 | $searchSelect .= '<input type="checkbox" name="searchin[]" value="keywords"'; |
||||
| 129 | if (is_array($searchin) && in_array('meta_keywords', $searchin, true)) { |
||||
| 130 | $searchSelect .= ' checked'; |
||||
| 131 | } |
||||
| 132 | $searchSelect .= '>' . _CO_PUBLISHER_ITEM_META_KEYWORDS . ' '; |
||||
| 133 | $searchSelect .= '<input type="checkbox" name="searchin[]" value="all"'; |
||||
| 134 | if (empty($searchin) || (is_array($searchin) && in_array('all', $searchin, true))) { |
||||
| 135 | $searchSelect .= ' checked'; |
||||
| 136 | } |
||||
| 137 | $searchSelect .= '>' . _ALL . ' '; |
||||
| 138 | |||||
| 139 | /* sortby */ |
||||
| 140 | $sortbySelect = '<select name="sortby">'; |
||||
| 141 | $sortbySelect .= '<option value="itemid"'; |
||||
| 142 | if ('itemid' === $sortby || empty($sortby)) { |
||||
| 143 | $sortbySelect .= ' selected="selected"'; |
||||
| 144 | } |
||||
| 145 | $sortbySelect .= '>' . _NONE . '</option>'; |
||||
| 146 | $sortbySelect .= '<option value="datesub"'; |
||||
| 147 | if ('datesub' === $sortby) { |
||||
| 148 | $sortbySelect .= ' selected="selected"'; |
||||
| 149 | } |
||||
| 150 | $sortbySelect .= '>' . _CO_PUBLISHER_DATESUB . '</option>'; |
||||
| 151 | $sortbySelect .= '<option value="title"'; |
||||
| 152 | if ('title' === $sortby) { |
||||
| 153 | $sortbySelect .= ' selected="selected"'; |
||||
| 154 | } |
||||
| 155 | $sortbySelect .= '>' . _CO_PUBLISHER_TITLE . '</option>'; |
||||
| 156 | $sortbySelect .= '<option value="categoryid"'; |
||||
| 157 | if ('categoryid' === $sortby) { |
||||
| 158 | $sortbySelect .= ' selected="selected"'; |
||||
| 159 | } |
||||
| 160 | $sortbySelect .= '>' . _CO_PUBLISHER_CATEGORY . '</option>'; |
||||
| 161 | $sortbySelect .= '</select>'; |
||||
| 162 | |||||
| 163 | $block['typeSelect'] = $typeSelect; |
||||
| 164 | $block['searchSelect'] = $searchSelect; |
||||
| 165 | $block['categorySelect'] = $categorySelect; |
||||
| 166 | $block['sortbySelect'] = $sortbySelect; |
||||
| 167 | $block['search_term'] = htmlspecialchars($term, ENT_QUOTES | ENT_HTML5); |
||||
| 168 | $block['search_user'] = $username; |
||||
| 169 | $block['publisher_url'] = PUBLISHER_URL; |
||||
| 170 | |||||
| 171 | return $block; |
||||
| 172 | } |
||||
| 173 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.