mambax7 /
adslight
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | /* |
||
| 3 | ------------------------------------------------------------------------- |
||
| 4 | ADSLIGHT 2 : Module for Xoops |
||
| 5 | |||
| 6 | Redesigned and ameliorate By Luc Bizet user at www.frxoops.org |
||
| 7 | Started with the Classifieds module and made MANY changes |
||
| 8 | Website : http://www.luc-bizet.fr |
||
| 9 | Contact : [email protected] |
||
| 10 | ------------------------------------------------------------------------- |
||
| 11 | Original credits below Version History |
||
| 12 | ########################################################################## |
||
| 13 | # Classified Module for Xoops # |
||
| 14 | # By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com # |
||
| 15 | # Started with the MyAds module and made MANY changes # |
||
| 16 | ########################################################################## |
||
| 17 | Original Author: Pascal Le Boustouller |
||
| 18 | Author Website : [email protected] |
||
| 19 | Licence Type : GPL |
||
| 20 | ------------------------------------------------------------------------- |
||
| 21 | */ |
||
| 22 | |||
| 23 | use Xmf\Request; |
||
| 24 | |||
| 25 | include_once __DIR__ . '/header.php'; |
||
| 26 | require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php'; |
||
| 27 | xoops_load('XoopsLocal'); |
||
| 28 | $tempXoopsLocal = new XoopsLocal; |
||
| 29 | $myts = MyTextSanitizer::getInstance(); |
||
| 30 | $module_id = $xoopsModule->getVar('mid'); |
||
| 31 | |||
| 32 | View Code Duplication | if (is_object($GLOBALS['xoopsUser'])) { |
|
| 33 | $groups = $GLOBALS['xoopsUser']->getGroups(); |
||
| 34 | } else { |
||
| 35 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
| 36 | } |
||
| 37 | /** @var XoopsGroupPermHandler $gpermHandler */ |
||
| 38 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 39 | |||
| 40 | $perm_itemid = Request::getInt('item_id', 0, 'POST'); |
||
| 41 | |||
| 42 | View Code Duplication | if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) { |
|
| 43 | redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM); |
||
| 44 | } |
||
| 45 | if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) { |
||
| 46 | $prem_perm = '0'; |
||
| 47 | } else { |
||
| 48 | $prem_perm = '1'; |
||
| 49 | } |
||
| 50 | |||
| 51 | include XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php'; |
||
| 52 | //include XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.php'; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
38% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 53 | $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
||
| 54 | |||
| 55 | # function view (categories) |
||
| 56 | ##################################################### |
||
| 57 | /** |
||
| 58 | * @param int $cid |
||
| 59 | * @param int $min |
||
| 60 | * @param $orderby |
||
| 61 | * @param int $show |
||
| 62 | */ |
||
| 63 | function adsView($cid = 0, $min = 0, $orderby, $show = 0) |
||
| 64 | { |
||
| 65 | global $xoopsDB, $xoopsTpl, $xoopsConfig, $myts, $mytree, $imagecat, $meta, $moduleDirName, $main_lang, $mid, $prem_perm, $xoopsModule; |
||
| 66 | $pathIcon16 = $xoopsModule->getInfo('icons16'); |
||
| 67 | |||
| 68 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl'; |
||
| 69 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 70 | |||
| 71 | $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid')); |
||
| 72 | $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); |
||
| 73 | $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); |
||
| 74 | $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); |
||
| 75 | $xoopsTpl->assign('only_pix', _ADSLIGHT_ONLYPIX); |
||
| 76 | $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK); |
||
| 77 | $xoopsTpl->assign('permit', $prem_perm); |
||
| 78 | |||
| 79 | $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" />'); |
||
| 80 | |||
| 81 | // $adslight_use_catscode = $GLOBALS['xoopsModuleConfig']['adslight_use_catscode']; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 82 | // $adslight_cats_code = $GLOBALS['xoopsModuleConfig']['adslight_cats_code']; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 83 | |||
| 84 | $xoopsTpl->assign('adslight_use_catscode', $GLOBALS['xoopsModuleConfig']['adslight_use_catscode']); |
||
| 85 | $xoopsTpl->assign('adslight_cats_code', $GLOBALS['xoopsModuleConfig']['adslight_cats_code']); |
||
| 86 | |||
| 87 | $banner = xoops_getbanner(); |
||
| 88 | $xoopsTpl->assign('banner', $banner); |
||
| 89 | // $index_code_place = $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 90 | // $use_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 91 | // $adslight_use_banner = $GLOBALS['xoopsModuleConfig']['adslight_use_banner']; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 92 | // $index_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_index_code']; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 93 | |||
| 94 | $xoopsTpl->assign('use_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']); |
||
| 95 | $xoopsTpl->assign('adslight_use_banner', $GLOBALS['xoopsModuleConfig']['adslight_use_banner']); |
||
| 96 | $xoopsTpl->assign('index_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_index_code']); |
||
| 97 | $xoopsTpl->assign('index_code_place', $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']); |
||
| 98 | |||
| 99 | // adslight 2 |
||
| 100 | $xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']); |
||
| 101 | $xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']); |
||
| 102 | |||
| 103 | /// No Adds in this Cat /// |
||
| 104 | $submit_perms = AdslightUtilities::getMyItemIds('adslight_submit'); |
||
| 105 | |||
| 106 | if ($GLOBALS['xoopsUser'] && is_array($submit_perms) && count($submit_perms) > 0) { |
||
| 107 | $xoopsTpl->assign('not_adds_in_this_cat', |
||
| 108 | '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_NOTADDSSUBMIT . '</a>'); |
||
| 109 | } else { |
||
| 110 | $xoopsTpl->assign('not_adds_in_this_cat', |
||
| 111 | '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<br>' . _ADSLIGHT_ADD_LISTING_BULL . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.'); |
||
| 112 | } |
||
| 113 | |||
| 114 | $xoopsTpl->assign('Feed_RSS_cat', ' <a href="rss.php?cid=' . addslashes($cid) . '"><img border="0" alt="Feed RSS" src="assets/images/rssfeed_buttons.png" /></a>'); |
||
| 115 | |||
| 116 | if ($GLOBALS['xoopsUser']) { |
||
| 117 | $member_usid = $GLOBALS['xoopsUser']->getVar('uid'); |
||
| 118 | if ($usid = $member_usid) { |
||
| 119 | $xoopsTpl->assign('istheirs', true); |
||
| 120 | |||
| 121 | list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $member_usid . '')); |
||
| 122 | |||
| 123 | $xoopsTpl->assign('show_user', $show_user); |
||
| 124 | $xoopsTpl->assign('show_user_link', 'members.php?usid=' . $member_usid); |
||
| 125 | } |
||
| 126 | } |
||
| 127 | |||
| 128 | $default_sort = $GLOBALS['xoopsModuleConfig']['adslight_lsort_order']; |
||
| 129 | |||
| 130 | $cid = ((int)$cid > 0) ? (int)$cid : 0; |
||
| 131 | $min = ((int)$min > 0) ? (int)$min : 0; |
||
| 132 | $show = ((int)$show > 0) ? (int)$show : $GLOBALS['xoopsModuleConfig']['adslight_perpage']; |
||
| 133 | $max = $min + $show; |
||
| 134 | $orderby = isset($orderby) ? AdslightUtilities::convertOrderByIn($orderby) : $default_sort; |
||
| 135 | |||
| 136 | $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload']; |
||
|
0 ignored issues
–
show
$updir is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 137 | $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); |
||
| 138 | $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); |
||
| 139 | $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); |
||
| 140 | $xoopsTpl->assign('subcat_title2', _ADSLIGHT_ANNONCES); |
||
| 141 | |||
| 142 | $categories = AdslightUtilities::getMyItemIds('adslight_view'); |
||
| 143 | View Code Duplication | if (is_array($categories) && count($categories) > 0) { |
|
| 144 | if (!in_array($cid, $categories)) { |
||
| 145 | redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM); |
||
| 146 | } |
||
| 147 | } else { // User can't see any category |
||
| 148 | redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM); |
||
| 149 | } |
||
| 150 | |||
| 151 | $arrow = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="»" />'; |
||
|
0 ignored issues
–
show
$arrow is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 152 | |||
| 153 | $pathstring = '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>'; |
||
| 154 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcats.php?'); |
||
| 155 | $xoopsTpl->assign('module_name', $xoopsModule->getVar('name')); |
||
| 156 | $xoopsTpl->assign('category_path', $pathstring); |
||
| 157 | $xoopsTpl->assign('category_id', $cid); |
||
| 158 | |||
| 159 | $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' AND valid="Yes" AND status!="1"'); |
||
| 160 | list($trow) = $xoopsDB->fetchRow($countresult); |
||
| 161 | $trows = $trow; |
||
| 162 | |||
| 163 | $cat_perms = ''; |
||
| 164 | if (is_array($categories) && count($categories) > 0) { |
||
| 165 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
| 166 | } |
||
| 167 | |||
| 168 | $result = $xoopsDB->query('SELECT cid, pid, title, cat_desc, cat_keywords FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' ' . $cat_perms); |
||
| 169 | list($cid, $pid, $title, $cat_desc, $cat_keywords) = $xoopsDB->fetchRow($result); |
||
| 170 | |||
| 171 | $xoopsTpl->assign('cat_desc', $cat_desc); |
||
| 172 | $xoopsTpl->assign('cat_title', _ADSLIGHT_ANNONCES . ' ' . $title); |
||
| 173 | $xoopsTpl->assign('cat_keywords', $cat_keywords); |
||
| 174 | $xoopsTpl->assign('xoops_pagetitle', $title); |
||
| 175 | |||
| 176 | if ($cat_desc > '0') { |
||
| 177 | // meta description & keywords tags for categories |
||
| 178 | $cat_desc_clean = strip_tags($cat_desc, '<font><img><strong><i><u>'); |
||
| 179 | $cat_keywords_clean = strip_tags($cat_keywords, '<font><img><strong><i><u><br><li>'); |
||
| 180 | |||
| 181 | $GLOBALS['xoTheme']->addMeta('meta', 'description', '' . substr($cat_desc_clean, 0, 200)); |
||
| 182 | $GLOBALS['xoTheme']->addMeta('meta', 'keywords', '' . substr($cat_keywords_clean, 0, 1000)); |
||
| 183 | } |
||
| 184 | |||
| 185 | $submit_perms = AdslightUtilities::getMyItemIds('adslight_submit'); |
||
| 186 | if ($GLOBALS['xoopsUser'] && is_array($submit_perms) && count($submit_perms) > 0) { |
||
| 187 | $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATS . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_SUBOK . '</a> |
||
| 188 | '; |
||
| 189 | } else { // User can't see any category |
||
| 190 | $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATSOK . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>. |
||
| 191 | '; |
||
| 192 | } |
||
| 193 | |||
| 194 | if ($GLOBALS['xoopsModuleConfig']['adslight_main_cat'] == 1 || $pid != 0) { |
||
| 195 | $xoopsTpl->assign('bullinfotext', $add_listing); |
||
| 196 | } |
||
| 197 | |||
| 198 | $arr = array(); |
||
|
0 ignored issues
–
show
$arr is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 199 | $arr = $mytree->getFirstChild($cid, 'title'); |
||
| 200 | |||
| 201 | if (count($arr) > 0) { |
||
| 202 | $scount = 1; |
||
| 203 | foreach ($arr as $ele) { |
||
| 204 | if (in_array($ele['cid'], $categories)) { |
||
| 205 | $sub_arr = array(); |
||
|
0 ignored issues
–
show
$sub_arr is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 206 | $sub_arr = $mytree->getFirstChild($ele['cid'], 'title'); |
||
| 207 | $space = 0; |
||
| 208 | $chcount = 0; |
||
| 209 | $infercategories = ''; |
||
| 210 | $totallisting = AdslightUtilities::getTotalItems($ele['cid'], 1); |
||
| 211 | foreach ($sub_arr as $sub_ele) { |
||
| 212 | if (in_array($sub_ele['cid'], $categories)) { |
||
| 213 | $chtitle = $myts->htmlSpecialChars($sub_ele['title']); |
||
| 214 | |||
| 215 | if ($chcount > 5) { |
||
| 216 | $infercategories .= '...'; |
||
| 217 | break; |
||
| 218 | } |
||
| 219 | if ($space > 0) { |
||
| 220 | $infercategories .= ', '; |
||
| 221 | } |
||
| 222 | $infercategories .= '<a href="' . XOOPS_URL . '/modules/adslight/viewcats.php?cid=' . $sub_ele['cid'] . '">' . $chtitle . '</a>'; |
||
| 223 | |||
| 224 | $infercategories .= ' (' . AdslightUtilities::getTotalItems($sub_ele['cid']) . ')'; |
||
| 225 | $infercategories .= ' ' . categorynewgraphic($sub_ele['cid']) . ''; |
||
| 226 | ++$space; |
||
| 227 | ++$chcount; |
||
| 228 | } |
||
| 229 | } |
||
| 230 | |||
| 231 | $xoopsTpl->append('subcategories', array( |
||
| 232 | 'title' => $myts->htmlSpecialChars($ele['title']), |
||
| 233 | 'id' => $ele['cid'], |
||
| 234 | 'infercategories' => $infercategories, |
||
| 235 | 'totallisting' => $totallisting, |
||
| 236 | '' |
||
| 237 | )); |
||
| 238 | |||
| 239 | ++$scount; |
||
| 240 | $xoopsTpl->assign('lang_subcat', _ADSLIGHT_AVAILAB); |
||
| 241 | } |
||
| 242 | } |
||
| 243 | } |
||
| 244 | |||
| 245 | $pagenav = ''; |
||
| 246 | if ($trows > '0') { |
||
| 247 | $xoopsTpl->assign('last_head', _ADSLIGHT_THE . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD); |
||
| 248 | $xoopsTpl->assign('last_head_title', _ADSLIGHT_TITLE); |
||
| 249 | $xoopsTpl->assign('last_head_price', _ADSLIGHT_PRICE); |
||
| 250 | $xoopsTpl->assign('last_head_date', _ADSLIGHT_DATE); |
||
| 251 | $xoopsTpl->assign('last_head_local', _ADSLIGHT_LOCAL2); |
||
| 252 | $xoopsTpl->assign('last_head_hits', _ADSLIGHT_VIEW); |
||
| 253 | $xoopsTpl->assign('last_head_photo', _ADSLIGHT_PHOTO); |
||
| 254 | $xoopsTpl->assign('cat', $cid); |
||
| 255 | $xoopsTpl->assign('min', $min); |
||
| 256 | $rank = 1; |
||
| 257 | |||
| 258 | $cat_perms = ''; |
||
| 259 | if (is_array($categories) && count($categories) > 0) { |
||
| 260 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
| 261 | } |
||
| 262 | |||
| 263 | $sql = 'SELECT lid, title, status, type, price, typeprice, date, town, country, contactby, usid, premium, valid, photo, hits FROM ' |
||
| 264 | . $xoopsDB->prefix('adslight_listing') |
||
| 265 | . ' WHERE valid="Yes" and cid=' |
||
| 266 | . $xoopsDB->escape($cid) |
||
| 267 | . ' AND status!="1" ' |
||
| 268 | . $cat_perms |
||
| 269 | . ' ORDER BY ' |
||
| 270 | . $orderby |
||
| 271 | . ''; |
||
| 272 | $result1 = $xoopsDB->query($sql, $show, $min); |
||
| 273 | if ($trows > '1') { |
||
| 274 | $xoopsTpl->assign('show_nav', true); |
||
| 275 | $orderbyTrans = AdslightUtilities::convertOrderByTrans($orderby); |
||
|
0 ignored issues
–
show
$orderbyTrans is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 276 | $xoopsTpl->assign('lang_sortby', _ADSLIGHT_SORTBY); |
||
| 277 | $xoopsTpl->assign('lang_title', _ADSLIGHT_TITLE); |
||
| 278 | $xoopsTpl->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ); |
||
| 279 | $xoopsTpl->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA); |
||
| 280 | $xoopsTpl->assign('lang_date', _ADSLIGHT_DATE); |
||
| 281 | $xoopsTpl->assign('lang_dateold', _ADSLIGHT_DATEOLD); |
||
| 282 | $xoopsTpl->assign('lang_datenew', _ADSLIGHT_DATENEW); |
||
| 283 | $xoopsTpl->assign('lang_price', _ADSLIGHT_PRICE); |
||
| 284 | $xoopsTpl->assign('lang_priceltoh', _ADSLIGHT_PRICELTOH); |
||
| 285 | $xoopsTpl->assign('lang_pricehtol', _ADSLIGHT_PRICEHTOL); |
||
| 286 | $xoopsTpl->assign('lang_popularity', _ADSLIGHT_POPULARITY); |
||
| 287 | $xoopsTpl->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM); |
||
| 288 | $xoopsTpl->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL); |
||
| 289 | $xoopsTpl->assign('lang_cursortedby', sprintf(_ADSLIGHT_CURSORTEDBY, AdslightUtilities::convertOrderByTrans($orderby))); |
||
| 290 | } |
||
| 291 | |||
| 292 | while (list($lid, $title, $status, $type, $price, $typeprice, $date, $town, $country, $contactby, $usid, $premium, $valid, $photo, $hits) = $xoopsDB->fetchRow($result1)) { |
||
|
0 ignored issues
–
show
The assignment to
$premium is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
The assignment to
$valid is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
|
|||
| 293 | $a_item = array(); |
||
| 294 | $title = $myts->htmlSpecialChars($title); |
||
| 295 | $type = $myts->htmlSpecialChars($type); |
||
| 296 | // $price = number_format($price, 2, ',', ' '); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 297 | $town = $myts->htmlSpecialChars($town); |
||
| 298 | $country = $myts->htmlSpecialChars($country); |
||
| 299 | $contactby = $myts->htmlSpecialChars($contactby); |
||
| 300 | $useroffset = ''; |
||
| 301 | |||
| 302 | $newcount = $GLOBALS['xoopsModuleConfig']['adslight_countday']; |
||
| 303 | $startdate = (time() - (86400 * $newcount)); |
||
| 304 | View Code Duplication | if ($startdate < $date) { |
|
| 305 | $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" />'; |
||
| 306 | $a_item['new'] = $newitem; |
||
| 307 | } |
||
| 308 | if ($GLOBALS['xoopsUser']) { |
||
| 309 | $timezone = $GLOBALS['xoopsUser']->timezone(); |
||
| 310 | if (isset($timezone)) { |
||
| 311 | $useroffset = $GLOBALS['xoopsUser']->timezone(); |
||
| 312 | } else { |
||
| 313 | $useroffset = $xoopsConfig['default_TZ']; |
||
| 314 | } |
||
| 315 | } |
||
| 316 | $date = ($useroffset * 3600) + $date; |
||
| 317 | $date = formatTimestamp($date, 's'); |
||
| 318 | View Code Duplication | if ($GLOBALS['xoopsUser']) { |
|
| 319 | if ($GLOBALS['xoopsUser']->isAdmin()) { |
||
| 320 | $a_item['admin'] = '<a href="' |
||
| 321 | . XOOPS_URL |
||
| 322 | . '/modules/adslight/admin/validate_ads.php?op=ModifyAds&lid=' |
||
| 323 | . $lid |
||
| 324 | . '"><img src="' |
||
| 325 | . $pathIcon16 |
||
| 326 | . '/edit.png' |
||
| 327 | . '" border=0 alt="' |
||
| 328 | . _ADSLIGHT_MODADMIN |
||
| 329 | . '" title="' |
||
| 330 | . _ADSLIGHT_MODADMIN |
||
| 331 | . '"/></a>'; |
||
| 332 | } |
||
| 333 | } |
||
| 334 | |||
| 335 | $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='" . $xoopsDB->escape($type) . "'"); |
||
| 336 | list($nom_type) = $xoopsDB->fetchRow($result7); |
||
| 337 | |||
| 338 | $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'"); |
||
| 339 | list($nom_price) = $xoopsDB->fetchRow($result8); |
||
| 340 | |||
| 341 | $a_item['type'] = $myts->htmlSpecialChars($nom_type); |
||
| 342 | $a_item['title'] = '<a href="viewads.php?lid=' . $lid . '"><strong>' . $title . '</strong></a>'; |
||
| 343 | $a_item['status'] = $status; |
||
| 344 | if ($price > 0) { |
||
| 345 | |||
| 346 | // $a_item['price'] = $price. ' '. $GLOBALS['xoopsModuleConfig']['adslight_money'].''; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
63% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 347 | $a_item['price'] = AdslightUtilities::getMoneyFormat('%.2n', $price); |
||
| 348 | $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price); |
||
| 349 | } |
||
| 350 | $a_item['date'] = $date; |
||
| 351 | $a_item['local'] = ''; |
||
| 352 | if ($town) { |
||
| 353 | $a_item['local'] .= $town; |
||
| 354 | } |
||
| 355 | $a_item['country'] = ''; |
||
| 356 | if ($country) { |
||
| 357 | $a_item['country'] = $country; |
||
| 358 | } |
||
| 359 | |||
| 360 | $cat = addslashes($cid); |
||
|
0 ignored issues
–
show
$cat is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 361 | if ($status == 2) { |
||
| 362 | $a_item['sold'] = _ADSLIGHT_RESERVEDMEMBER; |
||
| 363 | } |
||
| 364 | |||
| 365 | View Code Duplication | if ($GLOBALS['xoopsModuleConfig']['active_thumbscats'] > 0) { |
|
| 366 | $a_item['no_photo'] = '<a href="' |
||
| 367 | . XOOPS_URL |
||
| 368 | . '/modules/adslight/viewads.php?lid=' |
||
| 369 | . $lid |
||
| 370 | . '"><img class="thumb" src="' |
||
| 371 | . XOOPS_URL |
||
| 372 | . '/modules/adslight/assets/images/nophoto.jpg" align="left" width="100px" alt="' |
||
| 373 | . $title |
||
| 374 | . '" /></a>'; |
||
| 375 | |||
| 376 | $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload']; |
||
| 377 | $sql = 'SELECT cod_img, lid, uid_owner, url FROM ' |
||
| 378 | . $xoopsDB->prefix('adslight_pictures') |
||
| 379 | . ' WHERE uid_owner=' |
||
| 380 | . $xoopsDB->escape($usid) |
||
| 381 | . ' AND lid=' |
||
| 382 | . $xoopsDB->escape($lid) |
||
| 383 | . ' ORDER BY date_added ASC limit 1'; |
||
| 384 | $resultp = $xoopsDB->query($sql); |
||
| 385 | |||
| 386 | while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) { |
||
|
0 ignored issues
–
show
The assignment to
$cod_img is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
The assignment to
$pic_lid is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
The assignment to
$uid_owner is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
|
|||
| 387 | if ($photo) { |
||
| 388 | $a_item['photo'] = '<a href="' |
||
| 389 | . XOOPS_URL |
||
| 390 | . '/modules/adslight/viewads.php?lid=' |
||
| 391 | . $lid |
||
| 392 | . '"><img class="thumb" src="' |
||
| 393 | . $updir |
||
| 394 | . '/thumbs/thumb_' |
||
| 395 | . $url |
||
| 396 | . '" align="left" width="100px" alt="' |
||
| 397 | . $title |
||
| 398 | . '" /></a>'; |
||
| 399 | } |
||
| 400 | } |
||
| 401 | } else { |
||
| 402 | $a_item['no_photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_nophoto.png" align="left" width="24" alt="' . $title . '" /></p>'; |
||
| 403 | $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload']; |
||
|
0 ignored issues
–
show
$updir is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 404 | $sql = 'SELECT cod_img, lid, uid_owner, url FROM ' |
||
| 405 | . $xoopsDB->prefix('adslight_pictures') |
||
| 406 | . ' WHERE uid_owner=' |
||
| 407 | . $xoopsDB->escape($usid) |
||
| 408 | . ' AND lid=' |
||
| 409 | . $xoopsDB->escape($lid) |
||
| 410 | . ' ORDER BY date_added ASC limit 1'; |
||
| 411 | $resultp = $xoopsDB->query($sql); |
||
| 412 | while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) { |
||
|
0 ignored issues
–
show
The assignment to
$cod_img is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
The assignment to
$pic_lid is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
The assignment to
$uid_owner is unused. Consider omitting it like so list($first,,$third).
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
Loading history...
|
|||
| 413 | if ($photo) { |
||
| 414 | $a_item['photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_photo.png" align="left" width="24" alt="' . $title . '" /></p>'; |
||
| 415 | } |
||
| 416 | } |
||
| 417 | } |
||
| 418 | |||
| 419 | $a_item['hits'] = $hits; |
||
| 420 | ++$rank; |
||
| 421 | $xoopsTpl->append('items', $a_item); |
||
| 422 | } |
||
| 423 | |||
| 424 | $cid = ((int)$cid > 0) ? (int)$cid : 0; |
||
| 425 | |||
| 426 | $orderby = AdslightUtilities::convertOrderByOut($orderby); |
||
| 427 | $linkpages = ceil($trows / $show); |
||
| 428 | |||
| 429 | //Page Numbering |
||
| 430 | if ($linkpages != 1 && $linkpages != 0) { |
||
| 431 | $prev = $min - $show; |
||
| 432 | if ($prev >= 0) { |
||
| 433 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$prev&orderby=$orderby&show=$show'><strong><u>«</u></strong></a> "; |
||
| 434 | } |
||
| 435 | $counter = 1; |
||
| 436 | $currentpage = ($max / $show); |
||
| 437 | while ($counter <= $linkpages) { |
||
| 438 | $mintemp = ($show * $counter) - $show; |
||
| 439 | if ($counter == $currentpage) { |
||
| 440 | $pagenav .= "<strong>($counter)</strong> "; |
||
| 441 | } else { |
||
| 442 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$mintemp&orderby=$orderby&show=$show'>$counter</a> "; |
||
| 443 | } |
||
| 444 | ++$counter; |
||
| 445 | } |
||
| 446 | if ($trows > $max) { |
||
| 447 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$max&orderby=$orderby&show=$show'>"; |
||
| 448 | $pagenav .= '<strong><u>»</u></strong></a>'; |
||
| 449 | } |
||
| 450 | } |
||
| 451 | } |
||
| 452 | |||
| 453 | $xoopsTpl->assign('nav_page', $pagenav); |
||
| 454 | |||
| 455 | if (!$GLOBALS['xoopsUser']) { |
||
| 456 | global $xoopsDB; |
||
| 457 | |||
| 458 | $xt = new XoopsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
||
| 459 | $jump = XOOPS_URL . '/modules/adslight/viewcats.php?cid='; |
||
| 460 | ob_start(); |
||
| 461 | $xt->makeMySelBox('title', 'title', $cid, 1, 'pid', "location=\"" . $jump . "\"+this.options[this.selectedIndex].value"); |
||
| 462 | $select_go_cats = ob_get_contents(); |
||
| 463 | ob_end_clean(); |
||
| 464 | $xoopsTpl->assign('select_go_cats', $select_go_cats); |
||
| 465 | } |
||
| 466 | } |
||
| 467 | |||
| 468 | # function categorynewgraphic |
||
| 469 | ##################################################### |
||
| 470 | /** |
||
| 471 | * @param $cid |
||
| 472 | */ |
||
| 473 | function categorynewgraphic($cid) |
||
|
0 ignored issues
–
show
The function
categorynewgraphic() has been defined more than once; this definition is ignored, only the first definition in index.php (L378-381) is considered.
This check looks for functions that have already been defined in other files. Some Codebases, like WordPress, make a practice of defining functions multiple times. This
may lead to problems with the detection of function parameters and types. If you really
need to do this, you can mark the duplicate definition with the /**
* @ignore
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. Loading history...
|
|||
| 474 | { |
||
| 475 | global $xoopsDB; |
||
| 476 | } |
||
| 477 | |||
| 478 | ###################################################### |
||
| 479 | |||
| 480 | $pa = Request::getInt('pa', null, 'GET'); |
||
| 481 | $lid = Request::getInt('lid', null, 'GET'); |
||
| 482 | $cid = Request::getInt('cid', null, 'GET'); |
||
| 483 | $usid = Request::getString('usid', '', 'GET'); |
||
| 484 | $min = Request::getInt('min', null, 'GET'); |
||
| 485 | $show = Request::getInt('show', null, 'GET'); |
||
| 486 | $orderby = Request::getInt('orderby', null, 'GET'); |
||
| 487 | |||
| 488 | switch ($pa) { |
||
| 489 | default: |
||
| 490 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl'; |
||
| 491 | adsView($cid, $min, $orderby, $show); |
||
| 492 | break; |
||
| 493 | } |
||
| 494 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 495 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.