<?php

//Autoload
//PHP >= 5.3

function cmp($a, $b)
{
    return strnatcmp($b[1], $a[1]);
}

spl_autoload_register(function ($class){
    $PathNames = array('app', 'models', 'controllers', 'widgets', 'modules');
    foreach ($PathNames as $pathName){
        $dir = scandir("".$pathName);
        unset($dir[0]);
        unset($dir[1]);
        foreach ($dir as $d)
        {
            if ($class.".php" == $d)
            {
                include ""  .$pathName . DIRECTORY_SEPARATOR . $class . ".php";
                return;
            }
        }
    }
 
});
function unhtmlentities ($str)
{
    $trans_tbl = get_html_translation_table (HTML_ENTITIES);
    $trans_tbl = array_flip ($trans_tbl);
    return strtr ($str, $trans_tbl);
}
//phpinfo();
//die();

session_start();

/*
* Создание конфигов в json формате
* Вспомогательная
*/
   if ($_SERVER['REMOTE_ADDR'] == "93.79.138.35") {
            error_reporting(E_ALL);
            ini_set('display_errors', true);
        }
//error_reporting(E_ALL);

//ini_set('display_errors', true);
//include "ConfigCreator.php";

date_default_timezone_set('Europe/Moscow');
$Uri = $_SERVER['REQUEST_URI'];
$Uri = trim($Uri,"/\\");
$Paths = explode("/",$Uri);
if($Uri == "captcha"){Captcha::GetCaptcha(); die;}
$var = substr($Uri,strlen($Uri)-4);
if ($var == ".png" || $var == ".gif" || $var == ".js" || $var == ".css") die();


//include "web/install.php";
$app = new App();
$app->run();
?>