<?
error_reporting(0);
if ( $_GET['check'] )
  exit( 'OK' );
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 ( $c == 'Securimage' )
  {
    require_once 'resources/securimage/securimage.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' );
include 'files/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;
$securimage = new \Securimage;
if ( file_exists( 'resources/xajax/xajax_core/xajax.inc.php' ) )
  include( 'resources/xajax/xajax_core/xajax.inc.php' );
$lang = \System::getSessionVar( 'lang' );
if ( !\System::getSessionVar( 'token' ) )
  \System::setSessionVar( 'token' , sha1( uniqid( rand() , true ) ) );
if ( !$lang ) 
{
  $lang = \language\FLanguage::loadLang();
  \System::setSessionVar( 'lang' , $lang );
}
\front\controls\Page::checkUrlParams();
$lang   = \System::getSessionVar( 'lang' );
$user   = \System::getSessionVar( 'user' );
if ( !$site = \System::getSessionVar( 'site' ) ) 
{
  $site = \site\FSite::loadSite();
  \System::setSessionVar( 'site' , $site );
}
if ( !\System::getSessionVar('visit_counter') )
  \System::updateVisitCounter();
include( 'functions/xajax.php' );
if ( file_exists( 'functions/proces.php' ) )
  include 'functions/proces.php';
echo \front\view\Page::show();
?>