Пример #1
0
    function main($module_id, $mode)
    {
        global $db, $user, $auth, $template, $cache, $request;
        global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx, $k_config, $table_prefix, $cache;
        include_once $phpbb_root_path . 'ext/phpbbireland/portal/config/constants.' . $phpEx;
        if (!function_exists('obtain_k_config')) {
            include $phpbb_root_path . 'ext/phpbbireland/portal/includes/functions.' . $phpEx;
            $k_config = obtain_k_config();
        }
        $img_path = $phpbb_root_path . 'ext/phpbbireland/portal/images/block_images/block/';
        $img_path_acp = $phpbb_root_path . 'ext/phpbbireland/portal/adm/images/';
        $portal_js = $phpbb_root_path . 'ext/phpbbireland/portal/js/portal.js';
        $user->add_lang_ext('phpbbireland/portal', 'k_pages');
        $this->tpl_name = 'acp_pages';
        $this->page_title = $user->lang['ACP_PAGES'];
        add_form_key('pages');
        if (!class_exists('sgp_functions_admin')) {
            require $phpbb_root_path . 'ext/phpbbireland/portal/includes/sgp_functions_admin.' . $phpEx;
            $sgp_functions_admin = new sgp_functions_admin();
        }
        $mode = $request->variable('mode', '');
        $page_id = $request->variable('page_id', 0);
        $action = $request->variable('config', '');
        $tag_id = $request->variable('tag_id', '');
        $current_pages = array();
        $submit = false;
        if ($request->is_set_post('submit')) {
            if (!check_form_key('pages')) {
                $submit = false;
                $mode = '';
                trigger_error('FORM_INVALID');
            }
            $submit = true;
        }
        if ($tag_id != '') {
            $mode = 'add';
        }
        switch ($action) {
            case 'config':
                $template->assign_var('MESSAGE', $user->lang['SWITCHING']);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=k_vars&mode=config&switch=k_pages"));
                break;
            default:
                break;
        }
        if ($submit && !check_form_key('pages')) {
            $submit = false;
            $mode = '';
            trigger_error($user->lang['FORM_INVALID'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__);
        }
        if ($submit) {
            $mod_pages = $request->variable('k_mod_folders', '');
            // trap trailing commas in mod pages //
            if ($mod_pages && $mod_pages[strlen($mod_pages) - 1] == ',') {
                trigger_error($user->lang['TRAILING_COMMA'] . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage")), E_USER_WARNING);
            }
            //  We check to see  the mod folder exists, if not return... //
            $mod_pages = str_replace(' ', '', $mod_pages);
            // has mod folder been updated/modified //
            if (strcmp($mod_pages, $k_config['k_mod_folders'] != 0)) {
                $mods_folder_array = explode(',', $mod_pages);
                foreach ($mods_folder_array as $folder) {
                    $folder = trim($folder);
                    if (!file_exists($phpbb_root_path . $folder)) {
                        $submit = false;
                        $mod_pages = '';
                        trigger_error($user->lang['NO_MOD_FOLDER'] . $folder . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage")), E_USER_WARNING);
                    }
                }
                $template->assign_vars(array('MESSAGE' => $user->lang['FOLDER_ADDED']));
            }
            $sgp_functions_admin->sgp_acp_set_config('k_mod_folders', $mod_pages);
        }
        $template->assign_vars(array('U_BACK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage"), 'U_ADD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=add"), 'U_MANAGE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage"), 'S_OPT' => 'S_MANAGE', 'S_PAGE' => isset($k_config['k_landing_page']) ? $k_config['k_landing_page'] : 'portal', 'IMG_PATH_ACP' => $img_path_acp));
        switch ($mode) {
            case 'delete':
                $page_name = get_page_filename($page_id);
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . K_PAGES_TABLE . '
						WHERE page_id = ' . (int) $page_id;
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['ERROR_PORTAL_PAGES'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__);
                    }
                    $cache->destroy('sql', K_PAGES_TABLE);
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['REMOVING_PAGES'] . $page_name));
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage"));
                    break;
                } else {
                    confirm_box(false, sprintf("%s (%s)", $user->lang['DELETE_FROM_LIST'], $page_name), build_hidden_fields(array('id' => $page_id, 'mode' => $mode, 'action' => 'delete')));
                }
                $template->assign_var('MESSAGE', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage"));
                break;
            case 'add':
                if ($submit) {
                    // drop extension
                    $tag_id = str_replace('.php', '', $tag_id);
                    // skip the spacer //
                    if ($tag_id == '..') {
                        $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => sprintf($user->lang['ERROR_PAGE'], $tag_id)));
                        meta_refresh(2, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage"));
                        return;
                    }
                    if (in_array($tag_id, $current_pages)) {
                        break;
                    }
                    $sql_array = array('page_name' => $tag_id);
                    $db->sql_query('INSERT INTO ' . K_PAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array));
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage"));
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['ADDING_PAGES']));
                    $cache->destroy('sql', K_PAGES_TABLE);
                    break;
                }
                break;
            case 'land':
                $page_name = get_page_filename($page_id);
                $sgp_functions_admin->sgp_acp_set_config('k_landing_page', $page_name, 1);
                $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['LANDING_PAGE_SET'] . ': ' . $page_name));
                $cache->destroy('k_config');
                $cache->destroy('sql', K_VARS_TABLE);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&mode=manage"));
                break;
            case 'config':
                break;
            case 'manage':
                get_all_available_files();
                get_pages_data();
                break;
            case 'default':
                break;
        }
        $template->assign_var('U_ACTION', $this->u_action);
    }
