mambax7 /
adslight
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 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 | include_once __DIR__ . '/header.php'; |
||
| 24 | require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php'; |
||
| 25 | xoops_load('XoopsLocal'); |
||
| 26 | |||
| 27 | $myts = MyTextSanitizer::getInstance(); |
||
| 28 | $module_id = $xoopsModule->getVar('mid'); |
||
| 29 | |||
| 30 | View Code Duplication | if (is_object($GLOBALS['xoopsUser'])) { |
|
|
1 ignored issue
–
show
|
|||
| 31 | $groups = $GLOBALS['xoopsUser']->getGroups(); |
||
| 32 | } else { |
||
| 33 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
| 34 | } |
||
| 35 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 36 | if (isset($_POST['item_id'])) { |
||
| 37 | $perm_itemid = (int)$_POST['item_id']; |
||
| 38 | } else { |
||
| 39 | $perm_itemid = 0; |
||
| 40 | } |
||
| 41 | //If no access |
||
| 42 | View Code Duplication | if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) { |
|
|
1 ignored issue
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 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'; |
||
| 53 | $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
||
| 54 | |||
| 55 | # function viewads |
||
| 56 | ##################################################### |
||
| 57 | /** |
||
| 58 | * @param int $lid |
||
| 59 | */ |
||
| 60 | function viewAds($lid = 0) |
||
| 61 | { |
||
| 62 | global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsTpl, $myts, $meta, $moduleDirName, $main_lang, $prem_perm, $xoopsModule; |
||
| 63 | $pathIcon16 = $xoopsModule->getInfo('icons16'); |
||
| 64 | |||
| 65 | $tempXoopsLocal = new XoopsLocal; |
||
| 66 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl'; |
||
| 67 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 68 | include XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||
| 69 | $lid = ((int)$lid > 0) ? (int)$lid : 0; |
||
| 70 | $rate = ($GLOBALS['xoopsModuleConfig']['adslight_rate_item'] == '1') ? '1' : '0'; |
||
| 71 | $xoopsTpl->assign('rate', $rate); |
||
| 72 | $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid')); |
||
| 73 | $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK); |
||
| 74 | |||
| 75 | // Hack redirection erreur 404 si lid=null |
||
| 76 | View Code Duplication | if ($lid == '') { |
|
| 77 | header('Status: 301 Moved Permanently', false, 301); |
||
| 78 | // header('Location: '.XOOPS_URL.'/modules/adslight/404.php'); |
||
| 79 | // exit(); |
||
| 80 | redirect_header(XOOPS_URL . '/modules/adslight/404.php', 1); |
||
| 81 | } |
||
| 82 | |||
| 83 | $xoopsTpl->assign('adslight_active_bookmark', $GLOBALS['xoopsModuleConfig']['adslight_active_bookmark']); |
||
| 84 | $xoopsTpl->assign('adslight_style_bookmark', $GLOBALS['xoopsModuleConfig']['adslight_style_bookmark']); |
||
| 85 | $xoopsTpl->assign('adslight_active_xpayement', $GLOBALS['xoopsModuleConfig']['adslight_active_xpayment']); |
||
| 86 | |||
| 87 | // adslight 2 |
||
| 88 | $xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']); |
||
| 89 | $xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']); |
||
| 90 | |||
| 91 | if ($GLOBALS['xoopsUser']) { |
||
| 92 | $member_usid = $GLOBALS['xoopsUser']->getVar('uid'); |
||
| 93 | if ($usid = $member_usid) { |
||
| 94 | $xoopsTpl->assign('istheirs', true); |
||
| 95 | |||
| 96 | if (strlen($GLOBALS['xoopsUser']->getVar('name'))) { |
||
| 97 | $xoopsTpl->assign('user_name', $GLOBALS['xoopsUser']->getVar('name') . ' (' . $GLOBALS['xoopsUser']->getVar('uname') . ')'); |
||
| 98 | } else { |
||
| 99 | $xoopsTpl->assign('user_name', $GLOBALS['xoopsUser']->getVar('uname')); |
||
| 100 | } |
||
| 101 | |||
| 102 | $xoopsTpl->assign('user_email', $GLOBALS['xoopsUser']->getVar('email')); |
||
| 103 | |||
| 104 | list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid=$member_usid")); |
||
| 105 | |||
| 106 | $xoopsTpl->assign('show_user', $show_user); |
||
| 107 | $xoopsTpl->assign('show_user_link', 'members.php?usid=' . $member_usid . ''); |
||
| 108 | } |
||
| 109 | } |
||
| 110 | |||
| 111 | if ($GLOBALS['xoopsUser']) { |
||
| 112 | $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E'); |
||
| 113 | } |
||
| 114 | |||
| 115 | $cat_perms = ''; |
||
| 116 | $categories = AdslightUtilities::getMyItemIds('adslight_view'); |
||
| 117 | if (is_array($categories) && count($categories) > 0) { |
||
| 118 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
| 119 | } |
||
| 120 | |||
| 121 | $result = $xoopsDB->query('SELECT l.lid, l.cid, l.title, l.status, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.typeusure, l.date, l.email, l.submitter, l.usid, l.town, l.country, l.contactby, l.premium, l.valid, l.photo, l.hits, l.item_rating, l.item_votes, l.user_rating, l.user_votes, l.comments, p.cod_img, p.lid, p.uid_owner, p.url FROM ' |
||
| 122 | . $xoopsDB->prefix('adslight_listing') |
||
| 123 | . ' l LEFT JOIN ' |
||
| 124 | . $xoopsDB->prefix('adslight_pictures') |
||
| 125 | . " p ON l.lid=p.lid WHERE l.valid='Yes' AND l.lid = " |
||
| 126 | . $xoopsDB->escape($lid) |
||
| 127 | . " and l.status!='1' $cat_perms"); |
||
| 128 | $recordexist = $xoopsDB->getRowsNum($result); |
||
| 129 | |||
| 130 | // Hack redirection erreur 404 si recordexist=null |
||
| 131 | View Code Duplication | if ($recordexist == '') { |
|
| 132 | header('Status: 301 Moved Permanently', false, 301); |
||
| 133 | // header('Location: '.XOOPS_URL.'/modules/adslight/404.php'); |
||
| 134 | // exit(); |
||
| 135 | redirect_header(XOOPS_URL . '/modules/adslight/404.php', 1); |
||
| 136 | } |
||
| 137 | |||
| 138 | if ($recordexist) { |
||
| 139 | list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid, $photo, $hits, $item_rating, $item_votes, $user_rating, $user_votes, $comments, $cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($result); |
||
| 140 | |||
| 141 | $newcount = $GLOBALS['xoopsModuleConfig']['adslight_countday']; |
||
| 142 | $startdate = (time() - (86400 * $newcount)); |
||
| 143 | if ($startdate < $date) { |
||
| 144 | $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" />'; |
||
| 145 | $xoopsTpl->assign('new', $newitem); |
||
| 146 | } |
||
| 147 | |||
| 148 | $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload']; |
||
| 149 | $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); |
||
| 150 | $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); |
||
| 151 | $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); |
||
| 152 | $xoopsTpl->assign('ad_exists', $recordexist); |
||
| 153 | $xoopsTpl->assign('mydirname', $moduleDirName); |
||
| 154 | |||
| 155 | $count = 0; |
||
| 156 | $x = 0; |
||
| 157 | $i = 0; |
||
| 158 | |||
| 159 | $result3 = $xoopsDB->query('SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ''); |
||
| 160 | list($ccid, $pid, $ctitle) = $xoopsDB->fetchRow($result3); |
||
| 161 | |||
| 162 | $xoopsTpl->assign('category_title', $ctitle); |
||
| 163 | |||
| 164 | $module_id = $xoopsModule->getVar('mid'); |
||
| 165 | View Code Duplication | if (is_object($GLOBALS['xoopsUser'])) { |
|
|
1 ignored issue
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 166 | $groups = $GLOBALS['xoopsUser']->getGroups(); |
||
| 167 | } else { |
||
| 168 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
| 169 | } |
||
| 170 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 171 | $xoopsTpl->assign('purchasable', $gpermHandler->checkRight('adslight_purchase', $cid, $groups, $module_id)); |
||
| 172 | |||
| 173 | $ctitle = $myts->htmlSpecialChars($ctitle); |
||
| 174 | $varid[$x] = $ccid; |
||
| 175 | $varnom[$x] = $ctitle; |
||
| 176 | |||
| 177 | list($nbe) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE valid="Yes" AND cid=' . $xoopsDB->escape($cid) . ' AND status!="1"')); |
||
| 178 | |||
| 179 | if ($pid != 0) { |
||
| 180 | $x = 1; |
||
| 181 | while ($pid != 0) { |
||
| 182 | $result4 = $xoopsDB->query('SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($pid) . ''); |
||
| 183 | list($ccid, $pid, $ctitle) = $xoopsDB->fetchRow($result4); |
||
| 184 | |||
| 185 | $ctitle = $myts->htmlSpecialChars($ctitle); |
||
| 186 | $varid[$x] = $ccid; |
||
| 187 | $varnom[$x] = $ctitle; |
||
| 188 | ++$x; |
||
| 189 | } |
||
| 190 | --$x; |
||
| 191 | } |
||
| 192 | $subcats = ''; |
||
| 193 | $arrow = ' <img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="»" />'; |
||
| 194 | while ($x != -1) { |
||
| 195 | $subcats .= ' ' . $arrow . ' <a href="viewcats.php?cid=' . $varid[$x] . '">' . $varnom[$x] . '</a>'; |
||
| 196 | --$x; |
||
| 197 | } |
||
| 198 | $xoopsTpl->assign('nav_main', '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>'); |
||
| 199 | $xoopsTpl->assign('nav_sub', $subcats); |
||
| 200 | $xoopsTpl->assign('nav_subcount', $nbe); |
||
| 201 | $viewcount_judge = true; |
||
| 202 | $useroffset = ''; |
||
| 203 | if ($GLOBALS['xoopsUser']) { |
||
| 204 | $timezone = $GLOBALS['xoopsUser']->timezone(); |
||
| 205 | if (isset($timezone)) { |
||
| 206 | $useroffset = $GLOBALS['xoopsUser']->timezone(); |
||
| 207 | } else { |
||
| 208 | $useroffset = $xoopsConfig['default_TZ']; |
||
| 209 | } |
||
| 210 | if ($GLOBALS['xoopsUser']->isAdmin()) { |
||
| 211 | $adslight_admin = true; |
||
| 212 | } else { |
||
| 213 | $adslight_admin = false; |
||
| 214 | } |
||
| 215 | |||
| 216 | if (($adslight_admin = true) || ($GLOBALS['xoopsUser']->getVar('uid') == $usid)) { |
||
| 217 | $viewcount_judge = false; |
||
| 218 | } |
||
| 219 | |||
| 220 | $contact_pm = '<a href="' . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . addslashes($usid) . '"> ' . _ADSLIGHT_CONTACT_BY_PM . '</a>'; |
||
| 221 | } |
||
| 222 | if (true === $viewcount_judge) { |
||
| 223 | $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_listing') . ' SET hits=hits+1 WHERE lid = ' . $xoopsDB->escape($lid) . ''); |
||
| 224 | } |
||
| 225 | if ($item_votes == 1) { |
||
| 226 | $votestring = _ADSLIGHT_ONEVOTE; |
||
| 227 | } else { |
||
| 228 | $votestring = sprintf(_ADSLIGHT_NUMVOTES, $item_votes); |
||
| 229 | } |
||
| 230 | $date = ($useroffset * 3600) + $date; |
||
| 231 | $date2 = $date + ($expire * 86400); |
||
| 232 | $date = formatTimestamp($date, 's'); |
||
| 233 | $date2 = formatTimestamp($date2, 's'); |
||
| 234 | $title = $myts->htmlSpecialChars($title); |
||
| 235 | $status = $myts->htmlSpecialChars($status); |
||
| 236 | $expire = $myts->htmlSpecialChars($expire); |
||
| 237 | $type = $myts->htmlSpecialChars($type); |
||
| 238 | $desctext = $myts->displayTarea($desctext, 1, 1, 1); |
||
| 239 | $tel = $myts->htmlSpecialChars($tel); |
||
| 240 | // $price = XoopsLocal::number_format($price, 2, ',', ' '); |
||
| 241 | $typeprice = $myts->htmlSpecialChars($typeprice); |
||
| 242 | $typeusure = $myts->htmlSpecialChars($typeusure); |
||
| 243 | $submitter = $myts->htmlSpecialChars($submitter); |
||
| 244 | $usid = $myts->htmlSpecialChars($usid); |
||
| 245 | $town = $myts->htmlSpecialChars($town); |
||
| 246 | $country = $myts->htmlSpecialChars($country); |
||
| 247 | $contactby = $myts->htmlSpecialChars($contactby); |
||
| 248 | $premium = $myts->htmlSpecialChars($premium); |
||
| 249 | |||
| 250 | if ($status == 2) { |
||
| 251 | $sold = _ADSLIGHT_RESERVED; |
||
| 252 | } else { |
||
| 253 | $sold = ''; |
||
| 254 | } |
||
| 255 | |||
| 256 | $xoopsTpl->assign('printA', '<a href="print.php?op=PrintAd&lid=' . $lid . '" ><img src="assets/images/print.gif" border=0 alt="' . _ADSLIGHT_PRINT . '" /></a> '); |
||
| 257 | |||
| 258 | if ($usid > 0) { |
||
| 259 | $xoopsTpl->assign('submitter', '<img src="assets/images/lesannonces.png" border="0" alt="' |
||
| 260 | . _ADSLIGHT_VIEW_MY_ADS |
||
| 261 | . '" /> <a href="members.php?usid=' |
||
| 262 | . addslashes($usid) |
||
| 263 | . '" />' |
||
| 264 | . _ADSLIGHT_VIEW_MY_ADS |
||
| 265 | . ' ' |
||
| 266 | . $submitter |
||
| 267 | . '</a>'); |
||
| 268 | } else { |
||
| 269 | $xoopsTpl->assign('submitter', _ADSLIGHT_VIEW_MY_ADS . ' $submitter'); |
||
| 270 | } |
||
| 271 | $xoopsTpl->assign('lid', $lid); |
||
| 272 | $xoopsTpl->assign('read', "$hits " . _ADSLIGHT_VIEW2); |
||
| 273 | $xoopsTpl->assign('rating', $tempXoopsLocal->number_format($item_rating, 2)); |
||
| 274 | $xoopsTpl->assign('votes', $votestring); |
||
| 275 | $xoopsTpl->assign('lang_rating', _ADSLIGHT_RATINGC); |
||
| 276 | $xoopsTpl->assign('lang_ratethisitem', _ADSLIGHT_RATETHISITEM); |
||
| 277 | $xoopsTpl->assign('xoop_user', false); |
||
| 278 | $isOwner = ''; |
||
| 279 | if ($GLOBALS['xoopsUser']) { |
||
| 280 | $xoopsTpl->assign('xoop_user', true); |
||
| 281 | $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E'); |
||
| 282 | if ($usid == $currentid) { |
||
| 283 | $xoopsTpl->assign('modifyads', '<img src=' |
||
| 284 | . $pathIcon16 |
||
| 285 | . '/edit.png border="0" alt="' |
||
| 286 | . _ADSLIGHT_MODIFANN |
||
| 287 | . '" /> <a href="modify.php?op=ModAd&lid=' |
||
| 288 | . $lid |
||
| 289 | . '">' |
||
| 290 | . _ADSLIGHT_MODIFANN |
||
| 291 | . '</a>'); |
||
| 292 | $xoopsTpl->assign('deleteads', '<img src=' |
||
| 293 | . $pathIcon16 |
||
| 294 | . '/delete.png border="0" alt="' |
||
| 295 | . _ADSLIGHT_SUPPRANN |
||
| 296 | . '" /> <a href="modify.php?op=ListingDel&lid=' |
||
| 297 | . $lid |
||
| 298 | . '">' |
||
| 299 | . _ADSLIGHT_SUPPRANN |
||
| 300 | . '</a>'); |
||
| 301 | $xoopsTpl->assign('add_photos', '<img src="assets/images/shape_square_add.png" border="0" alt="' |
||
| 302 | . _ADSLIGHT_SUPPRANN |
||
| 303 | . '" /> <a href="view_photos.php?lid=' |
||
| 304 | . $lid |
||
| 305 | . '&uid=' |
||
| 306 | . $usid |
||
| 307 | . '">' |
||
| 308 | . _ADSLIGHT_ADD_PHOTOS |
||
| 309 | . '</a>'); |
||
| 310 | |||
| 311 | $isOwner = true; |
||
| 312 | $xoopsTpl->assign('isOwner', $isOwner); |
||
| 313 | } |
||
| 314 | if ($GLOBALS['xoopsUser']->isAdmin()) { |
||
| 315 | $xoopsTpl->assign('admin', '<a href="' |
||
| 316 | . XOOPS_URL |
||
| 317 | . '/modules/adslight/admin/modify_ads.php?op=ModifyAds&lid=' |
||
| 318 | . $lid |
||
| 319 | . '"><img src=' |
||
| 320 | . $pathIcon16 |
||
| 321 | . '/edit.png border=0 alt="' |
||
| 322 | . _ADSLIGHT_MODADMIN |
||
| 323 | . '" /></a>'); |
||
| 324 | } |
||
| 325 | } |
||
| 326 | |||
| 327 | $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . $xoopsDB->escape($type) . ''); |
||
| 328 | list($nom_type) = $xoopsDB->fetchRow($result7); |
||
| 329 | |||
| 330 | $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . $xoopsDB->escape($typeprice) . ''); |
||
| 331 | list($nom_price) = $xoopsDB->fetchRow($result8); |
||
| 332 | |||
| 333 | $result9 = $xoopsDB->query('SELECT nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' WHERE id_usure=' . $xoopsDB->escape($typeusure) . ''); |
||
| 334 | list($nom_usure) = $xoopsDB->fetchRow($result9); |
||
| 335 | |||
| 336 | $xoopsTpl->assign('type', $myts->htmlSpecialChars($nom_type)); |
||
| 337 | $xoopsTpl->assign('title', $title); |
||
| 338 | $xoopsTpl->assign('status', $status); |
||
| 339 | $xoopsTpl->assign('desctext', $desctext); |
||
| 340 | $xoopsTpl->assign('xoops_pagetitle', $title . ' - ' . $town . ': ' . $country . ' - ' . $ctitle); |
||
| 341 | |||
| 342 | // meta description tags for ads |
||
| 343 | $desctextclean = strip_tags($desctext, '<font><img><strong><i><u>'); |
||
| 344 | $xoTheme->addMeta('meta', 'description', "$title - " . substr($desctextclean, 0, 150)); |
||
| 345 | |||
| 346 | if ($price > 0) { |
||
| 347 | $xoopsTpl->assign('price', '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $price . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_money'] . ' - ' . $typeprice); |
||
| 348 | $xoopsTpl->assign('price_head', _ADSLIGHT_PRICE2); |
||
| 349 | // $xoopsTpl->assign('price_price', $price.' '.$GLOBALS['xoopsModuleConfig']['adslight_money'].' '); |
||
| 350 | |||
| 351 | $xoopsTpl->assign('price_price', AdslightUtilities::getMoneyFormat('%.2n', $price)); |
||
| 352 | |||
| 353 | $xoopsTpl->assign('price_typeprice', $myts->htmlSpecialChars($nom_price)); |
||
| 354 | $xoopsTpl->assign('price_currency', $GLOBALS['xoopsModuleConfig']['adslight_currency']); |
||
| 355 | $xoopsTpl->assign('price_amount', $price); |
||
| 356 | } |
||
| 357 | |||
| 358 | $xoopsTpl->assign('usure_typeusure', $nom_usure); |
||
| 359 | $xoopsTpl->assign('premium', $premium); |
||
| 360 | |||
| 361 | // $xoopsTpl->assign('mustlogin', _ADSLIGHT_MUSTLOGIN); |
||
| 362 | $xoopsTpl->assign('redirect', '' . '?xoops_redirect=/modules/adslight/index.php'); |
||
| 363 | |||
| 364 | if ($town) { |
||
| 365 | $xoopsTpl->assign('local_town', $town); |
||
| 366 | } |
||
| 367 | if ($GLOBALS['xoopsModuleConfig']['adslight_use_country'] == 1) { |
||
| 368 | if ($country) { |
||
| 369 | $xoopsTpl->assign('local_country', $country); |
||
| 370 | $xoopsTpl->assign('country_head', '<img src="assets/images/world_go.png" border="0" alt="country" /> ' . _ADSLIGHT_COUNTRY); |
||
| 371 | } |
||
| 372 | } |
||
| 373 | |||
| 374 | $tphon = ''; |
||
| 375 | if ($tel) { |
||
| 376 | $tphon = '<br>' . _ADSLIGHT_ORBY . ' <strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel; |
||
| 377 | } |
||
| 378 | |||
| 379 | if ($contactby == 1) { |
||
| 380 | $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . ''; |
||
| 381 | } |
||
| 382 | if ($contactby == 2) { |
||
| 383 | $contact = $contact_pm . '' . $tphon; |
||
| 384 | } |
||
| 385 | if ($contactby == 3) { |
||
| 386 | $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . '<br>' . _ADSLIGHT_ORBY . '' . $contact_pm; |
||
| 387 | } |
||
| 388 | if ($contactby == 4) { |
||
| 389 | $contact = '<br><strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel; |
||
| 390 | } |
||
| 391 | // $xoopsTpl->assign('contact', $contact); |
||
| 392 | $xoopsTpl->assign('local_head', '<img src="assets/images/house.png" border="0" alt="local_head" /> ' . _ADSLIGHT_LOCAL); |
||
| 393 | |||
| 394 | if ($lid) { |
||
| 395 | if ($sold) { |
||
| 396 | $xoopsTpl->assign('bullinfotext', $sold); |
||
| 397 | } else { |
||
| 398 | if ($GLOBALS['xoopsUser']) { |
||
| 399 | $xoopsTpl->assign('bullinfotext', _ADSLIGHT_CONTACT_SUBMITTER . ' ' . $submitter . ' ' . _ADSLIGHT_CONTACTBY2 . ' ' . $contact); |
||
| 400 | } else { |
||
| 401 | $xoopsTpl->assign('bullinfotext', '<span style="color: #de090e;"><b>' . _ADSLIGHT_MUSTLOGIN . '</b></span>'); |
||
| 402 | } |
||
| 403 | } |
||
| 404 | } |
||
| 405 | |||
| 406 | $user_profile = XoopsUser::getUnameFromId($usid); |
||
| 407 | $xoopsTpl->assign('user_profile', '<img src="assets/images/profil.png" border="0" alt="' |
||
| 408 | . _ADSLIGHT_PROFILE |
||
| 409 | . '" /> <a rel="nofollow" href="' |
||
| 410 | . XOOPS_URL |
||
| 411 | . '/user.php?usid=' |
||
| 412 | . addslashes($usid) |
||
| 413 | . '">' |
||
| 414 | . _ADSLIGHT_PROFILE |
||
| 415 | . ' ' |
||
| 416 | . $user_profile |
||
| 417 | . '</a>'); |
||
| 418 | |||
| 419 | if ($photo != '') { |
||
| 420 | include_once __DIR__ . '/class/pictures.php'; |
||
| 421 | |||
| 422 | $criteria_lid = new criteria('lid', $lid); |
||
| 423 | $criteria_uid = new criteria('uid', $usid); |
||
| 424 | $album_factory = new Xoopsjlm_picturesHandler($xoopsDB); |
||
| 425 | $pictures_object_array =& $album_factory->getObjects($criteria_lid, $criteria_uid); |
||
| 426 | $pictures_number = $album_factory->getCount($criteria_lid, $criteria_uid); |
||
| 427 | View Code Duplication | if ($pictures_number == 0) { |
|
| 428 | $nopicturesyet = _ADSLIGHT_NOTHINGYET; |
||
| 429 | $xoopsTpl->assign('lang_nopicyet', $nopicturesyet); |
||
| 430 | } else { |
||
| 431 | |||
| 432 | /** |
||
| 433 | * Lets populate an array with the data from the pictures |
||
| 434 | */ |
||
| 435 | $i = 0; |
||
| 436 | foreach ($pictures_object_array as $picture) { |
||
| 437 | $pictures_array[$i]['url'] = $picture->getVar('url', 's'); |
||
| 438 | $pictures_array[$i]['desc'] = $picture->getVar('title', 's'); |
||
| 439 | $pictures_array[$i]['cod_img'] = $picture->getVar('cod_img', 's'); |
||
| 440 | $pictures_array[$i]['lid'] = $picture->getVar('lid', 's'); |
||
| 441 | $xoopsTpl->assign('pics_array', $pictures_array); |
||
| 442 | |||
| 443 | ++$i; |
||
| 444 | } |
||
| 445 | } |
||
| 446 | $owner = new XoopsUser(); |
||
| 447 | $identifier = $owner->getUnameFromId($usid); |
||
| 448 | if ($GLOBALS['xoopsModuleConfig']['adslight_lightbox'] == 1) { |
||
| 449 | $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" /> |
||
| 450 | <script type="text/javascript" src="assets/lightbox/js/jquery-1.7.2.min.js"></script> |
||
| 451 | <script type="text/javascript" src="assets/lightbox/js/jquery-ui-1.8.18.custom.min"></script> |
||
| 452 | <script type="text/javascript" src="assets/lightbox/js/jquery.smooth-scroll.min.js"></script> |
||
| 453 | <script type="text/javascript" src="assets/lightbox/js/lightbox.js"></script> |
||
| 454 | <link rel="stylesheet" href="assets/css/galery.css" type="text/css" media="screen" /> |
||
| 455 | <link rel="stylesheet" type="text/css" media="screen" href="assets/lightbox/css/lightbox.css"></link>'; |
||
| 456 | } else { |
||
| 457 | $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" /> |
||
| 458 | <link rel="stylesheet" href="assets/css/galery.css" type="text/css" media="screen" />'; |
||
| 459 | } |
||
| 460 | |||
| 461 | $xoopsTpl->assign('path_uploads', $GLOBALS['xoopsModuleConfig']['adslight_link_upload']); |
||
| 462 | |||
| 463 | $xoopsTpl->assign('permit', $prem_perm); |
||
| 464 | |||
| 465 | if ($GLOBALS['xoopsModuleConfig']['active_rewriteurl'] > 0) { |
||
| 466 | /* ici le meta Canonicale pour le Rewrite */ |
||
| 467 | $xoopsTpl->assign('xoops_module_header', $header_lightbox); |
||
| 468 | } else { |
||
| 469 | $xoopsTpl->assign('xoops_module_header', $header_lightbox); |
||
| 470 | } |
||
| 471 | $xoopsTpl->assign('photo', $photo); |
||
| 472 | $xoopsTpl->assign('pic_lid', $pic_lid); |
||
| 473 | $xoopsTpl->assign('pic_owner', $uid_owner); |
||
| 474 | } else { |
||
| 475 | $xoopsTpl->assign('photo', ''); |
||
| 476 | } |
||
| 477 | $xoopsTpl->assign('date', '<img alt="date" border="0" src="assets/images/date.png" /> <strong>' |
||
| 478 | . _ADSLIGHT_DATE2 |
||
| 479 | . ':</strong> ' |
||
| 480 | . $date |
||
| 481 | . '<br><img alt="date_error" border="0" src="assets/images/date_error.png" /> <strong>' |
||
| 482 | . _ADSLIGHT_DISPO |
||
| 483 | . ':</strong> ' |
||
| 484 | . $date2 |
||
| 485 | . ''); |
||
| 486 | } else { |
||
| 487 | $xoopsTpl->assign('no_ad', _ADSLIGHT_NOCLAS); |
||
| 488 | } |
||
| 489 | $result8 = $xoopsDB->query('SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ''); |
||
| 490 | |||
| 491 | list($ctitle) = $xoopsDB->fetchRow($result8); |
||
| 492 | $xoopsTpl->assign('friend', '<img src="assets/images/friend.gif" border="0" alt="' |
||
| 493 | . _ADSLIGHT_SENDFRIENDS |
||
| 494 | . '" /> <a rel="nofollow" href="sendfriend.php?op=SendFriend&lid=' |
||
| 495 | . $lid |
||
| 496 | . '">' |
||
| 497 | . _ADSLIGHT_SENDFRIENDS |
||
| 498 | . '</a>'); |
||
| 499 | |||
| 500 | $xoopsTpl->assign('alerteabus', '<img src="assets/images/error.png" border="0" alt="' |
||
| 501 | . _ADSLIGHT_ALERTEABUS |
||
| 502 | . '" /> <a rel="nofollow" href="report-abuse.php?op=ReportAbuse&lid=' |
||
| 503 | . $lid |
||
| 504 | . '">' |
||
| 505 | . _ADSLIGHT_ALERTEABUS |
||
| 506 | . '</a>'); |
||
| 507 | |||
| 508 | $xoopsTpl->assign('link_main', '<a href="../adslight/">' . _ADSLIGHT_MAIN . '</a>'); |
||
| 509 | $xoopsTpl->assign('link_cat', '<a href="viewcats.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_GORUB . ' ' . $ctitle . '</a>'); |
||
| 510 | |||
| 511 | $xoopsTpl->assign('printA', '<img src="assets/images/print.gif" border="0" alt="' |
||
| 512 | . _ADSLIGHT_PRINT |
||
| 513 | . '" /> <a rel="nofollow" href="print.php?op=PrintAd&lid=' |
||
| 514 | . $lid |
||
| 515 | . '">' |
||
| 516 | . _ADSLIGHT_PRINT |
||
| 517 | . '</a>'); |
||
| 518 | } |
||
| 519 | |||
| 520 | # function categorynewgraphic |
||
| 521 | ##################################################### |
||
| 522 | /** |
||
| 523 | * @param $cid |
||
| 524 | * |
||
| 525 | * @return string |
||
| 526 | */ |
||
| 527 | function categorynewgraphic($cid) |
||
|
1 ignored issue
–
show
categorynewgraphic uses the super-global variable $GLOBALS which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
Loading history...
|
|||
| 528 | { |
||
| 529 | global $xoopsDB; |
||
| 530 | |||
| 531 | $cat_perms = ''; |
||
| 532 | $categories = AdslightUtilities::getMyItemIds('adslight_view'); |
||
| 533 | if (is_array($categories) && count($categories) > 0) { |
||
| 534 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
| 535 | } |
||
| 536 | |||
| 537 | $newresult = $xoopsDB->query('SELECT date FROM ' |
||
| 538 | . $xoopsDB->prefix('adslight_listing') |
||
| 539 | . ' WHERE cid=' |
||
| 540 | . $xoopsDB->escape($cid) |
||
| 541 | . ' AND valid = "Yes" ' |
||
| 542 | . $cat_perms |
||
| 543 | . ' ORDER BY date desc limit 1'); |
||
| 544 | list($date) = $xoopsDB->fetchRow($newresult); |
||
| 545 | |||
| 546 | $newcount = $GLOBALS['xoopsModuleConfig']['adslight_countday']; |
||
| 547 | $startdate = (time() - (86400 * $newcount)); |
||
| 548 | if ($startdate < $date) { |
||
| 549 | return '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" />'; |
||
| 550 | } |
||
| 551 | } |
||
| 552 | |||
| 553 | ###################################################### |
||
| 554 | |||
| 555 | $pa = !isset($_GET['pa']) ? null : $_GET['pa']; |
||
| 556 | $lid = !isset($_GET['lid']) ? null : $_GET['lid']; |
||
| 557 | $cid = !isset($_GET['cid']) ? null : $_GET['cid']; |
||
| 558 | $usid = isset($_GET['usid']) ? $_GET['usid'] : ''; |
||
| 559 | $min = !isset($_GET['min']) ? null : $_GET['min']; |
||
| 560 | $show = !isset($_GET['show']) ? null : $_GET['show']; |
||
| 561 | $orderby = !isset($_GET['orderby']) ? null : $_GET['orderby']; |
||
| 562 | |||
| 563 | switch ($pa) { |
||
| 564 | |||
| 565 | default: |
||
| 566 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl'; |
||
| 567 | |||
| 568 | viewAds($lid); |
||
| 569 | break; |
||
| 570 | } |
||
| 571 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 572 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.