Location: PHPKode > projects > Laffer > htdocs/im.php
<?php
#######################################
#	Main Laffer Web Client Page
#	Copyright: Laffer Project, Slavej Karadjov (c) 2004-2005
# 	Licensed under GPL.
#	See LICENSE file for details
# $Id: im.php 427 2007-03-20 19:42:57Z slaff $
#######################################
$CFG_PATH="../modules";

// don't take some variables from HTTP_REQUEST
$hExcludeVars = array (
			'CFG_PATH'=>1,
		);

if(1) { // fix this later
	foreach($_REQUEST as $key=>$val) {
		if(isset($hExcludeVars[$key])) {
			continue;
		}
		$GLOBALS[$key]=$val;
	}
	foreach($_ENV as $key=>$val) {
		$GLOBALS[$key]=$val;
	}
	foreach($_SERVER as $key=>$val) {
		$GLOBALS[$key]=$val;
	}
}

# [Load Configuration ] #
require_once($CFG_PATH."/config.inc");

#warning:: debug code
require_once($INC_PATH."/timer.inc");
$c=new c_Timer();
$c->start();

# [+ some local configuration ]
define("SCRIPT_NAME", basename(__FILE__));
define("EXTERNAL_PATH", dirname($SCRIPT_NAME)."/");

# [Load standard_library ] #
require_once($INC_PATH."/standard_library");

# [Load external config file] #
$CONFIG = loadConfig("main.conf"); 

# [Load Graphic Elements Class] #
require_once($INC_PATH."/graphic_elements");
$oGE=new GraphicElements();

# [Load Language Defaults ]#
if(isset($_COOKIE["lang"])) {	
	if(isset($allowedLanguages[$_COOKIE["lang"]])) {
		$LANG = $_COOKIE["lang"];
	}
}
if($a!='SET_LANG') {
	require_once("$LANG_PATH/$LANG/default");
}

# [ Call the external configuration after the Language is set ] #
if(USE_EXT_PROTOCOLS) {
	include_once($CFG_PATH."/ext_config.inc");
}

# [establiesh DB connection] #
@$DatabaseLink = mysql_connect($CONFIG['DB_HOST'],$CONFIG['DB_USER'],$CONFIG['DB_PASS']);

// we have problem connecting to  DB
if(!$DatabaseLink) {
	if(@$a=='SET_LANG') {
		require_once("$LANG_PATH/$LANG/default");
	}
	# [no output should be send before this line, because both check_sid and GENERATE_SID send cookies.] #
	header("Content-type: text/html; charset=$CHARSET");
	echo $oGE->webMessage(STR_DB_ERROR);
	logToFile("DB - Unable to Connect to DB", $ERROR_LOG_FILE);
        exit;
}

// we have problem using $Database from DB
if(!(mysql_select_db($CONFIG['DB_DATABASE'], $DatabaseLink))) {
	# [no output should be send before this line, because both check_sid and GENERATE_SID send cookies.] #
	header("Content-type: text/html; charset=$CHARSET");
	echo $oGE->webMessage(STR_DB_ERROR);
	logToFile("DB - Unable select ".$CONFIG['DB_DATABASE']." DB", $ERROR_LOG_FILE);
        exit;
}

# [Get Browser constants] #
getBrowserConstants($HTTP_USER_AGENT);	

require_once($INC_PATH."/ScreenInfo");

# [Check SID] #
if($ScreenInfo[$s][2]!=-1) {
	require_once($INC_PATH."/check_sid");
}

# [Load Action(if any)] #
if($a!= "" && file_exists($ACT_PATH."/$a")) {
        include($ACT_PATH."/$a");
}

# [Page Cache Control] #
header("Expires: Mon, 14 Aug 2000 06:30:00 GMT");    // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");                          // HTTP/1.0

# [no output should be send before this line, because both check_sid and GENERATE_SID send cookies.] #
header("Content-type: text/html; charset=$CHARSET");

# [ If we aren't given a screen, go home ] #
if(!(isset($s)) OR ($s=="")) {
        $s="f";
}


# [ set the path to the page body ] #
$pageBody = $SCR_PATH."/$s";

# [ If screen is bad, go home ] #
if(!(file_exists($pageBody)) OR (!isset($ScreenInfo[$s][0])))
{
        $s="f"; $pageBody = $SCR_PATH."/$s";
}

# [ Start HTML page ] #
if($ScreenInfo[$s][3]=="bare") {
	include($LAYOUT_PATH."/".$ScreenInfo[$s][3]);
}
else {
	echo("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
	echo("<HTML><HEAD>\n");
	echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$CHARSET\">");
	echo("<TITLE>" . $ScreenInfo[$s][0] . "</TITLE>\n");
	
	# [ Meta tags ] #
	echo("<META NAME=\"description\" CONTENT=\"".$ScreenInfo[$s][1]."\">\n");
	echo("<META NAME=\"keywords\" CONTENT=\"".$ScreenInfo[$s][2].",$DefaultKeywords\">\n");
	echo("<META NAME=\"distribution\" CONTENT=\"global\">\n");
	if(isset($ScreenInfo[$s][4])) {
		echo($ScreenInfo[$s][4]);
	}
	
	# [add styles ] #
	if(defined('Browser_CSSOK')) {
	        //echo '<link type="text/css" rel="StyleSheet" href="'.$CSS_URL.'main.css">'."\n";
	}
	
	# [ add  Javascript functions ] #
	if(defined('Browser_JavaScriptOK')) {
	        //echo '<script language="JavaScript" src="'.$JS_URL.'main.js"></script>'."\n";
	}
	echo("</HEAD>\n");
	# [include the page body between BODY tags] #
	include($LAYOUT_PATH."/".$ScreenInfo[$s][3]);
	# [End HTML page] #
	echo("</HTML>\n");
}

# [close connection to DB]
mysql_close($DatabaseLink);

#warning::debug code
$c->stop();
if(@$MORE_INFO) {
	echo "<center>Èçïúëíåíèåòî îòíå: ".$c->elapsed()." ñåêóíäè</center>";
}
?>
Return current item: Laffer