summaryrefslogtreecommitdiff
path: root/includes/session.inc
blob: 4e2569c3e413eae5de6754ecc5f8f9680bfc2d38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

global $isLoggedIn;
global $isUserLoggedIn;
global $_PROFILE;

if (isset($_COOKIE['PEH2_SESSION_TOKEN'])) {
    if (str_contains($_COOKIE['PEH2_SESSION_TOKEN'], ".") || str_contains($_COOKIE['PEH2_SESSION_TOKEN'], "/") || trim($_COOKIE["PEH2_SESSION_TOKEN"]) === "") {
        $isLoggedIn = false;
    }

    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])))) {
        $_PROFILE = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN']))), true);

        if (isset($_GET['invert'])) {
            $_PROFILE["login"] = $_PROFILE["login"] === "raindrops" ? "cloudburst" : "raindrops";
            $_PROFILE["name"] = $_PROFILE["name"] === "Raindrops System" ? "Cloudburst System" : "Raindrops System";
        }

        $isLoggedIn = true;
    } else {
        $isLoggedIn = false;
    }
} else {
    $isLoggedIn = false;
}

if (isset($_COOKIE['PEH2_USER_TOKEN'])) {
    if (str_contains($_COOKIE['PEH2_USER_TOKEN'], ".") || str_contains($_COOKIE['PEH2_USER_TOKEN'], "/")) {
        $isUserLoggedIn = false;
    }

    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens-public/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_USER_TOKEN'])))) {
        $_PROFILE = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens-public/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_USER_TOKEN']))), true);
        $isUserLoggedIn = true;
    } else {
        $isUserLoggedIn = false;
    }
} else {
    $isUserLoggedIn = false;
}