Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/PortalSources/Portal.ini.php
<?php
/*
*****************************************************************

 Portal.ini.php
 
*****************************************************************
LSP: Lunabyte Systems Portal
Open-Source Project Inspired by Zef Hemel (hide@address.com)
*****************************************************************
Software Version:                  LSP 2.0 "Enigma 2"
Software by:                         Lunabyte Systems (http://www.lunabyte.net)
Copyright 2002-2005 by:       Lunabyte Systems (http://www.lunabyte.net)
Support, News, Updates at:    http://www.lunabyte.net
*****************************************************************
This program is free software; you may redistribute it and/or modify it 
under the terms of the provided license as published by Lunabyte Systems.

This program is distributed in the hope that it is and will be useful,                  
but WITHOUT ANY WARRANTIES; without even any implied warranty of           
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        

See the "LSP_license.txt" file for details of the LSP license.
The latest version can always be found at http://www.lunabyte.net.
*****************************************************************
*/


// This is not much of a file now but it is here for further expansion
//and possible stand alone capabilities

if (!defined('SMF'))
	die('<b>Access Violation</b><br />Direct Access to this location is not allowed.');

// Define Enigma as initiated
define('ENIGMA', TRUE);

// Current Enigma version number
$portal_version = 'Enigma 2.0 (RC1)';

// Set the portal sources directory.
$portalSources = $boarddir . '/PortalSources';

// include Enigma support files
require_once $portalSources . '/PortalSubs.php';

// when loading a module, Enigma does it's own query string adjustments, instead of allowing the SMF cleanRequest()
if (!empty($_REQUEST['module']))
	e2_qstr_fix();

function portalRequests()
{

	global $portal, $context, $portal_version, $settings, $modSettings, $moduledir, $boarddir, $scripturl;
	global $board, $topic, $blockdir, $portalSources, $catchArray, $portalversion, $forum_version;

	if (empty($forum_version) && defined('E2_BRIDGED'))
		$forum_version = 'SMF ' . $modSettings['smfVersion'];

	$portal = $context['forum_name'] . ' | Powered by <a href="http://www.lunabyte.net/" title="Lunabyte Systems Portal" target="_blank">' . $portal_version . '</a>.<br />&copy; 2003-' . date('Y') . ', LSP Dev Team. All Rights Reserved.';

	// setup a theme images url if 'defaults' images location is set, see the template_init() function in the Enigma index.template.php file for more info
	if (!empty($settings['use_default_images']) && $settings['use_default_images'] == 'defaults')
		$settings['theme_images_url'] = $settings['theme_url'] . '/images';

	// setup modules if their enabled
	if (!empty($modSettings['enablemodules']) && $modSettings['enablemodules'] == '1')
	{
		$moduledir = $boarddir . '/modules'; // setup the module path
		// set $context['module'] if a module was requested
		$context['module'] = !empty($_REQUEST['module']) ? $_REQUEST['module'] : '';
	}
	else // not enabled, but make sure it's defined
		$modSettings['enablemodules'] = (int) false;

	// Check for Block Override
	$context['block_override'] = !empty($_REQUEST['block_override']) ? $_REQUEST['block_override'] : '0';

	// Let's fix the Forum link tree if we're viewing the forum
	if (isset($context['linktree'][1]) && strstr($context['linktree'][1]['url'], "$scripturl#"))
		$context['linktree'][1]['url'] = $scripturl . '?action=forum' . strstr($context['linktree'][1]['url'], '#');
	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'forum' || !empty($board) || !empty($topic))
	{
		array_shift($context['linktree']);
		array_unshift($context['linktree'], array(
			'url' => $scripturl . '?action=forum',
			'name' => &$context['forum_name']
		));
	}

	// Load Blocks for Enigma
	if (!empty($modSettings['enableblocks']) && $modSettings['enableblocks'] == '1')
	{
		$blockdir = $boarddir . '/Blocks';
		require_once($portalSources . '/BlockSubs.php');
		loadBlocks();
	}
	else // not enabled, but make sure it's defined
		$modSettings['enableblocks'] = (int) false;

	// for YaBB SE / YaPP / Enigma 1, backwards compatibility
	if ($modSettings['parse_query_string'])
		doLegacyQueryParse();

	// load Portal errors messages into memory & use the orignal loadLanguage function in case we're loading a module
	loadPLanguage('PortalErrors');
	
	// check for some actions that we want to catch and control some input to
	if (!empty($_REQUEST['action']))
	{	// setup the array of actions to catch for Enigma's additional content
		$catchArray = array(
				'post' 			=> array('Post.inc.php', 'ePost'),
				'post2' 			=> array('Post.inc.php', 'ePost2'),
				'helpadmin' 		=> array('', 'eShowAdminHelp'),
				'deletemsg' 		=> array('RemoveTopic.inc.php', 'eDeleteMessage'),
				'removetopic2'		=> array('RemoveTopic.inc.php', 'eRemoveTopic2'),
				'removeoldtopics2'	=> array('RemoveTopic.inc.php', 'eRemoveOldTopics2'),
			);
		// set 'op' so that portalRequests picks it up
		if (isset($catchArray[$_REQUEST['action']]))
		{
			$_REQUEST['op']['catch'] = $_REQUEST['action'];
			unset($_REQUEST['action']); // We don't want the normal action to process, so we unset it
		}
	}
	$portalversion = $context['forum_name'] . ' | Powered by <a href="http://www.lunabyte.net/" title="Lunabyte Systems Portal" target="_blank">' . $portal_version . '</a>.<br />&copy; 2003-' . date('Y') . ', LSP Dev Team. All Rights Reserved.';
}

