<?
error_reporting(0);

ob_start();
function __autoload_my_classes( $classname )
{
  $q = explode( '\\' , $classname );
  $c = array_pop( $q );
  $f = '../autoload/' . implode( '/' , $q ) . '/class.' . $c . '.php';
  if ( $c == 'Savant3' )
  {
    require_once( '../autoload/Savant3.php' );
    return true;
  }
  if ( file_exists( $f ) )
    require_once( $f );
}
spl_autoload_register( '__autoload_my_classes' );

define( 'OPD_DIR' , '../autoload/' );
require( OPD_DIR . 'opd.class.php' );
if ( file_exists( '../files/config.php' ) )
  include '../files/config.php';
else
  include '../config.php';
date_default_timezone_set('Europe/Warsaw');

session_start();

$db = opdClass::create(
                        array(
                            'dsn' => 'mysql:host=' . $database['host'] . ';dbname=' . $database['name'],
                            'user' => $database['user'] ,
                            'password' => $database['password'] ,
                            'cache' => 'Temp/' ,
                            'debugConsole' => false
                            )
                      );
$db -> query('SET NAMES utf8');

$sys    = new \System;
$cache  = new \FileCache;

if ( \System::formGet( 'del' ) == 'true' )
{
  \System::deleteCacheAdmin();
  \System::deleteCache();
  session_destroy();
  echo '<script>document.location.href="./";</script>';
}

$lang   = $sys -> getSessionVar('lang' , true );
if ( !$lang )
{
  $lang = \language\FLanguage::loadLang();
  $sys -> setSessionVar( 'lang' , $lang , true );
}


\admin\controls\Page::checkUrlParams();

$user   = $sys -> getSessionVar( 'user' , true );
if ( file_exists( '../resources/xajax/xajax_core/xajax.inc.php' ) )
  include( '../resources/xajax/xajax_core/xajax.inc.php' );

include( '../functions/xajax.php' );

echo \admin\view\Page::show();
?>