XoopsModules25x /
xoopspartners
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 | XOOPS - PHP Content Management System |
||
| 5 | Copyright (c) 2000 XOOPS.org |
||
| 6 | <http://www.xoops.org/> |
||
| 7 | ------------------------------------------------------------------------ |
||
| 8 | This program is free software; you can redistribute it and/or modify |
||
| 9 | it under the terms of the GNU General Public License as published by |
||
| 10 | the Free Software Foundation; either version 2 of the License, or |
||
| 11 | (at your option) any later version. |
||
| 12 | |||
| 13 | You may not change or alter any portion of this comment or credits |
||
| 14 | of supporting developers from this source code or any supporting |
||
| 15 | source code which is considered copyrighted (c) material of the |
||
| 16 | original comment or credit authors. |
||
| 17 | |||
| 18 | This program is distributed in the hope that it will be useful, |
||
| 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 21 | GNU General Public License for more details. |
||
| 22 | |||
| 23 | You should have received a copy of the GNU General Public License |
||
| 24 | along with this program; if not, write to the Free Software |
||
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
| 26 | ------------------------------------------------------------------------ |
||
| 27 | Author: Raul Recio (AKA UNFOR) |
||
| 28 | Project: The XOOPS Project |
||
| 29 | ------------------------------------------------------------------------- |
||
| 30 | */ |
||
| 31 | /** |
||
| 32 | * Module: XoopsPartners - a partner affiliation links module |
||
| 33 | * |
||
| 34 | * @category Module |
||
| 35 | * @package xoopspartners |
||
| 36 | * @subpackage admin |
||
| 37 | * @author Raul Recio (aka UNFOR) |
||
| 38 | * @author XOOPS Module Development Team |
||
| 39 | * @copyright {@link http://xoops.org 2001-2016 XOOPS Project} |
||
| 40 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
||
| 41 | * @link http://xoops.org XOOPS |
||
| 42 | * @since 1.11 |
||
| 43 | */ |
||
| 44 | |||
| 45 | require __DIR__ . '/admin_header.php'; |
||
| 46 | $adminClass = new ModuleAdmin(); |
||
| 47 | $pathImageIcon = $GLOBALS['xoops']->url('www/' . $moduleInfo->getInfo('icons16')); |
||
| 48 | |||
| 49 | $myts = MyTextSanitizer::getInstance(); |
||
| 50 | |||
| 51 | xoops_load('XoopsRequest'); |
||
| 52 | $op = XoopsRequest::getCmd('op', ''); |
||
| 53 | $id = XoopsRequest::getInt('id', 0); |
||
| 54 | |||
| 55 | $del = isset($_POST['del']) ? XoopsRequest::getInt('del', XoopspartnersConstants::CONFIRM_NOT_OK, 'POST') : null; |
||
| 56 | $hits = isset($_POST['hits']) ? XoopsRequest::getInt('hits', 0, 'POST') : null; |
||
| 57 | $url = isset($_POST['url']) ? XoopsRequest::getString('url', '', 'POST') : null; |
||
| 58 | $image = isset($_POST['image']) ? XoopsRequest::getText('image', '', 'POST') : null; |
||
| 59 | $title = isset($_POST['title']) ? XoopsRequest::getString('title', '', 'POST') : null; |
||
| 60 | $description = isset($_POST['description']) ? XoopsRequest::getText('description', '', 'POST') : null; |
||
| 61 | $status = isset($_POST['status']) ? XoopsRequest::getInt('status', array(), 'POST') : null; |
||
| 62 | |||
| 63 | switch ($op) { |
||
| 64 | |||
| 65 | case 'partnersAdmin': |
||
| 66 | default: |
||
| 67 | $xpPartnerHandler = xoops_getModuleHandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 68 | |||
| 69 | echo $adminClass->addNavigation('main.php'); |
||
| 70 | $adminClass->addItemButton(_AM_XPARTNERS_ADD, 'main.php' . '?op=partnersAdminAdd', $icon = 'add'); |
||
| 71 | echo $adminClass->renderButton(); |
||
| 72 | |||
| 73 | echo " <form action='main.php' method='post' name='reorderform'>\n" . " <table style='margin: 1px; padding: 0px;' class='outer width100 bnone'>\n" . " <thead>\n" . " <tr>\n" . " <th class='txtcenter width20'>" . _AM_XPARTNERS_TITLE . "</th>\n" |
||
| 74 | . " <th style='width: 3%; text-align: center;'>" . _AM_XPARTNERS_IMAGE . "</th>\n" . ' <th>' . _AM_XPARTNERS_DESCRIPTION . "</th>\n" . " <th class='width3 txtcenter'>" . _AM_XPARTNERS_ACTIVE . "</th>\n" . " <th class='width3 txtcenter'>" |
||
| 75 | . _AM_XPARTNERS_WEIGHT . "</th>\n" . " <th class='width3 txtcenter'>" . _AM_XPARTNERS_HITS . "</th>\n" . " <th class='width3 txtcenter'>" . _AM_XPARTNERS_ACTIONS . "</th>\n" . " </tr>\n" . " </thead>\n" . " <tbody\n"; |
||
| 76 | |||
| 77 | $criteria = new CriteriaCompo(); |
||
| 78 | $criteria->setSort('status DESC, weight ASC, title'); |
||
| 79 | $criteria->setOrder('DESC'); |
||
| 80 | $partnerObjs = $xpPartnerHandler->getAll($criteria); |
||
| 81 | $class = 'even'; |
||
| 82 | $maxWidth = $GLOBALS['xoopsModuleConfig']['maxwidth']; |
||
| 83 | $maxHeight = $GLOBALS['xoopsModuleConfig']['maxheight']; |
||
| 84 | foreach ($partnerObjs as $partnerObj) { |
||
| 85 | $url = formatURL($partnerObj->getVar('url')); |
||
| 86 | $image = formatURL($partnerObj->getVar('image')); |
||
| 87 | $title = $partnerObj->getVar('title'); |
||
| 88 | $description = $partnerObj->getVar('description'); |
||
| 89 | //@TODO - find a way to check size of remote image if allow_url_fopen=0 |
||
| 90 | if ($imageInfo = @getimagesize($image)) { //note this will "fail" if server set with allow_url_fopen=0 |
||
| 91 | $imageWidth = $imageInfo[0]; |
||
| 92 | $imageHeight = $imageInfo[1]; |
||
| 93 | $errorMsg = ($imageWidth > $maxWidth || $imageHeight > $maxHeight) ? '<br>' . _AM_XPARTNERS_IMAGE_ERROR : ''; |
||
| 94 | } else { |
||
| 95 | $imageWidth = $maxWidth; |
||
| 96 | $imageHeight = $maxHeight; |
||
| 97 | $errorMsg = ''; |
||
| 98 | } |
||
| 99 | if (1 == $partnerObj->getVar('status')) { |
||
| 100 | $check1 = " selected='selected'"; |
||
| 101 | $check2 = ''; |
||
| 102 | } else { |
||
| 103 | $check1 = ''; |
||
| 104 | $check2 = " selected='selected'"; |
||
| 105 | } |
||
| 106 | echo " <tr>\n" . " <td class='{$class} width20 txtcenter alignmiddle'><a href='{$url}' rel='external'>{$title}</a></td>\n" . " <td class='{$class} width3 txtcenter'>"; |
||
| 107 | if (!empty($image)) { |
||
| 108 | echo "<img src='{$image}' alt='{$title}' style='width: " . (int)(.65 * $imageWidth) . 'px; height: ' . (int)(.65 * $imageHeight) . "px;'>{$errorMsg}"; |
||
| 109 | } else { |
||
| 110 | echo ' '; |
||
| 111 | } |
||
| 112 | |||
| 113 | echo " </td>\n" . " <td class='{$class} alignmiddle'>{$description}</td>\n" . " <td class='{$class} width3 txtcenter alignmiddle'>\n" . " <select name='status[" . $partnerObj->getVar('id') . "]'>\n" . " <option value='0'{$check2}>" . _NO |
||
| 114 | . "</option>\n" . " <option value='1'{$check1}>" . _YES . "</option>\n" . " </select>\n" . " <td class='{$class} width3 txtcenter alignmiddle'>\n" . " <input type='number' class='txtcenter' name='weight[" . $partnerObj->getVar('id') . "]' value='" |
||
| 115 | . $partnerObj->getVar('weight') . "' min='0' size='3'>\n" . " </td>\n" . " <td class='{$class} width3 txtcenter alignmiddle'>" . $partnerObj->getVar('hits') . "</td>\n" . " <td class='{$class} width3 txtcenter alignmiddle'>\n" |
||
| 116 | . " <a href='main.php?op=editPartner&id=" . $partnerObj->getVar('id') . "'><img src='{$pathImageIcon}/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "'></a>\n" . " <a href='main.php?op=delPartner&id=" . $partnerObj->getVar('id') |
||
| 117 | . "'><img src='{$pathImageIcon}/delete.png' alt='" . _DELETE . "' title='" . _DELETE . "'></a>\n" . " </td>\n" . " </tr>\n"; |
||
| 118 | $class = ($class == 'odd') ? 'even' : 'odd'; |
||
| 119 | } |
||
| 120 | if (empty($partnerObjs)) { |
||
| 121 | echo "<tr><td class='{$class} txtcenter bold line140' colspan='7'>" . _AM_XPARTNERS_NOPARTNERS . "</td></tr>\n"; |
||
| 122 | $adminButtons = ''; |
||
| 123 | } else { |
||
| 124 | $adminButtons = " <input type='button' name='button' onclick=\"location='main.php?op=reorderAutoPartners'\" value='" . _AM_XPARTNERS_AUTOMATIC_SORT . "'>\n" . " <input type='submit' name='submit' value='" . _AM_XPARTNERS_UPDATE . "'>"; |
||
| 125 | |||
| 126 | } |
||
| 127 | echo " <tr>\n" . " <td class='foot txtright' colspan='7'>\n" . " <input type='hidden' name='op' value='reorderPartners'>\n" |
||
| 128 | // . " <input type='button' name='button' onclick=\"location='main.php?op=partnersAdminAdd'\" value='" . _AM_XPARTNERS_ADD . "'>\n" |
||
| 129 | . "{$adminButtons}\n" . " </td>\n" . " </tr>\n" . " </tbody>\n" . " </table>\n" . " </form>\n"; |
||
| 130 | |||
| 131 | unset($partnerObjs); |
||
| 132 | include __DIR__ . '/admin_footer.php'; |
||
| 133 | break; |
||
| 134 | |||
| 135 | case 'reorderPartners': |
||
| 136 | $weight = isset($_POST['weight']) ? XoopsRequest::getArray('weight', array(), 'POST') : null; |
||
| 137 | $status = isset($_POST['status']) ? XoopsRequest::getArray('status', array(), 'POST') : null; |
||
| 138 | |||
| 139 | $xpPartnerHandler = xoops_getModuleHandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 140 | $partnerCount = $xpPartnerHandler->getCount(); |
||
| 141 | if ($partnerCount) { |
||
| 142 | foreach ($weight as $id => $order) { |
||
| 143 | if ((int)$id > XoopspartnersConstants::DEFAULT_PID) { |
||
| 144 | $order = ((!empty($order)) && ((int)$order > XoopspartnersConstants::DEFAULT_WEIGHT)) ? (int)$order : XoopspartnersConstants::DEFAULT_WEIGHT; |
||
| 145 | $stat = (!empty($status[$id]) && ($status[$id] > XoopspartnersConstants::STATUS_INACTIVE)) ? (int)$status[$id] : XoopspartnersConstants::STATUS_INACTIVE; |
||
| 146 | $thisObj = $xpPartnerHandler->get($id); |
||
| 147 | if (!empty($thisObj) && ($thisObj instanceof XoopspartnersPartners)) { |
||
| 148 | $thisObj->setVars(array('weight' => $order, 'status' => $stat)); |
||
| 149 | $xpPartnerHandler->insert($thisObj); |
||
| 150 | unset($thisObj); |
||
| 151 | } |
||
| 152 | } |
||
| 153 | } |
||
| 154 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); |
||
| 155 | } else { |
||
| 156 | redirect_header('main.php?op=partnersAdminAdd', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_EMPTYDATABASE, false); |
||
| 157 | } |
||
| 158 | break; |
||
| 159 | |||
| 160 | case 'reorderAutoPartners': |
||
| 161 | $xpPartnerHandler = xoops_getModuleHandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 162 | $partnerObjs = $xpPartnerHandler->getAll(null, array('weight')); |
||
| 163 | $partnerCount = count($partnerObjs); |
||
| 164 | $weight = XoopspartnersConstants::DEFAULT_WEIGHT; |
||
| 165 | if ($partnerCount > 1) { |
||
| 166 | foreach ($partnerObjs as $thisObj) { |
||
| 167 | ++$weight; |
||
| 168 | $thisObj->setVar('weight', $weight); |
||
| 169 | $xpPartnerHandler->insert($thisObj); |
||
| 170 | unset($thisObj); |
||
| 171 | } |
||
| 172 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); |
||
| 173 | } else { |
||
| 174 | redirect_header('main.php?op=partnersAdminAdd', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_EMPTYDATABASE, false); |
||
| 175 | } |
||
| 176 | break; |
||
| 177 | |||
| 178 | case 'partnersAdminAdd': |
||
| 179 | echo $adminClass->addNavigation('main.php?op=partnersAdminAdd'); |
||
| 180 | //echo "<h4>"._AM_XPARTNERS_ADD."</h4>"; |
||
|
0 ignored issues
–
show
|
|||
| 181 | |||
| 182 | include $GLOBALS['xoops']->path('/class/xoopsformloader.php'); |
||
| 183 | $form = new XoopsThemeForm(_AM_XPARTNERS_ADDPARTNER, 'addform', 'main.php', 'post', true); |
||
| 184 | $formWeight = new XoopsFormText(_AM_XPARTNERS_WEIGHT, 'weight', 3, 10, XoopspartnersConstants::DEFAULT_WEIGHT); |
||
| 185 | $formImage = new XoopsFormText(_AM_XPARTNERS_IMAGE, 'image', 100, 150, 'http://'); |
||
| 186 | $formUrl = new XoopsFormText(_AM_XPARTNERS_URL, 'url', 100, 150, 'http://'); |
||
| 187 | $formTitle = new XoopsFormText(_AM_XPARTNERS_TITLE, 'title', 100, 150); |
||
| 188 | $formDesc = new XoopsFormTextArea(_AM_XPARTNERS_DESCRIPTION, 'description', '', 10, '60'); |
||
| 189 | $statOnTxt = " <img src='{$pathImageIcon}/on.png' alt='" . _AM_XPARTNERS_ACTIVE . "'> " . _AM_XPARTNERS_ACTIVE . ' '; |
||
| 190 | $statOffTxt = " <img src='{$pathImageIcon}/off.png' alt='" . _AM_XPARTNERS_INACTIVE . "'> " . _AM_XPARTNERS_INACTIVE . ' '; |
||
| 191 | $formStat = new XoopsFormRadioYN(_AM_XPARTNERS_STATUS, 'status', XoopspartnersConstants::STATUS_ACTIVE, $statOnTxt, $statOffTxt); |
||
| 192 | $opHidden = new XoopsFormHidden('op', 'addPartner'); |
||
| 193 | $submitButton = new XoopsFormButton('', 'submit', _AM_XPARTNERS_ADDPARTNER, 'submit'); |
||
| 194 | $form->addElement($formTitle, true); |
||
| 195 | $form->addElement($formImage); |
||
| 196 | $form->addElement($formUrl, true); |
||
| 197 | $form->addElement($formWeight); |
||
| 198 | $form->addElement($formDesc, true); |
||
| 199 | $form->addElement($formStat); |
||
| 200 | $form->addElement($opHidden); |
||
| 201 | $form->addElement($submitButton); |
||
| 202 | $form->display(); |
||
| 203 | include __DIR__ . '/admin_footer.php'; |
||
| 204 | break; |
||
| 205 | |||
| 206 | case 'addPartner': |
||
| 207 | $xpPartnerHandler = xoops_getModuleHandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 208 | $newPartner = $xpPartnerHandler->create(); |
||
| 209 | $status = ((!empty($status)) && ((int)$status > 0)) ? (int)$status : XoopspartnersConstants::STATUS_INACTIVE; |
||
| 210 | $weight = XoopsRequest::getInt('weight', XoopspartnersConstants::DEFAULT_WEIGHT, 'POST'); |
||
| 211 | $title = isset($title) ? trim($title) : ''; |
||
| 212 | $url = isset($url) ? trim($url) : ''; |
||
| 213 | $image = isset($image) ? trim($image) : ''; |
||
| 214 | $image = $myts->addSlashes(formatURL($image)); |
||
| 215 | $description = isset($description) ? trim($description) : ''; |
||
| 216 | if (empty($title) || empty($url) || empty($description)) { |
||
| 217 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_BESURE); |
||
| 218 | } |
||
| 219 | $newPartner->setVars(array( |
||
| 220 | 'url' => $myts->addSlashes(formatURL($url)), |
||
| 221 | 'image' => $image, |
||
| 222 | 'title' => $myts->addSlashes($title), |
||
| 223 | 'description' => $myts->addSlashes($description), |
||
| 224 | 'status' => $status, |
||
| 225 | 'weight' => $weight |
||
| 226 | )); |
||
| 227 | |||
| 228 | if ($GLOBALS['xoopsSecurity']->check() && $xpPartnerHandler->insert($newPartner)) { |
||
| 229 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); |
||
| 230 | } else { |
||
| 231 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_NOTUPDATED . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 232 | } |
||
| 233 | break; |
||
| 234 | |||
| 235 | case 'editPartner': |
||
| 236 | echo $adminClass->addNavigation('main.php'); |
||
| 237 | $id = ((int)$id > XoopspartnersConstants::DEFAULT_PID) ? (int)$id : XoopspartnersConstants::DEFAULT_PID; |
||
| 238 | |||
| 239 | $xpPartnerHandler = xoops_getModuleHandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 240 | $partnerObj = $xpPartnerHandler->get($id); |
||
| 241 | if (!empty($partnerObj) && ($partnerObj instanceof XoopspartnersPartners)) { |
||
| 242 | $partnerVars = $partnerObj->getValues(); |
||
| 243 | //url, image, title, and description are all txtboxes so they have gone through htmlspecialchars via XoopsObject getVar |
||
| 244 | |||
| 245 | include $GLOBALS['xoops']->path('/class/xoopsformloader.php'); |
||
| 246 | $form = new XoopsThemeForm(_AM_XPARTNERS_EDITPARTNER, 'editform', 'main.php', 'post', true); |
||
| 247 | $formWeight = new XoopsFormText(_AM_XPARTNERS_WEIGHT, 'weight', 3, 10, $partnerVars['weight']); |
||
| 248 | $formHits = new XoopsFormText(_AM_XPARTNERS_HITS, 'hits', 3, 10, $partnerVars['hits']); |
||
| 249 | $formImage = new XoopsFormText(_AM_XPARTNERS_IMAGE, 'image', 50, 150, $partnerVars['image']); |
||
| 250 | $formUrl = new XoopsFormText(_AM_XPARTNERS_URL, 'url', 50, 150, $partnerVars['url']); |
||
| 251 | $formTitle = new XoopsFormText(_AM_XPARTNERS_TITLE, 'title', 50, 150, $partnerVars['title']); |
||
| 252 | $formDesc = new XoopsFormTextArea(_AM_XPARTNERS_DESCRIPTION, 'description', $partnerVars['description'], 10, '100%'); |
||
| 253 | |||
| 254 | $statOnTxt = " <img src='{$pathImageIcon}/on.png' alt='" . _AM_XPARTNERS_ACTIVE . "'> " . _AM_XPARTNERS_ACTIVE . ' '; |
||
| 255 | $statOffTxt = " <img src='{$pathImageIcon}/off.png' alt='" . _AM_XPARTNERS_INACTIVE . "'> " . _AM_XPARTNERS_INACTIVE . ' '; |
||
| 256 | $formStat = new XoopsFormRadioYN(_AM_XPARTNERS_STATUS, 'status', $partnerVars['status'], $statOnTxt, $statOffTxt); |
||
| 257 | |||
| 258 | $submitButton = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
||
| 259 | $form->addElement($formTitle, true); |
||
| 260 | $form->addElement($formImage); |
||
| 261 | $form->addElement($formUrl, true); |
||
| 262 | $form->addElement($formWeight); |
||
| 263 | $form->addElement($formDesc, true); |
||
| 264 | $form->addElement($formHits); |
||
| 265 | $form->addElement($formStat); |
||
| 266 | $form->addElement(new XoopsFormHidden('id', $id)); |
||
| 267 | $form->addElement(new XoopsFormHidden('op', 'updatePartner')); |
||
| 268 | $form->addElement($submitButton); |
||
| 269 | $form->display(); |
||
| 270 | include __DIR__ . '/admin_footer.php'; |
||
| 271 | } else { |
||
| 272 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_INVALIDID); |
||
| 273 | } |
||
| 274 | break; |
||
| 275 | |||
| 276 | case 'updatePartner': |
||
| 277 | $title = isset($title) ? trim($title) : ''; |
||
| 278 | $image = isset($image) ? trim($image) : ''; |
||
| 279 | $image = $myts->addSlashes(formatURL($image)); |
||
| 280 | $url = isset($url) ? trim($url) : ''; |
||
| 281 | $description = isset($description) ? trim($description) : ''; |
||
| 282 | $id = ($id > XoopspartnersConstants::DEFAULT_PID) ? $id : XoopspartnersConstants::DEFAULT_PID; |
||
| 283 | $status = ((!empty($status)) && ($status > XoopspartnersConstants::STATUS_INACTIVE)) ? (int)$status : XoopspartnersConstants::STATUS_INACTIVE; |
||
| 284 | $weight = XoopsRequest::getInt('weight', XoopspartnersConstants::DEFAULT_WEIGHT, 'POST'); |
||
| 285 | $weight = $weight > XoopspartnersConstants::DEFAULT_WEIGHT ? $weight : XoopspartnersConstants::DEFAULT_WEIGHT; |
||
| 286 | $hits = ((!empty($hits)) && ((int)$hits > 0)) ? (int)$hits : 0; |
||
| 287 | if ($title == '' || $url == '' || empty($id) || $description == '') { |
||
| 288 | redirect_header("main.php?op=edit_partner&id={$id}", XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_BESURE); |
||
| 289 | } |
||
| 290 | /* |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% 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...
|
|||
| 291 | if (!empty($image)) { |
||
| 292 | $image_info = exif_imagetype($image);; |
||
| 293 | if (false === $image_info) { |
||
| 294 | redirect_header("main.php?op=edit_partner&id={$id}", 1, _AM_XPARTNERS_NOEXIST); |
||
| 295 | } |
||
| 296 | } |
||
| 297 | */ |
||
| 298 | $xpPartnerHandler = xoops_getModuleHandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 299 | $partnerObj = $xpPartnerHandler->get($id); |
||
| 300 | if ($GLOBALS['xoopsSecurity']->check() && ($partnerObj instanceof XoopspartnersPartners)) { |
||
| 301 | $partnerObj->setVar('url', $myts->addSlashes(formatURL($url))); |
||
| 302 | $partnerObj->setVar('title', $myts->addSlashes($title)); |
||
| 303 | $partnerObj->setVar('description', $myts->addSlashes($description)); |
||
| 304 | $partnerObj->setVar('hits', $hits); |
||
| 305 | $partnerObj->setVar('weight', $weight); |
||
| 306 | $partnerObj->setVar('status', $status); |
||
| 307 | $partnerObj->setVar('image', $image); |
||
| 308 | $success = $xpPartnerHandler->insert($partnerObj); |
||
| 309 | if ($success) { |
||
| 310 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); |
||
| 311 | } |
||
| 312 | } |
||
| 313 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_NOTUPDATED . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 314 | break; |
||
| 315 | |||
| 316 | case 'delPartner': |
||
| 317 | if ((XoopspartnersConstants::CONFIRM_OK == $del) && ($id > XoopspartnersConstants::DEFAULT_PID)) { |
||
| 318 | $xpPartnerHandler = xoops_getModuleHandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 319 | $partnerObj = $xpPartnerHandler->get($id); |
||
| 320 | if ($partnerObj instanceof XoopspartnersPartners) { |
||
| 321 | if ($xpPartnerHandler->delete($partnerObj)) { |
||
| 322 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); |
||
| 323 | } |
||
| 324 | } |
||
| 325 | redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_NOTUPDATED); |
||
| 326 | } else { |
||
| 327 | echo $adminClass->addNavigation('main.php'); |
||
| 328 | xoops_confirm(array('op' => 'delPartner', 'id' => (int)$id, 'del' => XoopspartnersConstants::CONFIRM_OK), 'main.php', _AM_XPARTNERS_SUREDELETE); |
||
| 329 | include __DIR__ . '/admin_footer.php'; |
||
| 330 | } |
||
| 331 | break; |
||
| 332 | } |
||
| 333 |
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.