Location: PHPKode > projects > TestMaker > testmaker-3.3p4/index.php
<?php

/* This file is part of testMaker.

testMaker is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.

testMaker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>. */


/**
 * Initializes the system and starts Portal
 * @package Portal
 */

// Load developer options from dev.conf
$isDevMachine = file_exists(dirname(__FILE__)."/is_developer_machine");
if ($isDevMachine) {
	$GLOBALS["is_dev_machine"] = true;
	$devConf = dirname(__FILE__)."/dev.conf";
	$stopWatchPrintReport = false;
	if (file_exists($devConf)) {
		$file = file($devConf);
		$devOptions = array();
		foreach ($file as $lineNum => $line)
		{
			$temp = explode("=", $line);
			$devOptions[$temp[0]] = str_replace("\n", "", $temp[1]);
		}
		if (array_key_exists("stop_watch", $devOptions) 
			&& ($devOptions["stop_watch"] == "1" 
			|| $devOptions["stop_watch"] == "true" 
			|| $devOptions["stop_watch"] == "yes")) 
		{ 
			$GLOBALS["enable_stopwatch"] = true; 
		} else
		{
			$GLOBALS["enable_stopwatch"] = false;
		}
		if (array_key_exists("test_run_debug_info", $devOptions) 
			&& (intVal($devOptions["test_run_debug_info"]) == 1 
			|| $devOptions["test_run_debug_info"] == "true" 
			|| $devOptions["test_run_debug_info"] == "yes")) 
		{ 
			$GLOBALS["enable_debug"] = true; 
		} else
		{
			$GLOBALS["enable_debug"] = false; 
		}

	}
} else
{
	$GLOBALS["enable_stopwatch"] = false;
	$GLOBALS["enable_debug"] = false;
	$GLOBALS["is_dev_machine"] = false;
}

// Load the StopWatch
require_once("lib/utilities/StopWatch.php");

start("Initializing");

// Initialize the system
require_once(dirname(__FILE__)."/init.php");

// Initialize Portal
start("Initializing Portal");
require_once(ROOT.'portal/init.php');
stop();

stop();

// Start Portal
start("Running Portal");
$GLOBALS["PORTAL"]->run();
stop();

// Show debug output at the end of the page (can be dangerous e.g. with ajax code)
if ($isDevMachine) {
	$found = FALSE;
	foreach (headers_list() as $item) {
		if(!$found) $found = strpos($item,"text/html");
	}

	// Show stop watch report
	
	if($found && isset($GLOBALS["enable_stopwatch"]) && $GLOBALS["enable_stopwatch"] == TRUE)
	{
		$stopWatch = getStopWatch();
		$stopWatch->printReport();
	}

	// Print additional debug infos
	if(array_key_exists("DEBUG", $_SESSION)) printVar($_SESSION["DEBUG"]);
}
Return current item: TestMaker