function portalOutput()
{
	global $modSettings, $blockdir, $portalSources, $page, $catchArray, $board, $topic;

	// see if a HTML form in a block is calling a function for processing
	// The block must already be enabled or this will just fall through
	if (!empty($_REQUEST['block']) && !empty($modSettings['enableblocks']))
	{ // file has to exist
		if (file_exists($blockdir . '/' . $_REQUEST['block'] . '.php'))
		{
			require_once($blockdir . '/' . $_REQUEST['block'] . '.php');
			// the func being called has to exist too
			if (function_exists($_REQUEST['func']))
				$_REQUEST['func']();
		}
	}

	// See if this is a request to a Module
	if (!empty($_REQUEST['module']) && !empty($modSettings['enablemodules']))
	{
		require_once $portalSources . '/LoadModule.php';
		return 'ModuleHub';
	}
	// See if this is a request to a Page?
	if (!empty($_REQUEST['page']))
	{
		$page = $_REQUEST['page'];
		require_once $portalSources . '/Pages.php';
		return 'Pages';
	}
	if (isset($_REQUEST['op']) && !empty($_REQUEST['op']))
	{
		$opNotExist = false;
		// Enigma Portal Actions...
     	$opArray = array(
			'PageManagement'	=> array('PageManagement.php',	'Pagehub'),
			'BlockManagement'	=> array('BlockManagement.php',	'Blockhub'),
			'MenuManagement'	=> array('MenuManagement.php',	'MenuHub'),
			'NewsManagement'	=> array('NewsManagement.php',	'NewsManageHub'),
			'PortalAdmin'		=> array('PortalAdmin.php',	'AdminHub'),
			'News'			=> array('News.php',		'NewsHub'),
			'news2'			=> array('Post.inc.php',	'newsRules'),
			'submissions'		=> array('submissionIndex.php',	'submissionIndex'),
			'PageListing'		=> array('Pages.php',		'ListPages'),
			'page'			=> array('Pages.php',		'Pages'),
			'Articles'		=> array('Articles.php',	'ArticlesHub'),
			'modifyPortalSettings' => array('PortalSettings.php', 'ModifyPortalSettings'),
			'modifyPortalSettings2' => array('PortalSettings.php', 'ModifyPortalSettings2'),
	    );

		// if the 'catch' key is set, we need to call the Enigma function for an action instead of op
		if (!empty($_REQUEST['op']['catch']) && isset($catchArray[$_REQUEST['op']['catch']]))
		{
			if (!empty($catchArray[$_REQUEST['op']['catch']]['0']))
				require_once($portalSources . '/' . $catchArray[$_REQUEST['op']['catch']]['0']);
			return $catchArray[$_REQUEST['op']['catch']]['1'];
		}
		// if the requested op doesn't exist, see if the oldOps function is enabled and run it..
		elseif (!isset($opArray[$_REQUEST['op']]) && !empty($modSettings['old_ops']) && $modSettings['old_ops'])
		{
			$oldOp = oldOps();
			if ($oldOp != '')
				return $oldOp;
		}
		// make sure the op exists
		elseif (isset($opArray[$_REQUEST['op']]))
		{
		    require_once($portalSources . '/' . $opArray[$_REQUEST['op']]['0']);
		    return $opArray[$_REQUEST['op']]['1'];
		}
		else
		{  // otherwise, set a variable so that the home page will display
			$opNotExist = true;
		}
     }

	if (($modSettings['use_portal_home_page'] && empty($board) && empty($topic)) || isset($opNotExist))
	{
		return 'SiteIndex';
	}
}

function initialize_portal()
{
	global $portal, $modSettings, $portalversion, $db_prefix;

	if (!$portal)
		$portal = 'initialize';
	if (!$portalversion)
		$portalversion = 'Enigma 2.0';

	// time 30 min ago
	$t = time() - 1800;
	if ($t > $modSettings['initime'])
		$initialized = true;
	else
	{
		$lsp_ini = new portal($modSettings['initime'], $modSettings['pversion'], $modSettings['pclass'], $portal, $portalversion);

		$x = 0;

		if ($lsp_ini->get_ini())
			$x++;

		if ($lsp_ini->get_version())
			$x++;
		
		if ($x == 2)
		{
			db_query("UPDATE {$db_prefix}settings SET value = " . time() . " WHERE variable = 'initime'",__FILE__,__LINE__);
			$initialized = true;
		}

		else
		{
			$lsp_ini->notinitialized();
			$initialized = false;
		}
	}
	
	if (empty($lsp_ini))
		$lsp_ini = new portal();
	$lsp_ini->check();

	return $initialized;
		
}

?>
Return current item: Enigma