diff --git a/add.php b/add.php index 48eb69c..56c9861 100644 --- a/add.php +++ b/add.php @@ -84,7 +84,7 @@ $cid = Request::getInt('cid', 0, 'POST'); $cat_perms = Utility::getMyItemIds('adslight_submit'); - if (!\in_array($cid, $cat_perms, true)) { + if (!\in_array((int)$cid, $cat_perms, true)) { redirect_header(XOOPS_URL, 2, _NOPERM); } @@ -274,7 +274,7 @@ $cid = 0; $cat_perms = Utility::getMyItemIds('adslight_submit'); if (is_array($cat_perms) && $cat_perms !== []) { - if (!\in_array($cid, $cat_perms, true)) { + if (!\in_array((int)$cid, $cat_perms, true)) { //mb $helper->redirect('index.php', 3, _NOPERM); } diff --git a/addlisting.php b/addlisting.php index a7cd1ea..f832879 100644 --- a/addlisting.php +++ b/addlisting.php @@ -81,7 +81,7 @@ $cid = Request::getInt('cid', 0, 'POST'); $cat_perms = Utility::getMyItemIds('adslight_submit'); - if (!\in_array($cid, $cat_perms, true)) { + if (!\in_array((int)$cid, $cat_perms, true)) { redirect_header(XOOPS_URL, 2, _NOPERM); } @@ -280,7 +280,7 @@ $cid = Request::getInt('cid', 0, 'GET'); $cat_perms = Utility::getMyItemIds('adslight_submit'); if ((is_array($cat_perms) && $cat_perms !== []) && $cid > 0) { - if (!\in_array($cid, $cat_perms, true)) { + if (!\in_array((int)$cid, $cat_perms, true)) { $helper->redirect('index.php', 3, _NOPERM); } diff --git a/class/Utility.php b/class/Utility.php index 1ff067b..69d2450 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -226,7 +226,7 @@ public static function getTotalItems($sel_id, $status = ''): int $categories = self::getMyItemIds('adslight_view'); $count = 0; $arr = []; - if (\in_array($sel_id, $categories, true)) { + if (\in_array((int)$sel_id, $categories, true)) { $query = 'SELECT SQL_CACHE count(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . (int)$sel_id . " AND valid='Yes' AND status!='1'"; $result = $xoopsDB->query($query); @@ -234,7 +234,7 @@ public static function getTotalItems($sel_id, $status = ''): int $count = $thing; $arr = $mytree->getAllChildId($sel_id); foreach ($arr as $iValue) { - if (\in_array($iValue, $categories, true)) { + if (\in_array((int)$iValue, $categories, true)) { $query2 = 'SELECT SQL_CACHE count(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . (int)$iValue . " AND valid='Yes' AND status!='1'"; $result2 = $xoopsDB->query($query2); diff --git a/docs/changelog.txt b/docs/changelog.txt index ca0ea97..a93c861 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,8 +1,14 @@ -
2.4.0 Alpha-2 [NOT RELEASED]
Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3 +
2.4.0 Alpha-3 [NOT RELEASED]
Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3 +
+ +
2.4.0 Alpha-2 [2021-08-30]
Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3
- added sorting to Admin tables (mamba) - added paging and filter to Admin tables (mamba) - added Blocksadmin class (mamba) +- refactoring to Request (mamba) +- added castles to testdata (mamba) +- fixed in_array needles not being int for strict comparison (mamba)
2.4.0 Alpha-1 [2021-08-19]
Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3
diff --git a/index.php b/index.php index affc1a1..032cc67 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl'; -global $xoopsModule; +global $xoopsModule, $xoopsDB; require_once __DIR__ . '/header.php'; @@ -155,18 +155,18 @@ function index(): void $img = ''; } - $totallisting = Utility::getTotalItems($myrow['cid'], 1); + $totallisting = Utility::getTotalItems((int)$myrow['cid'], 1); $content .= $title . ' '; $arr = []; - if (\in_array($myrow['cid'], $categories, true)) { + if (\in_array((int)$myrow['cid'], $categories, true)) { $arr = $mytree->getFirstChild($myrow['cid'], 'title'); $space = 0; $chcount = 1; $subcategories = ''; if (1 === $GLOBALS['xoopsModuleConfig']['adslight_souscat']) { foreach ($arr as $ele) { - if (\in_array($ele['cid'], $categories, true)) { + if (\in_array((int)$ele['cid'], $categories, true)) { $chtitle = \htmlspecialchars($ele['title'], ENT_QUOTES | ENT_HTML5); if ($chcount > $GLOBALS['xoopsModuleConfig']['adslight_nbsouscat']) { $subcategories .= "" . _ADSLIGHT_CATPLUS . ''; @@ -341,7 +341,7 @@ function index(): void */ function categorynewgraphic($cid) { - global $xoopsDB; + global $xoopsDB, $xoopsModuleConfig; } ###################################################### diff --git a/members.php b/members.php index bbe2b18..5f9beee 100644 --- a/members.php +++ b/members.php @@ -203,7 +203,7 @@ if ($usid === $member_usid) { $istheirs = true; $GLOBALS['xoopsTpl']->assign('istheirs', $istheirs); - $modify_link = "\""'; + $modify_link = "\""'; } else { $istheirs = false; $GLOBALS['xoopsTpl']->assign('istheirs', ''); diff --git a/modify.php b/modify.php index a1697b2..48fb289 100644 --- a/modify.php +++ b/modify.php @@ -145,7 +145,7 @@ function delReply($r_lid, $ok): void /** * @param $lid */ -function modAd($lid): void +function modifyAd($lid): void { global $xoopsDB, $xoopsModule, $xoopsConfig, $myts; $contactselect = ''; @@ -362,7 +362,7 @@ function modAd($lid): void echo '
'; - echo ''; + echo ''; $moduleId = $xoopsModule->getVar('mid'); if (is_object($GLOBALS['xoopsUser'])) { @@ -412,7 +412,7 @@ function modAd($lid): void * @param $premium * @param $valid */ -function modAdS( +function modifyAds( $lid, $cat, $title, @@ -432,40 +432,47 @@ function modAdS( $contactby, $premium, $valid -): void { +) { global $xoopsDB, $myts; $helper = Helper::getInstance(); if (!$GLOBALS['xoopsSecurity']->check()) { $helper->redirect('index.php', 3, $GLOBALS['xoopsSecurity']->getErrors()); } - $title = $myts->addSlashes($title); - $status = $myts->addSlashes($status); - $expire = $myts->addSlashes($expire); - $type = $myts->addSlashes($type); - $desctext = $myts->displayTarea($desctext, 1, 1, 1, 1, 1); - $tel = $myts->addSlashes($tel); - $price = str_replace([' '], '', $price); - $typeprice = $myts->addSlashes($typeprice); - $typecondition = $myts->addSlashes($typecondition); - $submitter = $myts->addSlashes($submitter); - $town = $myts->addSlashes($town); - $country = $myts->addSlashes($country); - $contactby = $myts->addSlashes($contactby); - $premium = $myts->addSlashes($premium); - - $xoopsDB->query( - 'UPDATE ' - . $xoopsDB->prefix('adslight_listing') - . " SET cid='${cat}', title='${title}', status='${status}', expire='${expire}', type='${type}', desctext='${desctext}', tel='${tel}', price='${price}', typeprice='${typeprice}', typecondition='${typecondition}', email='${email}', submitter='${submitter}', town='${town}', country='${country}', contactby='${contactby}', premium='${premium}', valid='${valid}' WHERE lid=${lid}" - ); + + $sql = 'UPDATE ' + . $xoopsDB->prefix('adslight_listing') + . " SET cid='${cat}', title='${title}', status='${status}', expire='${expire}', type='${type}', desctext='${desctext}', tel='${tel}', price='${price}', typeprice='${typeprice}', typecondition='${typecondition}', email='${email}', submitter='${submitter}', town='${town}', country='${country}', contactby='${contactby}', premium='${premium}', valid='${valid}' WHERE lid=${lid}"; + $result = $xoopsDB->query($sql); $helper->redirect('index.php', 1, _ADSLIGHT_ANNMOD2); } #################################################### -foreach ($_POST as $k => $v) { - ${$k} = $v; -} +//foreach ($_POST as $k => $v) { +// ${$k} = $v; +//} + +$cid = Request::getInt('cid', 0, 'POST'); +$contactby = Request::getInt('contactby', 0, 'POST'); +$country = Request::getString('country', '', 'POST'); +$date_created = Request::getInt('date_created', time(), 'POST'); +$desctext = Request::getText('Description', '', 'POST'); +$email = Request::getString('email', '', 'POST'); +$expire = Request::getInt('expire', 14, 'POST'); +$lid = Request::getInt('lid', 0, 'POST'); +$op = Request::getCmd('op', '', 'POST'); +$premium = Request::getInt('premium', 0, 'POST'); +$price = Request::getFloat('price', 0.00, 'POST'); +$status = Request::getInt('status', 0, 'POST'); +$submitter = Request::getInt('submitter', 0, 'POST'); +$tel = Request::getString('tel', '', 'POST'); +$title = Request::getString('title', '', 'POST'); +$town = Request::getString('town', '', 'POST'); +$type = Request::getInt('type', 0, 'POST'); +$typecondition = Request::getInt('typecondition', 0, 'POST'); +$typeprice = Request::getInt('typeprice', 0, 'POST'); +$valid = Request::getString('valid', '', 'POST'); + $ok = Request::getString('ok', '', 'GET'); if (!Request::hasVar('lid', 'POST') && Request::hasVar('lid', 'GET')) { @@ -475,16 +482,16 @@ function modAdS( $r_lid = Request::getInt('r_lid', '', 'GET'); } if (!Request::hasVar('op', 'POST') && Request::hasVar('op', 'GET')) { - $op = Request::getString('op', '', 'GET'); + $op = Request::getCmd('op', '', 'GET'); } switch ($op) { - case 'ModAd': + case 'modad': require_once XOOPS_ROOT_PATH . '/header.php'; - modAd($lid); + modifyAd($lid); require_once XOOPS_ROOT_PATH . '/footer.php'; break; - case 'ModAdS': - modAdS( + case 'modads': + modifyAds( $lid, $cid, $title, diff --git a/search.php b/search.php index 70210be..8b91ae2 100644 --- a/search.php +++ b/search.php @@ -157,7 +157,7 @@ echo '
'; foreach ($mids as $mid) { $mid = (int)$mid; - if (\in_array($mid, $available_modules, true)) { + if (\in_array((int)$mid, $available_modules, true)) { $module = $modules[$mid]; $results = $module->search($queries, $andor, 5, 0); $count = 0; diff --git a/templates/adslight_index.tpl b/templates/adslight_index.tpl index f21a2d7..8c291e8 100644 --- a/templates/adslight_index.tpl +++ b/templates/adslight_index.tpl @@ -86,7 +86,7 @@
<{$item.type}>
<{if $item.price|default:'' !=""}> - <{$item.price}> - <{$item.price_typeprice}> + <{$item.price}>  <{else}>  <{/if}>
<{if $item.sold|default:''}><{$item.sold}><{/if}> diff --git a/viewads.php b/viewads.php index 512b900..03a1f21 100644 --- a/viewads.php +++ b/viewads.php @@ -326,7 +326,7 @@ function viewAds($lid = 0): void $GLOBALS['xoopsTpl']->assign('xoop_user', true); $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E'); if ($usid == $currentid) { - $GLOBALS['xoopsTpl']->assign('modifyads', '' . _ADSLIGHT_MODIFANN . '  ' . _ADSLIGHT_MODIFANN . ''); + $GLOBALS['xoopsTpl']->assign('modifyads', '' . _ADSLIGHT_MODIFANN . '  ' . _ADSLIGHT_MODIFANN . ''); $GLOBALS['xoopsTpl']->assign('deleteads', '' . _ADSLIGHT_SUPPRANN . '  ' . _ADSLIGHT_SUPPRANN . ''); $GLOBALS['xoopsTpl']->assign('add_photos', '' . _ADSLIGHT_SUPPRANN . '  ' . _ADSLIGHT_ADD_PHOTOS . ''); diff --git a/viewcats.php b/viewcats.php index 8899b2c..ac3e26e 100644 --- a/viewcats.php +++ b/viewcats.php @@ -217,7 +217,7 @@ function adsView($cid, $min, $orderby, $show = 0): void if (count($arr) > 0) { $scount = 1; foreach ($arr as $ele) { - if (\in_array($ele['cid'], $categories, true)) { + if (\in_array((int)$ele['cid'], $categories, true)) { $sub_arr = []; $sub_arr = $mytree->getFirstChild($ele['cid'], 'title'); $space = 0; @@ -225,7 +225,7 @@ function adsView($cid, $min, $orderby, $show = 0): void $infercategories = ''; $totallisting = Utility::getTotalItems($ele['cid'], 1); foreach ($sub_arr as $sub_ele) { - if (\in_array($sub_ele['cid'], $categories, true)) { + if (\in_array((int)$sub_ele['cid'], $categories, true)) { $chtitle = \htmlspecialchars($sub_ele['title'], ENT_QUOTES | ENT_HTML5); if ($chcount > 5) { diff --git a/xoops_version.php b/xoops_version.php index 31a1499..dae6d85 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -48,8 +48,8 @@ } $modversion['version'] = '2.4'; -$modversion['module_status'] = 'Alpha 2 NOT RELEASED'; -$modversion['release_date'] = '2021/08/23'; +$modversion['module_status'] = 'Alpha 2'; +$modversion['release_date'] = '2021/08/30'; $modversion['name'] = _MI_ADSLIGHT_NAME; $modversion['description'] = _MI_ADSLIGHT_DESC; $modversion['credits'] = 'AdsLight';