/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('alien_check', array('h'), array()), '', ''); } else { require_code('upgrade'); $master_data = @unserialize(file_get_contents(get_file_base() . '/data/files.dat', FILE_TEXT)); if ($master_data === false) { $master_data = array(); } $result = check_alien(file_exists(get_file_base() . '/data/files_previous.dat') ? unserialize(file_get_contents(get_file_base() . '/data/files_previous.dat', FILE_TEXT)) : array(), $master_data, get_file_base() . '/', '', true); if ($result == '') { $result = do_lang('NO_ACTION_REQUIRED'); } else { require_lang('upgrade'); $result .= do_lang('RM_HINT'); } return array('', $result, '', ''); } }
/** * Check for alien files. * * @param array List of files from old version * @param array List of verbatim files * @param SHORT_TEXT The directory we are scanning relative to * @param SHORT_TEXT The directory (relative) we are scanning * @param boolean Whether to give raw output (no UI) * @return string HTML list of alien files */ function check_alien($old_files, $files, $dir, $rela = '', $raw = false) { $alien = ''; $dh = @opendir($dir); if ($dh !== false) { if ($rela == '') { $old_addons_now_gone = array('sources/hooks/systems/addon_registry/core_installation_uninstallation.php'); $modules_moved_intentionally = array('collaboration/pages/modules/filedump.php'); foreach (array_merge($old_addons_now_gone, $modules_moved_intentionally) as $x) { if (file_exists(get_file_base() . '/' . $x)) { $alien .= '<li>'; if (!$raw) { $alien .= '<input checked="checked" type="checkbox" name="' . uniqid('', true) . '" value="delete:' . escape_html($x) . '" /> '; } $alien .= '<kbd>' . escape_html($x) . '</kbd></li>'; } } } while (($file = readdir($dh)) !== false) { if (should_ignore_file($rela . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_THEMES | IGNORE_USER_CUSTOMISE)) { continue; } if ($rela . $file == 'data/images') { continue; } if ($rela . $file == 'data/areaedit/plugins/SpellChecker/aspell') { continue; } $is_dir = @is_dir($dir . $file); if (!is_readable($dir . $file)) { continue; } if ($file == 'index.php') { continue; } // New zone if ($is_dir) { if (!file_exists($dir . $file . '/info.php')) { if ($rela == '' && !file_exists($dir . $file . '/pages')) { $ok = false; foreach (array_keys($files) as $f) { if (substr($f, 0, strlen($rela . $file . '/')) == $rela . $file . '/') { $ok = true; break; } } if (!$ok) { continue; } } $alien .= check_alien($old_files, $files, $dir . $file . '/', $rela . $file . '/', $raw); } } else { if (!array_key_exists($rela . $file, $files)) { if (strpos($rela, 'pages/modules') !== false) { $zones = find_all_zones(); $matches = array(); preg_match('#(.*)pages/modules#', $rela, $matches); $current_zone = str_replace('/', '', $matches[1]); foreach ($zones as $zone) { if (array_key_exists(str_replace($current_zone . '/', $zone . '/', $rela . $file), $files)) { continue 2; } } } $disabled = ''; //if ((is_dir($dir.'/'.$file=='')) && ()) Not needed as this is only for files $checked = ''; if (array_key_exists($rela . $file, $old_files)) { $checked = 'checked="checked" '; } $alien .= '<li>'; if (!$raw) { $alien .= '<input ' . $disabled . $checked . 'type="checkbox" name="' . uniqid('', true) . '" value="delete:' . escape_html($rela . $file) . '" /> '; } if (strlen($alien) <= 100000) { // Reasonable limit $alien .= '<kbd>' . escape_html($rela . $file) . '</kbd></li>'; } } } } } if (strlen($alien) > 100000) { $alien = ''; } // Reasonable limit return $alien; }