/** * The actualiser to delete a page. * * @return tempcode The UI */ function __delete() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/deletepage'; $zone = post_param('zone', NULL); $afm_needed = false; $pages = find_all_pages_wrap($zone); foreach ($pages as $page => $type) { if (is_integer($page)) { $page = strval($page); } if (post_param_integer('page__' . $page, 0) == 1) { if (get_file_base() != get_custom_file_base() && strpos($type, 'comcode_custom') !== false) { warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); } if ($type != 'comcode_custom') { $afm_needed = true; } } } if ($afm_needed) { require_code('abstract_file_manager'); force_have_afm_details(); } foreach ($pages as $page => $type) { if (is_integer($page)) { $page = strval($page); } if (post_param_integer('page__' . $page, 0) == 1) { if (substr($type, 0, 7) == 'modules') { $_page = $page . '.php'; } elseif (substr($type, 0, 7) == 'comcode') { $_page = $page . '.txt'; } elseif (substr($type, 0, 4) == 'html') { $_page = $page . '.htm'; } $GLOBALS['SITE_DB']->query_delete('menu_items', array('i_url' => $zone . ':' . $page)); if (substr($type, 0, 7) == 'comcode' || substr($type, 0, 4) == 'html') { $type_shortened = preg_replace('#/.+#', '', $type); if (substr($type, 0, 7) == 'comcode' && get_option('store_revisions') == '1') { $time = time(); $fullpath = zone_black_magic_filterer((strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page); $bs_path = zone_black_magic_filterer(str_replace('/comcode/', '/comcode_custom/', $fullpath) . '.' . strval($time)); @copy($fullpath, $bs_path) or intelligent_write_error($fullpath); sync_file($bs_path); fix_permissions($bs_path); } $langs = find_all_langs(true); foreach (array_keys($langs) as $lang) { $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type_shortened) . '/' . $lang . '/' . $_page, true); $path = (strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . $_path; if (file_exists($path)) { if ($afm_needed) { afm_delete_file($_path); } else { unlink(get_custom_file_base() . '/' . $_path); } } } if (substr($type, 0, 7) == 'comcode') { require_code('attachments2'); require_code('attachments3'); delete_comcode_attachments('comcode_page', $zone . ':' . $page); $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $page, 'the_zone' => $zone)); $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_page' => $page, 'the_zone' => $zone)); persistant_cache_empty(); decache('main_comcode_page_children'); require_code('seo2'); seo_meta_erase_storage('comcode_page', $zone . ':' . $page); } } else { $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true); $path = (strpos($type, '_custom') === false ? get_file_base() : get_custom_file_base()) . '/' . $_path; if (file_exists($path)) { if ($afm_needed) { afm_delete_file($_path); } else { unlink(get_custom_file_base() . '/' . $_path); } } } $GLOBALS['SITE_DB']->query_delete('https_pages', array('https_page_name' => $page), '', 1); log_it('DELETE_PAGES', $page); } } persistant_cache_empty(); decache('main_sitemap'); $title = get_page_title('DELETE_PAGES'); breadcrumb_set_self(do_lang_tempcode('DONE')); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:delete', do_lang_tempcode('DELETE_PAGES')))); return $this->do_next_manager($title, NULL, $zone, new ocp_tempcode()); }
/** * Move/delete certain selected things, in follow up to an integrity scan. */ function _integrity_scan() { foreach (array_keys($_POST) as $key) { $val = post_param($key); if (strpos($val, ':') !== false) { $bits = explode(':', $val); if ($bits[0] == 'delete') { afm_delete_file($bits[1]); } elseif ($bits[0] == 'move') { afm_delete_file($bits[2]); afm_move($bits[1], $bits[2]); } } } }
/** * Delete a directory over the open AFM connection. * * @param PATH The path to and of the directory we are deleting. * @param boolean Whether we should recursively delete any child files and directories. */ function afm_delete_directory($basic_path, $recursive = false) { $paths = $recursive ? array_reverse(_get_dir_tree($basic_path)) : array(array('dir', '')); $conn = _ftp_info(); foreach ($paths as $bits) { list($type, $path) = $bits; if ($type == 'file') { afm_delete_file($basic_path . '/' . $path); } else { $path = _rescope_path($basic_path . '/' . $path); if ($conn !== false) { ftp_rmdir($conn, $path); clearstatcache(); sync_file(get_custom_file_base() . '/' . $basic_path); } else { @rmdir($path) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($path))); sync_file($path); } } } }
/** * Uninstall an addon. * * @param string Name of the addon */ function uninstall_addon($name) { $addon_row = read_addon_info($name); require_code('zones2'); require_code('zones3'); require_code('abstract_file_manager'); // Clear some cacheing require_code('view_modes'); require_code('zones2'); require_code('zones3'); erase_comcode_page_cache(); erase_tempcode_cache(); persistant_cache_empty(); erase_cached_templates(); erase_cached_language(); global $HOOKS_CACHE; $HOOKS_CACHE = array(); // Remove addon info from database, modules, blocks, and files $last = array(); foreach ($addon_row['addon_files'] as $filename) { if (@file_exists(get_file_base() . '/' . $filename)) { $test = $GLOBALS['SITE_DB']->query_value('addons_files', 'COUNT(*)', array('filename' => $filename)); if ($test <= 1) { if (substr($filename, 0, 37) == 'sources/hooks/systems/addon_registry/') { $last[] = $filename; continue; } $matches = array(); if (preg_match('#([^/]*)/?pages/modules(_custom)?/(.*)\\.php#', $filename, $matches) != 0) { uninstall_module($matches[1], $matches[3]); } if (preg_match('#sources(_custom)?/blocks/(.*)\\.php#', $filename, $matches) != 0) { uninstall_block($matches[2]); } if (preg_match('#^([^/]*)/index.php#', $filename, $matches) != 0) { actual_delete_zone_lite($matches[1]); } if ($filename != 'mod.inf' && $filename != 'mod.php' && $filename != '' && substr($filename, -1) != '/') { $last[] = $filename; } } } } foreach ($last as $filename) { afm_delete_file($filename); } $GLOBALS['SITE_DB']->query_delete('addons_files', array('addon_name' => $addon_row['addon_name'])); $GLOBALS['SITE_DB']->query_delete('addons_dependencies', array('addon_name' => $addon_row['addon_name'])); $GLOBALS['SITE_DB']->query_delete('addons', array('addon_name' => $addon_row['addon_name']), '', 1); global $ADDON_INSTALLED_CACHE; unset($ADDON_INSTALLED_CACHE[$addon_row['addon_name']]); if (function_exists('persistent_cache_set')) { persistent_cache_set('ADDONS_INSTALLED', $ADDON_INSTALLED_CACHE, true); } log_it('UNINSTALL_ADDON', $addon_row['addon_name']); }