Remove invalid behaviour with ring databases

This commit is contained in:
kaetemi 2014-09-02 19:56:37 +02:00
parent 6a8e2f314e
commit 57781ca616
3 changed files with 148 additions and 140 deletions

View file

@ -198,49 +198,56 @@ return parse_ini_file( $AMS_TRANS . '/' . $_SESSION['Language'] . '.ini', true )
}
/**
* Time output function for handling the time display.
*
* @return returns the time in the format specified in the $TIME_FORMAT global variable.
*/
static public function outputTime( $time, $str = 1 ) {
global $TIME_FORMAT;
if ( $str ) {
return date( $TIME_FORMAT, strtotime( $time ) );
} else {
return date( $TIME_FORMAT, $time );
}
}
/**
* Auto login function for ingame use.
* This function will allow users who access the website ingame, to log in without entering the username and password. It uses the COOKIE entry in the open_ring db.
* it checks if the cookie sent by the http request matches the one in the db. This cookie in the db is changed everytime the user relogs.
*
* @return returns "FALSE" if the cookies didn't match, else it returns an array with the user's id and name.
*/
static public function check_login_ingame() {
if ( helpers :: check_if_game_client () or $forcelibrender = false ) {
$dbr = new DBLayer( "ring" );
if ( isset( $_GET['UserId'] ) && isset( $_COOKIE['ryzomId'] ) ) {
$id = $_GET['UserId'];
$statement = $dbr -> select( "ring_users", array( 'id' => $id, 'cookie' => $_COOKIE['ryzomId'] ), "user_id=:id AND cookie =:cookie" );
// $statement = $dbr->execute("SELECT * FROM ring_users WHERE user_id=:id AND cookie =:cookie", array('id' => $id, 'cookie' => $_COOKIE['ryzomId']));
if ( $statement -> rowCount() ) {
$entry = $statement -> fetch();
// print_r($entry);
return array( 'id' => $entry['user_id'], 'name' => $entry['user_name'] );
} else {
return "FALSE";
}
} else {
return "FALSE";
}
} else {
return "FALSE";
}
}
/**
* Time output function for handling the time display.
*
* @return returns the time in the format specified in the $TIME_FORMAT global variable.
*/
static public function outputTime($time, $str = 1) {
global $TIME_FORMAT;
if ($str) {
return date($TIME_FORMAT, strtotime($time));
} else {
return date($TIME_FORMAT, $time);
}
}
/**
* Auto login function for ingame use.
* This function will allow users who access the website ingame, to log in without entering the username and password. It uses the COOKIE entry in the open_ring db.
* it checks if the cookie sent by the http request matches the one in the db. This cookie in the db is changed everytime the user relogs.
*
* @return returns "FALSE" if the cookies didn't match, else it returns an array with the user's id and name.
*/
static public function check_login_ingame() {
return NULL;
// FIXME
/*
if ( helpers :: check_if_game_client () or $forcelibrender = false ) {
$dbr = new DBLayer( "ring" );
if ( isset( $_GET['UserId'] ) && isset( $_COOKIE['ryzomId'] ) ) {
$id = $_GET['UserId'];
$statement = $dbr -> select( "ring_users", array( 'id' => $id, 'cookie' => $_COOKIE['ryzomId'] ), "user_id=:id AND cookie =:cookie" );
// $statement = $dbr->execute("SELECT * FROM ring_users WHERE user_id=:id AND cookie =:cookie", array('id' => $id, 'cookie' => $_COOKIE['ryzomId']));
if ( $statement -> rowCount() ) {
$entry = $statement -> fetch();
// print_r($entry);
return array( 'id' => $entry['user_id'], 'name' => $entry['user_name'] );
} else {
return "FALSE";
}
} else {
return "FALSE";
}
} else {
return "FALSE";
}
}
*/
}
}

View file

@ -291,11 +291,13 @@ class Users{
//make connection with and put into shard db
$dbs = new DBLayer("shard");
$dbs->insert("user", $values);
/*
$dbr = new DBLayer("ring");
$valuesRing['user_id'] =$user_id;
$valuesRing['user_name'] = $values['Login'];
$valuesRing['user_type'] = 'ut_pioneer';
$dbr->insert("ring_users", $valuesRing);
*/
ticket_user::createTicketUser( $user_id, 1);
return "ok";
}

View file

@ -5,35 +5,34 @@
* We will compare the values and if they match, the user will be automatically logged in!
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function login(){
function login() {
global $INGAME_WEBPATH;
global $WEBPATH;
if ( helpers :: check_if_game_client () ){
if (helpers::check_if_game_client()) {
//check if you are logged in ingame, this should auto login
$result = Helpers::check_login_ingame();
if( $result != "FALSE"){
if ($result) {
//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.
if (Helpers::check_if_game_client()) {
header( 'Location: '.$INGAME_WEBPATH );
}else{
header( 'Location: '.$WEBPATH );
header('Location: ' . $INGAME_WEBPATH);
} else {
header('Location: ' . $WEBPATH);
}
exit;
}
}
$pageElements['ingame_webpath'] = $INGAME_WEBPATH;
$GETString = "";
foreach($_GET as $key => $value){
foreach ($_GET as $key => $value) {
$GETString = $GETString . $key . '=' . $value . "&";
}
if($GETString != ""){
$GETString = '?'.$GETString;
if ($GETString != "") {
$GETString = '?' . $GETString;
}
$pageElements['getstring'] = $GETString;
return $pageElements;
}