<?php
	header ('Location: home');
	exit;

	// if (!isset ($_COOKIE ['virgin']))
	// {
	// 	setcookie ('virgin', true, time () + 60 * 60 * 24 * 30); //IP address cookie, expiring in one month.
	// 	include 'intro.html';
	// 	exit;
	// }
	// 
	// setcookie ('virgin', true, time () + 60 * 60 * 24 * 30); //IP address cookie, expiring in one month.
//	echo 'hi';exit;
	define ('LIBRARY_LOCATION_URL', 'http://10.2.1.1/sesalos2/');
	require_once ('scripts/constants.php');
//	echo 'hi';exit;	
	require_once (LIBRARY_LOCATION_URL.'scripts/database.inc');
	$db = db ();

	$sql = 
		"SELECT site.defaultPage ".
		"FROM page, site ".
		"WHERE page.parent = '' ".
		"AND page.active = '1' ".
		"AND page.site = site.id ".
		"LIMIT 1";
	
	$result = $db->query ($sql);
	if (DB::isError ($result)) die ($result->getMessage ());
	
	if ($row = $result->fetchRow ()) 
	{	
		header ('Location: '.dirname ($_SERVER ['PHP_SELF']).'/'.$row ['defaultPage']);
		exit;
	}
	
	header ('Location: '.dirname ($_SERVER ['PHP_SELF']).'/home');
	exit;

/*
	$directoriesBetween = dirname ($_SERVER ['PHP_SELF']); //if there, it would be '/test' for example, if not it would be '/'
	if ($directoriesBetween == '/') $directoriesBetween = '';

	header ('Location: http://'.$_SERVER ['SERVER_NAME'].dirname ($_SERVER ['PHP_SELF']).'home');
	exit;
*/	
?>