<?php

// -----------------------------------------------------------------------
// This file is part of Igloo
//
// Copyright (C) 2003, 2005 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
//
// This program 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 program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------
$menu_section = "splash";
include "inc/header.inc.php";

if (!empty($_REQUEST['http_referer'])) {
    $http_referer = $_REQUEST['http_referer'];
}

//set up user
require_once($c_node['dir']['class_path'] . 'User.class.php');
$user = new User($db, $date);
$user->status_ids = $c_node['user']['status'];


//form actions
if (isset($_POST['login'])) {

	if (isset($_POST['email']) && $_POST['email'] && isset($_POST['password']) && $_POST['password']) {
		$user->relation_type = $c_node['user']['relation_type']['approved'];

		require_once($c_node['dir']['class_path'] . 'Statistic.class.php');
		$statistic = new Statistic($db, null);
		$user->statistic = $statistic;
		$user->total_login_stat_id = $c_node['statistic']['user']['total_logins'];

		$user->checkLogin($_REQUEST['email'],$_REQUEST['password']);
		
		if (empty($GLOBALS['igloo_error_log'])) {
			//setup relations
			require_once($c_node['dir']['class_path'] . 'SocialNetwork.class.php');
			$sn = new SocialNetwork(null, $db, null);
			$sn->relation_type_ids = $c_node['user']['relation_type'];
			$sn->status_ids = $c_node['user']['status'];
			$user->sn = $sn;
			
			if (isset($http_referer)) {
			    $user->http_referer = $http_referer;
			}
			$user->loginUser($_REQUEST['email'],$_REQUEST['password']);

		}
	}
	else {
		$GLOBALS['igloo_error_log'][] = array(20, null, null);
	}

}
elseif (isset($_REQUEST['registration_complete'])) {
	$display = "registration_complete";
}
elseif (isset($_REQUEST['man'])) {
	
	require_once($languageArrayPath . 'arr_man.lang.php');
	
	//wiki
	require_once($c_node['dir']['class_path'] . 'Wiki/Wiki.php');
	$wiki =& new Text_Wiki();
	$wiki->disableRule('wikilink');
	
	if (isset($_REQUEST['man_id']) && $_REQUEST['man_id'] > 0) {
		$page = $_REQUEST['man_id'];
	}
	else {
		$page = 0;
	}
	
	$langfile = $lang['man'][$page][0] . ".man.php";
	$output_manual_page['man'] = readTxtFile($languagePath . 'man/' . $langfile);
	$output_manual_page['man'] = stripslashes($output_manual_page['man']);
	$output_manual_page['man'] = $wiki->transform($output_manual_page['man'], 'Xhtml');
	$output_manual_page['title'] = $lang['man'][$page][1];
	$output_manual_page['man_id'] = $page;
	$display = "man";
}

if (!empty($display)) {
	$body->set('display', $display);
}


if (!empty($output_manual_page)) {
	$body->set('manual_page', $output_manual_page);
}

$template_pageLink = $lang['txt_welcome'];

include "inc/footer.inc.php";

?>
