XoopsModules25x /
xoopstube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Module: XoopsTube |
||
| 4 | * |
||
| 5 | * You may not change or alter any portion of this comment or credits |
||
| 6 | * of supporting developers from this source code or any supporting source code |
||
| 7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 8 | * |
||
| 9 | * PHP version 5 |
||
| 10 | * |
||
| 11 | * @category Module |
||
| 12 | * @package Xoopstube |
||
| 13 | * @author Fernando Santos (topet05), [email protected] |
||
| 14 | * @copyright Mastop InfoDigital (c) 2003-2007 |
||
| 15 | * @link http://www.mastop.com.br |
||
| 16 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
| 17 | * @since 1.0.6 |
||
| 18 | */ |
||
| 19 | |||
| 20 | include_once __DIR__ . '/admin_header.php'; |
||
| 21 | if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule) || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
||
| 22 | exit(_AM_XOOPSTUBE_ERROR403); |
||
| 23 | } |
||
| 24 | if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
||
| 25 | include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
||
| 26 | $op = 'list'; |
||
| 27 | if (isset($_POST)) { |
||
| 28 | foreach ($_POST as $k => $v) { |
||
| 29 | $$k = $v; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | /* |
||
|
0 ignored issues
–
show
|
|||
| 33 | if (XoopsRequest::getCmd('op', '')) { |
||
| 34 | if ($_GET['op'] === "edit" || $_GET['op'] === "delete" || $_GET['op'] === "delete_ok" || $_GET['op'] === "clone" |
||
| 35 | || $_GET['op'] === "edit" |
||
| 36 | ) { |
||
| 37 | $op = $_GET['op']; |
||
| 38 | $bid = XoopsRequest::getInt('bid',0 ,'GET'); //isset($_GET['bid']) ? (int) $_GET['bid'] : 0; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | */ |
||
| 42 | |||
| 43 | $op = XoopsRequest::getCmd('op', XoopsRequest::getCmd('op', '', 'POST'), 'GET'); |
||
| 44 | if (in_array($op, array('edit', 'delete', 'delete_ok', 'clone'))) { |
||
| 45 | $bid = XoopsRequest::getInt('bid', 0, 'GET'); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * |
||
| 50 | */ |
||
| 51 | function listBlocks() |
||
| 52 | { |
||
| 53 | global $xoopsModule, $pathIcon16; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 54 | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
| 55 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 56 | View Code Duplication | if (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php')) { |
|
|
0 ignored issues
–
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...
|
|||
| 57 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin.php'); |
||
| 58 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php'); |
||
| 59 | //include_once(XOOPS_ROOT_PATH."/modules/system/language/".$GLOBALS['xoopsConfig']['language']."/admin/groups.php"); |
||
| 60 | } else { |
||
| 61 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin.php'); |
||
| 62 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/blocksadmin.php'); |
||
| 63 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/groups.php'); |
||
| 64 | } |
||
| 65 | $moduleHandler = xoops_getHandler('module'); |
||
| 66 | $memberHandler = xoops_getHandler('member'); |
||
| 67 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 68 | $groups = $memberHandler->getGroups(); |
||
| 69 | $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
||
| 70 | $criteria->add(new Criteria('isactive', 1)); |
||
| 71 | $module_list =& $moduleHandler->getList($criteria); |
||
| 72 | $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; |
||
| 73 | $module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; |
||
| 74 | ksort($module_list); |
||
| 75 | echo " |
||
| 76 | <h4 style='text-align:left;'>" . _AM_XOOPSTUBE_BADMIN . '</h4>'; |
||
| 77 | $moduleHandler = xoops_getHandler('module'); |
||
|
0 ignored issues
–
show
$moduleHandler 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...
|
|||
| 78 | echo "<form action='" . $_SERVER['PHP_SELF'] . "' name='blockadmin' method='post'> |
||
| 79 | <table width='100%' class='outer' cellpadding='4' cellspacing='1'> |
||
| 80 | <tr valign='middle'><th align='center'>" . _AM_XOOPSTUBE_TITLE . "</th><th align='center' nowrap='nowrap'>" . _AM_XOOPSTUBE_SIDE . '<br>' . _LEFT . '-' . _CENTER . '-' . _RIGHT |
||
| 81 | . "</th><th align='center'>" . _AM_XOOPSTUBE_WEIGHT . "</th><th align='center'>" . _AM_XOOPSTUBE_VISIBLE . "</th><th align='center'>" . _AM_SYSTEM_BLOCKS_VISIBLEIN |
||
| 82 | . "</th><th align='center'>" . _AM_SYSTEM_ADGS . "</th><th align='center'>" . _AM_SYSTEM_BLOCKS_BCACHETIME . "</th><th align='center'>" . _AM_XOOPSTUBE_ACTION . '</th></tr> |
||
| 83 | '; |
||
| 84 | $block_arr =& XoopsBlock::getByModule($xoopsModule->mid()); |
||
| 85 | $block_count = count($block_arr); |
||
| 86 | $class = 'even'; |
||
| 87 | $cachetimes = array( |
||
| 88 | '0' => _NOCACHE, |
||
| 89 | '30' => sprintf(_SECONDS, 30), |
||
| 90 | '60' => _MINUTE, |
||
| 91 | '300' => sprintf(_MINUTES, 5), |
||
| 92 | '1800' => sprintf(_MINUTES, 30), |
||
| 93 | '3600' => _HOUR, |
||
| 94 | '18000' => sprintf(_HOURS, 5), |
||
| 95 | '86400' => _DAY, |
||
| 96 | '259200' => sprintf(_DAYS, 3), |
||
| 97 | '604800' => _WEEK, |
||
| 98 | '2592000' => _MONTH |
||
| 99 | ); |
||
| 100 | foreach ($block_arr as $i) { |
||
| 101 | $groups_perms =& $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); |
||
| 102 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); |
||
| 103 | $result = $db->query($sql); |
||
| 104 | $modules = array(); |
||
| 105 | View Code Duplication | while (false !== ($row = $db->fetchArray($result))) { |
|
|
0 ignored issues
–
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...
|
|||
| 106 | $modules[] = (int)$row['module_id']; |
||
| 107 | } |
||
| 108 | |||
| 109 | $cachetime_options = ''; |
||
| 110 | foreach ($cachetimes as $cachetime => $cachetime_name) { |
||
| 111 | if ($i->getVar('bcachetime') == $cachetime) { |
||
| 112 | $cachetime_options .= "<option value='$cachetime' selected='selected'>$cachetime_name</option>\n"; |
||
| 113 | } else { |
||
| 114 | $cachetime_options .= "<option value='$cachetime'>$cachetime_name</option>\n"; |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | $sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = ''; |
||
| 119 | if ($i->getVar('visible') == 1) { |
||
| 120 | $sel1 = " checked='checked'"; |
||
| 121 | } else { |
||
| 122 | $sel0 = " checked='checked'"; |
||
| 123 | } |
||
| 124 | if ($i->getVar('side') == XOOPS_SIDEBLOCK_LEFT) { |
||
| 125 | $ssel0 = " checked='checked'"; |
||
| 126 | } elseif ($i->getVar('side') == XOOPS_SIDEBLOCK_RIGHT) { |
||
| 127 | $ssel1 = " checked='checked'"; |
||
| 128 | } elseif ($i->getVar('side') == XOOPS_CENTERBLOCK_LEFT) { |
||
| 129 | $ssel2 = " checked='checked'"; |
||
| 130 | } elseif ($i->getVar('side') == XOOPS_CENTERBLOCK_RIGHT) { |
||
| 131 | $ssel4 = " checked='checked'"; |
||
| 132 | } elseif ($i->getVar('side') == XOOPS_CENTERBLOCK_CENTER) { |
||
| 133 | $ssel3 = " checked='checked'"; |
||
| 134 | } elseif ($i->getVar('side') == XOOPS_CENTERBLOCK_BOTTOMLEFT) { |
||
| 135 | $ssel5 = " checked='checked'"; |
||
| 136 | } elseif ($i->getVar('side') == XOOPS_CENTERBLOCK_BOTTOMRIGHT) { |
||
| 137 | $ssel6 = " checked='checked'"; |
||
| 138 | } elseif ($i->getVar('side') == XOOPS_CENTERBLOCK_BOTTOM) { |
||
| 139 | $ssel7 = " checked='checked'"; |
||
| 140 | } |
||
| 141 | if ('' === $i->getVar('title')) { |
||
| 142 | $title = ' '; |
||
| 143 | } else { |
||
| 144 | $title = $i->getVar('title'); |
||
| 145 | } |
||
| 146 | $name = $i->getVar('name'); |
||
| 147 | echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar('bid') . "]' value='" . $title . "'></td><td class='$class' align='center' nowrap='nowrap'> |
||
| 148 | <div align='center' > |
||
| 149 | <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_CENTERBLOCK_LEFT . "'$ssel2 /> |
||
| 150 | <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_CENTERBLOCK_CENTER . "'$ssel3 /> |
||
| 151 | <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_CENTERBLOCK_RIGHT . "'$ssel4 /> |
||
| 152 | </div> |
||
| 153 | <div> |
||
| 154 | <span style='float:right;'><input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_SIDEBLOCK_RIGHT . "'$ssel1 /></span> |
||
| 155 | <div align='left'><input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_SIDEBLOCK_LEFT . "'$ssel0 /></div> |
||
| 156 | </div> |
||
| 157 | <div align='center'> |
||
| 158 | <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_CENTERBLOCK_BOTTOMLEFT . "'$ssel5 /> |
||
| 159 | <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_CENTERBLOCK_BOTTOM . "'$ssel7 /> |
||
| 160 | <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . XOOPS_CENTERBLOCK_BOTTOMRIGHT . "'$ssel6 /> |
||
| 161 | </div> |
||
| 162 | </td><td class='$class' align='center'><input type='text' name='weight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') |
||
| 163 | . "' size='5' maxlength='5' /></td><td class='$class' align='center' nowrap><input type='radio' name='visible[" . $i->getVar('bid') . "]' value='1'$sel1>" . _YES |
||
| 164 | . " <input type='radio' name='visible[" . $i->getVar('bid') . "]' value='0'$sel0>" . _NO . '</td>'; |
||
| 165 | |||
| 166 | echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||
| 167 | foreach ($module_list as $k => $v) { |
||
| 168 | echo "<option value='$k'" . (in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>"; |
||
| 169 | } |
||
| 170 | echo '</select></td>'; |
||
| 171 | |||
| 172 | echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||
| 173 | foreach ($groups as $grp) { |
||
| 174 | echo "<option value='" . $grp->getVar('groupid') . "' " . (in_array($grp->getVar('groupid'), $groups_perms) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>'; |
||
| 175 | } |
||
| 176 | echo '</select></td>'; |
||
| 177 | |||
| 178 | // Cache lifetime |
||
| 179 | echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetime_options . '</select> |
||
| 180 | </td>'; |
||
| 181 | |||
| 182 | // Actions |
||
| 183 | |||
| 184 | echo "<td class='$class' align='center'><a href='blocksadmin.php?op=edit&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT |
||
| 185 | . "' /> |
||
| 186 | </a> <a href='blocksadmin.php?op=clone&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "' /> |
||
| 187 | </a>"; |
||
| 188 | if ($i->getVar('block_type') !== 'S' && $i->getVar('block_type') !== 'M') { |
||
| 189 | echo " <a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&op=delete&bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" |
||
| 190 | . _DELETE . "' title='" . _DELETE . "' /> |
||
| 191 | </a>"; |
||
| 192 | } |
||
| 193 | echo " |
||
| 194 | <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "' /> |
||
| 195 | <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "' /> |
||
| 196 | <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "' /> |
||
| 197 | <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "' /> |
||
| 198 | <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "' /> |
||
| 199 | <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "' /> |
||
| 200 | <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "' /> |
||
| 201 | </td></tr> |
||
| 202 | "; |
||
| 203 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 204 | } |
||
| 205 | echo "<tr><td class='foot' align='center' colspan='7'> |
||
| 206 | <input type='hidden' name='op' value='order' /> |
||
| 207 | " . $GLOBALS['xoopsSecurity']->getTokenHTML() . " |
||
| 208 | <input type='submit' name='submit' value='" . _SUBMIT . "' /> |
||
| 209 | </td></tr></table> |
||
| 210 | </form> |
||
| 211 | <br><br>"; |
||
| 212 | } |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @param $bid |
||
| 216 | */ |
||
| 217 | function cloneBlock($bid) |
||
|
0 ignored issues
–
show
cloneBlock 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...
|
|||
| 218 | { |
||
| 219 | include_once __DIR__ . '/admin_header.php'; |
||
| 220 | //include_once __DIR__ . '/admin_header.php'; |
||
| 221 | xoops_cp_header(); |
||
| 222 | |||
| 223 | //xoops_loadLanguage('admin', XTUBE_DIRNAME); |
||
| 224 | //xoops_loadLanguage('modinfo', XTUBE_DIRNAME); |
||
|
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...
|
|||
| 225 | //xoops_loadLanguage('main', XTUBE_DIRNAME); |
||
|
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...
|
|||
| 226 | |||
| 227 | View Code Duplication | if (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php')) { |
|
|
0 ignored issues
–
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...
|
|||
| 228 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin.php'); |
||
| 229 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php'); |
||
| 230 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/groups.php'); |
||
| 231 | } else { |
||
| 232 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin.php'); |
||
| 233 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/blocksadmin.php'); |
||
| 234 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/groups.php'); |
||
| 235 | } |
||
| 236 | // mpu_adm_menu(); |
||
| 237 | $myblock = new XoopsBlock($bid); |
||
| 238 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 239 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||
| 240 | $result = $db->query($sql); |
||
| 241 | $modules = array(); |
||
| 242 | View Code Duplication | while (false !== ($row = $db->fetchArray($result))) { |
|
|
0 ignored issues
–
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...
|
|||
| 243 | $modules[] = (int)$row['module_id']; |
||
| 244 | } |
||
| 245 | $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')) ? true : false; |
||
| 246 | $block = array( |
||
| 247 | 'title' => $myblock->getVar('title') . ' Clone', |
||
| 248 | 'form_title' => _AM_XOOPSTUBE_BLOCKS_CLONEBLOCK, |
||
| 249 | 'name' => $myblock->getVar('name'), |
||
| 250 | 'side' => $myblock->getVar('side'), |
||
| 251 | 'weight' => $myblock->getVar('weight'), |
||
| 252 | 'visible' => $myblock->getVar('visible'), |
||
| 253 | 'content' => $myblock->getVar('content', 'N'), |
||
| 254 | 'modules' => $modules, |
||
| 255 | 'is_custom' => $is_custom, |
||
| 256 | 'ctype' => $myblock->getVar('c_type'), |
||
| 257 | 'bcachetime' => $myblock->getVar('bcachetime'), |
||
| 258 | 'op' => 'clone_ok', |
||
| 259 | 'bid' => $myblock->getVar('bid'), |
||
| 260 | 'edit_form' => $myblock->getOptions(), |
||
| 261 | 'template' => $myblock->getVar('template'), |
||
| 262 | 'options' => $myblock->getVar('options') |
||
| 263 | ); |
||
| 264 | echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>'; |
||
| 265 | include __DIR__ . '/blockform.php'; |
||
| 266 | $form->display(); |
||
| 267 | // xoops_cp_footer(); |
||
| 268 | include_once __DIR__ . '/admin_footer.php'; |
||
| 269 | exit(); |
||
| 270 | } |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @param $bid |
||
| 274 | * @param $bside |
||
| 275 | * @param $bweight |
||
| 276 | * @param $bvisible |
||
| 277 | * @param $bcachetime |
||
| 278 | * @param $bmodule |
||
| 279 | * @param $options |
||
| 280 | */ |
||
| 281 | function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options) |
||
| 282 | { |
||
| 283 | View Code Duplication | if (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php')) { |
|
|
0 ignored issues
–
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...
|
|||
| 284 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin.php'); |
||
| 285 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php'); |
||
| 286 | //include_once(XOOPS_ROOT_PATH."/modules/system/language/".$GLOBALS['xoopsConfig']['language']."/admin/groups.php"); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
77% 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...
|
|||
| 287 | } else { |
||
| 288 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin.php'); |
||
| 289 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/blocksadmin.php'); |
||
| 290 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/groups.php'); |
||
| 291 | } |
||
| 292 | $block = new XoopsBlock($bid); |
||
| 293 | $clone =& $block->xoopsClone(); |
||
| 294 | if (empty($bmodule)) { |
||
| 295 | xoops_cp_header(); |
||
| 296 | xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); |
||
| 297 | xoops_cp_footer(); |
||
| 298 | exit(); |
||
| 299 | } |
||
| 300 | $clone->setVar('side', $bside); |
||
| 301 | $clone->setVar('weight', $bweight); |
||
| 302 | $clone->setVar('visible', $bvisible); |
||
| 303 | //$clone->setVar('content', $_POST['bcontent']); |
||
| 304 | $clone->setVar('title', XoopsRequest::getString('btitle', '', 'POST')); |
||
| 305 | $clone->setVar('bcachetime', $bcachetime); |
||
| 306 | if (isset($options) && (count($options) > 0)) { |
||
| 307 | $options = implode('|', $options); |
||
| 308 | $clone->setVar('options', $options); |
||
| 309 | } |
||
| 310 | $clone->setVar('bid', 0); |
||
| 311 | if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) { |
||
| 312 | $clone->setVar('block_type', 'E'); |
||
| 313 | } else { |
||
| 314 | $clone->setVar('block_type', 'D'); |
||
| 315 | } |
||
| 316 | $newid = $clone->store(); |
||
| 317 | if (!$newid) { |
||
| 318 | xoops_cp_header(); |
||
| 319 | $clone->getHtmlErrors(); |
||
| 320 | xoops_cp_footer(); |
||
| 321 | exit(); |
||
| 322 | } |
||
| 323 | if ($clone->getVar('template') !== '') { |
||
| 324 | $tplfileHandler = xoops_getHandler('tplfile'); |
||
| 325 | $btemplate =& $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
||
| 326 | if (count($btemplate) > 0) { |
||
| 327 | $tplclone =& $btemplate[0]->xoopsClone(); |
||
| 328 | $tplclone->setVar('tpl_id', 0); |
||
| 329 | $tplclone->setVar('tpl_refid', $newid); |
||
| 330 | $tplfileHandler->insert($tplclone); |
||
| 331 | } |
||
| 332 | } |
||
| 333 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 334 | foreach ($bmodule as $bmid) { |
||
| 335 | $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; |
||
| 336 | $db->query($sql); |
||
| 337 | } |
||
| 338 | $groups =& $GLOBALS['xoopsUser']->getGroups(); |
||
| 339 | $count = count($groups); |
||
| 340 | for ($i = 0; $i < $count; ++$i) { |
||
| 341 | $sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')"; |
||
| 342 | $db->query($sql); |
||
| 343 | } |
||
| 344 | redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED); |
||
| 345 | } |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @param $bid |
||
| 349 | * @param $title |
||
| 350 | * @param $weight |
||
| 351 | * @param $visible |
||
| 352 | * @param $side |
||
| 353 | * @param $bcachetime |
||
| 354 | */ |
||
| 355 | function xtubeSetOrder($bid, $title, $weight, $visible, $side, $bcachetime) |
||
| 356 | { |
||
| 357 | $myblock = new XoopsBlock($bid); |
||
| 358 | $myblock->setVar('title', $title); |
||
| 359 | $myblock->setVar('weight', $weight); |
||
| 360 | $myblock->setVar('visible', $visible); |
||
| 361 | $myblock->setVar('side', $side); |
||
| 362 | $myblock->setVar('bcachetime', $bcachetime); |
||
| 363 | $myblock->store(); |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @param $bid |
||
| 368 | */ |
||
| 369 | function xtubeEditBlock($bid) |
||
|
0 ignored issues
–
show
xtubeEditBlock 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...
|
|||
| 370 | { |
||
| 371 | include_once __DIR__ . '/admin_header.php'; |
||
| 372 | //include_once __DIR__ . '/admin_header.php'; |
||
| 373 | xoops_cp_header(); |
||
| 374 | |||
| 375 | //xoops_loadLanguage('admin', XTUBE_DIRNAME); |
||
| 376 | //xoops_loadLanguage('modinfo', XTUBE_DIRNAME); |
||
|
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...
|
|||
| 377 | //xoops_loadLanguage('main', XTUBE_DIRNAME); |
||
|
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...
|
|||
| 378 | |||
| 379 | View Code Duplication | if (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php')) { |
|
|
0 ignored issues
–
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...
|
|||
| 380 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin.php'); |
||
| 381 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/blocksadmin.php'); |
||
| 382 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/admin/groups.php'); |
||
| 383 | } else { |
||
| 384 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin.php'); |
||
| 385 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/blocksadmin.php'); |
||
| 386 | include_once(XOOPS_ROOT_PATH . '/modules/system/language/portuguesebr/admin/groups.php'); |
||
| 387 | } |
||
| 388 | // mpu_adm_menu(); |
||
| 389 | $myblock = new XoopsBlock($bid); |
||
| 390 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 391 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||
| 392 | $result = $db->query($sql); |
||
| 393 | $modules = array(); |
||
| 394 | View Code Duplication | while (false !== ($row = $db->fetchArray($result))) { |
|
|
0 ignored issues
–
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...
|
|||
| 395 | $modules[] = (int)$row['module_id']; |
||
| 396 | } |
||
| 397 | $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')) ? true : false; |
||
| 398 | $block = array( |
||
| 399 | 'title' => $myblock->getVar('title'), |
||
| 400 | 'form_title' => _AM_XOOPSTUBE_BLOCKS_EDITBLOCK, |
||
| 401 | // 'name' => $myblock->getVar('name'), |
||
| 402 | 'side' => $myblock->getVar('side'), |
||
| 403 | 'weight' => $myblock->getVar('weight'), |
||
| 404 | 'visible' => $myblock->getVar('visible'), |
||
| 405 | 'content' => $myblock->getVar('content', 'N'), |
||
| 406 | 'modules' => $modules, |
||
| 407 | 'is_custom' => $is_custom, |
||
| 408 | 'ctype' => $myblock->getVar('c_type'), |
||
| 409 | 'bcachetime' => $myblock->getVar('bcachetime'), |
||
| 410 | 'op' => 'edit_ok', |
||
| 411 | 'bid' => $myblock->getVar('bid'), |
||
| 412 | 'edit_form' => $myblock->getOptions(), |
||
| 413 | 'template' => $myblock->getVar('template'), |
||
| 414 | 'options' => $myblock->getVar('options') |
||
| 415 | ); |
||
| 416 | echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>'; |
||
| 417 | include __DIR__ . '/blockform.php'; |
||
| 418 | $form->display(); |
||
| 419 | // xoops_cp_footer(); |
||
| 420 | include_once __DIR__ . '/admin_footer.php'; |
||
| 421 | exit(); |
||
| 422 | } |
||
| 423 | |||
| 424 | /** |
||
| 425 | * @param $bid |
||
| 426 | * @param $btitle |
||
| 427 | * @param $bside |
||
| 428 | * @param $bweight |
||
| 429 | * @param $bvisible |
||
| 430 | * @param $bcachetime |
||
| 431 | * @param $bmodule |
||
| 432 | * @param $options |
||
| 433 | * @param $groups |
||
| 434 | */ |
||
| 435 | function xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups) |
||
|
0 ignored issues
–
show
xtubeUpdateBlock 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...
|
|||
| 436 | { |
||
| 437 | $myblock = new XoopsBlock($bid); |
||
| 438 | $myblock->setVar('title', $btitle); |
||
| 439 | $myblock->setVar('weight', $bweight); |
||
| 440 | $myblock->setVar('visible', $bvisible); |
||
| 441 | $myblock->setVar('side', $bside); |
||
| 442 | $myblock->setVar('bcachetime', $bcachetime); |
||
| 443 | $myblock->store(); |
||
| 444 | |||
| 445 | if (!empty($bmodule) && count($bmodule) > 0) { |
||
| 446 | $sql = sprintf('DELETE FROM %s WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid); |
||
| 447 | $GLOBALS['xoopsDB']->query($sql); |
||
| 448 | if (in_array(0, $bmodule)) { |
||
| 449 | $sql = sprintf('INSERT INTO %s (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, 0); |
||
| 450 | $GLOBALS['xoopsDB']->query($sql); |
||
| 451 | View Code Duplication | } else { |
|
|
0 ignored issues
–
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...
|
|||
| 452 | foreach ($bmodule as $bmid) { |
||
| 453 | $sql = sprintf('INSERT INTO %s (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, (int)$bmid); |
||
| 454 | $GLOBALS['xoopsDB']->query($sql); |
||
| 455 | } |
||
| 456 | } |
||
| 457 | } |
||
| 458 | $sql = sprintf('DELETE FROM %s WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid); |
||
| 459 | $GLOBALS['xoopsDB']->query($sql); |
||
| 460 | if (!empty($groups)) { |
||
| 461 | View Code Duplication | foreach ($groups as $grp) { |
|
| 462 | $sql = sprintf("INSERT INTO %s (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $GLOBALS['xoopsDB']->prefix('group_permission'), $grp, $bid); |
||
| 463 | $GLOBALS['xoopsDB']->query($sql); |
||
| 464 | } |
||
| 465 | } |
||
| 466 | redirect_header($_SERVER['PHP_SELF'], 1, _AM_XOOPSTUBE_UPDATE_SUCCESS); |
||
| 467 | } |
||
| 468 | |||
| 469 | if ('list' === $op) { |
||
| 470 | xoops_cp_header(); |
||
| 471 | // mpu_adm_menu(); |
||
| 472 | listBlocks(); |
||
| 473 | include_once __DIR__ . '/admin_footer.php'; |
||
| 474 | exit(); |
||
| 475 | } |
||
| 476 | |||
| 477 | if ('order' === $op) { |
||
| 478 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 479 | redirect_header($_SERVER['PHP_SELF'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 480 | } |
||
| 481 | foreach (array_keys($bid) as $i) { |
||
| 482 | if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i] || $oldside[$i] !== $side[$i] || $oldbcachetime[$i] !== $bcachetime[$i]) { |
||
| 483 | xtubeSetOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]); |
||
|
0 ignored issues
–
show
The call to
xtubeSetOrder() has too many arguments starting with $bmodule[$i].
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 484 | } |
||
| 485 | if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) { |
||
| 486 | $sql = sprintf('DELETE FROM %s WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i]); |
||
| 487 | $GLOBALS['xoopsDB']->query($sql); |
||
| 488 | if (in_array(0, $bmodule[$i])) { |
||
| 489 | $sql = sprintf('INSERT INTO %s (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], 0); |
||
| 490 | $GLOBALS['xoopsDB']->query($sql); |
||
| 491 | View Code Duplication | } else { |
|
|
0 ignored issues
–
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...
|
|||
| 492 | foreach ($bmodule[$i] as $bmid) { |
||
| 493 | $sql = sprintf('INSERT INTO %s (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], (int)$bmid); |
||
| 494 | $GLOBALS['xoopsDB']->query($sql); |
||
| 495 | } |
||
| 496 | } |
||
| 497 | } |
||
| 498 | $sql = sprintf('DELETE FROM %s WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid[$i]); |
||
| 499 | $GLOBALS['xoopsDB']->query($sql); |
||
| 500 | if (!empty($groups[$i])) { |
||
| 501 | View Code Duplication | foreach ($groups[$i] as $grp) { |
|
| 502 | $sql = sprintf("INSERT INTO %s (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $GLOBALS['xoopsDB']->prefix('group_permission'), $grp, |
||
| 503 | $bid[$i]); |
||
| 504 | $GLOBALS['xoopsDB']->query($sql); |
||
| 505 | } |
||
| 506 | } |
||
| 507 | } |
||
| 508 | redirect_header($_SERVER['PHP_SELF'], 1, _AM_XOOPSTUBE_UPDATE_SUCCESS); |
||
| 509 | } |
||
| 510 | if ('clone' === $op) { |
||
| 511 | cloneBlock($bid); |
||
| 512 | } |
||
| 513 | |||
| 514 | if ('edit' === $op) { |
||
| 515 | xtubeEditBlock($bid); |
||
| 516 | } |
||
| 517 | |||
| 518 | if ('edit_ok' === $op) { |
||
| 519 | xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
||
| 520 | } |
||
| 521 | |||
| 522 | if ('clone_ok' === $op) { |
||
| 523 | isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options); |
||
| 524 | } |
||
| 525 | } else { |
||
| 526 | echo _AM_XOOPSTUBE_ERROR403; |
||
| 527 | } |
||
| 528 |
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.