mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-29 12:20:53 +00:00
Ingame version works now too more or less
This commit is contained in:
parent
3edcab4218
commit
7784854c4a
11 changed files with 216 additions and 53 deletions
|
@ -57,17 +57,11 @@ class WebUsers extends Users{
|
|||
* @return string Info: Returns true or false if a login match is found in the web db
|
||||
*/
|
||||
public function checkLoginMatch($username,$password){
|
||||
$dbw = new DBLayer("web");
|
||||
$statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:user", array('user' => $username));
|
||||
$row = $statement->fetch();
|
||||
|
||||
$salt = substr($row['Password'],0,2);
|
||||
$hashed_input_pass = crypt($password, $salt);
|
||||
if($hashed_input_pass == $row['Password']){
|
||||
return $row;
|
||||
}else{
|
||||
return "fail";
|
||||
}
|
||||
if(!user_authenticate($username, $password)){
|
||||
return 'fail';
|
||||
}else{
|
||||
return db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchAssoc();
|
||||
}
|
||||
}
|
||||
|
||||
//returns te id for a given username
|
||||
|
@ -132,13 +126,7 @@ class WebUsers extends Users{
|
|||
}
|
||||
|
||||
public function getLanguage(){
|
||||
$dbw = new DBLayer("web");
|
||||
if(! isset($this->language) || $this->language == ""){
|
||||
$statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId));
|
||||
$row = $statement->fetch();
|
||||
$this->set($row);
|
||||
}
|
||||
return $this->language;
|
||||
return $DEFAULT_LANGUAGE;
|
||||
}
|
||||
|
||||
public function isLoggedIn(){
|
||||
|
|
|
@ -73,7 +73,11 @@ $AMS_LIB = dirname( __FILE__ ) . '/ams_lib';
|
|||
$AMS_TRANS = $AMS_LIB . '/translations';
|
||||
$AMS_CACHEDIR = $AMS_LIB . '/cache';
|
||||
$SITEBASE = dirname( __FILE__ );
|
||||
$WEBPATH ='http://localhost:40917/drupal/sites/all/modules/ryzommanage/' ;
|
||||
$BASE_WEBPATH = 'http://localhost:40917/drupal';
|
||||
$IMAGELOC_WEBPATH = $BASE_WEBPATH. '/sites/all/modules/ryzommanage/' ;
|
||||
$WEBPATH = $BASE_WEBPATH .'/ams';
|
||||
$INGAME_WEBPATH = $BASE_WEBPATH . '/ingame';
|
||||
$CONFIG_PATH = dirname( __FILE__ );
|
||||
|
||||
//defines the default language
|
||||
$DEFAULT_LANGUAGE = 'en';
|
||||
|
@ -88,3 +92,4 @@ $TIME_FORMAT = "m-d-Y H:i:s";
|
|||
$INGAME_LAYOUT = "basic";
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
function login(){
|
||||
|
||||
try{
|
||||
$username = filter_var($_POST['Username'],FILTER_SANITIZE_STRING);
|
||||
$password = filter_var($_POST['Password'],FILTER_SANITIZE_STRING);
|
||||
$result = WebUsers::checkLoginMatch($username, $password);
|
||||
if( $result != "fail"){
|
||||
//handle successful login
|
||||
$_SESSION['user'] = $username;
|
||||
$_SESSION['id'] = $result['uid'];
|
||||
$_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($result['uid']));
|
||||
$user = new WebUsers($_SESSION['id']);
|
||||
$_SESSION['Language'] = $user->getLanguage();
|
||||
|
||||
//go back to the index page.
|
||||
header( 'Location: '. $INGAME_WEBPATH );
|
||||
exit;
|
||||
}else{
|
||||
//handle login failure
|
||||
$result = Array();
|
||||
$result['login_error'] = 'TRUE';
|
||||
$result['no_visible_elements'] = 'TRUE';
|
||||
helpers :: loadtemplate( 'login', $result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}catch (PDOException $e) {
|
||||
//go to error page or something, because can't access website db
|
||||
print_r($e);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,8 @@ function dashboard(){
|
|||
$result['newestTicketId'] = $ticket->getTId();
|
||||
$result['newestTicketTitle'] = $ticket->getTitle();
|
||||
$result['newestTicketAuthor'] = Ticket_User::get_username_from_id($ticket->getAuthor());
|
||||
global $INGAME_WEBPATH;
|
||||
$result['ingame_webpath'] = $INGAME_WEBPATH;
|
||||
return $result;
|
||||
|
||||
}else{
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
function login(){
|
||||
if ( helpers :: check_if_game_client () ){
|
||||
//check if you are logged in ingame.
|
||||
$result = Helpers::check_login_ingame();
|
||||
if( $result != "FALSE"){
|
||||
//handle successful login
|
||||
$_SESSION['user'] = $result['name'];
|
||||
$_SESSION['id'] = WebUsers::getId($result['name']);
|
||||
$_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id']));
|
||||
//go back to the index page.
|
||||
header( 'Location: '.$INGAME_WEBPATH );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
global $INGAME_WEBPATH;
|
||||
$pageElements['ingame_webpath'] = $INGAME_WEBPATH;
|
||||
return $pageElements;
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
function logout(){
|
||||
session_unset();
|
||||
session_destroy();
|
||||
}
|
|
@ -31,8 +31,8 @@ function show_ticket_info(){
|
|||
$result['ht'] = $ticket_info->getHT();
|
||||
$result['nel3d'] = $ticket_info->getNel3D();
|
||||
$result['user_id'] = $ticket_info->getUser_Id();
|
||||
global $WEBPATH;
|
||||
$result['WEBPATH'] = $WEBPATH;
|
||||
global $IMAGELOC_WEBPATH;
|
||||
$result['IMAGELOC_WEBPATH'] = $IMAGELOC_WEBPATH;
|
||||
|
||||
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
||||
$result['isMod'] = "TRUE";
|
||||
|
|
|
@ -22,10 +22,15 @@ global $cfg;
|
|||
global $TICKET_LOGGING;
|
||||
global $TIME_FORMAT;
|
||||
global $TICKET_MAILING_SUPPORT;
|
||||
global $IMAGELOC_WEBPATH;
|
||||
global $WEBPATH;
|
||||
global $INGAME_WEBPATH;
|
||||
global $BASE_WEBPATH;
|
||||
global $INGAME_LAYOUT;
|
||||
|
||||
require 'ams_lib/libinclude.php';
|
||||
spl_autoload_register('__autoload');
|
||||
|
||||
require 'config.php';
|
||||
|
||||
/*
|
||||
|
@ -132,6 +137,15 @@ function ryzommanage_menu()
|
|||
'type' => MENU_NORMAL_ITEM
|
||||
);
|
||||
|
||||
$items['ingame'] = array(
|
||||
'title' => 'Ingame AMS',
|
||||
'page callback' => '_collect_ingame_ams',
|
||||
'page arguments' => array(1, 2),
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array('access content'),
|
||||
'type' => MENU_CALLBACK
|
||||
);
|
||||
|
||||
//main menu item
|
||||
$items['admin/config/ryzommanage'] = array(
|
||||
'title' => 'Ryzom Server Integration',
|
||||
|
@ -256,7 +270,7 @@ function ryzommanage_block_view($delta = '')
|
|||
|
||||
function _ams_handler()
|
||||
{
|
||||
|
||||
global $BASE_WEBPATH;
|
||||
//Decide what page to load
|
||||
if ( ! isset( $_GET["page"]) ){
|
||||
if(isset($_SESSION['user'])){
|
||||
|
@ -267,7 +281,7 @@ function _ams_handler()
|
|||
}
|
||||
}else{
|
||||
//default page
|
||||
header("Location: user/login");
|
||||
header("Location: ".$BASE_WEBPATH."/user/login");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
|
@ -333,11 +347,99 @@ function _collect_register($nids, $collection)
|
|||
return_client_httpdata();
|
||||
} else {
|
||||
//redirect to registration page
|
||||
header("Location: user/register");
|
||||
header("Location: ".$BASE_WEBPATH. "/user/register");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Function _collect_register
|
||||
*
|
||||
* @takes
|
||||
* @return Nothing
|
||||
*
|
||||
* Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to /
|
||||
*
|
||||
*/
|
||||
function _collect_ingame_ams($nids, $collection)
|
||||
{
|
||||
//if not using ryzom core client show registration page
|
||||
if (Helpers::check_if_game_client(true)) {
|
||||
_return_ingame_httpdata();
|
||||
} else {
|
||||
//redirect to registration page
|
||||
global $WEBPATH;
|
||||
header("Location: ". $WEBPATH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _return_ingame_httpdata(){
|
||||
|
||||
//Decide what page to load
|
||||
if ( ! isset( $_GET["page"]) ){
|
||||
if(isset($_SESSION['user'])){
|
||||
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
||||
$page = 'dashboard';
|
||||
}else{
|
||||
$page = 'show_user';
|
||||
}
|
||||
}else{
|
||||
//default page
|
||||
$page = 'login';
|
||||
}
|
||||
}else{
|
||||
$page = $_GET["page"];
|
||||
}
|
||||
|
||||
//perform an action in case one is specified
|
||||
//else check if a php page is included in the inc folder, else just set page to the get param
|
||||
global $SITEBASE;
|
||||
if ( isset( $_POST["function"] ) ){
|
||||
$filename = $SITEBASE.'/func/' . $_POST["function"] . '.php';
|
||||
if(is_file($filename)){
|
||||
require($filename);
|
||||
$return = $_POST["function"]();
|
||||
}
|
||||
}else{
|
||||
|
||||
$filename = $SITEBASE.'/inc/' . $page . '.php';
|
||||
if(is_file($filename)){
|
||||
require_once($filename);
|
||||
$return = $page();
|
||||
}
|
||||
}
|
||||
|
||||
//add username to the return array in case logged in.
|
||||
if(isset($_SESSION['user'])){
|
||||
$return['username'] = $_SESSION['user'];
|
||||
}
|
||||
|
||||
//Set permission
|
||||
if(isset($_SESSION['ticket_user'])){
|
||||
$return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
|
||||
}else{
|
||||
//default permission
|
||||
$return['permission'] = 0;
|
||||
}
|
||||
|
||||
//hide sidebar + topbar in case of login/register
|
||||
if($page == 'login' || $page == 'register' || $page == 'logout'){
|
||||
$return['no_visible_elements'] = 'TRUE';
|
||||
}else{
|
||||
$return['no_visible_elements'] = 'FALSE';
|
||||
}
|
||||
|
||||
//handle error page
|
||||
if($page == 'error'){
|
||||
$return['permission'] = 0;
|
||||
$return['no_visible_elements'] = 'FALSE';
|
||||
}
|
||||
|
||||
helpers :: loadTemplate( $page , $return );
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Function _collect_register
|
||||
|
@ -350,6 +452,8 @@ function _collect_register($nids, $collection)
|
|||
*/
|
||||
function _collect_login($nids, $collection)
|
||||
{
|
||||
global $WEBPATH;
|
||||
global $BASE_WEBPATH;
|
||||
$result = Helpers::check_login_ingame();
|
||||
if ($result != "FALSE") {
|
||||
//handle successful ingame login
|
||||
|
@ -364,10 +468,10 @@ function _collect_login($nids, $collection)
|
|||
$user->timezone = $account->timezone;
|
||||
user_login_finalize();
|
||||
}
|
||||
header( 'Location: ams' );
|
||||
header( 'Location: '.$WEBPATH );
|
||||
} else {
|
||||
//redirect to registration page
|
||||
header("Location: user/login");
|
||||
header("Location: ".$BASE_WEBPATH."/user/login");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,21 +654,23 @@ function login_form($login_form)
|
|||
function top_bar()
|
||||
{
|
||||
global $user;
|
||||
global $WEBPATH;
|
||||
global $BASE_WEBPATH;
|
||||
$userId = $user->uid;
|
||||
if (user_is_logged_in()) {
|
||||
// Logged in user
|
||||
//check permission, if user
|
||||
if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){
|
||||
return "<div class='ryzomuserbar'><a href='ams?page=show_user&id=".$userId."'>Profile</a> |
|
||||
<a href='ams?page=createticket&id=".$userId."'>Create Ticket</a> |
|
||||
<a href='/user/".$userId."/edit'>Settings</a> | <a href='ams?page=userlist'>Users</a> |
|
||||
<a href='ams?page=show_queue&get=todo'>Queues</a> |
|
||||
<a href='ams?page=sgroup_list'>Support Groups</a> | <a href='/user/logout'>Logout</a></div>";
|
||||
return "<div class='ryzomuserbar'><a href='".$WEBPATH."?page=show_user&id=".$userId."'>Profile</a> |
|
||||
<a href='".$WEBPATH."?page=createticket&id=".$userId."'>Create Ticket</a> |
|
||||
<a href='".$BASE_WEBPATH."/user/".$userId."/edit'>Settings</a> | <a href='".$WEBPATH."?page=userlist'>Users</a> |
|
||||
<a href='".$WEBPATH."?page=show_queue&get=todo'>Queues</a> |
|
||||
<a href='".$WEBPATH."?page=sgroup_list'>Support Groups</a> | <a href='".$BASE_WEBPATH."/user/logout'>Logout</a></div>";
|
||||
|
||||
}else{
|
||||
return "<div class='ryzomuserbar'><a href='ams?page=show_user&id=".$userId."'>Profile</a> |
|
||||
<a href='ams?page=createticket&id=".$userId."'>Create Ticket</a> |
|
||||
<a href='/user/".$userId."/edit'>Settings</a> | <a href='/user/logout'>Logout</a></div>";
|
||||
return "<div class='ryzomuserbar'><a href='".$WEBPATH."?page=show_user&id=".$userId."'>Profile</a> |
|
||||
<a href='".$WEBPATH."?page=createticket&id=".$userId."'>Create Ticket</a> |
|
||||
<a href='".$BASE_WEBPATH."/user/".$userId."/edit'>Settings</a> | <a href='".$BASE_WEBPATH."/user/logout'>Logout</a></div>";
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
{if $reply.permission eq '1'}
|
||||
<span class="label label-success"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$reply.authorExtern}"> {$reply.author}{else} {$reply.author} {/if}</a></strong></span>
|
||||
{else if $reply.permission gt '1'}
|
||||
<span class="label label-warning"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$reply.authorExtern}">{$reply.author}{else} {$reply.author} {/if}</a></strong></span>
|
||||
<span class="label label-warning"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$reply.authorExtern}"><font color="red">{$reply.author}</font>{else}<font color="red"> {$reply.author} </font>{/if}</a></strong></span>
|
||||
{/if}
|
||||
</p>
|
||||
<p><pre{if $reply.permission gt '1'} {if $reply.hidden eq 0} style="background-color:rgb(248, 200, 200);"{else if $reply.hidden eq 1}style="background-color:rgb(207, 254, 255);"{/if}{/if}> {if $reply.hidden eq 1}<i>{/if}{$reply.replyContent}{if $reply.hidden eq 1}</i>{/if}</pre></p>
|
||||
|
|
|
@ -16,61 +16,61 @@
|
|||
<td><center><strong> Ingame related </strong></center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/shard.png"/><strong> Shard ID: </strong>{$shard_id}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/shard.png"/><strong> Shard ID: </strong>{$shard_id}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/user.png"/><strong> User_Id: </strong>{$user_id}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/user.png"/><strong> User_Id: </strong>{$user_id}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/position.png"/><strong> User Position: </strong>{$user_position}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/position.png"/><strong> User Position: </strong>{$user_position}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/view.png"/><strong> View Position: </strong>{$view_position}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/view.png"/><strong> View Position: </strong>{$view_position}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/client.png"/><strong> Client_Version: </strong> {$client_version}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/client.png"/><strong> Client_Version: </strong> {$client_version}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/patch.png"/><strong> Patch_Version: </strong>{$patch_version}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/patch.png"/><strong> Patch_Version: </strong>{$patch_version}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/server.png"/><strong> Server_Tick: </strong>{$server_tick}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/server.png"/><strong> Server_Tick: </strong>{$server_tick}</td>
|
||||
</tr>
|
||||
<tr class="alert alert-info">
|
||||
<td><center><strong> Hardware & Software related </strong></center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><img src="{$WEBPATH}/ams_lib/img/info/memory.png"/> Memory: </strong>{$memory}</td>
|
||||
<td><strong><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/memory.png"/> Memory: </strong>{$memory}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/processor.png"/><strong> Processor: </strong>{$processor}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/processor.png"/><strong> Processor: </strong>{$processor}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/cpuid.png"/><strong> Cpu_Id: </strong>{$cpu_id}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/cpuid.png"/><strong> Cpu_Id: </strong>{$cpu_id}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/mask.png"/><strong> Cpu_Mask: </strong>{$cpu_mask}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/mask.png"/><strong> Cpu_Mask: </strong>{$cpu_mask}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/ht.png"/><strong> HT: </strong>{$ht}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/ht.png"/><strong> HT: </strong>{$ht}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/os.png"/><strong> OS: </strong>{$os}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/os.png"/><strong> OS: </strong>{$os}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/nel.png"/><strong> NeL3D: </strong>{$nel3d}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/nel.png"/><strong> NeL3D: </strong>{$nel3d}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="alert alert-info">
|
||||
<td><center><strong> Network related </strong></center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/connect.png"/><strong> Connect_State: </strong>{$connect_state}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/connect.png"/><strong> Connect_State: </strong>{$connect_state}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$WEBPATH}/ams_lib/img/info/local.png"/><strong> Local_Address: </strong>{$local_address}</td>
|
||||
<td><img src="{$IMAGELOC_WEBPATH}/ams_lib/img/info/local.png"/><strong> Local_Address: </strong>{$local_address}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
function dashboard(){
|
||||
|
||||
//if logged in
|
||||
//if logged in
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
//is Mod
|
||||
|
|
Loading…
Reference in a new issue