mambax7 /
extcal
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 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 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 14 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
| 15 | * @package extcal |
||
| 16 | * @since |
||
| 17 | * @author XOOPS Development Team, |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param XoopsModule $xoopsModule |
||
| 23 | * @param null $previousVersion |
||
| 24 | * |
||
| 25 | * @return bool |
||
| 26 | */ |
||
| 27 | function xoops_module_update_extcal(XoopsModule $xoopsModule, $previousVersion = null) |
||
| 28 | { |
||
| 29 | $newVersion = $xoopsModule->getVar('version') * 100; |
||
| 30 | if ($newVersion == $previousVersion) { |
||
| 31 | return true; |
||
| 32 | } |
||
| 33 | |||
| 34 | //---------------------------------------------------------- |
||
| 35 | // Create eXtCal upload directory |
||
| 36 | $indexFile = __DIR__ . '/index.html'; |
||
| 37 | |||
| 38 | $dir = XOOPS_ROOT_PATH . '/uploads/extcal'; |
||
| 39 | if (!is_dir($dir)) { |
||
| 40 | mkdir($dir, 0777); |
||
| 41 | copy($indexFile, $dir . '/index.html'); |
||
| 42 | } |
||
| 43 | |||
| 44 | $dir = XOOPS_ROOT_PATH . '/uploads/extcal/etablissement'; |
||
| 45 | if (!is_dir($dir)) { |
||
| 46 | mkdir($dir, 0777); |
||
| 47 | copy($indexFile, $dir . '/index.html'); |
||
| 48 | } |
||
| 49 | //------------------------------------------------------------ |
||
| 50 | |||
| 51 | $fld = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/versions/'; |
||
| 52 | $cls = 'extcal_%1$s'; |
||
| 53 | |||
| 54 | $version = array( |
||
| 55 | '2_04' => 204, |
||
| 56 | '2_15' => 215, |
||
| 57 | '2_21' => 221, |
||
| 58 | '2_28' => 228, |
||
| 59 | '2_29' => 229, |
||
| 60 | '2_33' => 233, |
||
| 61 | '2_34' => 234, |
||
| 62 | '2_35' => 235, |
||
| 63 | '2_37' => 237, |
||
| 64 | ); |
||
| 65 | |||
| 66 | // while (list($key, $val) = each($version)) { |
||
|
0 ignored issues
–
show
|
|||
| 67 | View Code Duplication | foreach ($version as $key => $val) { |
|
|
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. Loading history...
|
|||
| 68 | if ($previousVersion < $val) { |
||
| 69 | $name = sprintf($cls, $key); |
||
| 70 | $f = $fld . $name . '.php'; |
||
| 71 | //ext_echo ("<hr>{$f}<hr>"); |
||
| 72 | if (is_readable($f)) { |
||
| 73 | echo "mise à jour version : {$key} = {$val}<br>"; |
||
| 74 | require_once $f; |
||
| 75 | $cl = new $name($xoopsModule, array('previousVersion' => $previousVersion)); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | /* |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
44% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 81 | //$db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 82 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 83 | |||
| 84 | $sql = "ALTER TABLE `".$db->prefix('extcal_event')."` ADD `event_organisateur` varchar( 255 ) NOT NULL AFTER `event_desc` ;"; |
||
| 85 | $db->query($sql); |
||
| 86 | /////////// |
||
| 87 | // Create eXtcal upload directory |
||
| 88 | $dir = XOOPS_ROOT_PATH."/uploads/extcal/etablissement"; |
||
| 89 | if(!is_dir($dir)) |
||
| 90 | mkdir($dir, 0777); |
||
| 91 | chmod($dir, 0777); |
||
| 92 | |||
| 93 | // Copy index.html files on uploads folders |
||
| 94 | $indexFile = XOOPS_ROOT_PATH."/modules/extcal/include/index.html"; |
||
| 95 | copy($indexFile, XOOPS_ROOT_PATH."/uploads/extcal/etablissement/index.html"); |
||
| 96 | |||
| 97 | */ |
||
| 98 | |||
| 99 | return true; |
||
| 100 | } |
||
| 101 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.