2013-07-31 20:38:47 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to load info that's needed for the login page.
|
|
|
|
* it will try to auto-login, this can only be used while ingame, the web browser sends additional cookie information that's also stored in the open_ring db.
|
|
|
|
* We will compare the values and if they match, the user will be automatically logged in!
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2014-09-02 17:56:37 +00:00
|
|
|
function login() {
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
global $WEBPATH;
|
2014-09-02 17:56:37 +00:00
|
|
|
if (helpers::check_if_game_client()) {
|
2013-09-13 22:39:03 +00:00
|
|
|
//check if you are logged in ingame, this should auto login
|
2013-07-31 20:38:47 +00:00
|
|
|
$result = Helpers::check_login_ingame();
|
2014-09-02 17:56:37 +00:00
|
|
|
if ($result) {
|
2013-07-31 20:38:47 +00:00
|
|
|
//handle successful login
|
|
|
|
$_SESSION['user'] = $result['name'];
|
2013-07-31 22:08:35 +00:00
|
|
|
$_SESSION['id'] = WebUsers::getId($result['name']);
|
2013-09-09 01:47:32 +00:00
|
|
|
$_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id']));
|
2013-07-31 20:38:47 +00:00
|
|
|
//go back to the index page.
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-09-09 01:47:32 +00:00
|
|
|
if (Helpers::check_if_game_client()) {
|
2014-09-02 17:56:37 +00:00
|
|
|
header('Location: ' . $INGAME_WEBPATH);
|
|
|
|
} else {
|
|
|
|
header('Location: ' . $WEBPATH);
|
2013-09-09 01:47:32 +00:00
|
|
|
}
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-31 20:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-09 01:47:32 +00:00
|
|
|
$pageElements['ingame_webpath'] = $INGAME_WEBPATH;
|
2013-09-20 03:33:39 +00:00
|
|
|
$GETString = "";
|
2014-09-02 17:56:37 +00:00
|
|
|
foreach ($_GET as $key => $value) {
|
2013-09-20 03:33:39 +00:00
|
|
|
$GETString = $GETString . $key . '=' . $value . "&";
|
2014-09-02 17:56:37 +00:00
|
|
|
}
|
|
|
|
if ($GETString != "") {
|
|
|
|
$GETString = '?' . $GETString;
|
2013-09-20 03:33:39 +00:00
|
|
|
}
|
|
|
|
$pageElements['getstring'] = $GETString;
|
2013-09-09 01:47:32 +00:00
|
|
|
return $pageElements;
|
2013-07-31 22:08:35 +00:00
|
|
|
}
|