if (!session_id()) {
    @session_start();
}
require_once "../core/core_defines.inc.php";
require_once ROOT_PATH . "core/global_fce.php";
requireFile("admin/admin_fce.php");
$DB = new cDb();
$DB->connect();
$CFG = new cCfg();
$Logs = new cLogs("index.php");
$Logs->on();
$Logs->addLog($_POST, "POST");
$_aErrors = array();
$_aAlerts = array();
$Authent = new cAuthentication();
$bAut = $Authent->authenticate();
if (!$bAut && ADMIN_PAGE_ACCESS_AUTHORIZIED || $bAut && !$CFG->hasCapability('superadmin')) {
    header("Location: " . HTTP_PATH);
}
$_index_rights = true;
foreach ($_GET as $k => $v) {
    $_GET[$k] = get_magic_quotes_gpc() ? trim($v) : trim(addslashes($v));
}
/// update capabilities ///
if (isset($_POST['update_capab'])) {
    _updateCapabilities();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
        if (is_string($CFG->getDefaultPage('path'))) {
            header("Location: " . $CFG->getDefaultPage('path'));
        } else {
            if (!ADMIN_PAGE_ACCESS_AUTHORIZIED) {
                header("Location: " . HTTP_PATH . "admin");
            }
        }
    }
    $action = get_magic_quotes_gpc() ? $_GET['_pageAction_'] : addslashes($_GET['_pageAction_']);
    //$Logs->addLog($action,"_pageAction_");
    $CORE = new cBuildIndex($action);
    if (MK_DEBUG) {
        $CORE->addCssToHead("core/logs.css");
    }
    $Authent = new cAuthentication();
    $Authent->authenticate();
    /// user authenticated ///
    if ($CFG->isAuthenticated()) {
        $Logs->addLog("user authenticated", "authentication process");
        $CFG->setUserAccount();
    }
    $CORE->buildPage();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
if (isset($CORE)) {
    $CORE->printHead();
} else {