These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
||
14 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
15 | * @package NEWBB |
||
16 | * @since 4.3 |
||
17 | * @author irmtfan <[email protected]> |
||
18 | * @author The Persian Xoops Support Site<www.xoops.ir> |
||
19 | */ |
||
20 | |||
21 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
||
0 ignored issues
–
show
|
|||
22 | |||
23 | global $xoTheme; |
||
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
}
}
![]() |
|||
24 | |||
25 | include_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php'); |
||
26 | $iconHandler = newbbGetIconHandler(); |
||
27 | // get css rel path from setted language |
||
28 | $css_rel_path = $iconHandler->getPath('language/' . $GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'css'); |
||
29 | // add local stylesheet |
||
30 | /** @var xos_opal_Theme $xoTheme */ |
||
31 | $xoTheme->addStylesheet($css_rel_path . '/style.css'); |
||
32 | |||
33 | // get js rel path from setted language |
||
34 | $js_rel_path = $iconHandler->getPath('language/' . $GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'js'); |
||
35 | // add all local js files inside js directory |
||
36 | xoops_load('XoopsLists'); |
||
37 | $allfiles = XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($js_rel_path)); |
||
38 | foreach ($allfiles as $jsfile) { |
||
39 | if (strtolower(pathinfo($jsfile, PATHINFO_EXTENSION)) === 'js') { |
||
40 | $xoTheme->addScript($js_rel_path . '/' . $jsfile); |
||
41 | } |
||
42 | } |
||
43 | global $forumCookie; // for $forumCookie["prefix"] revert last change - use global instead of include_once |
||
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
}
}
![]() |
|||
44 | // add toggle script |
||
45 | //$toggle_script = "var toggle_cookie=\"" . $forumCookie['prefix'] . 'G' . '\';'; |
||
46 | $toggle_script = 'var toggle_cookie="' . $forumCookie['prefix'] . 'G";'; |
||
47 | $xoTheme->addScript(null, ['type' => 'text/javascript'], $toggle_script); |
||
48 |
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.