| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * **************************************************************************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * marquee - MODULE FOR XOOPS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Copyright (c) Hervé Thouzard (http://www.herve-thouzard.com) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * You may not change or alter any portion of this comment or credits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * of supporting developers from this source code or any supporting source code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * which is considered copyrighted (c) material of the original comment or credit authors. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  * @copyright         Hervé Thouzard (http://www.herve-thouzard.com) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @license           http://www.fsf.org/copyleft/gpl.html GNU public license | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @package           marquee | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @author            Hervé Thouzard (http://www.herve-thouzard.com) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * Version : $Id: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * **************************************************************************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @param      $module | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @param null $oldversion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | //function xoops_module_update_marquee() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | //{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | //    $db = XoopsDatabaseFactory::getDatabaseConnection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | //    $sql = "ALTER TABLE `" . $db->prefix('marquee') . "` MODIFY `marquee_bgcolor` varchar(7) NOT NULL default '';"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | //    $db->query($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | //    return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | //} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 37 |  |  | function xoops_module_update_marquee(XoopsObject $module, $oldversion = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 38 |  |  | { | 
            
                                                        
            
                                    
            
            
                | 39 |  |  |     $db  = XoopsDatabaseFactory::getDatabaseConnection(); | 
            
                                                        
            
                                    
            
            
                | 40 |  |  |     $sql = 'ALTER TABLE `' . $db->prefix('marquee') . "` MODIFY `marquee_bgcolor` varchar(7) NOT NULL default '';"; | 
            
                                                        
            
                                    
            
            
                | 41 |  |  |     $db->query($sql); | 
            
                                                        
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 43 |  |  |     if ($oldversion < 250) { | 
            
                                                        
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |         // delete old block html template files | 
            
                                                        
            
                                    
            
            
                | 46 |  |  |         $templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/blocks/'; | 
            
                                                        
            
                                    
            
            
                | 47 |  |  |         $template_list     = array_diff(scandir($templateDirectory), array('..', '.')); | 
            
                                                        
            
                                    
            
            
                | 48 |  |  |         foreach ($template_list as $k => $v) { | 
            
                                                        
            
                                    
            
            
                | 49 |  |  |             $fileinfo = new SplFileInfo($templateDirectory . $v); | 
            
                                                        
            
                                    
            
            
                | 50 |  |  |             if ($fileinfo->getExtension() === 'html' && $fileinfo->getFilename() !== 'index.html') { | 
            
                                                        
            
                                    
            
            
                | 51 |  |  |                 // @unlink($templateDirectory . $v); | 
            
                                                        
            
                                    
            
            
                | 52 |  |  |                 if (false === @unlink($templateDirectory . $v)) { | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |                     throw new \RuntimeException('The file ' . $templateDirectory . $v . ' could not be deleted.'); | 
            
                                                        
            
                                    
            
            
                | 54 |  |  |                 } | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 56 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 57 |  |  |         // Load class XoopsFile | 
            
                                                        
            
                                    
            
            
                | 58 |  |  |         xoops_load('xoopsfile'); | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |         //delete /images directory | 
            
                                                        
            
                                    
            
            
                | 60 |  |  |         $imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/'; | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |         $folderHandler   = XoopsFile::getHandler('folder', $imagesDirectory); | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |         $folderHandler->delete($imagesDirectory); | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |         //delete /js directory | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |         $jsDirectory   = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/js/'; | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |         $folderHandler = XoopsFile::getHandler('folder', $jsDirectory); | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |         $folderHandler->delete($jsDirectory); | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |         //delete /templates/style.css file | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |         $deleteFile    = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/admin/marquee.php'; | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |         $folderHandler = XoopsFile::getHandler('file', $deleteFile); | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |         $folderHandler->delete($deleteFile); | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |     $gpermHandler = xoops_getHandler('groupperm'); | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 75 |  |  |     return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); | 
            
                                                        
            
                                    
            
            
                | 76 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |  | 
            
                        
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.