mambax7 /
contact
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 declare(strict_types=1); |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Contact module |
||
| 14 | * |
||
| 15 | * @copyright XOOPS Project (https://xoops.org) |
||
| 16 | * @license https://www.fsf.org/copyleft/gpl.html GNU public license |
||
| 17 | * @author Kazumi Ono (aka Onokazu) |
||
| 18 | * @author Trabis <[email protected]> |
||
| 19 | * @author Hossein Azizabadi (AKA Voltan) |
||
| 20 | * @param \XoopsModule $module |
||
| 21 | * @param $version |
||
| 22 | */ |
||
| 23 | |||
| 24 | use XoopsModules\Contact\{ |
||
| 25 | Common\Configurator, |
||
| 26 | Helper, |
||
| 27 | Utility |
||
| 28 | }; |
||
| 29 | |||
| 30 | /** @var Helper $helper */ |
||
| 31 | /** @var Utility $utility */ |
||
| 32 | /** @var Configurator $configurator */ |
||
| 33 | if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser) |
||
| 34 | || !$GLOBALS['xoopsUser']->isAdmin()) { |
||
| 35 | exit('Restricted access' . PHP_EOL); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Prepares system prior to attempting to install module |
||
| 40 | * @param \XoopsModule $module {@link XoopsModule} |
||
| 41 | * |
||
| 42 | * @return bool true if ready to install, false if not |
||
| 43 | */ |
||
| 44 | function xoops_module_pre_update_contact(\XoopsModule $module) |
||
| 45 | { |
||
| 46 | /** @var Helper $helper */ |
||
| 47 | /** @var Utility $utility */ |
||
| 48 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 49 | $helper = Helper::getInstance(); |
||
|
0 ignored issues
–
show
|
|||
| 50 | $utility = new Utility(); |
||
| 51 | |||
| 52 | $xoopsSuccess = $utility::checkVerXoops($module); |
||
| 53 | $phpSuccess = $utility::checkVerPhp($module); |
||
| 54 | |||
| 55 | return $xoopsSuccess && $phpSuccess; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Performs tasks required during update of the module |
||
| 60 | * @param \XoopsModule $module {@link XoopsModule} |
||
| 61 | * @param null $previousVersion |
||
|
0 ignored issues
–
show
|
|||
| 62 | * |
||
| 63 | * @return bool true if update successful, false if not |
||
| 64 | */ |
||
| 65 | function xoops_module_update_contact(\XoopsModule $module, $previousVersion = null) |
||
| 66 | { |
||
| 67 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 68 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
||
|
0 ignored issues
–
show
|
|||
| 69 | |||
| 70 | /** @var Helper $helper */ |
||
| 71 | /** @var Utility $utility */ |
||
| 72 | /** @var Configurator $configurator */ |
||
| 73 | $helper = Helper::getInstance(); |
||
|
0 ignored issues
–
show
|
|||
| 74 | $utility = new Utility(); |
||
|
0 ignored issues
–
show
|
|||
| 75 | $configurator = new Configurator(); |
||
|
0 ignored issues
–
show
|
|||
| 76 | |||
| 77 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 78 | |||
| 79 | if ($previousVersion < 180) { |
||
| 80 | $sql = 'CREATE TABLE ' . $xoopsDB->prefix('contact') . ' ( |
||
| 81 | contact_id int(10) unsigned NOT NULL auto_increment, |
||
| 82 | contact_uid int(10) NOT NULL, |
||
| 83 | contact_cid int(10) NOT NULL, |
||
| 84 | contact_create int(10) NOT NULL, |
||
| 85 | contact_subject varchar(255) NOT NULL, |
||
| 86 | contact_name varchar(255) NOT NULL, |
||
| 87 | contact_mail varchar(255) NOT NULL, |
||
| 88 | contact_url varchar(255) NOT NULL, |
||
| 89 | contact_icq varchar(255) NOT NULL, |
||
| 90 | contact_company varchar(255) NOT NULL, |
||
| 91 | contact_location varchar(255) NOT NULL, |
||
| 92 | contact_department varchar(60) NOT NULL, |
||
| 93 | contact_ip varchar(20) NOT NULL, |
||
| 94 | contact_phone varchar(20) NOT NULL, |
||
| 95 | contact_message text NOT NULL, |
||
| 96 | contact_address text NOT NULL, |
||
| 97 | contact_reply tinyint(1) NOT NULL, |
||
| 98 | PRIMARY KEY (contact_id) |
||
| 99 | ) ENGINE=MyISAM;'; |
||
| 100 | $xoopsDB->query($sql); |
||
| 101 | } |
||
| 102 | |||
| 103 | if ($previousVersion < 181) { |
||
| 104 | // Add contact_platform |
||
| 105 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . "` ADD `contact_platform` ENUM('Android','Ios','Web') NOT NULL DEFAULT 'Web'"; |
||
| 106 | $xoopsDB->query($sql); |
||
| 107 | // Add contact_type |
||
| 108 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . "` ADD `contact_type` ENUM('Contact','Phone','Mail') NOT NULL DEFAULT 'Contact'"; |
||
| 109 | $xoopsDB->query($sql); |
||
| 110 | // Add index contact_uid |
||
| 111 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_uid` ( `contact_uid` )'; |
||
| 112 | $xoopsDB->query($sql); |
||
| 113 | // Add index contact_cid |
||
| 114 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_cid` ( `contact_cid` )'; |
||
| 115 | $xoopsDB->query($sql); |
||
| 116 | // Add index contact_create |
||
| 117 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_create` ( `contact_create` )'; |
||
| 118 | $xoopsDB->query($sql); |
||
| 119 | // Add index contact_mail |
||
| 120 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_mail` ( `contact_mail` )'; |
||
| 121 | $xoopsDB->query($sql); |
||
| 122 | // Add index contact_phone |
||
| 123 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_phone` ( `contact_phone` )'; |
||
| 124 | $xoopsDB->query($sql); |
||
| 125 | // Add index contact_platform |
||
| 126 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_platform` ( `contact_platform` )'; |
||
| 127 | $xoopsDB->query($sql); |
||
| 128 | // Add index contact_type |
||
| 129 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_type` ( `contact_type` )'; |
||
| 130 | $xoopsDB->query($sql); |
||
| 131 | } |
||
| 132 | |||
| 133 | if ($previousVersion < 227) { |
||
| 134 | $configurator = new Configurator(); |
||
| 135 | $utility = new Utility(); |
||
| 136 | |||
| 137 | //delete old HTML templates |
||
| 138 | if (count($configurator->templateFolders) > 0) { |
||
| 139 | foreach ($configurator->templateFolders as $folder) { |
||
| 140 | $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder); |
||
| 141 | if (is_dir($templateFolder)) { |
||
| 142 | $templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']); |
||
| 143 | foreach ($templateList as $k => $v) { |
||
| 144 | $fileInfo = new \SplFileInfo($templateFolder . $v); |
||
| 145 | if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) { |
||
| 146 | if (is_file($templateFolder . $v)) { |
||
| 147 | unlink($templateFolder . $v); |
||
| 148 | } |
||
| 149 | } |
||
| 150 | } |
||
| 151 | } |
||
| 152 | } |
||
| 153 | } |
||
| 154 | |||
| 155 | // --- DELETE OLD FILES --------------- |
||
| 156 | if (count($configurator->oldFiles) > 0) { |
||
| 157 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 158 | foreach (array_keys($configurator->oldFiles) as $i) { |
||
| 159 | $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]); |
||
| 160 | if (is_file($tempFile)) { |
||
| 161 | unlink($tempFile); |
||
| 162 | } |
||
| 163 | } |
||
| 164 | } |
||
| 165 | |||
| 166 | // --- DELETE OLD FOLDERS --------------- |
||
| 167 | xoops_load('XoopsFile'); |
||
| 168 | if (count($configurator->oldFolders) > 0) { |
||
| 169 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 170 | foreach (array_keys($configurator->oldFolders) as $i) { |
||
| 171 | $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]); |
||
| 172 | /** @var XoopsObjectHandler $folderHandler */ |
||
| 173 | $folderHandler = XoopsFile::getHandler('folder', $tempFolder); |
||
| 174 | $folderHandler->delete($tempFolder); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | // --- CREATE FOLDERS --------------- |
||
| 179 | if (count($configurator->uploadFolders) > 0) { |
||
| 180 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 181 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 182 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 183 | } |
||
| 184 | } |
||
| 185 | |||
| 186 | // --- COPY blank.png FILES --------------- |
||
| 187 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 188 | $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 189 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 190 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 191 | $utility::copyFile($file, $dest); |
||
| 192 | } |
||
| 193 | } |
||
| 194 | |||
| 195 | //delete .html entries from the tpl table |
||
| 196 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . '\' AND `tpl_file` LIKE \'%.html%\''; |
||
| 197 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 198 | |||
| 199 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 200 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 201 | |||
| 202 | return $grouppermHandler->deleteByModule($module->getVar('mid'), 'item_read'); |
||
| 203 | } |
||
| 204 | |||
| 205 | if ($previousVersion < 227) { |
||
| 206 | // Add contact_skype |
||
| 207 | $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD `contact_skype` VARCHAR(255) NULL AFTER `contact_icq`'; |
||
| 208 | $xoopsDB->query($sql); |
||
| 209 | } |
||
| 210 | } |
||
| 211 |