<?php
/*
  ===============================================================

  inGenio X
  http://ingenio.area421.com

  Created by 
  Julian Moreno Hidalgo (Software developer)
  Jesus Moreno Hidalgo (Communication's tree)

  inGenio X is a free software licensed under CC-GNU GPL

  ===============================================================
*/
	if (!defined("IGNX")) { die("Attempt..."); }

	// autorizar al administrador
	if ((isset($_COOKIE["GX_ss"]) && isset($_COOKIE["GX_ps"]) && isset($_COOKIE["GX_us"])) && $_COOKIE["GX_ss"] == CONFIG_8 && $_COOKIE["GX_ps"] == CONFIG_9)
	{
		
		$si_autorizo = 1;
		// nivel
		$GX_us = $_COOKIE["GX_us"];
		
		// aumentar la gestion
		if (isset($_COOKIE["GX_prm"]))
		{
			if (!isset($_SESSION["aumentar_gestion"]))
			{
				setcookie("GX_ss", CONFIG_8, time()+3600*24*15, "/");
				setcookie("GX_ps", CONFIG_9, time()+3600*24*15, "/");
				setcookie("GX_us", $GX_us, time()+3600*24*15, "/");
				setcookie("GX_prm", "perm", time()+3600*24*15, "/");
			}
			$_SESSION["aumentar_gestion"] = 1;		
		}
		
		
	} else if ((isset($_SESSION["log"]) && isset($_SESSION["pass"]) && isset($_SESSION["lv"])) && $_SESSION["log"] == CONFIG_8 && $_SESSION["pass"] == CONFIG_9)
	{
	
		$si_autorizo = 1;
		// nivel
		$GX_us = $_SESSION["lv"];
	
	} else {
	
		$si_autorizo = 0;
	
	}

	if ($si_autorizo == 0)
	{ 
		// no autorizado
		if (isset($redir_admin))
		{
			$redir_admin = "./".$ingenio_conn[6];
			$redir_admin_get = "";
		} else {
			$redir_admin = "../".$ingenio_conn[6];		
			$redir_admin_get = "?g=1";
		}
		
		if (file_exists_url($redir_admin))
		{
			Redir ($redir_admin.$redir_admin_get);
		} else {
			die(LEN_ADMIN_15);
		}
		

	}
	
	if ($si_autorizo == 1)
	{
		// ADMINISTRADOR y USUARIOS
		$tpl_log_nivel = $GX_us;
	}

	
?>
