XoopsModules25x /
oledrion
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 |
||
| 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 | * oledrion |
||
| 14 | * |
||
| 15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
| 17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Recherche dans les produits |
||
| 22 | */ |
||
| 23 | |||
| 24 | use XoopsModules\Oledrion; |
||
| 25 | |||
| 26 | require_once __DIR__ . '/header.php'; |
||
| 27 | // require_once OLEDRION_PATH . 'class/tree.php'; |
||
| 28 | $GLOBALS['current_category'] = -1; // Pour le bloc des catégories |
||
| 29 | $GLOBALS['xoopsOption']['template_main'] = 'oledrion_search.tpl'; |
||
| 30 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 31 | |||
| 32 | $limit = Oledrion\Utility::getModuleOption('newproducts'); // Nombre maximum d'éléments à afficher |
||
| 33 | $categories = $manufacturers = $vendors = []; |
||
| 34 | $baseurl = OLEDRION_URL . basename(__FILE__); // URL de ce script (sans son nom) |
||
| 35 | |||
| 36 | $xoopsTpl->assign('mod_pref', $mod_pref); // Module Preferences |
||
| 37 | $xoopsTpl->assign('columnsCount', Oledrion\Utility::getModuleOption('category_colums')); |
||
| 38 | |||
| 39 | $categories = $categoryHandler->getAllCategories(new Oledrion\Parameters()); |
||
| 40 | $vendors = $vendorsHandler->getAllVendors(new Oledrion\Parameters()); |
||
| 41 | $manufacturers = $manufacturerHandler->getItems(0, 0, 'manu_name', 'ASC', false); |
||
| 42 | |||
| 43 | if ((isset($_POST['op']) && 'go' === $_POST['op']) || isset($_GET['start'])) { |
||
| 44 | // Recherche des résultats |
||
| 45 | $xoopsTpl->assign('search_results', true); |
||
| 46 | $xoopsTpl->assign('global_advert', Oledrion\Utility::getModuleOption('advertisement')); |
||
| 47 | $xoopsTpl->assign('breadcrumb', Oledrion\Utility::breadcrumb([OLEDRION_URL . basename(__FILE__) => _OLEDRION_SEARCHRESULTS])); |
||
| 48 | Oledrion\Utility::setMetas(Oledrion\Utility::getModuleName() . ' - ' . _OLEDRION_SEARCHRESULTS, Oledrion\Utility::getModuleName() . ' - ' . _OLEDRION_SEARCHRESULTS); |
||
| 49 | |||
| 50 | if (!isset($_GET['start'])) { |
||
| 51 | $sql = 'SELECT b.product_id, b.product_title, b.product_submitted, b.product_submitter, b.product_thumb_url, b.product_price, b.product_property1, b.product_property2, b.product_property3, b.product_property4, b.product_property5, b.product_property6, b.product_property7, b.product_property8, b.product_property9, b.product_property10, b.product_stock, b.product_summary FROM ' |
||
| 52 | . $xoopsDB->prefix('oledrion_products') |
||
| 53 | . ' b, ' |
||
| 54 | . $xoopsDB->prefix('oledrion_productsmanu') |
||
| 55 | . ' a WHERE (b.product_id = a.pm_product_id AND b.product_online = 1) '; |
||
| 56 | if (0 == Oledrion\Utility::getModuleOption('show_unpublished')) { |
||
| 57 | // Ne pas afficher les produits qui ne sont pas publiés |
||
| 58 | $sql .= ' AND b.product_submitted <= ' . time(); |
||
| 59 | } |
||
| 60 | if (0 == Oledrion\Utility::getModuleOption('nostock_display')) { |
||
| 61 | // Se limiter aux seuls produits encore en stock |
||
| 62 | $sql .= ' AND b.product_stock > 0'; |
||
| 63 | } |
||
| 64 | $sql .= ') '; |
||
| 65 | |||
| 66 | // Recherche sur une catégorie |
||
| 67 | if (\Xmf\Request::hasVar('product_category', 'POST')) { |
||
| 68 | $cat_cid = \Xmf\Request::getInt('product_category', 0, 'POST'); |
||
| 69 | if ($cat_cid > 0) { |
||
| 70 | $sql .= 'AND (b.product_cid = ' . $cat_cid . ')'; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | // Recherche sur les fabricants |
||
| 75 | if (\Xmf\Request::hasVar('product_manufacturers', 'POST')) { |
||
| 76 | $submittedManufacturers = null; |
||
| 77 | $submittedManufacturers = $_POST['product_manufacturers']; |
||
| 78 | if (is_array($submittedManufacturers) && 0 == (int)$submittedManufacturers[0]) { |
||
| 79 | $submittedManufacturers = array_shift($submittedManufacturers); |
||
| 80 | } |
||
| 81 | if ($submittedManufacturers && is_array($submittedManufacturers)) { |
||
| 82 | array_walk($submittedManufacturers, 'intval'); |
||
| 83 | $sql .= ' AND (a.pm_manu_id IN ( ' . implode(',', $submittedManufacturers) . '))'; |
||
| 84 | } else { |
||
| 85 | $submittedManufacturer = (int)$submittedManufacturers; |
||
| 86 | if ($submittedManufacturer > 0) { |
||
| 87 | $sql .= ' AND (a.pm_manu_id = ' . $submittedManufacturer . ')'; |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 92 | // Recherche sur les vendeurs |
||
| 93 | if (\Xmf\Request::hasVar('product_vendors', 'POST')) { |
||
| 94 | $vendor = \Xmf\Request::getInt('product_vendors', 0, 'POST'); |
||
| 95 | if ($vendor > 0) { |
||
| 96 | $sql .= ' AND (product_vendor_id = ' . $vendor . ')'; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | // set from |
||
| 101 | if (\Xmf\Request::hasVar('product_from', 'POST')) { |
||
| 102 | $product_from = \Xmf\Request::getInt('product_from', 0, 'POST'); |
||
| 103 | if ($product_from > 0) { |
||
| 104 | $sql .= ' AND (product_price > ' . $product_from . ')'; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | // set to |
||
| 109 | if (\Xmf\Request::hasVar('product_to', 'POST')) { |
||
| 110 | $product_to = \Xmf\Request::getInt('product_to', 0, 'POST'); |
||
| 111 | if ($product_to > 0) { |
||
| 112 | $sql .= ' AND (product_price < ' . $product_to . ')'; |
||
| 113 | } |
||
| 114 | } |
||
| 115 | |||
| 116 | if (2 == $_POST['product_stock']) { |
||
| 117 | $sql .= ' AND (product_stock > 0)'; |
||
| 118 | } elseif (0 == $_POST['product_stock']) { |
||
| 119 | $sql .= ' AND (product_stock = 0)'; |
||
| 120 | } |
||
| 121 | |||
| 122 | if (\Xmf\Request::hasVar('product_property1', 'POST')) { |
||
| 123 | if ($_POST['product_property1']) { |
||
| 124 | $sql .= ' AND (b.product_property1 = "' . $_POST['product_property1'] . '")'; |
||
| 125 | } |
||
| 126 | } |
||
| 127 | |||
| 128 | if (\Xmf\Request::hasVar('product_property2', 'POST')) { |
||
| 129 | if ($_POST['product_property2']) { |
||
| 130 | $sql .= ' AND (b.product_property2 = "' . $_POST['product_property2'] . '")'; |
||
| 131 | } |
||
| 132 | } |
||
| 133 | |||
| 134 | if (\Xmf\Request::hasVar('product_property3', 'POST')) { |
||
| 135 | if ($_POST['product_property3']) { |
||
| 136 | $sql .= ' AND (b.product_property3 = "' . $_POST['product_property3'] . '")'; |
||
| 137 | } |
||
| 138 | } |
||
| 139 | |||
| 140 | if (\Xmf\Request::hasVar('product_property4', 'POST')) { |
||
| 141 | if ($_POST['product_property4']) { |
||
| 142 | $sql .= ' AND (b.product_property4 = "' . $_POST['product_property4'] . '")'; |
||
| 143 | } |
||
| 144 | } |
||
| 145 | |||
| 146 | if (\Xmf\Request::hasVar('product_property5', 'POST')) { |
||
| 147 | if ($_POST['product_property5']) { |
||
| 148 | $sql .= ' AND (b.product_property5 = "' . $_POST['product_property5'] . '")'; |
||
| 149 | } |
||
| 150 | } |
||
| 151 | |||
| 152 | if (\Xmf\Request::hasVar('product_property6', 'POST')) { |
||
| 153 | if ($_POST['product_property6']) { |
||
| 154 | $sql .= ' AND (b.product_property6 = "' . $_POST['product_property6'] . '")'; |
||
| 155 | } |
||
| 156 | } |
||
| 157 | |||
| 158 | if (\Xmf\Request::hasVar('product_property7', 'POST')) { |
||
| 159 | if ($_POST['product_property7']) { |
||
| 160 | $sql .= ' AND (b.product_property7 = "' . $_POST['product_property7'] . '")'; |
||
| 161 | } |
||
| 162 | } |
||
| 163 | |||
| 164 | if (\Xmf\Request::hasVar('product_property8', 'POST')) { |
||
| 165 | if ($_POST['product_property8']) { |
||
| 166 | $sql .= ' AND (b.product_property8 = "' . $_POST['product_property8'] . '")'; |
||
| 167 | } |
||
| 168 | } |
||
| 169 | |||
| 170 | if (\Xmf\Request::hasVar('product_property9', 'POST')) { |
||
| 171 | if ($_POST['product_property9']) { |
||
| 172 | $sql .= ' AND (b.product_property9 = "' . $_POST['product_property9'] . '")'; |
||
| 173 | } |
||
| 174 | } |
||
| 175 | |||
| 176 | if (\Xmf\Request::hasVar('product_property10', 'POST')) { |
||
| 177 | if ($_POST['product_property10']) { |
||
| 178 | $sql .= ' AND (b.product_property10 = "' . $_POST['product_property10'] . '")'; |
||
| 179 | } |
||
| 180 | } |
||
| 181 | |||
| 182 | // Recherche sur du texte |
||
| 183 | if (\Xmf\Request::hasVar('product_text', 'POST') && '' !== xoops_trim($_POST['product_text'])) { |
||
| 184 | $temp_queries = $queries = []; |
||
| 185 | $temp_queries = preg_split('/[\s,]+/', $_POST['product_text']); |
||
| 186 | |||
| 187 | foreach ($temp_queries as $q) { |
||
| 188 | $q = trim($q); |
||
| 189 | $queries[] = $myts->addSlashes($q); |
||
| 190 | } |
||
| 191 | if (count($queries) > 0) { |
||
| 192 | $tmpObject = new Oledrion\Products(); |
||
| 193 | $datas = $tmpObject->getVars(); |
||
| 194 | $fields = []; |
||
| 195 | $cnt = 0; |
||
| 196 | foreach ($datas as $key => $value) { |
||
| 197 | if (XOBJ_DTYPE_TXTBOX == $value['data_type'] || XOBJ_DTYPE_TXTAREA == $value['data_type']) { |
||
| 198 | if (0 == $cnt) { |
||
| 199 | $fields[] = 'b.' . $key; |
||
| 200 | } else { |
||
| 201 | $fields[] = ' OR b.' . $key; |
||
| 202 | } |
||
| 203 | ++$cnt; |
||
| 204 | } |
||
| 205 | } |
||
| 206 | $count = count($queries); |
||
| 207 | $cnt = 0; |
||
| 208 | $sql .= ' AND '; |
||
| 209 | $searchType = \Xmf\Request::getInt('search_type', 0, 'POST'); |
||
| 210 | $andor = ' OR '; |
||
| 211 | foreach ($queries as $oneQuery) { |
||
| 212 | $sql .= '('; |
||
| 213 | switch ($searchType) { |
||
| 214 | case 0: // Commence par |
||
| 215 | |||
| 216 | $cond = " LIKE '" . $oneQuery . "%' "; |
||
| 217 | |||
| 218 | break; |
||
| 219 | case 1: // Finit par |
||
| 220 | |||
| 221 | $cond = " LIKE '%" . $oneQuery . "' "; |
||
| 222 | |||
| 223 | break; |
||
| 224 | case 2: // Correspond Ă |
||
| 225 | |||
| 226 | $cond = " = '" . $oneQuery . "' "; |
||
| 227 | |||
| 228 | break; |
||
| 229 | case 3: // Contient |
||
| 230 | |||
| 231 | $cond = " LIKE '%" . $oneQuery . "%' "; |
||
| 232 | |||
| 233 | break; |
||
| 234 | } |
||
| 235 | $sql .= implode($cond, $fields) . $cond . ')'; |
||
| 236 | ++$cnt; |
||
| 237 | if ($cnt != $count) { |
||
| 238 | $sql .= ' ' . $andor . ' '; |
||
| 239 | } |
||
| 240 | } |
||
| 241 | } |
||
| 242 | } |
||
| 243 | $_SESSION['criteria_oledrion'] = serialize($sql); |
||
| 244 | } else { |
||
| 245 | // $_GET['start'] est en place, on a cliqué sur un chevron pour aller voir les autres pages, il faut travailler à partir des informations de la session |
||
| 246 | if (\Xmf\Request::hasVar('criteria_oledrion', 'SESSION')) { |
||
| 247 | $sql = unserialize($_SESSION['criteria_oledrion']); |
||
| 248 | } |
||
| 249 | } |
||
| 250 | $start = \Xmf\Request::getInt('start', 0, 'GET'); |
||
| 251 | $sqlCount = str_replace('b.product_id, b.product_title, b.product_submitted, b.product_submitter', 'Count(*) as cpt', $sql); |
||
| 252 | $result = $xoopsDB->query($sqlCount); |
||
| 253 | $rowCount = $xoopsDB->fetchArray($result); |
||
| 254 | if ($rowCount['cpt'] > $limit) { |
||
| 255 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
| 256 | $pagenav = new \XoopsPageNav($rowCount['cpt'], $limit, $start, 'start'); |
||
| 257 | $xoopsTpl->assign('pagenav', $pagenav->renderNav()); |
||
| 258 | } |
||
| 259 | |||
| 260 | $sql .= ' GROUP BY b.product_id ORDER BY product_submitted DESC'; |
||
| 261 | $result = $xoopsDB->query($sql, $limit, $start); |
||
| 262 | $ret = []; |
||
| 263 | $tempProduct = $productsHandler->create(true); |
||
| 264 | $count = 1; |
||
| 265 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||
| 266 | $ret = []; |
||
| 267 | $ret['product_url_rewrited'] = $tempProduct->getLink($myrow['product_id'], $myrow['product_title']); |
||
| 268 | $ret['product_title'] = $myts->htmlSpecialChars($myrow['product_title']); |
||
| 269 | $ret['product_href_title'] = Oledrion\Utility::makeHrefTitle($myts->htmlSpecialChars($myrow['product_title'])); |
||
| 270 | $ret['product_time'] = $myrow['product_submitted']; |
||
| 271 | $ret['product_uid'] = $myrow['product_submitter']; |
||
| 272 | $ret['product_id'] = $myrow['product_id']; |
||
| 273 | $ret['product_thumb_url'] = $myrow['product_thumb_url']; |
||
| 274 | $ret['product_thumb_full_url'] = OLEDRION_PICTURES_URL . '/' . $myrow['product_thumb_url']; |
||
| 275 | $ret['product_property1'] = $myrow['product_property1']; |
||
| 276 | $ret['product_property2'] = $myrow['product_property2']; |
||
| 277 | $ret['product_property3'] = $myrow['product_property3']; |
||
| 278 | $ret['product_property4'] = $myrow['product_property4']; |
||
| 279 | $ret['product_property5'] = $myrow['product_property5']; |
||
| 280 | $ret['product_property6'] = $myrow['product_property6']; |
||
| 281 | $ret['product_property7'] = $myrow['product_property7']; |
||
| 282 | $ret['product_property8'] = $myrow['product_property8']; |
||
| 283 | $ret['product_property9'] = $myrow['product_property9']; |
||
| 284 | $ret['product_property10'] = $myrow['product_property10']; |
||
| 285 | $ret['product_price'] = $myrow['product_price']; |
||
| 286 | if (0 == $myrow['product_price']) { |
||
| 287 | $criteria = new \CriteriaCompo(); |
||
| 288 | $criteria->add(new \Criteria('attribute_product_id', $myrow['product_id'])); |
||
| 289 | $attribute = $attributesHandler->getObjects($criteria, false); |
||
| 290 | foreach ($attribute as $root) { |
||
| 291 | $ret['product_price'] = $root->getVar('attribute_default_value'); |
||
| 292 | } |
||
| 293 | } |
||
| 294 | $ret['product_stock'] = $myrow['product_stock']; |
||
| 295 | $ret['product_price_ttc'] = Oledrion\Utility::getTTC($ret['product_price'], ''); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 296 | $ret['product_count'] = $count; |
||
| 297 | $ret['product_summary'] = $myrow['product_summary']; |
||
| 298 | $xoopsTpl->append('products', $ret); |
||
| 299 | ++$count; |
||
| 300 | } |
||
| 301 | unset($tempProduct); |
||
| 302 | } else { |
||
| 303 | $xoopsTpl->assign('search_results', false); |
||
| 304 | $xoopsTpl->assign('global_advert', Oledrion\Utility::getModuleOption('advertisement')); |
||
| 305 | $xoopsTpl->assign('breadcrumb', Oledrion\Utility::breadcrumb([OLEDRION_URL . basename(__FILE__) => _OLEDRION_SEARCHFOR])); |
||
| 306 | Oledrion\Utility::setMetas(Oledrion\Utility::getModuleName() . ' - ' . _OLEDRION_SEARCHFOR, Oledrion\Utility::getModuleName() . ' - ' . _OLEDRION_SEARCHFOR); |
||
| 307 | } |
||
| 308 | |||
| 309 | require_once OLEDRION_PATH . 'include/product_search_form.php'; |
||
| 310 | $sform = Oledrion\Utility::formMarkRequiredFields($sform); |
||
| 311 | $xoopsTpl->assign('search_form', $sform->render()); |
||
|
0 ignored issues
–
show
Are you sure the usage of
$sform->render() targeting XoopsForm::render() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||
| 312 | |||
| 313 | Oledrion\Utility::setCSS(); |
||
| 314 | Oledrion\Utility::setLocalCSS($xoopsConfig['language']); |
||
| 315 | |||
| 316 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 317 |