<?
/*****************************************************************
**																**
**			 			GSudoku Homepage				  		**
**																**
**	 		Scripted in PHP 4/XHTML 1.0 Transistional			**
**		   (c) 2007 by Nico Ritschel & Jannis Schnitzer			**
**																**
**			 Index-File which includes all other files			**
**				   Original name: "/index.php"					**
**				v. 0.6		Last change: 2007/03/29 			**
**																**
*****************************************************************/



//  If INCLUDE isn't 1, included files would report an error. 
define ("INCLUDE", "1");

// Functionlist.php contains links to the functions, used by this website.
require "src/functions/functionlist.php";

// Languages.php conntains the names of the avaiable languages and aliases.
require "lang/languages.php";

// This checks if there is a timecode from the user transmitted. 
// The order of the information is folowing: (from important to unimportant)
//
// 1. GET-Value, 2. COOKIE-Value, 3. Prefered language (browser-settings)
// If there aren't any informations, the system will set the language to english.
// $langsetby is only set by debug-reasons.
if (isset($lang[$_GET['p0']])) {
	define ("SYSLANG", $_GET['p0']);
	$langsetby = "GET";
}
else {
	if ($_COOKIE['language'] AND isset($lang[$_COOKIE['language']])) {
		define ("SYSLANG", $_COOKIE['language']);
		$langsetby = "COOKIE";
	}
	else {	
		if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] AND isset($httplang[substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5)])) {
			define ("SYSLANG", $httplang[substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5)]);
			$langsetby = "LANGVAR";
		}
		else {
			define ("SYSLANG", "en_US");
			$langsetby = "AUTO_EN";
		}
	}
}

// Sets a Cookie with a lifetime of around one year. So, the set language will be saved until it is changed again.
setcookie("language", SYSLANG, time() + 31536000);

// Tests if cookie was set successfull (only for debug-reasons).
if ($_COOKIE['language']) {
	$cookiesuccess = 1;
}

// Loads the language-files themselves.
require "lang/".SYSLANG."/list.php";

// Loads the subpages
require "src/subpages.php";

// Checks GET-, POST- and COOKIE-Values for hacking-tries.
require "src/header.php";

// Checks the GET-Value for an transmitted subpage to load.
// $transsubpage is only set by debug-reasons.
if (!isset($go)) {
	if (isset($_GET['p0'])) {
		 if(isset($subpage[$_GET['p0']])) {
			$go = $_GET['p0'];
			$transsubpage = $_GET['p0'];
		 }
		 else {
			$go = "home";
			$transsubpage = "inv!";
		 }
	}
	else {
		$go= "home";
		$transsubpage = "none!";
	}
}

/*

END OF PRE-PREPROCESSING ;)

The following block is only HTML with some variable language-options and some includes.
*/


?> 
<!--
The following informations are only debug-output and have no practical use:

System language: <? echo SYSLANG; ?> 
Language set by: <? echo $langsetby; ?> 
Cookie set: <? echo $cookiesuccess; ?> 
Transmitted subpage: <? echo $transsubpage; ?> 
Selected subpage: <? echo $go; ?> 

User IP: <? echo $_SERVER['REMOTE_ADDR']; ?> 
User language: <? echo substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5); ?> 
User encoding: <? echo $_SERVER['HTTP_ACCEPT_CHARSET']; ?> 
User software: <? echo $_SERVER['HTTP_USER_AGENT']; ?> 

These informations won't be particulary logged or used for non-statistical reasons. 
We'll NEVER use this information to identify or contact you! 

This is only a debug-message and can be ignored if the page loads as it should do.
 -->
 
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd charset=iso-8859-1">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<meta name="expires" content="NEVER" />
	<meta name="page-topic" content="Computer" />
	<meta name="author" content="<? echo langstr($lang, SYSLANG, 'main_author'); ?>" />
	<meta name="publisher" content="<? echo langstr($lang, SYSLANG, 'main_publisher'); ?>" />
	<meta name="copyright" content="<? echo langstr($lang, SYSLANG, 'main_copyright'); ?>" />
	<meta name="robots" content="INDEX,NOFOLLOW" />
	<meta name="description" content="<? echo langstr($lang, SYSLANG, 'main_description'); ?>" />
	<meta name="keywords" content="<? echo langstr($lang, SYSLANG, 'main_keywords'); ?>" />
	
	<link href="/style.css" rel="stylesheet" type="text/css" />
	<!--[if gte IE 5]>
	<link rel="stylesheet" type="text/css" href="/ie.css">
	<![endif]-->

	<title><? echo langstr($lang, SYSLANG, 'main_title'); ?>: <? echo langstr($lang, SYSLANG, 'subname_'.$go); ?></title>
</head>

<body>

	<br /><br /><br />
	
	<a name="top" id="top" />
	
	<div class="menu" align="center">
<?
// Includes the Menu-file.
require "src/menu.php";	
?> 
	</div>
	
	<br />
	
	<div class="main">
<?
// Includes the chosen subpage.
require $subpage[$go];	
?> 
		<div class="icons" align="right">
			<a href="#top"><? echo langstr($lang, SYSLANG, 'main_top'); ?></a>
		</div>
	
	</div>
	
	<br />
	
	<div class="icons" align="left">
		<a href="http://validator.w3.org/check?uri=referer" style="color:#CCCCCC;">Valid XHTML 1.0 Transitional</a> |
		
		<a href="http://jigsaw.w3.org/css-validator/check/referer" style="color:#CCCCCC;">Valid CSS</a> | 
		 
		<a href="/impressum" style="color:#CCCCCC;"><? echo langstr($lang, SYSLANG, 'main_copyright'); ?></a>
	</div>

</body>

</html>
