58 lines
1.3 KiB
PHP
Executable File
58 lines
1.3 KiB
PHP
Executable File
<?php require_once '../autoloader.php';
|
|
|
|
use \router\core\Router;
|
|
use \database\core\Repo;
|
|
use \api\core\Request;
|
|
use \api\core\AuthSystemDefault;
|
|
use \database\core\DatabaseDriver;
|
|
use \kwebsocket\core\wsinterop;
|
|
|
|
/* (1) Start session */
|
|
session_start();
|
|
if( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 ){
|
|
|
|
// ask with websocketInterop
|
|
$wsi = new wsinterop('localhost', 9998);
|
|
|
|
if( count($_SESSION['USER']) > 0 ){
|
|
|
|
// get/send name to web socket
|
|
$wsi->send(['type' => 'user', 'name' => $_SESSION['USER']['username']]);
|
|
$check = $wsi->receive();
|
|
|
|
if( $check['error'] == false )
|
|
$_SESSION['NAME'] = $check['name'];
|
|
|
|
}elseif( count($_SESSION['ADMIN']) > 0 ){
|
|
|
|
// get/send name to web socket
|
|
$wsi->send(['type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]);
|
|
$check = $wsi->receive();
|
|
|
|
if( $check['error'] == false )
|
|
$_SESSION['NAME'] = $check['name'];
|
|
|
|
}else{
|
|
|
|
// get/send name to web socket
|
|
$wsi->send(['type' => 'guest', 'name' => null]);
|
|
$check = $wsi->receive();
|
|
|
|
if( $check['error'] == false )
|
|
$_SESSION['NAME'] = $check['name'];
|
|
}
|
|
|
|
$wsi = null;
|
|
|
|
}
|
|
|
|
/* (2) Set default Driver for Repos */
|
|
Repo::setDriver(DatabaseDriver::get());
|
|
|
|
/* (3) Set default AuthSystem */
|
|
Request::setAuthSystem(new AuthSystemDefault);
|
|
|
|
/* (4) launch router */
|
|
Router::launch($_GET['url']);
|
|
|