<?php
/*
	Stempora web framework
	copyright (c) 2002-2013 Stempora
		web:  www.stempora.com
		mail: support@stempora.com

	$Id: name.php,v 0.0.1 dd/mm/yyyy hh:mm:ss oxylus Exp $
	description
*/

// dependencies

if (CONSTANT("STP_ENABLE_DEMO") == "1") {

	if (!is_array($_SESS["minibase"]["raw"])) {
		$_SESS["minibase"] = array(
			"demo_mode" => 1,
			"user"	=> 1,
			"raw"	=> array(
				"user_login"		=> "demo",
				"user_first_name"	=> "Demo",
			)
		);	

		urlredirect("index.php");
	}
} else {
	if ($_SESS["minibase"]["demo_mode"]) {
		unset($_SESS["minibase"]);
		urlredirect("index.php");
	}	
}


if (!is_array($_SESS["minibase"])) {
	if ($_COOKIE["autologin"] == "true") {
		//get the default user

		$user = $this->db->QFetchArray("SELECT * FROM site_users WHERE `user_login`='$_COOKIE[username]'");


		if (is_array($user)) {
			if ($_COOKIE["keycode"] == md5($user["user_login"] . $user["user_password"])) {
				$_SESS["minibase"]["raw"] = $user;
				$_SESS["minibase"]["user"] = 1;
			}			
		}
	}
}

?>