Ingame version works now too more or less

--HG--
branch : quitta-gsoc-2013
This commit is contained in:
Quitta 2013-09-07 04:12:47 +02:00
parent ae9fcba077
commit d583b2cd8e
11 changed files with 216 additions and 53 deletions

View file

@ -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 * @return string Info: Returns true or false if a login match is found in the web db
*/ */
public function checkLoginMatch($username,$password){ public function checkLoginMatch($username,$password){
$dbw = new DBLayer("web"); if(!user_authenticate($username, $password)){
$statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:user", array('user' => $username)); return 'fail';
$row = $statement->fetch(); }else{
return db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchAssoc();
$salt = substr($row['Password'],0,2); }
$hashed_input_pass = crypt($password, $salt);
if($hashed_input_pass == $row['Password']){
return $row;
}else{
return "fail";
}
} }
//returns te id for a given username //returns te id for a given username
@ -132,13 +126,7 @@ class WebUsers extends Users{
} }
public function getLanguage(){ public function getLanguage(){
$dbw = new DBLayer("web"); return $DEFAULT_LANGUAGE;
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;
} }
public function isLoggedIn(){ public function isLoggedIn(){

View file

@ -73,7 +73,11 @@ $AMS_LIB = dirname( __FILE__ ) . '/ams_lib';
$AMS_TRANS = $AMS_LIB . '/translations'; $AMS_TRANS = $AMS_LIB . '/translations';
$AMS_CACHEDIR = $AMS_LIB . '/cache'; $AMS_CACHEDIR = $AMS_LIB . '/cache';
$SITEBASE = dirname( __FILE__ ); $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 //defines the default language
$DEFAULT_LANGUAGE = 'en'; $DEFAULT_LANGUAGE = 'en';
@ -88,3 +92,4 @@ $TIME_FORMAT = "m-d-Y H:i:s";
$INGAME_LAYOUT = "basic"; $INGAME_LAYOUT = "basic";

View file

@ -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;
}
}

View file

@ -15,6 +15,8 @@ function dashboard(){
$result['newestTicketId'] = $ticket->getTId(); $result['newestTicketId'] = $ticket->getTId();
$result['newestTicketTitle'] = $ticket->getTitle(); $result['newestTicketTitle'] = $ticket->getTitle();
$result['newestTicketAuthor'] = Ticket_User::get_username_from_id($ticket->getAuthor()); $result['newestTicketAuthor'] = Ticket_User::get_username_from_id($ticket->getAuthor());
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result; return $result;
}else{ }else{

View file

@ -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;
}

View file

@ -0,0 +1,6 @@
<?php
function logout(){
session_unset();
session_destroy();
}

View file

