mambax7 /
adslight
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * You may not change or alter any portion of this comment or credits |
||
| 7 | * of supporting developers from this source code or any supporting source code |
||
| 8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | * |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @copyright XOOPS Project (https://xoops.org) |
||
| 17 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 18 | * @author XOOPS Development Team |
||
| 19 | * @author Pascal Le Boustouller: original author ([email protected]) |
||
| 20 | * @author Luc Bizet (www.frxoops.org) |
||
| 21 | * @author jlm69 (www.jlmzone.com) |
||
| 22 | * @author mamba (www.xoops.org) |
||
| 23 | */ |
||
| 24 | |||
| 25 | use Xmf\Request; |
||
| 26 | use XoopsModules\Adslight\{ |
||
| 27 | Helper, |
||
| 28 | Tree, |
||
| 29 | Utility |
||
| 30 | }; |
||
| 31 | |||
| 32 | /** @var Helper $helper */ |
||
| 33 | |||
| 34 | require_once __DIR__ . '/header.php'; |
||
| 35 | |||
| 36 | global $xoopsModule, $xoopsDB, $xoopsConfig, $xoTheme; |
||
| 37 | |||
| 38 | $myts = \MyTextSanitizer::getInstance(); |
||
| 39 | $moduleId = $xoopsModule->getVar('mid'); |
||
| 40 | $groups = $GLOBALS['xoopsUser'] instanceof \XoopsUser ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
| 41 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 42 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 43 | $perm_itemid = Request::getInt('item_id', 0, 'POST'); |
||
| 44 | |||
| 45 | //If no access |
||
| 46 | if (!$grouppermHandler->checkRight('adslight_submit', $perm_itemid, $groups, $moduleId)) { |
||
| 47 | $helper->redirect('index.php', 3, _NOPERM); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param $lid |
||
| 52 | * @param $ok |
||
| 53 | */ |
||
| 54 | function listingDel($lid, $ok): void |
||
| 55 | { |
||
| 56 | global $xoopsDB; |
||
| 57 | $helper = Helper::getInstance(); |
||
| 58 | $result = $xoopsDB->query( |
||
| 59 | 'SELECT usid FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid) |
||
| 60 | ); |
||
| 61 | [$usid] = $xoopsDB->fetchRow($result); |
||
| 62 | $result1 = $xoopsDB->query( |
||
| 63 | 'SELECT url FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE lid=' . $xoopsDB->escape($lid) |
||
| 64 | ); |
||
| 65 | if ($GLOBALS['xoopsUser']) { |
||
| 66 | $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E'); |
||
| 67 | if ($usid === $currentid) { |
||
| 68 | if (1 === $ok) { |
||
| 69 | while ([$purl] = $xoopsDB->fetchRow($result1)) { |
||
| 70 | if ($purl) { |
||
| 71 | $destination = XOOPS_ROOT_PATH . '/uploads/adslight'; |
||
| 72 | if (is_file("${destination}/${purl}")) { |
||
| 73 | unlink("${destination}/${purl}"); |
||
| 74 | } |
||
| 75 | $destination2 = XOOPS_ROOT_PATH . '/uploads/adslight/thumbs'; |
||
| 76 | if (is_file("${destination2}/thumb_${purl}")) { |
||
| 77 | unlink("${destination2}/thumb_${purl}"); |
||
| 78 | } |
||
| 79 | $destination3 = XOOPS_ROOT_PATH . '/uploads/adslight/midsize'; |
||
| 80 | if (is_file("${destination3}/resized_${purl}")) { |
||
| 81 | unlink("${destination3}/resized_${purl}"); |
||
| 82 | } |
||
| 83 | $xoopsDB->queryF( |
||
| 84 | 'DELETE FROM ' . $xoopsDB->prefix( |
||
| 85 | 'adslight_pictures' |
||
| 86 | ) . ' WHERE lid=' . $xoopsDB->escape($lid) |
||
| 87 | ); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | $xoopsDB->queryF( |
||
| 91 | 'DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid) |
||
| 92 | ); |
||
| 93 | $helper->redirect('index.php', 1, _ADSLIGHT_ANNDEL); |
||
| 94 | } else { |
||
| 95 | echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n"; |
||
| 96 | echo '<br><div style="text-align:center">'; |
||
| 97 | echo '<strong>' . _ADSLIGHT_SURDELANN . '</strong></div><br><br>'; |
||
| 98 | } |
||
| 99 | echo '[ <a href="modify.php?op=ListingDel&lid=' . $lid . '&ok=1">' . _YES . '</a> | <a href="index.php">' . _NO . '</a> ]<br><br>'; |
||
| 100 | echo '</td></tr></table>'; |
||
| 101 | } |
||
| 102 | } |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @param $r_lid |
||
| 107 | * @param $ok |
||
| 108 | */ |
||
| 109 | function delReply($r_lid, $ok): void |
||
| 110 | { |
||
| 111 | global $xoopsDB; |
||
| 112 | $helper = Helper::getInstance(); |
||
| 113 | $sql = 'SELECT l.usid, r.r_lid, r.lid, r.title, r.date_created, r.submitter, r.message, r.tele, r.email, r.r_usid FROM ' . $xoopsDB->prefix( |
||
| 114 | 'adslight_listing' |
||
| 115 | ) . ' l LEFT JOIN ' . $xoopsDB->prefix( |
||
| 116 | 'adslight_replies' |
||
| 117 | ) . ' r ON l.lid=r.lid WHERE r.r_lid=' . $xoopsDB->escape($r_lid); |
||
| 118 | $result = $xoopsDB->query($sql); |
||
| 119 | [$usid, $r_lid, $rlid, $title, $date_created, $submitter, $message, $tele, $email, $r_usid] = $xoopsDB->fetchRow( |
||
| 120 | $result |
||
| 121 | ); |
||
| 122 | if ($GLOBALS['xoopsUser']) { |
||
| 123 | $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E'); |
||
| 124 | if ($usid === $currentid) { |
||
| 125 | if (1 === $ok) { |
||
| 126 | $xoopsDB->queryF( |
||
| 127 | 'DELETE FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE r_lid=' . $xoopsDB->escape($r_lid) |
||
| 128 | ); |
||
| 129 | $helper->redirect('members.php?usid=' . addslashes($usid) . '', 1, _ADSLIGHT_ANNDEL); |
||
| 130 | } else { |
||
| 131 | echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n"; |
||
| 132 | echo '<br><div style="text-align:center">'; |
||
| 133 | echo '<strong>' . _ADSLIGHT_SURDELANN . '</strong></div><br><br>'; |
||
| 134 | } |
||
| 135 | echo '[ <a href="modify.php?op=DelReply&r_lid=' . addslashes( |
||
| 136 | $r_lid |
||
| 137 | ) . '&ok=1">' . _YES . '</a> | <a href="members.php?usid=' . addslashes( |
||
| 138 | $usid |
||
| 139 | ) . '">' . _NO . '</a> ]<br><br>'; |
||
| 140 | echo '</td></tr></table>'; |
||
| 141 | } |
||
| 142 | } |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @param $lid |
||
| 147 | */ |
||
| 148 | function modifyAd($lid): void |
||
| 149 | { |
||
| 150 | global $xoopsDB, $xoopsModule, $xoopsConfig, $myts; |
||
| 151 | $contactselect = ''; |
||
| 152 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 153 | $helper = Helper::getInstance(); |
||
| 154 | $options = []; |
||
| 155 | $options['name'] = 'Editor'; |
||
| 156 | $options['value'] = _ADSLIGHT_DESC; |
||
| 157 | $options['rows'] = 10; |
||
| 158 | $options['cols'] = '100%'; |
||
| 159 | $options['width'] = '100%'; |
||
| 160 | $options['height'] = '200px'; |
||
| 161 | echo "<script language=\"javascript\">\nfunction CLA(CLA) { var MainWindow = window.open (CLA, \"_blank\",\"width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no\");}\n</script>"; |
||
| 162 | |||
| 163 | $mytree = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
||
| 164 | $sql = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typecondition, date_created, email, submitter, usid, town, country, contactby, premium, valid FROM ' . $xoopsDB->prefix( |
||
| 165 | 'adslight_listing' |
||
| 166 | ) . ' WHERE lid=' . $xoopsDB->escape( |
||
| 167 | $lid |
||
| 168 | ); |
||
| 169 | $result = $xoopsDB->query($sql); |
||
| 170 | [$lid, $cide, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typecondition, $date_created, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid] = $xoopsDB->fetchRow( |
||
| 171 | $result |
||
| 172 | ); |
||
| 173 | $categories = Utility::getMyItemIds('adslight_submit'); |
||
| 174 | if (is_array($categories) && count($categories) > 0) { |
||
| 175 | if (!\in_array((int)$cide, $categories, true)) { |
||
| 176 | $helper->redirect('index.php', 3, _NOPERM); |
||
| 177 | } |
||
| 178 | } else { // User can't see any category |
||
| 179 | redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM); |
||
| 180 | } |
||
| 181 | |||
| 182 | if ($GLOBALS['xoopsUser']) { |
||
| 183 | $calusern = $GLOBALS['xoopsUser']->uid(); |
||
| 184 | if ((int)$usid === $calusern) { |
||
| 185 | echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADSLIGHT_MODIFANN . '</legend><br><br>'; |
||
| 186 | $title = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5); |
||
| 187 | $status = \htmlspecialchars($status, ENT_QUOTES | ENT_HTML5); |
||
| 188 | $expire = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5); |
||
| 189 | $type = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5); |
||
| 190 | $desctext = $myts->displayTarea($desctext, 1); |
||
| 191 | $tel = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5); |
||
| 192 | |||
| 193 | // $price = number_format($price, 2, ',', ' '); |
||
| 194 | |||
| 195 | xoops_load('XoopsLocal'); |
||
| 196 | $tempXoopsLocal = new \XoopsLocal(); |
||
| 197 | // For US currency with 2 numbers after the decimal comment out if you don't want 2 numbers after decimal |
||
| 198 | $price = $tempXoopsLocal->number_format($price, 2, ',', ' '); |
||
| 199 | // For other countries uncomment the below line and comment out the above line |
||
| 200 | // $price = $tempXoopsLocal->number_format($price); |
||
| 201 | |||
| 202 | $typeprice = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5); |
||
| 203 | $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5); |
||
| 204 | $submitter = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5); |
||
| 205 | $town = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5); |
||
| 206 | $country = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5); |
||
| 207 | $contactby = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5); |
||
| 208 | $premium = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5); |
||
| 209 | $useroffset = ''; |
||
| 210 | if ($GLOBALS['xoopsUser']) { |
||
| 211 | $timezone = $GLOBALS['xoopsUser']->timezone(); |
||
| 212 | $useroffset = empty($timezone) ? $xoopsConfig['default_TZ'] : $GLOBALS['xoopsUser']->timezone(); |
||
| 213 | } |
||
| 214 | $dates = formatTimestamp($date_created, 's'); |
||
| 215 | |||
| 216 | echo '<form action="modify.php" method=post enctype="multipart/form-data">'; |
||
| 217 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||
| 218 | echo '<table><tr class="head" border="2"> |
||
| 219 | <td class="head">' . _ADSLIGHT_NUMANNN . " </td><td class=\"head\" border=\"1\">${lid} " . _ADSLIGHT_DU . " ${dates}</td> |
||
| 220 | </tr><tr>"; |
||
| 221 | if ('1' === $helper->getConfig('adslight_diff_name')) { |
||
| 222 | echo '<td class="head">' . _ADSLIGHT_SENDBY . " </td><td class=\"head\"><input type=\"text\" name=\"submitter\" size=\"50\" value=\"${submitter}\" ></td>"; |
||
| 223 | } else { |
||
| 224 | echo '<td class="head">' . _ADSLIGHT_SENDBY . " </td><td class=\"head\"><input type=\"hidden\" name=\"submitter\" value=\"${submitter}\">${submitter}</td>"; |
||
| 225 | } |
||
| 226 | echo '</tr><tr>'; |
||
| 227 | if (1 === $contactby) { |
||
| 228 | $contactselect = _ADSLIGHT_CONTACT_BY_EMAIL; |
||
| 229 | } |
||
| 230 | if (2 === $contactby) { |
||
| 231 | $contactselect = _ADSLIGHT_CONTACT_BY_PM; |
||
| 232 | } |
||
| 233 | if (3 === $contactby) { |
||
| 234 | $contactselect = _ADSLIGHT_CONTACT_BY_BOTH; |
||
| 235 | } |
||
| 236 | if (4 === $contactby) { |
||
| 237 | $contactselect = _ADSLIGHT_CONTACT_BY_PHONE; |
||
| 238 | } |
||
| 239 | |||
| 240 | echo " <td class='head'>" . _ADSLIGHT_CONTACTBY . " </td><td class='head'><select name=\"contactby\"> |
||
| 241 | <option value=\"" . $contactby . '">' . $contactselect . '</option> |
||
| 242 | <option value="1">' . _ADSLIGHT_CONTACT_BY_EMAIL . '</option> |
||
| 243 | <option value="2">' . _ADSLIGHT_CONTACT_BY_PM . '</option> |
||
| 244 | <option value="3">' . _ADSLIGHT_CONTACT_BY_BOTH . '</option> |
||
| 245 | <option value="4">' . _ADSLIGHT_CONTACT_BY_PHONE . '</option></select></td></tr>'; |
||
| 246 | if ('1' === $helper->getConfig('adslight_diff_email')) { |
||
| 247 | echo '<tr><td class="head">' . _ADSLIGHT_EMAIL . " </td><td class=\"head\"><input type=\"text\" name=\"email\" size=\"50\" value=\"${email}\" ></td>"; |
||
| 248 | } else { |
||
| 249 | echo '<tr><td class="head">' . _ADSLIGHT_EMAIL . " </td><td class=\"head\">${email}<input type=\"hidden\" name=\"email\" value=\"${email}\" ></td>"; |
||
| 250 | } |
||
| 251 | echo '</tr><tr> |
||
| 252 | <td class="head">' . _ADSLIGHT_TEL . " </td><td class=\"head\"><input type=\"text\" name=\"tel\" size=\"50\" value=\"${tel}\" ></td> |
||
| 253 | </tr>"; |
||
| 254 | echo '<tr> |
||
| 255 | <td class="head">' . _ADSLIGHT_TOWN . " </td><td class=\"head\"><input type=\"text\" name=\"town\" size=\"50\" value=\"${town}\" ></td> |
||
| 256 | </tr>"; |
||
| 257 | if ('1' === $helper->getConfig('adslight_use_country')) { |
||
| 258 | echo '<tr> |
||
| 259 | <td class="head">' . _ADSLIGHT_COUNTRY . " </td><td class=\"head\"><input type=\"text\" name=\"country\" size=\"50\" value=\"${country}\" ></td> |
||
| 260 | </tr>"; |
||
| 261 | } else { |
||
| 262 | echo '<input type="hidden" name="country" value="">'; |
||
| 263 | } |
||
| 264 | |||
| 265 | echo "<tr><td class='head'>" . _ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\""; |
||
| 266 | if (0 === (int)$status) { |
||
| 267 | echo 'checked'; |
||
| 268 | } |
||
| 269 | echo '>' . _ADSLIGHT_ACTIVE . ' <input type="radio" name="status" value="1"'; |
||
| 270 | if (1 === (int)$status) { |
||
| 271 | echo 'checked'; |
||
| 272 | } |
||
| 273 | echo '>' . _ADSLIGHT_INACTIVE . ' <input type="radio" name="status" value="2"'; |
||
| 274 | if (2 === (int)$status) { |
||
| 275 | echo 'checked'; |
||
| 276 | } |
||
| 277 | echo '>' . _ADSLIGHT_SOLD . '</td></tr>'; |
||
| 278 | echo '<tr> |
||
| 279 | <td class="head">' . _ADSLIGHT_TITLE2 . " </td><td class=\"head\"><input type=\"text\" name=\"title\" size=\"50\" value=\"${title}\" ></td> |
||
| 280 | </tr>"; |
||
| 281 | echo '<tr><td class="head">' . _ADSLIGHT_PRICE2 . " </td><td class=\"head\"><input type=\"text\" name=\"price\" size=\"20\" value=\"${price}\" > " . $helper->getConfig('adslight_currency_symbol'); |
||
| 282 | |||
| 283 | $sql = 'SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price'; |
||
| 284 | $result3 = $xoopsDB->query($sql); |
||
| 285 | echo ' <select name="typeprice">'; |
||
| 286 | while ([$nom_price, $id_price] = $xoopsDB->fetchRow($result3)) { |
||
| 287 | $sel = ''; |
||
| 288 | if ($id_price === $typeprice) { |
||
| 289 | $sel = 'selected'; |
||
| 290 | } |
||
| 291 | echo "<option value=\"${id_price}\" ${sel}>${nom_price}</option>"; |
||
| 292 | } |
||
| 293 | echo '</select></td></tr>'; |
||
| 294 | $moduleId = $xoopsModule->getVar('mid'); |
||
| 295 | $groups = $GLOBALS['xoopsUser'] instanceof \XoopsUser ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
| 296 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 297 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 298 | $perm_itemid = Request::getInt('item_id', 0, 'GET'); |
||
| 299 | |||
| 300 | //If no access |
||
| 301 | if ($grouppermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $moduleId)) { |
||
| 302 | echo "<tr> |
||
| 303 | <td width='30%' class='head'>" . _ADSLIGHT_HOW_LONG . " </td><td class='head'><input type=\"text\" name=\"expire\" size=\"3\" maxlength=\"3\" value=\"${expire}\" > " . _ADSLIGHT_DAY . '</td> |
||
| 304 | </tr>'; |
||
| 305 | } else { |
||
| 306 | echo "<tr> |
||
| 307 | <td width='30%' class='head'>" . _ADSLIGHT_WILL_LAST . " </td><td class='head'>${expire} " . _ADSLIGHT_DAY . '</td> |
||
| 308 | </tr>'; |
||
| 309 | echo "<input type=\"hidden\" name=\"expire\" value=\"${expire}\" >"; |
||
| 310 | } |
||
| 311 | |||
| 312 | /// Type d'annonce |
||
| 313 | echo '<tr> |
||
| 314 | <td class="head">' . _ADSLIGHT_TYPE . ' </td><td class="head"><select name="type">'; |
||
| 315 | |||
| 316 | $sql = 'SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type'; |
||
| 317 | $result5 = $xoopsDB->query($sql); |
||
| 318 | while ([$nom_type, $id_type] = $xoopsDB->fetchRow($result5)) { |
||
| 319 | $sel = ''; |
||
| 320 | if ($id_type === $type) { |
||
| 321 | $sel = 'selected'; |
||
| 322 | } |
||
| 323 | echo "<option value=\"${id_type}\" ${sel}>${nom_type}</option>"; |
||
| 324 | } |
||
| 325 | echo '</select></td></tr>'; |
||
| 326 | |||
| 327 | /// Etat de l'objet |
||
| 328 | echo '<tr> |
||
| 329 | <td class="head">' . _ADSLIGHT_TYPE_CONDITION . ' </td><td class="head"><select name="typecondition">'; |
||
| 330 | |||
| 331 | $sql = 'SELECT nom_condition, id_condition FROM ' . $xoopsDB->prefix('adslight_condition') . ' ORDER BY nom_condition'; |
||
| 332 | $result6 = $xoopsDB->query($sql); |
||
| 333 | while ([$nom_condition, $id_condition] = $xoopsDB->fetchRow($result6)) { |
||
| 334 | $sel = ''; |
||
| 335 | if ($id_condition === $typecondition) { |
||
| 336 | $sel = 'selected'; |
||
| 337 | } |
||
| 338 | echo "<option value=\"${id_condition}\" ${sel}>${nom_condition}</option>"; |
||
| 339 | } |
||
| 340 | echo '</select></td></tr>'; |
||
| 341 | |||
| 342 | echo '<tr> |
||
| 343 | <td class="head">' . _ADSLIGHT_CAT . ' </td><td class="head">'; |
||
| 344 | $mytree->makeMySelBox('title', 'title', $cide, 0, 'cid'); |
||
| 345 | echo '</td> |
||
| 346 | </tr><tr> |
||
| 347 | <td class="head">' . _ADSLIGHT_DESC . ' </td><td class="head">'; |
||
| 348 | // $wysiwyg_text_area = Utility::getEditor(_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px'); |
||
| 349 | |||
| 350 | // $desctext = $myts->displayTarea($desctext, 1); |
||
| 351 | |||
| 352 | $options = []; |
||
| 353 | $options['name'] = _ADSLIGHT_DESC; |
||
| 354 | $options['value'] = $desctext; |
||
| 355 | $options['rows'] = 10; |
||
| 356 | $options['cols'] = '100%'; |
||
| 357 | $options['width'] = '100%'; |
||
| 358 | $options['height'] = '400px'; |
||
| 359 | |||
| 360 | $wysiwyg_text_area = Utility::getEditor($helper, $options); |
||
| 361 | echo $wysiwyg_text_area->render(); |
||
| 362 | echo '</td></tr> |
||
| 363 | <td colspan=2><br><input type="submit" value="' . _ADSLIGHT_MODIFANN . '" ></td> |
||
| 364 | </tr></table>'; |
||
| 365 | echo '<input type="hidden" name="op" value="modads" >'; |
||
| 366 | |||
| 367 | $moduleId = $xoopsModule->getVar('mid'); |
||
| 368 | if (is_object($GLOBALS['xoopsUser'])) { |
||
| 369 | $groups = &$GLOBALS['xoopsUser']->getGroups(); |
||
| 370 | } else { |
||
| 371 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
| 372 | } |
||
| 373 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 374 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 375 | $perm_itemid = Request::getInt('item_id', 0, 'POST'); |
||
| 376 | //If no access |
||
| 377 | if ($grouppermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $moduleId)) { |
||
| 378 | echo '<input type="hidden" name="valid" value="Yes" >'; |
||
| 379 | } elseif ('1' === $helper->getConfig('adslight_moderated')) { |
||
| 380 | echo '<input type="hidden" name="valid" value="No" >'; |
||
| 381 | echo '<br>' . _ADSLIGHT_MODIFBEFORE . '<br>'; |
||
| 382 | } else { |
||
| 383 | echo '<input type="hidden" name="valid" value="Yes" >'; |
||
| 384 | } |
||
| 385 | echo "<input type=\"hidden\" name=\"lid\" value=\"${lid}\" >"; |
||
| 386 | echo "<input type=\"hidden\" name=\"premium\" value=\"${premium}\" >"; |
||
| 387 | echo "<input type=\"hidden\" name=\"date_created\" value=\"${date_created}\" > |
||
| 388 | " . $GLOBALS['xoopsSecurity']->getTokenHTML() . ''; |
||
| 389 | echo '</form><br></fieldset><br>'; |
||
| 390 | } |
||
| 391 | } |
||
| 392 | } |
||
| 393 | |||
| 394 | /** |
||
| 395 | * @param $lid |
||
| 396 | * @param $cat |
||
| 397 | * @param $title |
||
| 398 | * @param $status |
||
| 399 | * @param $expire |
||
| 400 | * @param $type |
||
| 401 | * @param $desctext |
||
| 402 | * @param $tel |
||
| 403 | * @param $price |
||
| 404 | * @param $typeprice |
||
| 405 | * @param $typecondition |
||
| 406 | * @param $date_created |
||
| 407 | * @param $email |
||
| 408 | * @param $submitter |
||
| 409 | * @param $town |
||
| 410 | * @param $country |
||
| 411 | * @param $contactby |
||
| 412 | * @param $premium |
||
| 413 | * @param $valid |
||
| 414 | */ |
||
| 415 | function modifyAds( |
||
| 416 | $lid, |
||
| 417 | $cat, |
||
| 418 | $title, |
||
| 419 | $status, |
||
| 420 | $expire, |
||
| 421 | $type, |
||
| 422 | $desctext, |
||
| 423 | $tel, |
||
| 424 | $price, |
||
| 425 | $typeprice, |
||
| 426 | $typecondition, |
||
| 427 | $date_created, |
||
| 428 | $email, |
||
| 429 | $submitter, |
||
| 430 | $town, |
||
| 431 | $country, |
||
| 432 | $contactby, |
||
| 433 | $premium, |
||
| 434 | $valid |
||
| 435 | ) { |
||
| 436 | global $xoopsDB, $myts; |
||
| 437 | $helper = Helper::getInstance(); |
||
| 438 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 439 | $helper->redirect('index.php', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||
| 440 | } |
||
| 441 | |||
| 442 | $sql = 'UPDATE ' |
||
| 443 | . $xoopsDB->prefix('adslight_listing') |
||
| 444 | . " 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}"; |
||
| 445 | $result = $xoopsDB->query($sql); |
||
| 446 | |||
| 447 | $helper->redirect('index.php', 1, _ADSLIGHT_ANNMOD2); |
||
| 448 | } |
||
| 449 | |||
| 450 | #################################################### |
||
| 451 | //foreach ($_POST as $k => $v) { |
||
| 452 | // ${$k} = $v; |
||
| 453 | //} |
||
| 454 | |||
| 455 | $cid = Request::getInt('cid', 0, 'POST'); |
||
| 456 | $contactby = Request::getInt('contactby', 0, 'POST'); |
||
| 457 | $country = Request::getString('country', '', 'POST'); |
||
| 458 | $date_created = Request::getInt('date_created', time(), 'POST'); |
||
| 459 | $desctext = Request::getText('Description', '', 'POST'); |
||
| 460 | $email = Request::getString('email', '', 'POST'); |
||
| 461 | $expire = Request::getInt('expire', 14, 'POST'); |
||
| 462 | $lid = Request::getInt('lid', 0, 'POST'); |
||
| 463 | $op = Request::getCmd('op', '', 'POST'); |
||
| 464 | $premium = Request::getInt('premium', 0, 'POST'); |
||
| 465 | $price = Request::getFloat('price', 0.00, 'POST'); |
||
| 466 | $status = Request::getInt('status', 0, 'POST'); |
||
| 467 | $submitter = Request::getInt('submitter', 0, 'POST'); |
||
| 468 | $tel = Request::getString('tel', '', 'POST'); |
||
| 469 | $title = Request::getString('title', '', 'POST'); |
||
| 470 | $town = Request::getString('town', '', 'POST'); |
||
| 471 | $type = Request::getInt('type', 0, 'POST'); |
||
| 472 | $typecondition = Request::getInt('typecondition', 0, 'POST'); |
||
| 473 | $typeprice = Request::getInt('typeprice', 0, 'POST'); |
||
| 474 | $valid = Request::getString('valid', '', 'POST'); |
||
| 475 | |||
| 476 | $ok = Request::getString('ok', '', 'GET'); |
||
| 477 | |||
| 478 | if (!Request::hasVar('lid', 'POST') && Request::hasVar('lid', 'GET')) { |
||
| 479 | $lid = Request::getInt('lid', 0, 'GET'); |
||
| 480 | } |
||
| 481 | if (!Request::hasVar('r_lid', 'POST') && Request::hasVar('r_lid', 'GET')) { |
||
| 482 | $r_lid = Request::getInt('r_lid', '', 'GET'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 483 | } |
||
| 484 | if (!Request::hasVar('op', 'POST') && Request::hasVar('op', 'GET')) { |
||
| 485 | $op = Request::getCmd('op', '', 'GET'); |
||
| 486 | } |
||
| 487 | switch ($op) { |
||
| 488 | case 'modad': |
||
| 489 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 490 | modifyAd($lid); |
||
| 491 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 492 | break; |
||
| 493 | case 'modads': |
||
| 494 | modifyAds( |
||
| 495 | $lid, |
||
| 496 | $cid, |
||
| 497 | $title, |
||
| 498 | $status, |
||
| 499 | $expire, |
||
| 500 | $type, |
||
| 501 | $desctext, |
||
| 502 | $tel, |
||
| 503 | $price, |
||
| 504 | $typeprice, |
||
| 505 | $typecondition, |
||
| 506 | $date_created, |
||
| 507 | $email, |
||
| 508 | $submitter, |
||
| 509 | $town, |
||
| 510 | $country, |
||
| 511 | $contactby, |
||
| 512 | $premium, |
||
| 513 | $valid |
||
| 514 | ); |
||
| 515 | break; |
||
| 516 | case 'ListingDel': |
||
| 517 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 518 | listingDel($lid, $ok); |
||
| 519 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 520 | break; |
||
| 521 | case 'DelReply': |
||
| 522 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 523 | delReply($r_lid, $ok); |
||
| 524 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 525 | break; |
||
| 526 | default: |
||
| 527 | $helper->redirect('index.php', 1, '' . _RETURNANN); |
||
| 528 | break; |
||
| 529 | } |
||
| 530 |