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: randomquote |
||
15 | * |
||
16 | * @category Module |
||
17 | * @package randomquote |
||
18 | * @author XOOPS Development Team <[email protected]> - <https://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 Xoopsmodules\randomquote; |
||
26 | |||
27 | if ((!defined('XOOPS_ROOT_PATH')) || !$GLOBALS['xoopsUser'] instanceof XoopsUser |
||
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_randomquote(\XoopsModule $module) |
||
52 | { |
||
53 | /** @var randomquote\Helper $helper */ |
||
54 | /** @var randomquote\Utility $utility */ |
||
55 | $helper = randomquote\Helper::getInstance(); |
||
56 | $utility = new randomquote\Utility(); |
||
57 | |||
58 | $xoopsSuccess = $utility::checkVerXoops($module); |
||
59 | $phpSuccess = $utility::checkVerPhp($module); |
||
60 | return $xoopsSuccess && $phpSuccess; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * |
||
65 | * Performs tasks required during update of the module |
||
66 | * @param \XoopsModule $module {@link XoopsModule} |
||
67 | * @param null $previousVersion |
||
68 | * |
||
69 | * @return bool true if update successful, false if not |
||
70 | */ |
||
71 | |||
72 | function xoops_module_update_randomquote(\XoopsModule $module, $previousVersion = null) |
||
73 | { |
||
74 | $moduleDirName = basename(dirname(__DIR__)); |
||
75 | $moduleDirNameUpper = strtoupper($moduleDirName); |
||
76 | |||
77 | /** @var randomquote\Helper $helper */ |
||
78 | /** @var randomquote\Utility $utility */ |
||
79 | /** @var randomquote\common\Configurator $configurator */ |
||
80 | $helper = randomquote\Helper::getInstance(); |
||
81 | $utility = new randomquote\Utility(); |
||
82 | $configurator = new randomquote\common\Configurator(); |
||
83 | $helper->loadLanguage('common'); |
||
84 | |||
85 | if ($previousVersion < 240) { |
||
86 | |||
87 | //delete old HTML templates |
||
88 | if (count($configurator->templateFolders) > 0) { |
||
89 | foreach ($configurator->templateFolders as $folder) { |
||
90 | $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder); |
||
91 | if (is_dir($templateFolder)) { |
||
92 | $templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']); |
||
93 | foreach ($templateList as $k => $v) { |
||
94 | $fileInfo = new SplFileInfo($templateFolder . $v); |
||
95 | if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) { |
||
96 | if (file_exists($templateFolder . $v)) { |
||
97 | unlink($templateFolder . $v); |
||
98 | } |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | } |
||
103 | } |
||
104 | |||
105 | // --- DELETE OLD FILES --------------- |
||
106 | if (count($configurator->oldFiles) > 0) { |
||
107 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
108 | foreach (array_keys($configurator->oldFiles) as $i) { |
||
109 | $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]); |
||
110 | if (is_file($tempFile)) { |
||
111 | unlink($tempFile); |
||
112 | } |
||
113 | } |
||
114 | } |
||
115 | |||
116 | // --- DELETE OLD FOLDERS --------------- |
||
117 | xoops_load('XoopsFile'); |
||
118 | if (count($configurator->oldFolders) > 0) { |
||
119 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
120 | foreach (array_keys($configurator->oldFolders) as $i) { |
||
121 | $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]); |
||
122 | /** @var XoopsObjectHandler $folderHandler */ |
||
123 | $folderHandler = \XoopsFile::getHandler('folder', $tempFolder); |
||
124 | $folderHandler->delete($tempFolder); |
||
125 | } |
||
126 | } |
||
127 | |||
128 | // --- CREATE FOLDERS --------------- |
||
129 | View Code Duplication | if (count($configurator->uploadFolders) > 0) { |
|
0 ignored issues
–
show
|
|||
130 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
131 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
132 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
133 | } |
||
134 | } |
||
135 | |||
136 | // --- COPY blank.png FILES --------------- |
||
137 | 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. ![]() |
|||
138 | $file = __DIR__ . '/../assets/images/blank.png'; |
||
139 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
140 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
141 | $utility::copyFile($file, $dest); |
||
142 | } |
||
143 | } |
||
144 | |||
145 | //delete .html entries from the tpl table |
||
146 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
147 | $GLOBALS['xoopsDB']->queryF($sql); |
||
148 | |||
149 | /** @var XoopsGroupPermHandler $gpermHandler */ |
||
150 | $gpermHandler = xoops_getHandler('groupperm'); |
||
151 | return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); |
||
152 | } |
||
153 | return true; |
||
154 | } |
||
155 |
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.