<?php

$app = $GLOBALS["ColdHazeApp"];

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;

header("Content-Type: application/json");

if (!$isLoggedIn && !$isLowerLoggedIn) die('{"valid": false}');
global $_PROFILE;

if ($_PROFILE['login'] === "raindrops") {
    die(json_encode([
        "valid" => true,
        "name" => "Raindrops System",
        "id" => "raindrops",
        "pluralkit" => "gdapd",
        "avatar" => getAsset("gdapd"),
        "email" => $_PROFILE["profile"]["email"]["email"]
    ]));
} else if ($_PROFILE["login"] === "cloudburst") {
    die(json_encode([
        "valid" => true,
        "name" => "Cloudburst System",
        "id" => "cloudburst",
        "pluralkit" => "ynmuc",
        "avatar" => getAsset("ynmuc"),
        "email" => $_PROFILE["profile"]["email"]["email"]
    ]));
} else {
    die(json_encode([
        "valid" => true,
        "name" => $app["other"]["name"],
        "id" => $app["other"]["slug"],
        "pluralkit" => $app["other"]["id"],
        "avatar" => getAsset($app["other"]["id"]),
        "email" => $_PROFILE["profile"]["email"]["email"]
    ]));
}