XoopsModules25x /
countdown
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 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | You may not change or alter any portion of this comment or credits |
||
| 7 | of supporting developers from this source code or any supporting source code |
||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Module: Countdown |
||
| 17 | * |
||
| 18 | * @category Module |
||
| 19 | * @package countdown |
||
| 20 | * @author XOOPS Development Team <https://xoops.org> |
||
| 21 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 22 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 23 | * @link https://xoops.org/ |
||
| 24 | * @since 1.0.0 |
||
| 25 | */ |
||
| 26 | |||
| 27 | use XoopsModules\Countdown; |
||
| 28 | |||
| 29 | if ((!defined('XOOPS_ROOT_PATH')) || !$GLOBALS['xoopsUser'] instanceof \XoopsUser |
||
| 30 | || !$GLOBALS['xoopsUser']->IsAdmin()) { |
||
| 31 | exit('Restricted access' . PHP_EOL); |
||
| 32 | } |
||
| 33 | |||
| 34 | require dirname(__DIR__) . '/preloads/autoloader.php'; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param string $tablename |
||
| 38 | * |
||
| 39 | * @return bool |
||
| 40 | */ |
||
| 41 | function tableExists($tablename) |
||
| 42 | { |
||
| 43 | $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); |
||
| 44 | |||
| 45 | return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * |
||
| 50 | * Prepares system prior to attempting to install module |
||
| 51 | * @param \XoopsModule $module {@link XoopsModule} |
||
| 52 | * |
||
| 53 | * @return bool true if ready to install, false if not |
||
| 54 | */ |
||
| 55 | function xoops_module_pre_update_countdown(\XoopsModule $module) |
||
| 56 | { |
||
| 57 | /** @var Countdown\Helper $helper */ |
||
| 58 | /** @var Countdown\Utility $utility */ |
||
| 59 | $helper = Countdown\Helper::getInstance(); |
||
| 60 | $utility = new Countdown\Utility(); |
||
| 61 | |||
| 62 | $xoopsSuccess = $utility::checkVerXoops($module); |
||
| 63 | $phpSuccess = $utility::checkVerPhp($module); |
||
| 64 | return $xoopsSuccess && $phpSuccess; |
||
| 65 | } |
||
| 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 | |||
| 76 | function xoops_module_update_countdown(\XoopsModule $module, $previousVersion = null) |
||
| 77 | { |
||
| 78 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 79 | $moduleDirNameUpper = strtoupper($moduleDirName); |
||
| 80 | |||
| 81 | /** @var Countdown\Helper $helper */ /** @var Countdown\Utility $utility */ |
||
| 82 | /** @var Countdown\Common\Configurator $configurator */ |
||
| 83 | $helper = Countdown\Helper::getInstance(); |
||
| 84 | $utility = new Countdown\Utility(); |
||
| 85 | $configurator = new Countdown\Common\Configurator(); |
||
| 86 | $helper->loadLanguage('common'); |
||
| 87 | |||
| 88 | if ($previousVersion < 240) { |
||
| 89 | //delete old HTML templates |
||
| 90 | if (count($configurator->templateFolders) > 0) { |
||
| 91 | foreach ($configurator->templateFolders as $folder) { |
||
| 92 | $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder); |
||
| 93 | if (is_dir($templateFolder)) { |
||
| 94 | $templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']); |
||
| 95 | foreach ($templateList as $k => $v) { |
||
| 96 | $fileInfo = new SplFileInfo($templateFolder . $v); |
||
| 97 | if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) { |
||
| 98 | if (file_exists($templateFolder . $v)) { |
||
| 99 | unlink($templateFolder . $v); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | } |
||
| 103 | } |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | // --- DELETE OLD FILES --------------- |
||
| 108 | if (count($configurator->oldFiles) > 0) { |
||
| 109 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 110 | foreach (array_keys($configurator->oldFiles) as $i) { |
||
| 111 | $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]); |
||
| 112 | if (is_file($tempFile)) { |
||
| 113 | unlink($tempFile); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | // --- DELETE OLD FOLDERS --------------- |
||
| 119 | xoops_load('XoopsFile'); |
||
| 120 | if (count($configurator->oldFolders) > 0) { |
||
| 121 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 122 | foreach (array_keys($configurator->oldFolders) as $i) { |
||
| 123 | $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]); |
||
| 124 | /** @var XoopsObjectHandler $folderHandler */ |
||
| 125 | $folderHandler = \XoopsFile::getHandler('folder', $tempFolder); |
||
| 126 | $folderHandler->delete($tempFolder); |
||
| 127 | } |
||
| 128 | } |
||
| 129 | |||
| 130 | // --- CREATE FOLDERS --------------- |
||
| 131 | if (count($configurator->uploadFolders) > 0) { |
||
| 132 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 133 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 134 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | // --- COPY blank.png FILES --------------- |
||
| 139 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 140 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 141 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 142 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 143 | $utility::copyFile($file, $dest); |
||
| 144 | } |
||
| 145 | } |
||
| 146 | |||
| 147 | //delete .html entries from the tpl table |
||
| 148 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
| 149 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 150 | |||
| 151 | /** @var XoopsGroupPermHandler $gpermHandler */ |
||
| 152 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 153 | return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); |
||
| 154 | } |
||
| 155 | return true; |
||
| 156 | } |
||
| 157 |