<?php
/**
 * @package linea21.core
 * @subpackage admin
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */
ob_start();
session_start();
// DO NOT REMOVE
header("Cache-control: private"); // necessary for IE and FF to display form data afer clicking the back button
 
if(!isset($_SESSION['authenticated'])) {
  if(!empty($_SERVER["QUERY_STRING"])) $page = "login.php?page=". rawurlencode("index.php?". $_SERVER["QUERY_STRING"]);
  else $page = "login.php";
  header("Location: ". $page);
  exit();
}

if(isset($_REQUEST['rub']))	$rub=$_REQUEST['rub'];
if(!isset($_REQUEST['todo'])) {
  $todo="list";
} else {
  $todo=$_REQUEST['todo'];
}

include_once("../config/define.php");

// check if session is not expired
$l21auth->isActive();

// if is simple user
if($l21auth->isSimpleUser()) {
	header("Location: login.php");
	exit();
}

// Set_Cookie_last_page() must be after define.php include
$l21auth->setCookieLastPage();


/**
 * Section include if dir exists
 **/
if(isset($rub)) {
  if(is_dir(override('../'.$rub, THEME_ADMIN_PATH))) $dir='../'.$rub;
  else ReloadIndex('admin');
} else {
  $dir='../home';
  $rub='home';
}

/**
 * language include
 **/
IncludeAdminLang($rub);

$rub_link="index.php?rub=".$rub;

include_once(SQL.'.inc.php');
$sql_inc_file=override($dir."/".SQL.".inc.php", THEME_ADMIN_PATH);
if(file_exists($sql_inc_file)) include_once($sql_inc_file);

if(isset($Dbg)) {
  $debug_line->setEndTime();
}

include_once(THEME_ADMIN_PATH."index.php");

$sql_object -> DBClose();
if(isset($Dbg)) $Dbg->display();
ob_end_flush();
?>