<?php

session_start();
include_once dirname(__FILE__) . '/../includes/classes/class.ini.file.php';
include_once dirname(__FILE__) . '/../includes/classes/class.mysql.php';
include_once dirname(__FILE__) . '/../includes/classes/class.kermert.php';
include_once dirname(__FILE__) . '/../includes/classes/class.kmImage.php';
include_once dirname(__FILE__) . '/../includes/lib.form.php';
include_once dirname(__FILE__) . '/../includes/functions.php';
include_once dirname(__FILE__) . '/includes/classes/class.kminfo.php';
include_once dirname(__FILE__) . '/includes/classes/class.kmuser.php';
include_once dirname(__FILE__) . '/includes/classes/class.GDWrapper.php';
include_once dirname(__FILE__) . '/includes/functions.php';
define('CONFIG_FILE', dirname(__FILE__) . '/../config/kermert.ini');
iniFile::read(CONFIG_FILE);
$con = new connection(km_dbuser, km_dbpassword, km_dbhost, km_dbbase);
$_SESSION['hashkey'] = !empty($_REQUEST['logout']) ? $_SESSION['hashkey'] = NULL : $_SESSION['hashkey'];
if (!kmUser::isAuthenticated() && empty($auth_page)) {
    header('Location: auth.php');
}
$kermert = new Kermert($con);
require_once "core/lib/crTemplater.php";
require_once "core/lib/iniFile.php";
require_once "core/lib/ADODB/adodb.inc.php";
require_once "core/lib/ADODB/toexport.inc.php";
require_once "core/lib/CrHeaderConstruct.php";
require_once "core/lib/User_class.php";
require_once "core/lib/ModulsRuner.php";
require_once "core/lib/cacher.php";
require_once "core/lib/parents/Parents_of_api.php";
require_once "core/lib/parents/Parents_of_moduls.php";
require_once "core/lib/CrEngine.php";
$system_moduls = array('CrMenu', 'CrAdminPannel', 'CrUser');
$on_moduls = array();
$CoreTemplater = new crTemplater("::", "not faund", "::");
$iniParser = new iniFile("settings/site.ini");
$core_and_site_parameters = $iniParser->read();
$iniParser->NewFile("settings/secret.ini");
$secret_parameters = $iniParser->read();
$head = new CrHeaderConstruct($core_and_site_parameters['site']['title']);
$head->SetCharseft("utf-8");
$head->SetIcon("favicon.ico");
$head->AddScriptFromFile($core_and_site_parameters['path']['code_js'] . "jquery-latest.min.js");
$core_database_driver = ADONewConnection($secret_parameters['database']['db_dbms']);
$core_database_driver->Connect($secret_parameters['database']['db_server'], $secret_parameters['database']['db_username'], $secret_parameters['database']['db_key'], $secret_parameters['database']['db_name']);
$url = split("/", $_GET['url']);
$Start_Parametrs['function'] = $url[1];
$url1 = split("[.]", $url[0]);
if ($url1[1]) {
    switch ($url1[1]) {
        case "api":
            $Start_Parametrs['mode'] = 'api';