XoopsModules25x /
mylinks
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | // $Id: notification.inc.php 8112 2011-11-06 13:41:14Z beckmi $ |
||
| 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 | |||
| 28 | /** |
||
| 29 | * @param $category |
||
| 30 | * @param $item_id |
||
| 31 | * @return mixed |
||
| 32 | */ |
||
| 33 | function mylinks_notify_iteminfo($category, $item_id) |
||
| 34 | { |
||
| 35 | global $xoopsModule, $xoopsModuleConfig, $xoopsConfig, $xoopsDB; |
||
| 36 | $dirname = basename(dirname(__DIR__)); |
||
| 37 | |||
| 38 | $item_id = (isset($item_id) && ((int)$item_id > 0)) ? (int)$item_id : 0; |
||
| 39 | |||
| 40 | if (empty($xoopsModule) || $xoopsModule->getVar('dirname') != $dirname) { |
||
| 41 | $moduleHandler = xoops_getHandler('module'); |
||
| 42 | $module = $moduleHandler->getByDirname($dirname); |
||
| 43 | $configHandler = xoops_getHandler('config'); |
||
| 44 | $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
|
0 ignored issues
–
show
|
|||
| 45 | } else { |
||
| 46 | $module = $xoopsModule; |
||
|
0 ignored issues
–
show
$module 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...
|
|||
| 47 | $config = $xoopsModuleConfig; |
||
|
0 ignored issues
–
show
$config 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...
|
|||
| 48 | } |
||
| 49 | |||
| 50 | switch ($category) { |
||
| 51 | case 'category': |
||
| 52 | // Assume we have a valid category id |
||
| 53 | $mylinksCatHandler = xoops_getModuleHandler('category', $dirname); |
||
| 54 | $catObj = $mylinksCatHandler->get($item_id); |
||
| 55 | if ($catObj) { |
||
| 56 | $item['name'] = $catObj->getVar('title'); |
||
| 57 | $item['url'] = XOOPS_URL . "/modules/{$dirname}/viewcat.php?cid={$item_id}"; |
||
| 58 | /* |
||
| 59 | $sql = "SELECT title FROM " . $xoopsDB->prefix('mylinks_cat') . " WHERE cid={$item_id}"; |
||
| 60 | $result = $xoopsDB->query($sql); // TODO: error check |
||
| 61 | $result_array = $xoopsDB->fetchArray($result); |
||
| 62 | $item['name'] = $result_array['title']; |
||
| 63 | $item['url'] = XOOPS_URL . "/modules/" . $module->getVar('dirname') . "/viewcat.php?cid={$item_id}"; |
||
| 64 | */ |
||
| 65 | } else { |
||
| 66 | $item['name'] = ''; |
||
| 67 | $item['url'] = ''; |
||
| 68 | } |
||
| 69 | break; |
||
| 70 | case 'link': |
||
| 71 | $sql = 'SELECT cid,title FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE lid={$item_id}"; |
||
| 72 | $result = $xoopsDB->query($sql); // TODO: error check |
||
| 73 | $result_array = $xoopsDB->fetchArray($result); |
||
| 74 | if (!empty($result_array['title'])) { |
||
| 75 | $item['name'] = $result_array['title']; |
||
| 76 | $item['url'] = XOOPS_URL . "/modules/{$dirname}/singlelink.php?cid={$result_array['cid']}&lid={$item_id}"; |
||
| 77 | } else { |
||
| 78 | $item['name'] = ''; |
||
| 79 | $item['url'] = ''; |
||
| 80 | } |
||
| 81 | break; |
||
| 82 | case 'global': |
||
| 83 | default: |
||
| 84 | $item['name'] = ''; |
||
| 85 | $item['url'] = ''; |
||
| 86 | break; |
||
| 87 | } |
||
| 88 | |||
| 89 | return $item; |
||
| 90 | } |
||
| 91 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.