Пример #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
 /**
  * grab the portal cache
  *
  * @return null
  */
 public function load_cache()
 {
     ///var_dump('helper.php > load_cache()');
     global $k_config;
     if (!isset($k_config)) {
         include $this->phpbb_root_path . 'ext/phpbbireland/portal/includes/functions.' . $this->php_ext;
         $k_config = obtain_k_config();
         $k_blocks = obtain_block_data();
         $k_menus = obtain_k_menus();
         $k_pages = obtain_k_pages();
         $k_groups = obtain_k_groups();
         $k_resources = obtain_k_resources();
     }
 }
Пример #3
0
 function main($id, $mode)
 {
     global $db, $user, $auth, $template, $cache, $request;
     global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
     include_once $phpbb_root_path . 'ext/phpbbireland/portal/config/constants.' . $phpEx;
     include $phpbb_root_path . 'ext/phpbbireland/portal/includes/sgp_functions.' . $phpEx;
     if (!function_exists('obtain_k_config')) {
         include $phpbb_root_path . 'ext/phpbbireland/portal/includes/functions.' . $phpEx;
         $k_config = obtain_k_config();
     }
     $user->add_lang_ext('phpbbireland/portal', 'k_resources');
     $this->tpl_name = 'acp_resources';
     $this->page_title = $user->lang['ACP_RESOURCES_TITLE'];
     add_form_key('resources');
     // Set up general vars
     $action = $request->variable('action', '');
     $action = isset($_POST['edit']) ? 'edit' : $action;
     $action = isset($_POST['add']) ? 'add' : $action;
     $action = isset($_POST['save']) ? 'save' : $action;
     $action = isset($_POST['switch']) ? 'switch' : $action;
     $action = isset($_POST['delete']) ? 'delete' : $action;
     // ======================================================
     //			[ MAIN PROCESS ]
     // ======================================================
     $add = $request->variable('add', '');
     $id_list = isset($_POST['id_list']) ? $request->variable('id_list', array(0)) : (isset($_GET['id_list']) ? $request->variable('id_list', array(0)) : array());
     switch ($action) {
         case 'add':
             $process = true;
             $start = '{';
             $end = '}';
             $new_word = $request->variable('new_word', '');
             if (isset($k_config[$new_word])) {
                 $value = isset($k_config[$new_word]) ? $k_config[$new_word] : '';
                 $table = $user->lang['K_CONFIG'];
             } else {
                 if (isset($config[$new_word])) {
                     $value = isset($config[$new_word]) ? $config[$new_word] : '';
                     $table = $user->lang['CONFIG'];
                 } else {
                     $table = $user->lang['UNKNOWN'];
                     $process = false;
                     $template->assign_var('L_PROCESS_REPORT', sprintf($user->lang['VAR_NOT_FOUND'], $new_word));
                 }
             }
             if ($process) {
                 $template->assign_var('L_PROCESS_REPORT', sprintf($user->lang['VAR_ADDED'], $new_word));
                 $start .= strtoupper($new_word) . $end;
                 $sql_array = array('word' => $start);
                 if (!$db->sql_query('INSERT INTO ' . K_RESOURCES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array))) {
                     trigger_error($user->lang['ERROR_PORTAL_WORDS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__);
                 }
             }
             break;
         case 'delete':
             for ($i = 0; $i < count($id_list); $i++) {
                 $sql = 'DELETE FROM ' . K_RESOURCES_TABLE . " WHERE id = " . (int) $id_list[$i];
                 if (!($result = $db->sql_query($sql))) {
                     trigger_error($user->lang['ERROR_PORTAL_WORDS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__);
                 }
             }
             break;
         default:
             $template->assign_var('L_PROCESS_REPORT', sprintf($user->lang['PROCESS_REPORT'], '...'));
             break;
     }
     $sql = 'SELECT * FROM ' . K_RESOURCES_TABLE;
     if (!($result = $db->sql_query($sql))) {
         trigger_error($user->lang['ERROR_PORTAL_WORDS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__);
     }
     $a = array('{', '}');
     $b = array('', '');
     $value = '';
     while ($row = $db->sql_fetchrow($result)) {
         $name = strtolower($row['word']);
         $name = str_replace($a, $b, $name);
         if (isset($k_config[$name])) {
             $value = isset($k_config[$name]) ? $k_config[$name] : '';
             $table = $user->lang['K_CONFIG'];
         } else {
             if (isset($config[$name])) {
                 $value = isset($config[$name]) ? $config[$name] : '';
                 $table = $user->lang['CONFIG'];
             } else {
                 $table = $user->lang['NA'];
             }
         }
         $template->assign_block_vars('wordrow', array('ID' => $row['id'], 'WORD' => $row['word'], 'NAME' => $name, 'VALUE' => $value, 'TABLE' => $table));
     }
     $db->sql_freeresult($result);
 }
Пример #4
0
 public function process_blocks_for_phpbb_pages()
 {
     //var_dump('listener.php > process_blocks_for_phpbb_pages');
     global $phpbb_container, $request, $phpbb_root_path, $user;
     global $queries, $cached_queries, $total_queries, $k_config, $k_blocks, $k_menus, $k_pages, $k_groups;
     if (!defined('KISS')) {
         define('KISS', true);
     }
     $this->includes_path = $phpbb_root_path . 'ext/phpbbireland/portal/includes/';
     if (!isset($k_config)) {
         include $phpbb_root_path . 'ext/phpbbireland/portal/includes/functions.' . $this->php_ext;
         $k_config = obtain_k_config();
         $k_blocks = obtain_block_data();
         $k_menus = obtain_k_menus();
         $k_pages = obtain_k_pages();
         $k_groups = obtain_k_groups();
         $k_resources = obtain_k_resources();
     }
     $this->includes_path = $phpbb_root_path . 'ext/phpbbireland/portal/includes/';
     include_once $this->includes_path . 'sgp_functions.' . $this->php_ext;
     $func = new \phpbbireland\portal\includes\func();
     $func->process_block_modules();
 }