FabrikaHradekTour/res/forum/api/user_info.php

35 lines
1015 B
PHP

<?php
include("../../global.php");
session_start();
if (!isset($_SESSION["username"])) goto fail;
$out = $database -> query("SELECT username, admin FROM user WHERE username=\"" . $_SESSION["username"] . "\" AND admin=\"1\"");
if ($out -> num_rows != 1)
{
fail:
echo "nope";
header("Location: ../../../index.php");
return;
}
if (!isset($_GET["username"])) return;
$out = $database -> query("SELECT user.username, user.admin, user_info.bio, user_info.nickname, user_info.sex FROM user INNER JOIN user_info ON user.user_info=user_info.id AND username=\"" . $_GET["username"] . "\"");
$sex = array();
$sex[0] = "Nespecifikováno";
$sex[1] = "Muž";
$sex[2] = "Žena";
$sex[9] = "Jiné";
while ($res = $out -> fetch_assoc())
{
echo "Uživatelské jméno: " . $res["username"] . "<br>";
echo "Přezdívka: " . $res["nickname"] . "<br>";
echo "Admin: " . ($res["admin"] == 1 ? "Ano" : "Ne") . "<br>";
echo "Pohlaví: " . $sex[$res["sex"]] . "<br>";
echo "Bio: " . $res["bio"];
}