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.
1 | <?php |
||||
2 | |||||
3 | use XoopsModules\About; |
||||
4 | use XoopsModules\About\Helper; |
||||
5 | use XoopsModules\About\Utility; |
||||
6 | |||||
7 | /** @var Helper $helper */ |
||||
8 | /** @var Utility $utility */ |
||||
9 | |||||
10 | defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
||||
11 | |||||
12 | /** |
||||
13 | * Prepares system prior to attempting to install module |
||||
14 | * |
||||
15 | * @param \XoopsModule $module |
||||
16 | * |
||||
17 | * @return bool true if ready to install, false if not |
||||
18 | */ |
||||
19 | function xoops_module_pre_install_about(\XoopsModule $module) |
||||
20 | { |
||||
21 | require_once dirname(__DIR__) . '/preloads/autoloader.php'; |
||||
22 | $utility = new Utility(); |
||||
23 | $xoopsSuccess = $utility::checkVerXoops($module); |
||||
24 | $phpSuccess = $utility::checkVerPhp($module); |
||||
25 | |||||
26 | if ($xoopsSuccess && $phpSuccess) { |
||||
27 | $moduleTables = &$module->getInfo('tables'); |
||||
28 | foreach ($moduleTables as $table) { |
||||
29 | $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
||||
30 | } |
||||
31 | } |
||||
32 | |||||
33 | return $xoopsSuccess && $phpSuccess; |
||||
34 | } |
||||
35 | |||||
36 | /** |
||||
37 | * @param \XoopsModule $module |
||||
38 | * @return bool true if install successful, false if not |
||||
39 | */ |
||||
40 | function xoops_module_install_about(\XoopsModule $module) |
||||
41 | { |
||||
42 | $success = true; |
||||
43 | $data_file = XOOPS_ROOT_PATH . '/modules/about/sql/mysql.about.sql'; |
||||
44 | $GLOBALS['xoopsDB']->queryF('SET NAMES utf8'); |
||||
45 | if (!$GLOBALS['xoopsDB']->queryFromFile($data_file)) { |
||||
46 | $module->setErrors('Pre-set data was not installed'); |
||||
47 | // preset info not set, but don't 'fail' install because of this |
||||
48 | //$success = false; |
||||
49 | } |
||||
50 | |||||
51 | // Delete files from previous version (if they exist) |
||||
52 | // this is only executed if this version copied over old version without running module update |
||||
53 | $oldFiles = [ |
||||
54 | XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/xoopsformloader.php', |
||||
55 | XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/blockform.php', |
||||
56 | XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/class/utilities.php', |
||||
57 | ]; |
||||
58 | foreach ($oldFiles as $file) { |
||||
59 | if (is_file($file)) { |
||||
60 | $delOk = unlink($file); |
||||
61 | if (!$delOk) { |
||||
62 | $module->setErrors(sprintf(_AM_ABOUT_ERROR_BAD_REMOVE, $file)); |
||||
63 | } else { |
||||
64 | $module->setErrors(sprintf(_AM_ABOUT_DELETED, $file)); |
||||
65 | } |
||||
66 | $success = $success && $delOk; |
||||
67 | } |
||||
68 | } |
||||
69 | // Create uploads folder |
||||
70 | $dirOk = mkdir(XOOPS_UPLOAD_PATH . '/' . $module->dirname()); |
||||
71 | if (!$dirOk) { |
||||
72 | $module->setErrors(_AM_ABOUT_ERROR_BAD_UPLOAD_DIR); |
||||
73 | } |
||||
74 | |||||
75 | return $dirOk && $success; |
||||
76 | } |
||||
77 | |||||
78 | /** |
||||
79 | * Prepares system prior to attempting to install module |
||||
80 | * |
||||
81 | * @param \XoopsModule $module |
||||
82 | * |
||||
83 | * @return bool true if ready to install, false if not |
||||
84 | */ |
||||
85 | function xoops_module_pre_update_about(\XoopsModule $module) |
||||
86 | { |
||||
87 | $moduleDirName = basename(dirname(__DIR__)); |
||||
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
88 | $helper = Helper::getInstance(); |
||||
0 ignored issues
–
show
|
|||||
89 | $utility = new Utility(); |
||||
90 | |||||
91 | $xoopsSuccess = $utility::checkVerXoops($module); |
||||
92 | $phpSuccess = $utility::checkVerPhp($module); |
||||
93 | |||||
94 | return $xoopsSuccess && $phpSuccess; |
||||
95 | } |
||||
96 | |||||
97 | /** |
||||
98 | * @param XoopsModule $module |
||||
99 | * @param null $prev_version |
||||
0 ignored issues
–
show
|
|||||
100 | * @return bool true if update successful, false if not |
||||
101 | */ |
||||
102 | function xoops_module_update_about(\XoopsModule $module, $prev_version = null) |
||||
0 ignored issues
–
show
The parameter
$prev_version is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||
103 | { |
||||
104 | $success = true; |
||||
105 | // Delete files from previous version (if they exist) |
||||
106 | $oldFiles = [ |
||||
107 | XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/xoopsformloader.php', |
||||
108 | XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/blockform.php', |
||||
109 | XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/class/utilities.php', |
||||
110 | ]; |
||||
111 | foreach ($oldFiles as $file) { |
||||
112 | if (is_file($file)) { |
||||
113 | if (!$delOk = unlink($file)) { |
||||
114 | $module->setErrors(sprintf(_AM_ABOUT_ERROR_BAD_REMOVE, $file)); |
||||
115 | } |
||||
116 | $success = $success && $delOk; |
||||
117 | } |
||||
118 | } |
||||
119 | |||||
120 | // Delete files from previous version (if they exist) |
||||
121 | // this is only executed if this version copied over old version without running module update |
||||
122 | $oldFiles = [ |
||||
123 | XOOPS_PATH . '/modules/' . $module->dirname() . '/include/xoopsformloader.php', |
||||
124 | XOOPS_PATH . '/modules/' . $module->dirname() . '/include/blockform.php', |
||||
125 | ]; |
||||
126 | foreach ($oldFiles as $file) { |
||||
127 | if (is_file($file)) { |
||||
128 | if (!$delOk = unlink($file)) { |
||||
129 | $module->setErrors(sprintf(_AM_ABOUT_ERROR_BAD_REMOVE, $file)); |
||||
130 | } |
||||
131 | $success = $success && $delOk; |
||||
132 | } |
||||
133 | } |
||||
134 | |||||
135 | // Create uploads folder if it doesn't exist |
||||
136 | $dirOk = true; |
||||
137 | if (!is_dir(XOOPS_UPLOAD_PATH . '/' . $module->dirname())) { |
||||
138 | // File doesn't exist so try and create it |
||||
139 | $dirOk = mkdir(XOOPS_UPLOAD_PATH . '/' . $module->dirname()); |
||||
140 | if (!$dirOk) { |
||||
141 | $module->setErrors(_AM_ABOUT_ERROR_BAD_UPLOAD_DIR); |
||||
142 | } |
||||
143 | } |
||||
144 | |||||
145 | return $dirOk && $success; |
||||
146 | } |
||||
147 | |||||
148 | /** |
||||
149 | * Function to complete upon module uninstall |
||||
150 | * |
||||
151 | * @param \XoopsModule $module |
||||
152 | * |
||||
153 | * @return bool true if successfully executed uninstall of module, false if not |
||||
154 | */ |
||||
155 | function xoops_module_uninstall_about(\XoopsModule $module) |
||||
156 | { |
||||
157 | $moduleDirName = $module->dirname(); |
||||
158 | $helper = Helper::getInstance(); |
||||
159 | $utility = new Utility(); |
||||
160 | |||||
161 | $success = true; |
||||
162 | $helper->loadLanguage('admin'); |
||||
163 | |||||
164 | //------------------------------------------------------------------ |
||||
165 | // Remove module uploads folder (and all subfolders) if they exist |
||||
166 | //------------------------------------------------------------------ |
||||
167 | |||||
168 | $old_directories = [XOOPS_UPLOAD_PATH . "/{$moduleDirName}"]; |
||||
169 | foreach ($old_directories as $old_dir) { |
||||
170 | $dirInfo = new \SplFileInfo($old_dir); |
||||
171 | if ($dirInfo->isDir()) { |
||||
172 | // The directory exists so delete it |
||||
173 | if (!$utility::rrmdir($old_dir)) { |
||||
174 | $module->setErrors(sprintf(_AM_ABOUT_ERROR_BAD_DEL_PATH, $old_dir)); |
||||
175 | $success = false; |
||||
176 | } |
||||
177 | } |
||||
178 | unset($dirInfo); |
||||
179 | } |
||||
180 | |||||
181 | return $success; |
||||
182 | } |
||||
183 |