$get_value) $get_string .= $get_var . (!empty($get_value) ? '=' . $get_value : '') . ';'; redirectexit(substr($get_string, 0, -1)); } return; } if (!$standalone) { require_once($sourcedir . '/PortalBlocks.php'); if (SMF != 'SSI') require_once($boarddir . '/SSI.php'); loadTemplate('Portal'); loadLanguage('SPortal', sp_languageSelect('SPortal')); if (!empty($modSettings['sp_maintenance']) && !allowedTo('sp_admin')) $modSettings['sp_portal_mode'] = 0; if (empty($modSettings['sp_standalone_url'])) $modSettings['sp_standalone_url'] = ''; if ($modSettings['sp_portal_mode'] == 3) $context += array( 'portal_url' => $modSettings['sp_standalone_url'], 'page_title' => $context['forum_name'], ); else $context += array( 'portal_url' => $scripturl, ); if ($modSettings['sp_portal_mode'] == 1) $context['linktree'][0] = array( 'url' => $scripturl . '?action=forum', 'name' => $context['forum_name'], ); // If you want to remove Forum link when it is // alone, take out the following two comment lines. //if (empty($context['linktree'][1])) // $context['linktree'] = array(); if (!empty($context['linktree']) && $modSettings['sp_portal_mode'] == 1) foreach ($context['linktree'] as $key => $tree) if (strpos($tree['url'], '#c') !== false && strpos($tree['url'], 'action=forum#c') === false) $context['linktree'][$key]['url'] = str_replace('#c', '?action=forum#c', $tree['url']); } $context['standalone'] = $standalone; // Load the headers if necessary. sportal_init_headers(); $context['SPortal']['sides'] = array( 5 => array( 'id' => '5', 'name' => 'header', 'active' => true, ), 1 => array( 'id' => '1', 'name' => 'left', 'active' => !empty($modSettings['showleft']), ), 2 => array( 'id' => '2', 'name' => 'top', 'active' => true, ), 3 => array( 'id' => '3', 'name' => 'bottom', 'active' => true, ), 4 => array( 'id' => '4', 'name' => 'right', 'active' => !empty($modSettings['showright']), ), 6 => array( 'id' => '6', 'name' => 'footer', 'active' => true, ), ); $blocks = getBlockInfo(null, null, true, true, true); $context['SPortal']['blocks'] = array(); foreach ($blocks as $block) { if (!$context['SPortal']['sides'][$block['column']]['active']) continue; $block['style'] = sportal_parse_style('explode', $block['style'], true); $context['SPortal']['sides'][$block['column']]['last'] = $block['id']; $context['SPortal']['blocks'][$block['column']][] = $block; } foreach($context['SPortal']['sides'] as $side) { if (empty($context['SPortal']['blocks'][$side['id']])) $context['SPortal']['sides'][$side['id']]['active'] = false; $context['SPortal']['sides'][$side['id']]['collapsed'] = $context['user']['is_guest'] ? !empty($_COOKIE['sp_' . $side['name']]) : !empty($options['sp_' . $side['name']]); } if (!empty($context['template_layers']) && !in_array('portal', $context['template_layers'])) $context['template_layers'][] = 'portal'; } // Deals with the initialization of SimplePortal headers. function sportal_init_headers() { global $context, $settings, $modSettings; static $initialized; if (!empty($initialized)) return; $context['html_headers'] .= ' '; $initialized = true; } function sportal_catch_action() { global $sourcedir, $modSettings, $board, $topic, $context; if (isset($_GET['about:sinan'])) return 'BookOfSinan'; if (empty($context['disable_sp'])) { if (empty($board) && empty($topic) && empty($_GET['page']) && $modSettings['sp_portal_mode'] == 1) { require_once($sourcedir . '/PortalMain.php'); return 'sportal_main'; } elseif (empty($board) && empty($topic) && !empty($_GET['page'])) { require_once($sourcedir . '/PortalPages.php'); return 'sportal_pages'; } } return false; } // This function, returns all of the information about particular blocks. function getBlockInfo($column_id = null, $block_id = null, $state = null, $show = null, $permission = null) { global $smcFunc, $context, $settings, $options, $txt; $query = array(); $parameters = array(); if (!empty($column_id)) { $query[] = 'spb.col = {int:col}'; $parameters['col'] = !empty($column_id) ? $column_id : 0; } if (!empty($block_id)) { $query[] = 'spb.id_block = {int:id_block}'; $parameters['id_block'] = !empty($block_id) ? $block_id : 0; } if (!empty($state)) { $query[] = 'spb.state = {int:state}'; $parameters['state'] = 1; } $request = $smcFunc['db_query']('',' SELECT spb.id_block, spb.label, spb.type, spb.col, spb.row, spb.permission_set, spb.groups_allowed, spb.groups_denied, spb.state, spb.force_view, spb.display, spb.display_custom, spb.style, spp.variable, spp.value FROM {db_prefix}sp_blocks AS spb LEFT JOIN {db_prefix}sp_parameters AS spp ON (spp.id_block = spb.id_block)' . (!empty($query) ? ' WHERE ' . implode(' AND ', $query) : '') . ' ORDER BY spb.col, spb.row', $parameters ); $return = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { if (!empty($show) && !getShowInfo($row['id_block'], $row['display'], $row['display_custom'])) continue; if (!empty($permission) && !sp_allowed_to('block', $row['id_block'], $row['permission_set'], $row['groups_allowed'], $row['groups_denied'])) continue; if (!isset($return[$row['id_block']])) { $return[$row['id_block']] = array( 'id' => $row['id_block'], 'label' => $row['label'], 'type' => $row['type'], 'type_text' => !empty($txt['sp_function_' . $row['type'] . '_label']) ? $txt['sp_function_' . $row['type'] . '_label'] : $txt['sp_function_unknown_label'], 'column' => $row['col'], 'row' => $row['row'], 'permission_set' => $row['permission_set'], 'groups_allowed' => $row['groups_allowed'] !== '' ? explode(',', $row['groups_allowed']) : array(), 'groups_denied' => $row['groups_denied'] !== '' ? explode(',', $row['groups_denied']) : array(), 'state' => empty($row['state']) ? 0 : 1, 'force_view' => $row['force_view'], 'display' => $row['display'], 'display_custom' => $row['display_custom'], 'style' => $row['style'], 'collapsed' => $context['user']['is_guest'] ? !empty($_COOKIE['sp_block_' . $row['id_block']]) : !empty($options['sp_block_' . $row['id_block']]), 'parameters' => array(), ); } if (!empty($row['variable'])) $return[$row['id_block']]['parameters'][$row['variable']] = $row['value']; } $smcFunc['db_free_result']($request); return $return; } // Function to get a block's display/show information. function getShowInfo($block_id = null, $display = null, $custom = null) { global $smcFunc, $context, $modSettings; static $variables; // Do we have the display info? if ($display === null || $custom === null) { // Make sure that its an integer. $block_id = (int) $block_id; // We need an ID. if (empty($block_id)) return false; // Get the info. $result = $smcFunc['db_query']('',' SELECT display, display_custom FROM {db_prefix}sp_blocks WHERE id_block = {int:id_block} LIMIT 1', array( 'id_block' => $block_id, ) ); list ($display, $custom) = $smcFunc['db_fetch_row']($result); $smcFunc['db_free_result']($result); } if (!empty($_GET['page']) && (empty($context['current_action']) || $context['current_action'] == 'portal')) $page_info = sportal_get_pages($_GET['page'], true, true); // Some variables for ease. $action = !empty($context['current_action']) ? $context['current_action'] : ''; $sub_action = !empty($context['current_subaction']) ? $context['current_subaction'] : ''; $board = !empty($context['current_board']) ? 'b' . $context['current_board'] : ''; $topic = !empty($context['current_topic']) ? 't' . $context['current_topic'] : ''; $page = !empty($page_info['id']) ? 'p' . $page_info['id'] : ''; $portal = (empty($action) && empty($sub_action) && empty($board) && empty($topic) && SMF != 'SSI' && $modSettings['sp_portal_mode'] == 1) || !empty($context['standalone']) ? true : false; // Will hopefully get larger in the future. $portal_actions = array( 'articles' => true, 'start' => true, 'theme' => true, 'PHPSESSID' => true, 'wwwRedirect' => true, 'www' => true, 'variant' => true, 'language' => true, ); // Set some action exceptions. $exceptions = array( 'post' => array('announce', 'editpoll', 'emailuser', 'post2', 'sendtopic'), 'register' => array('activate', 'coppa'), 'forum' => array('collapse'), 'admin' => array('credits', 'theme', 'viewquery', 'viewsmfile'), 'moderate' => array('groups'), 'login' => array('reminder'), 'profile' => array('trackip', 'viewprofile'), ); // Still, we might not be in portal! if (!empty($_GET) && empty($context['standalone'])) foreach ($_GET as $key => $value) { if (preg_match('~^news\d+$~', $key)) continue; if (!isset($portal_actions[$key])) $portal = false; elseif (is_array($portal_actions[$key]) && !in_array($value, $portal_actions[$key])) $portal = false; } // Set the action to more known one. foreach ($exceptions as $key => $exception) if (in_array($action, $exception)) $action = $key; // Take care of custom actions. $special = array(); $exclude = array(); if (!empty($custom)) { // Complex display options first... if (substr($custom, 0, 4) === '$php') { if (!isset($variables)) { $variables = array( '{$action}' => "'$action'", '{$sa}' => "'$sub_action'", '{$board}' => "'$board'", '{$topic}' => "'$topic'", '{$page}' => "'$page'", '{$portal}' => $portal, ); } return @eval(str_replace(array_keys($variables), array_values($variables), un_htmlspecialchars(substr($custom, 4))) . ';'); } $custom = explode(',', $custom); // This is special... foreach ($custom as $key => $value) { $name = ''; $item = ''; // Is this a weird action? if ($value[0] == '~') { @list($name, $item) = explode('|', substr($value, 1)); if (empty($item)) $special[$name] = true; else $special[$name][] = $item; } // Might be excluding something! elseif ($value[0] == '-') { // We still may have weird things... if ($value[1] == '~') { @list($name, $item) = explode('|', substr($value, 2)); if (empty($item)) $exclude['special'][$name] = true; else $exclude['special'][$name][] = $item; } else $exclude['regular'][] = substr($value, 1); } } // Add what we have to main variable. if (!empty($display)) $display = $display . ',' . implode(',', $custom); else $display = $custom; } // We don't want to show it on this action/page/board? if (!empty($exclude['regular']) && count(array_intersect(array($action, $page, $board), $exclude['regular'])) > 0) return false; // Maybe we don't want to show it in somewhere special. if (!empty($exclude['special'])) foreach ($exclude['special'] as $key => $value) if (isset($_GET[$key])) if (is_array($value) && !in_array($_GET[$key], $value)) continue; else return false; // If no display info and/or integration disabled and we are on portal; show it! if ((empty($display) || empty($modSettings['sp_enableIntegration'])) && $portal) return true; // No display info and/or integration disabled and no portal; no need... elseif (empty($display) || empty($modSettings['sp_enableIntegration'])) return false; // Get ready for real action if you haven't yet. elseif (!is_array($display)) $display = explode(',', $display); // Did we disable all blocks for this action? if (!empty($modSettings['sp_' . $action . 'IntegrationHide'])) return false; // If we will display show the block. elseif (in_array('all', $display)) return true; // If we are on portal, show portal blocks; if we are on forum, show forum blocks. elseif (($portal && (in_array('portal', $display) || in_array('sportal', $display))) || (!$portal && in_array('sforum', $display))) return true; elseif (!empty($board) && (in_array('allboard', $display) || in_array($board, $display))) return true; elseif (!empty($action) && $action != 'portal' && (in_array('allaction', $display) || in_array($action, $display))) return true; elseif (!empty($page) && (in_array('allpages', $display) || in_array($page, $display))) return true; elseif (empty($action) && empty($board) && empty($_GET['page']) && !$portal && ($modSettings['sp_portal_mode'] == 2 || $modSettings['sp_portal_mode'] == 3) && in_array('forum', $display)) return true; // For mods using weird urls... foreach ($special as $key => $value) if (isset($_GET[$key])) if (is_array($value) && !in_array($_GET[$key], $value)) continue; else return true; // Ummm, no block! return false; } function sp_allowed_to($type, $id, $set = null, $allowed = null, $denied = null) { global $smcFunc, $user_info; static $cache, $types; if (!isset($types)) { $types = array( 'block' => array( 'table' => 'blocks', 'id' => 'id_block', ), 'page' => array( 'table' => 'pages', 'id' => 'id_page', ), 'shoutbox' => array( 'table' => 'shoutboxes', 'id' => 'id_shoutbox', ), ); } if (empty($id) || empty($type) || !isset($types[$type])) return false; if (!isset($set, $allowed, $denied)) { $request = $smcFunc['db_query']('',' SELECT permission_set, groups_allowed, groups_denied FROM {db_prefix}sp_{raw:table} WHERE {raw:id} = {int:id_item} LIMIT {int:limit}', array( 'table' => $types[$type]['table'], 'id' => $types[$type]['id'], 'id_item' => $id, 'limit' => 1, ) ); list ($set, $allowed, $denied) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); } $result = false; $cache_name = md5(implode(':', array($set, $allowed, $denied))); if (isset($cache[$cache_name])) $result = $cache[$cache_name]; else { switch ($set) { case 3: $result = true; break; case 2: $result = empty($user_info['is_guest']); break; case 1: $result = !empty($user_info['is_guest']); break; case 0: if (!empty($denied) && count(array_intersect($user_info['groups'], explode(',', $denied))) > 0) $result = false; elseif (!empty($allowed) && count(array_intersect($user_info['groups'], explode(',', $allowed))) > 0) $result = true; break; default: break; } $cache[$cache_name] = $result; } return $result; } function BookOfSinan() { global $context, $scripturl; echo '