<?PHP
/*
* admin.php main admins control file.
* copyright (c)2005 Marco Islas <markuz@islascruz.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 of the License, 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 Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

//We need the config.php file!!
require_once("./include/config.php");
$url = $GLOBALS["functions"]->get_registry_value("/pagval/url");
$title = $GLOBALS["functions"]->get_registry_value("/pagval/title");
$tpl = new template(CINTILLA_PATH."xhtml");
if (empty($_COOKIE["admin"]) && !isset($_REQUEST["action"])){
	$tpl->load("layout","login.html");
	if (isset($_REQUEST["message"]))
		$message = $_REQUEST["message"];
	else
		$message = "Introduce el nombre de Usuario y Contraseņa";
	$tpl->set_variable("message",$message);
	$tpl->set_variable("url",$url);
	$tpl->expand("explayout","layout");
	$tpl->print_export("explayout");
}else{
	if (!isset($_REQUEST["action"]))
		$action = $GLOBALS["actions"]->execute("manage");
	else
		$action = $GLOBALS["actions"]->execute($_REQUEST["action"]);
	$tpl->load("layout","admin.html");
	$tpl->setBlock("main","layout");
	//header
	$tpl->setBlock("header","layout");
	$tpl->set_variable("title",$title);
	$tpl->expand("expheader","header");
	//body
	$tpl->setBlock("body","layout");
	$tpl->set_variable("data",$action);
	$tpl->expand("expbody","body");
	//footer
	$tpl->setBlock("body","layout");
	$tpl->expand("expbody","body");
	
	$tpl->expand("expmain","main");
	$tpl->print_export("expmain");
}
?>
