Location: PHPKode > projects > Enterprise CRM and Groupware System > egs/egs2/index.php
<?php
//start timer
$mtime = microtime(true);
$starttime = $mtime;
//error reporting
error_reporting(E_ALL);
session_start();

//include setup and configuration
require 'conf/config.php';
require 'app/setup.php';
require 'lib/setup.php';
require_once FILE_ROOT.'lib/phemto/phemto.php';
$injector=new Phemto();
if(isset($dependencies) && is_array($dependencies)) {
	foreach($dependencies as $interface=>$implementation) {
		$injector->register($implementation,$interface);
	}
}
//DB::Debug();
$current_user=null;
if(isLoggedIn()) {
	setupLoggedInUser();
	$current_user = getCurrentUser();	
}
else {
	define('EGS_COMPANY_ID','null');
}
require LIB_ROOT.'includes/router.php';
if(isLoggedIn()) {
	$access = AccessObject::Instance($_SESSION['username']);
	//print_r($access);
	checkPermission();
	$view->set("accessTree",$access->tree);
	$view->set('access',$access);
}
$view->set('current_user',$current_user);
if(!defined('EGS_USERNAME')) {
define('EGS_USERNAME','');
}

$theme=SystemCompanySettings::Get('THEME');


if(defined('LOGIN_PAGE_THEME')&&$module=='login') {
	$theme=LOGIN_PAGE_THEME;
}
if(!empty($theme)) {
	define('THEME',$theme);
}
else {
	define('THEME','default');
}
$view->set('theme',THEME);
/***BEGIN CACHE CHECK******/

$cache_key = md5($_SERVER['REQUEST_URI'].EGS_COMPANY_ID.EGS_USERNAME);
if(true||!$smarty->is_cached('index.tpl',$cache_key)) {
	
	$flash=Flash::Instance();


	//Perform action
	showtime('pre-action');
	call_user_func(array($controller,$action));
	showtime('post-action');
	$flash->save();
	if(isLoggedIn()) {
		$access->save();
	}

	//assign stuff to smarty
	
	$controller->assignModels();

	$prefix = 'module=';
	$modstring = '';
	foreach($modules as $mod) {
		$modstring.=$prefix.$mod.'&';
		$prefix = 'sub'.$prefix;
	}
	$modstring = substr($modstring, 7, -1);
	$view->assign('self',array('module'=>$module,'modstring'=>$modstring, 'modules'=>$modules,'controller'=>str_replace('Controller','',$controllername),'action'=>$action));
	if(isset($current_user)) {
		$view->assign('current_user',$current_user);
	}
	
	$echo=$controller->view->get('echo');
	if((isset($_GET['ajax'])||isset($_GET['json']))&&$echo!==false) {
		echo $controller->view->get('echo');
		exit;
	}
	else {
	/*********************************************************************************/

		if ((strtolower($action) == 'index'||strtolower(substr($action,-4))== 'view'||strtolower($action)=='render')) {
			unset($_SESSION['refererPage']);
			$_SESSION['refererPage']['module'] = $module;
			$_SESSION['refererPage']['controller'] = substr($controllername,0,-10);
			$_SESSION['refererPage']['action'] = $action;
			$qstring=$_GET;
			unset($qstring['module']);
			unset($qstring['controller']);
			unset($qstring['action']);
			$_SESSION['refererPage']['other'] = $qstring;
		}

	}

}
	

showtime('pre-display');
$view->display('index.tpl',$cache_key);
showtime('post-display');
?>
Return current item: Enterprise CRM and Groupware System