2017-11-23 10:23:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace router\controller;
|
|
|
|
|
|
|
|
|
2017-12-06 16:12:08 +00:00
|
|
|
use kwebsocket\core\wsinterop;
|
|
|
|
|
2017-11-23 10:23:09 +00:00
|
|
|
class page{
|
|
|
|
|
|
|
|
|
|
|
|
private $pagename;
|
|
|
|
|
|
|
|
/* PRE-CALL
|
|
|
|
*
|
|
|
|
* @url<String> Calling URI
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __construct($url){
|
2017-11-29 11:29:27 +00:00
|
|
|
|
2017-11-30 15:45:26 +00:00
|
|
|
$this->pagename = $url['page'];
|
2017-11-23 10:23:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* CALL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function load(){
|
2017-12-06 16:12:08 +00:00
|
|
|
|
|
|
|
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
|
2017-12-07 19:24:59 +00:00
|
|
|
$wsi->send(['operation' => "Connect",'type' => 'user', 'name' => $_SESSION['USER']['username']]);
|
2017-12-06 16:12:08 +00:00
|
|
|
$check = $wsi->receive();
|
|
|
|
|
|
|
|
if( $check['error'] == false )
|
|
|
|
$_SESSION['NAME'] = $check['name'];
|
|
|
|
|
|
|
|
}elseif( count($_SESSION['ADMIN']) > 0 ){
|
|
|
|
|
|
|
|
// get/send name to web socket
|
2017-12-07 19:24:59 +00:00
|
|
|
$wsi->send(['operation' => "Connect",'type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]);
|
2017-12-06 16:12:08 +00:00
|
|
|
$check = $wsi->receive();
|
|
|
|
|
|
|
|
if( $check['error'] == false )
|
|
|
|
$_SESSION['NAME'] = $check['name'];
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
// get/send name to web socket
|
2017-12-07 19:24:59 +00:00
|
|
|
$wsi->send(['operation' => "Connect",'type' => 'guest', 'name' => null]);
|
2017-12-06 16:12:08 +00:00
|
|
|
$check = $wsi->receive();
|
|
|
|
|
|
|
|
if( $check['error'] == false )
|
|
|
|
$_SESSION['NAME'] = $check['name'];
|
|
|
|
}
|
|
|
|
|
2017-12-07 14:35:07 +00:00
|
|
|
$wsi->close();
|
2017-12-06 16:12:08 +00:00
|
|
|
$wsi = null;
|
|
|
|
|
|
|
|
}
|
2017-12-04 21:55:41 +00:00
|
|
|
if( file_exists(__ROOT__."/view/home.php") )
|
|
|
|
include __ROOT__."/view/home.php";
|
2017-11-23 10:23:09 +00:00
|
|
|
else
|
|
|
|
echo "page not found";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* POST-CALL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __destruct(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|