mambax7 /
chess
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 | /* |
||||
| 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 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
| 15 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||
| 16 | * @package Chess |
||||
| 17 | * @since 2.01 |
||||
| 18 | * @author XOOPS Development Team |
||||
| 19 | */ |
||||
| 20 | |||||
| 21 | use XoopsModules\Chess; |
||||
| 22 | |||||
| 23 | if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser) |
||||
| 24 | || !$GLOBALS['xoopsUser']->isAdmin()) { |
||||
| 25 | exit('Restricted access' . PHP_EOL); |
||||
| 26 | } |
||||
| 27 | |||||
| 28 | /** |
||||
| 29 | * @param string $tablename |
||||
| 30 | * |
||||
| 31 | * @return bool |
||||
| 32 | */ |
||||
| 33 | function tableExists($tablename) |
||||
| 34 | { |
||||
| 35 | $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); |
||||
| 36 | |||||
| 37 | return $GLOBALS['xoopsDB']->getRowsNum($result) > 0; |
||||
| 38 | } |
||||
| 39 | |||||
| 40 | /** |
||||
| 41 | * Prepares system prior to attempting to install module |
||||
| 42 | * @param \XoopsModule $module {@link XoopsModule} |
||||
| 43 | * @return bool true if ready to install, false if not |
||||
| 44 | */ |
||||
| 45 | function xoops_module_pre_update_chess(\XoopsModule $module) |
||||
| 46 | { |
||||
| 47 | $moduleDirName = basename(dirname(__DIR__)); |
||||
| 48 | |||||
| 49 | /** @var Chess\Helper $helper */ |
||||
| 50 | |||||
| 51 | /** @var Chess\Utility $utility */ |
||||
| 52 | |||||
| 53 | $helper = Chess\Helper::getInstance(); |
||||
| 54 | |||||
| 55 | $utility = new Chess\Utility(); |
||||
| 56 | |||||
| 57 | $xoopsSuccess = $utility::checkVerXoops($module); |
||||
| 58 | |||||
| 59 | $phpSuccess = $utility::checkVerPhp($module); |
||||
| 60 | |||||
| 61 | $migrator = new \XoopsModules\Chess\Common\Migrate(); |
||||
| 62 | |||||
| 63 | $migrator->synchronizeSchema(); |
||||
| 64 | |||||
| 65 | return $xoopsSuccess && $phpSuccess; |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | /** |
||||
| 69 | * Performs tasks required during update of the module |
||||
| 70 | * @param \XoopsModule $module {@link XoopsModule} |
||||
| 71 | * @param null $previousVersion |
||||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||||
| 72 | * |
||||
| 73 | * @return bool true if update successful, false if not |
||||
| 74 | */ |
||||
| 75 | function xoops_module_update_chess(\XoopsModule $module, $previousVersion = null) |
||||
| 76 | { |
||||
| 77 | $moduleDirName = basename(dirname(__DIR__)); |
||||
| 78 | |||||
| 79 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
||||
| 80 | |||||
| 81 | /** @var Chess\Helper $helper */ |
||||
| 82 | |||||
| 83 | /** @var Chess\Utility $utility */ |
||||
| 84 | |||||
| 85 | /** @var Chess\Common\Configurator $configurator */ |
||||
| 86 | |||||
| 87 | $helper = Chess\Helper::getInstance(); |
||||
| 88 | |||||
| 89 | $utility = new Chess\Utility(); |
||||
| 90 | |||||
| 91 | $configurator = new Chess\Common\Configurator(); |
||||
| 92 | |||||
| 93 | $helper->loadLanguage('common'); |
||||
| 94 | |||||
| 95 | if ($previousVersion < 201) { |
||||
| 96 | |||||
| 97 | //delete old HTML templates |
||||
| 98 | |||||
| 99 | if (count($configurator->templateFolders) > 0) { |
||||
| 100 | foreach ($configurator->templateFolders as $folder) { |
||||
| 101 | $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder); |
||||
| 102 | |||||
| 103 | if (is_dir($templateFolder)) { |
||||
| 104 | $templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']); |
||||
|
0 ignored issues
–
show
It seems like
scandir($templateFolder, SCANDIR_SORT_NONE) can also be of type false; however, parameter $array1 of array_diff() does only seem to accept array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 105 | |||||
| 106 | foreach ($templateList as $k => $v) { |
||||
| 107 | $fileInfo = new SplFileInfo($templateFolder . $v); |
||||
| 108 | |||||
| 109 | if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) { |
||||
| 110 | if (file_exists($templateFolder . $v)) { |
||||
| 111 | unlink($templateFolder . $v); |
||||
| 112 | } |
||||
| 113 | } |
||||
| 114 | } |
||||
| 115 | } |
||||
| 116 | } |
||||
| 117 | } |
||||
| 118 | |||||
| 119 | // --- DELETE OLD FILES --------------- |
||||
| 120 | |||||
| 121 | if (count($configurator->oldFiles) > 0) { |
||||
| 122 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||||
| 123 | |||||
| 124 | foreach (array_keys($configurator->oldFiles) as $i) { |
||||
| 125 | $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]); |
||||
| 126 | |||||
| 127 | if (is_file($tempFile)) { |
||||
| 128 | unlink($tempFile); |
||||
| 129 | } |
||||
| 130 | } |
||||
| 131 | } |
||||
| 132 | |||||
| 133 | // --- DELETE OLD FOLDERS --------------- |
||||
| 134 | |||||
| 135 | xoops_load('XoopsFile'); |
||||
| 136 | |||||
| 137 | if (count($configurator->oldFolders) > 0) { |
||||
| 138 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||||
| 139 | |||||
| 140 | foreach (array_keys($configurator->oldFolders) as $i) { |
||||
| 141 | $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]); |
||||
| 142 | |||||
| 143 | /** @var XoopsObjectHandler $folderHandler */ |
||||
| 144 | |||||
| 145 | $folderHandler = \XoopsFile::getHandler('folder', $tempFolder); |
||||
| 146 | |||||
| 147 | $folderHandler->delete($tempFolder); |
||||
| 148 | } |
||||
| 149 | } |
||||
| 150 | |||||
| 151 | // --- CREATE UPLOAD FOLDERS --------------- |
||||
| 152 | |||||
| 153 | if (count($configurator->uploadFolders) > 0) { |
||||
| 154 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||||
| 155 | |||||
| 156 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||||
| 157 | $utility::createFolder($configurator->uploadFolders[$i]); |
||||
| 158 | } |
||||
| 159 | } |
||||
| 160 | |||||
| 161 | // --- COPY blank.png FILES --------------- |
||||
| 162 | |||||
| 163 | if (count($configurator->copyBlankFiles) > 0) { |
||||
| 164 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||||
| 165 | |||||
| 166 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||||
| 167 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||||
| 168 | |||||
| 169 | $utility::copyFile($file, $dest); |
||||
| 170 | } |
||||
| 171 | } |
||||
| 172 | |||||
| 173 | //delete .html entries from the tpl table |
||||
| 174 | |||||
| 175 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||||
| 176 | |||||
| 177 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 178 | |||||
| 179 | /** @var XoopsGroupPermHandler $gpermHandler */ |
||||
| 180 | |||||
| 181 | $gpermHandler = xoops_getHandler('groupperm'); |
||||
| 182 | |||||
| 183 | return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); |
||||
| 184 | } |
||||
| 185 | |||||
| 186 | return true; |
||||
| 187 | } |
||||
| 188 |