28 lines
994 B
PHP
28 lines
994 B
PHP
<?php
|
|
|
|
include("../../global.php");
|
|
session_start();
|
|
|
|
if (!isset($_SESSION["username"])) goto fail;
|
|
|
|
$out = $database -> query("SELECT username, admin, user_info FROM user WHERE BINARY username=\"" . $_SESSION["username"] . "\" AND admin=\"1\"");
|
|
|
|
if (!isset($_GET["old_username"])) return;
|
|
|
|
$user = false;
|
|
|
|
if ($out -> num_rows != 1 && $_GET["old_username"] != $_SESSION["username"])
|
|
{
|
|
fail:
|
|
echo "nope";
|
|
header("Location: ../../../index.php");
|
|
return;
|
|
} else if ($out -> num_rows != 1)
|
|
{
|
|
$user = true;
|
|
}
|
|
|
|
$user_info_id = (($database -> query("SELECT user_info FROM user WHERE username=\"" . $_GET["old_username"] . "\"")) -> fetch_assoc())["user_info"];
|
|
|
|
if (!$user) $database -> query("UPDATE user SET username=\"" . $_GET["username"] . "\", admin=" . $_GET["admin"] . " WHERE user_info=" . $user_info_id);
|
|
$database -> query("UPDATE user_info SET sex=" . $_GET["sex"] . ", bio=\"" . $_GET["bio"] . "\", nickname=\"" . $_GET["nickname"] . "\" WHERE id=" . $user_info_id); |