Merge branch 'main/rendor-staging' into main/atys-live
[ryzomcore.git] / web / public_php / ams / inc / login.php
blobd813bfd00563df09dc48aae3b9e60b86fc45196b
1 <?php
2 /**
3 * This function is being used to load info that's needed for the login page.
4 * 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.
5 * We will compare the values and if they match, the user will be automatically logged in!
6 * @author Daan Janssens, mentored by Matthew Lagoe
7 */
8 function login() {
9 global $INGAME_WEBPATH;
10 global $WEBPATH;
11 if (helpers::check_if_game_client()) {
12 //check if you are logged in ingame, this should auto login
13 $result = Helpers::check_login_ingame();
14 if ($result) {
15 //handle successful login
16 $_SESSION['user'] = $result['name'];
17 $_SESSION['id'] = WebUsers::getId($result['name']);
18 $_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id']));
19 //go back to the index page.
20 header("Cache-Control: max-age=1");
21 if (Helpers::check_if_game_client()) {
22 header('Location: ' . $INGAME_WEBPATH);
23 } else {
24 header('Location: ' . $WEBPATH);
26 throw new SystemExit();
29 $pageElements['ingame_webpath'] = $INGAME_WEBPATH;
30 $GETString = "";
31 foreach ($_GET as $key => $value) {
32 $GETString = $GETString . $key . '=' . $value . "&";
34 if ($GETString != "") {
35 $GETString = '?' . $GETString;
37 $pageElements['getstring'] = $GETString;
38 return $pageElements;