Skip to content

Commit

Permalink
2.4 Alpha 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Aug 30, 2021
1 parent faeb7b4 commit 1694b40
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 52 deletions.
4 changes: 2 additions & 2 deletions add.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions addlisting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions class/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ 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);
[$thing] = $xoopsDB->fetchRow($result);
$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);
Expand Down
8 changes: 7 additions & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<h5>2.4.0 Alpha-2 [NOT RELEASED]</h5> Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3
<h5>2.4.0 Alpha-3 [NOT RELEASED]</h5> Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3
<hr>

<h5>2.4.0 Alpha-2 [2021-08-30]</h5> Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3
<hr>
- 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)

<h5>2.4.0 Alpha-1 [2021-08-19]</h5> Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.0.9, PHP 8.1.0 Beta 3
<hr>
Expand Down
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

$GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl';

global $xoopsModule;
global $xoopsModule, $xoopsDB;

require_once __DIR__ . '/header.php';

Expand Down Expand Up @@ -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 .= "<a href=\"viewcats.php?cid={$myrow['cid']}\">" . _ADSLIGHT_CATPLUS . '</a>';
Expand Down Expand Up @@ -341,7 +341,7 @@ function index(): void
*/
function categorynewgraphic($cid)
{
global $xoopsDB;
global $xoopsDB, $xoopsModuleConfig;
}

######################################################
Expand Down
2 changes: 1 addition & 1 deletion members.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
if ($usid === $member_usid) {
$istheirs = true;
$GLOBALS['xoopsTpl']->assign('istheirs', $istheirs);
$modify_link = "<a href='modify.php?op=ModAd&amp;lid=" . $lid . "'><img src='" . $pathIcon16 . "/edit.png' border=0 alt=\"" . _ADSLIGHT_MODADMIN . '" ></a>';
$modify_link = "<a href='modify.php?op=modad&amp;lid=" . $lid . "'><img src='" . $pathIcon16 . "/edit.png' border=0 alt=\"" . _ADSLIGHT_MODADMIN . '" ></a>';
} else {
$istheirs = false;
$GLOBALS['xoopsTpl']->assign('istheirs', '');
Expand Down
71 changes: 39 additions & 32 deletions modify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -362,7 +362,7 @@ function modAd($lid): void
echo '</td></tr>
<td colspan=2><br><input type="submit" value="' . _ADSLIGHT_MODIFANN . '" ></td>
</tr></table>';
echo '<input type="hidden" name="op" value="ModAdS" >';
echo '<input type="hidden" name="op" value="modads" >';

$moduleId = $xoopsModule->getVar('mid');
if (is_object($GLOBALS['xoopsUser'])) {
Expand Down Expand Up @@ -412,7 +412,7 @@ function modAd($lid): void
* @param $premium
* @param $valid
*/
function modAdS(
function modifyAds(
$lid,
$cat,
$title,
Expand All @@ -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')) {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
echo '<br>';
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;
Expand Down
2 changes: 1 addition & 1 deletion templates/adslight_index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</strong><br>
<{$item.type}><br>
<{if $item.price|default:'' !=""}>
<strong><{$item.price}></strong>&nbsp;-&nbsp;<{$item.price_typeprice}>
<strong><{$item.price}></strong>&nbsp;
<{else}>&nbsp;
<{/if}><br>
<{if $item.sold|default:''}><{$item.sold}><{/if}>
Expand Down
2 changes: 1 addition & 1 deletion viewads.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<img src=' . $pathIcon16 . '/edit.png border="0" alt="' . _ADSLIGHT_MODIFANN . '" >&nbsp;&nbsp;<a href="modify.php?op=ModAd&amp;lid=' . $lid . '">' . _ADSLIGHT_MODIFANN . '</a>');
$GLOBALS['xoopsTpl']->assign('modifyads', '<img src=' . $pathIcon16 . '/edit.png border="0" alt="' . _ADSLIGHT_MODIFANN . '" >&nbsp;&nbsp;<a href="modify.php?op=modad&amp;lid=' . $lid . '">' . _ADSLIGHT_MODIFANN . '</a>');
$GLOBALS['xoopsTpl']->assign('deleteads', '<img src=' . $pathIcon16 . '/delete.png border="0" alt="' . _ADSLIGHT_SUPPRANN . '" >&nbsp;&nbsp;<a href="modify.php?op=ListingDel&amp;lid=' . $lid . '">' . _ADSLIGHT_SUPPRANN . '</a>');
$GLOBALS['xoopsTpl']->assign('add_photos', '<img src="assets/images/shape_square_add.png" border="0" alt="' . _ADSLIGHT_SUPPRANN . '" >&nbsp;&nbsp;<a href="view_photos.php?lid=' . $lid . '&uid=' . $usid . '">' . _ADSLIGHT_ADD_PHOTOS . '</a>');

Expand Down
4 changes: 2 additions & 2 deletions viewcats.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ 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;
$chcount = 0;
$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) {
Expand Down
4 changes: 2 additions & 2 deletions xoops_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 1694b40

Please sign in to comment.