<?php
/*
	DevSaver Web Framework
	Copyright (c) 2013-2016 DevSaver. 
	All rights reserved.
		web:  www.devsaver.com
		mail: support@devsaver.com		
*/


// 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;
			}			
		}
	}
}

?>