Пример #2
0
    function main($page_id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
        include $phpbb_root_path . 'includes/sgp_functions.' . $phpEx;
        $user->add_lang('acp/k_pages');
        $this->tpl_name = 'acp_k_pages';
        $this->page_filename = 'ACP_PAGES';
        $form_key = 'acp_k_pages';
        add_form_key($form_key);
        //$s_hidden_fields = '';
        $mode = request_var('mode', '');
        $page_id = request_var('page_id', 0);
        $action = request_var('config', '');
        $tag_id = request_var('tag_id', '');
        $submit = isset($_POST['submit']) ? true : false;
        if ($tag_id != '') {
            $mode = 'add';
        }
        switch ($action) {
            case 'config':
                $template->assign_var('MESSAGE', $user->lang['SWITCHING']);
                meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_vars&mode=config&switch=k_pages");
                break;
            default:
                break;
        }
        if ($submit && !check_form_key($form_key)) {
            $submit = false;
            $mode = '';
            trigger_error($user->lang['FORM_INVALID'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
        }
        $template->assign_vars(array('U_BACK' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=manage", 'U_ADD' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=add", 'U_EDIT' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=edit" . '&page_id=' . $page_id, 'U_DELETE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=delete" . '&page_id=' . $page_id, 'U_MANAGE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=manage", 'S_OPT' => 'S_MANAGE'));
        switch ($mode) {
            case 'delete':
                $page_name = get_page_filename($page_id);
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . K_PAGES_TABLE . '
						WHERE page_id = ' . (int) $page_id;
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['ERROR_PORTAL_PAGES'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $cache->destroy('sql', K_PAGES_TABLE);
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['REMOVING_PAGES'] . $page_name));
                    meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=manage");
                    break;
                } else {
                    confirm_box(false, sprintf("%s (%s)", $user->lang['CONFIRM_DELETE'], $page_name), build_hidden_fields(array('id' => $page_id, 'mode' => $mode, 'action' => 'delete')));
                }
                $template->assign_var('MESSAGE', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=manage");
                break;
            case 'add':
                if ($submit) {
                    // drop extension
                    $tag_id = str_replace('.php', '', $tag_id);
                    // skip the spacer //
                    if ($tag_id == '..') {
                        $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => sprintf($user->lang['ERROR_PAGE'], $tag_id)));
                        meta_refresh(3, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=manage");
                        return;
                    }
                    $sql_array = array('page_name' => $tag_id);
                    $db->sql_query('INSERT INTO ' . K_PAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array));
                    meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_pages&mode=manage");
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['ADDING_PAGES']));
                    $cache->destroy('sql', K_PAGES_TABLE);
                    break;
                }
                break;
            case 'config':
                break;
            case 'manage':
                get_all_available_files();
                get_pages_data();
                break;
            case 'default':
                break;
        }
        $template->assign_var('U_ACTION', $this->u_action);
    }