23 lines
912 B
PHP
23 lines
912 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;
|
||
|
|
||
|
if ($out -> num_rows != 1 && $_GET["old_username"] != $_SESSION["username"])
|
||
|
{
|
||
|
fail:
|
||
|
echo "nope";
|
||
|
header("Location: ../../../index.php");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$user_info_id = (($database -> query("SELECT user_info FROM user WHERE username=\"" . $_GET["old_username"] . "\"")) -> fetch_assoc())["user_info"];
|
||
|
|
||
|
$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);
|