@ -31,8 +31,8 @@ function show_ticket_info(){
$result['ht'] = $ticket_info->getHT(); $result['ht'] = $ticket_info->getHT();
$result['nel3d'] = $ticket_info->getNel3D(); $result['nel3d'] = $ticket_info->getNel3D();
$result['user_id'] = $ticket_info->getUser_Id(); $result['user_id'] = $ticket_info->getUser_Id();
global $WEBPATH; global $IMAGELOC_WEBPATH;
$result['WEBPATH'] = $WEBPATH; $result['IMAGELOC_WEBPATH'] = $IMAGELOC_WEBPATH;
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$result['isMod'] = "TRUE"; $result['isMod'] = "TRUE";

View file

@ -22,10 +22,15 @@ global $cfg;
global $TICKET_LOGGING; global $TICKET_LOGGING;
global $TIME_FORMAT; global $TIME_FORMAT;
global $TICKET_MAILING_SUPPORT; global $TICKET_MAILING_SUPPORT;
global $IMAGELOC_WEBPATH;
global $WEBPATH; global $WEBPATH;
global $INGAME_WEBPATH;
global $BASE_WEBPATH;
global $INGAME_LAYOUT;
require 'ams_lib/libinclude.php'; require 'ams_lib/libinclude.php';
spl_autoload_register('__autoload'); spl_autoload_register('__autoload');
require 'config.php'; require 'config.php';
/* /*
@ -132,6 +137,15 @@ function ryzommanage_menu()
'type' => MENU_NORMAL_ITEM '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 //main menu item
$items['admin/config/ryzommanage'] = array( $items['admin/config/ryzommanage'] = array(
'title' => 'Ryzom Server Integration', 'title' => 'Ryzom Server Integration',
@ -256,7 +270,7 @@ function ryzommanage_block_view($delta = '')
function _ams_handler() function _ams_handler()
{ {
global $BASE_WEBPATH;
//Decide what page to load //Decide what page to load
if ( ! isset( $_GET["page"]) ){ if ( ! isset( $_GET["page"]) ){
if(isset($_SESSION['user'])){ if(isset($_SESSION['user'])){
@ -267,7 +281,7 @@ function _ams_handler()
} }
}else{ }else{
//default page //default page
header("Location: user/login"); header("Location: ".$BASE_WEBPATH."/user/login");
exit; exit;
} }
}else{ }else{
@ -333,11 +347,99 @@ function _collect_register($nids, $collection)
return_client_httpdata(); return_client_httpdata();
} else { } else {
//redirect to registration page //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 * Function _collect_register
@ -350,6 +452,8 @@ function _collect_register($nids, $collection)
*/ */
function _collect_login($nids, $collection) function _collect_login($nids, $collection)
{ {
global $WEBPATH;
global $BASE_WEBPATH;
$result = Helpers::check_login_ingame(); $result = Helpers::check_login_ingame();
if ($result != "FALSE") { if ($result != "FALSE") {
//handle successful ingame login //handle successful ingame login
@ -364,10 +468,10 @@ function _collect_login($nids, $collection)
$user->timezone = $account->timezone; $user->timezone = $account->timezone;
user_login_finalize(); user_login_finalize();
} }
header( 'Location: ams' ); header( 'Location: '.$WEBPATH );
} else { } else {
//redirect to registration page //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() function top_bar()
{ {
global $user; global $user;
global $WEBPATH;
global $BASE_WEBPATH;
$userId = $user->uid; $userId = $user->uid;
if (user_is_logged_in()) { if (user_is_logged_in()) {
// Logged in user // Logged in user
//check permission, if user //check permission, if user
if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){ if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){
return "<div class='ryzomuserbar'><a href='ams?page=show_user&id=".$userId."'>Profile</a> | return "<div class='ryzomuserbar'><a href='".$WEBPATH."?page=show_user&id=".$userId."'>Profile</a> |
<a href='ams?page=createticket&id=".$userId."'>Create Ticket</a> | <a href='".$WEBPATH."?page=createticket&id=".$userId."'>Create Ticket</a> |
<a href='/user/".$userId."/edit'>Settings</a> | <a href='ams?page=userlist'>Users</a> | <a href='".$BASE_WEBPATH."/user/".$userId."/edit'>Settings</a> | <a href='".$WEBPATH."?page=userlist'>Users</a> |
<a href='ams?page=show_queue&get=todo'>Queues</a> | <a href='".$WEBPATH."?page=show_queue&get=todo'>Queues</a> |
<a href='ams?page=sgroup_list'>Support Groups</a> | <a href='/user/logout'>Logout</a></div>"; <a href='".$WEBPATH."?page=sgroup_list'>Support Groups</a> | <a href='".$BASE_WEBPATH."/user/logout'>Logout</a></div>";
}else{ }else{
return "<div class='ryzomuserbar'><a href='ams?page=show_user&id=".$userId."'>Profile</a> | return "<div class='ryzomuserbar'><a href='".$WEBPATH."?page=show_user&id=".$userId."'>Profile</a> |
<a href='ams?page=createticket&id=".$userId."'>Create Ticket</a> | <a href='".$WEBPATH."?page=createticket&id=".$userId."'>Create Ticket</a> |
<a href='/user/".$userId."/edit'>Settings</a> | <a href='/user/logout'>Logout</a></div>"; <a href='".$BASE_WEBPATH."/user/".$userId."/edit'>Settings</a> | <a href='".$BASE_WEBPATH."/user/logout'>Logout</a></div>";
} }
} else { } else {

View file

@ -119,7 +119,7 @@
{if $reply.permission eq '1'} {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> <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'} {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} {/if}
</p> </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> <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>

View file

@ -16,61 +16,61 @@
<td><center><strong> Ingame related </strong></center></td> <td><center><strong> Ingame related </strong></center></td>
</tr> </tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<tr class="alert alert-info"> <tr class="alert alert-info">
<td><center><strong> Hardware & Software related </strong></center></td> <td><center><strong> Hardware & Software related </strong></center></td>
</tr> </tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<tr class="alert alert-info"> <tr class="alert alert-info">
<td><center><strong> Network related </strong></center></td> <td><center><strong> Network related </strong></center></td>
</tr> </tr>
<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>
<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> </tr>
</table> </table>

View file

@ -1,8 +1,7 @@
<?php <?php
function dashboard(){ function dashboard(){
//if logged in
//if logged in
if(WebUsers::isLoggedIn()){ if(WebUsers::isLoggedIn()){
//is Mod //is Mod