This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | You may not change or alter any portion of this comment or credits |
||
5 | of supporting developers from this source code or any supporting source code |
||
6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
7 | |||
8 | This program is distributed in the hope that it will be useful, |
||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | */ |
||
12 | |||
13 | /** |
||
14 | * Module: Equipment |
||
15 | * |
||
16 | * @category Module |
||
17 | * @package equipment |
||
18 | * @author XOOPS Development Team <[email protected]> - <http://xoops.org> |
||
19 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
20 | * @license GPL 2.0 or later |
||
21 | * @link https://xoops.org/ |
||
22 | * @since 1.0.0 |
||
23 | */ |
||
24 | |||
25 | use Xmf\Language; |
||
26 | |||
27 | if ((!defined('XOOPS_ROOT_PATH')) || !$GLOBALS['xoopsUser'] instanceof XoopsUser |
||
0 ignored issues
–
show
|
|||
28 | || !$GLOBALS['xoopsUser']->IsAdmin()) { |
||
29 | exit('Restricted access' . PHP_EOL); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param string $tablename |
||
34 | * |
||
35 | * @return bool |
||
36 | */ |
||
37 | function tableExists($tablename) |
||
38 | { |
||
39 | $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); |
||
40 | |||
41 | return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * |
||
46 | * Prepares system prior to attempting to install module |
||
47 | * @param XoopsModule $module {@link XoopsModule} |
||
48 | * |
||
49 | * @return bool true if ready to install, false if not |
||
50 | */ |
||
51 | function xoops_module_pre_update_equipment(XoopsModule $module) |
||
52 | { |
||
53 | $moduleDirName = basename(dirname(__DIR__)); |
||
54 | $className = ucfirst($moduleDirName) . 'Utility'; |
||
55 | if (!class_exists($className)) { |
||
56 | xoops_load('utility', $moduleDirName); |
||
57 | } |
||
58 | //check for minimum XOOPS version |
||
59 | if (!$className::checkVerXoops($module)) { |
||
60 | return false; |
||
61 | } |
||
62 | |||
63 | // check for minimum PHP version |
||
64 | if (!$className::checkVerPhp($module)) { |
||
65 | return false; |
||
66 | } |
||
67 | |||
68 | return true; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * |
||
73 | * Performs tasks required during update of the module |
||
74 | * @param XoopsModule $module {@link XoopsModule} |
||
75 | * @param null $previousVersion |
||
76 | * |
||
77 | * @return bool true if update successful, false if not |
||
78 | */ |
||
79 | |||
80 | function xoops_module_update_equipment(XoopsModule $module, $previousVersion = null) |
||
81 | { |
||
82 | // global $xoopsDB; |
||
83 | $moduleDirName = basename(dirname(__DIR__)); |
||
84 | $capsDirName = strtoupper($moduleDirName); |
||
85 | |||
86 | if ($previousVersion < 240) { |
||
87 | $configurator = include __DIR__ . '/config.php'; |
||
88 | $classUtility = ucfirst($moduleDirName) . 'Utility'; |
||
89 | if (!class_exists($classUtility)) { |
||
90 | xoops_load('utility', $moduleDirName); |
||
91 | } |
||
92 | |||
93 | //delete old HTML templates |
||
94 | if (count($configurator['templateFolders']) > 0) { |
||
95 | foreach ($configurator['templateFolders'] as $folder) { |
||
96 | $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder); |
||
97 | if (is_dir($templateFolder)) { |
||
98 | $templateList = array_diff(scandir($templateFolder,SCANDIR_SORT_NONE), array('..', '.')); |
||
99 | foreach ($templateList as $k => $v) { |
||
100 | $fileInfo = new SplFileInfo($templateFolder . $v); |
||
101 | if ($fileInfo->getExtension() === 'html' && $fileInfo->getFilename() !== 'index.html') { |
||
102 | if (file_exists($templateFolder . $v)) { |
||
103 | unlink($templateFolder . $v); |
||
104 | } |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | } |
||
110 | |||
111 | // --- DELETE OLD FILES --------------- |
||
112 | if (count($configurator['oldFiles']) > 0) { |
||
113 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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. ![]() |
|||
114 | foreach (array_keys($configurator['oldFiles']) as $i) { |
||
115 | $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator['oldFiles'][$i]); |
||
116 | if (is_file($tempFile)) { |
||
117 | unlink($tempFile); |
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | |||
122 | // --- DELETE OLD FOLDERS --------------- |
||
123 | xoops_load('XoopsFile'); |
||
124 | if (count($configurator['oldFolders']) > 0) { |
||
125 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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. ![]() |
|||
126 | foreach (array_keys($configurator['oldFolders']) as $i) { |
||
127 | $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator['oldFolders'][$i]); |
||
128 | /** @var XoopsObjectHandler $folderHandler */ |
||
129 | $folderHandler = XoopsFile::getHandler('folder', $tempFolder); |
||
130 | $folderHandler->delete($tempFolder); |
||
131 | } |
||
132 | } |
||
133 | |||
134 | // --- CREATE FOLDERS --------------- |
||
135 | View Code Duplication | if (count($configurator['uploadFolders']) > 0) { |
|
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. ![]() |
|||
136 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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. ![]() |
|||
137 | foreach (array_keys($configurator['uploadFolders']) as $i) { |
||
138 | $classUtility::createFolder($configurator['uploadFolders'][$i]); |
||
139 | } |
||
140 | } |
||
141 | |||
142 | // --- COPY blank.png FILES --------------- |
||
143 | View Code Duplication | if (count($configurator['copyBlankFiles']) > 0) { |
|
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. ![]() |
|||
144 | $file = __DIR__ . '/../assets/images/blank.png'; |
||
145 | foreach (array_keys($configurator['copyBlankFiles']) as $i) { |
||
146 | $dest = $configurator['copyBlankFiles'][$i] . '/blank.png'; |
||
147 | $classUtility::copyFile($file, $dest); |
||
148 | } |
||
149 | } |
||
150 | |||
151 | //delete .html entries from the tpl table |
||
152 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
153 | $GLOBALS['xoopsDB']->queryF($sql); |
||
154 | } |
||
155 | |||
156 | return true; |
||
157 | } |
||
158 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.