示例#1
0
/**
 * Completely uninstall the specified module from the system.
 *
 * @param  ID_TEXT		The zone name
 * @param  ID_TEXT		The module name
 */
function uninstall_module($zone, $module)
{
    $module_path = get_file_base() . '/' . _get_module_path($zone, $module);
    require_code('database_action');
    require_code('config2');
    require_code('files2');
    $GLOBALS['SITE_DB']->query_delete('modules', array('module_the_name' => $module), '', 1);
    $GLOBALS['SITE_DB']->query_delete('group_page_access', array('page_name' => $module));
    // As some modules will try and install this themselves. Entry point permissions they won't.
    $GLOBALS['SITE_DB']->query_delete('gsp', array('the_page' => $module));
    // Ditto
    if (file_exists($module_path)) {
        $functions = extract_module_functions($module_path, array('uninstall'));
        if (is_null($functions[0]) && strpos($module_path, '/modules_custom/') !== false) {
            if (strpos($module_path, '/modules_custom/') !== false && file_exists(str_replace('/modules_custom/', '/modules/', $module_path)) && (strpos(file_get_contents($module_path), 'function install(') === false || strpos(file_get_contents($module_path), 'function info(') === false)) {
                $module_path = str_replace('/modules_custom/', '/modules/', $module_path);
            }
            $functions = extract_module_functions($module_path, array('uninstall'));
        }
        if (is_null($functions[0])) {
            return;
        }
        if (is_array($functions[0])) {
            call_user_func_array($functions[0][0], $functions[0][1]);
        } else {
            eval($functions[0]);
        }
    }
}
示例#2
0
/**
 * Show a helpful access-denied page. Has a login ability if it senses that logging in could curtail the error.
 *
 * @param  ID_TEXT		The class of error (e.g. SPECIFIC_PERMISSION)
 * @param  string			The parameteter given to the error message
 * @param  boolean		Force the user to login (even if perhaps they are logged in already)
 */
function _access_denied($class, $param, $force_login)
{
    $GLOBALS['HTTP_STATUS_CODE'] = '401';
    if (!headers_sent()) {
        if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
            header('HTTP/1.0 401 Unauthorized');
        }
        // Stop spiders ever storing the URL that caused this
    }
    require_lang('permissions');
    require_lang('ocf_config');
    $match_keys = $GLOBALS['SITE_DB']->query_select('match_key_messages', array('k_message', 'k_match_key'));
    global $M_SORT_KEY;
    $M_SORT_KEY = 'k_match_key';
    usort($match_keys, 'strlen_sort');
    $match_keys = array_reverse($match_keys);
    $message = NULL;
    foreach ($match_keys as $match_key) {
        if (match_key_match($match_key['k_match_key'])) {
            $message = get_translated_tempcode($match_key['k_message']);
        }
    }
    if (is_null($message)) {
        if (strpos($class, ' ') !== false) {
            $message = make_string_tempcode($class);
        } else {
            if ($class == 'SPECIFIC_PERMISSION') {
                $param = do_lang('PT_' . $param);
            }
            $message = do_lang_tempcode('ACCESS_DENIED__' . $class, escape_html($GLOBALS['FORUM_DRIVER']->get_username(get_member())), escape_html($param));
        }
    }
    // Run hooks, if any exist
    $hooks = find_all_hooks('systems', 'upon_access_denied');
    foreach (array_keys($hooks) as $hook) {
        require_code('hooks/systems/upon_access_denied/' . filter_naughty($hook));
        $ob = object_factory('Hook_upon_access_denied_' . filter_naughty($hook), true);
        if (is_null($ob)) {
            continue;
        }
        $ob->run($class, $param, $force_login);
    }
    require_code('site');
    log_stats('/access_denied', 0);
    if (is_guest() && (running_script('attachment') || running_script('dload') || $GLOBALS['NON_PAGE_SCRIPT'] == 0) || $force_login) {
        @ob_end_clean();
        $redirect = get_self_url(true, true, array('page' => get_param('page', '')));
        // We have to pass in 'page' because an access-denied situation tells get_page_name() (which get_self_url() relies on) that we are on page ''.
        $_GET['redirect'] = $redirect;
        $_GET['page'] = 'login';
        $_GET['type'] = 'misc';
        global $PAGE_NAME_CACHE;
        $PAGE_NAME_CACHE = 'login';
        $middle = load_module_page(_get_module_path('', 'login'), 'login');
        require_code('site');
        attach_message($message, 'warn');
        $echo = globalise($middle, NULL, '', true);
        $echo->evaluate_echo();
        exit;
    }
    //if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) fatal_exit($message);
    warn_exit($message);
}
示例#3
0
/**
 * Execute some temporary code put into this function.
 *
 * @return  mixed		Arbitrary result to output, if no text has already gone out
 */
function execute_temp()
{
    require_code('zones');
    require_code('zones2');
    @var_dump(extract_module_functions(_get_module_path('site', 'chat'), array('install')));
}