<?php
error_reporting(E_ERROR);
$RootPath = realpath(__DIR__ . '/../');
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/language.php';
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/database.php';
use Hybridauth\Storage\Session;
$db = new MysqliDb(array(
    'host' => $dbhost,
    'username' => $dbuser,
    'password' => $dbpass,
    'db' => $dbname,
    'port' => $dbport,
    'prefix' => $dbprefix,
    'charset' => $dbcharset
));
require_once __DIR__ . '/function.php';
$isLogged = false;
$loginSession = new Session();
$identifier = $loginSession->get('identifier');
$login_via = $loginSession->get('login_via');
if ($identifier && $login_via) {
    $AuthUser = $db->where('user_type', $login_via)->where('auth_id', $identifier)->getOne('users');
    if ($AuthUser) {
        if (file_exists($RootPath . '/upload_file/userthumb/40x40/' . $AuthUser['user_name'] . '.jpg')) {
            $avatorImg = APP_URL . '/upload_file/userthumb/40x40/' . $AuthUser['user_name'] . '.jpg';
        } else {
            $avatorImg = APP_URL . '/assets/images/user.svg';
        }
        $isLogged = true;
    }
}

if (!file_exists($RootPath . '/lock.txt')) {
    Redirect('../install');
}
if (APP_HTTPS == 1) {
    $wwwurl = 'www.' . BASE_URL;
    $httpsurl = 'https://' . BASE_URL;
    if ($_SERVER['HTTP_HOST'] == $wwwurl || empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off") {
        header('Location: ' . $httpsurl . $_SERVER['REQUEST_URI'], TRUE, 301);
        exit;
    }
}
$AmpURL = '';
$schema = array();
$allowExt = array('mp3', 'mid', 'midi', 'aac', 'wav', 'zip', 'rar', 'jpg', 'png', 'gif', 'jpeg', 'webp', 'tar.gz');
$Route = '';
$breadcrumb[] =  [
    "@type" => "ListItem",
    "position" => 1,
    "item" => [
        "@id" => "" . APP_URL . "",
        "name" => "Home"
    ]
];
