Skip to content

Commit

Permalink
⛔ Removed old pfp upload
Browse files Browse the repository at this point in the history
  • Loading branch information
anditv21 committed Sep 26, 2023
1 parent 34a38b8 commit c6017f2
Showing 1 changed file with 2 additions and 44 deletions.
46 changes: 2 additions & 44 deletions src/user/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
header("location: profile.php");
}
// if post request
if (Util::securevar($_SERVER["REQUEST_METHOD"]) === "POST" && !isset($_FILES["file_up"]["tmp_name"]) && !isset($_POST["activateSub"]) && !isset($_POST["updatePassword"]) && !isset($_POST["change_display_name"]) && $System->relinkdiscord == 1) {
if (Util::securevar($_SERVER["REQUEST_METHOD"]) === "POST" && !isset($_POST["activateSub"]) && !isset($_POST["updatePassword"]) && !isset($_POST["change_display_name"]) && $System->relinkdiscord == 1) {
header("Location: https://discord.com/api/oauth2/authorize?client_id=" . client_id . "&redirect_uri=" . SITE_URL . SUB_DIR . "/user/profile.php&response_type=code&scope=identify");
exit();
}
Expand Down Expand Up @@ -104,52 +104,10 @@
<div class="card">
<div class="card-body">
<h4 class="card-title text-center">Avatar</h4>
<form method="POST" enctype="multipart/form-data">
<center>
<div class="mb-3"><input class="btn btn-outline-primary btn-block" type="button" id="loadFileXml" value="Select Image" onclick="document.getElementById('file').click();" /></div>
<input type="file" name='file_up' style="display:none;" id="file">
<button onclick="return confirm('WARNING: Your existing profile picture will be overridden!');" class="btn btn-outline-primary btn-block" type="submit">Upload Profile Picture</button>
<br>
</center>
<br>
</form>
<?php # most of the upload script from -> https://www.plus2net.com/php_tutorial/php_file_upload.php
if (isset($_FILES["file_up"]["tmp_name"])) {
$file_upload_flag = "true";
$file_up_size = $_FILES["file_up"]["size"];
if ($_FILES["file_up"]["size"] > 3000000) {
echo '<script>alert("Your uploaded file size is more than 3MB")</script>';
$file_upload_flag = "false";
}
if (!($_FILES["file_up"]["type"] == "image/jpeg" or $_FILES["file_up"]["type"] == "image/gif" or $_FILES["file_up"]["type"] == "image/png")) {
echo '<script>alert("Your uploaded file must be of JPG PNG or GIF.")</script>';
$file_upload_flag = "false";
}
$ext = pathinfo($_FILES["file_up"]["name"], PATHINFO_EXTENSION);
$file_name = $_FILES["file_up"]["name"];
$path = IMG_DIR . $uid;
if ($file_upload_flag == "true") {
if (@getimagesize($path . ".png")) {
unlink($path . ".png");
} elseif (@getimagesize($path . ".jpg")) {
unlink($path . ".jpg");
} elseif (@getimagesize($path . ".gif")) {
unlink($path . ".gif");
}
if (move_uploaded_file($_FILES["file_up"]["tmp_name"], $path . "." . $ext)) {
chmod($path . "." . $ext, 775);
echo '<script>alert("File successfully uploaded")</script>';
} else {
echo '<script>alert("Failed to to move the file.")</script>';
}
} else {
echo '<script>alert("Failed to upload file.")</script>';
}
} ?>
<?php if ($System->getSystemData()->discordlinking == 1 || $System->relinkdiscord == 1 || ($System->relinkdiscord == 0 && !$user->isDiscordLinked())) : ?>
<form method="POST" enctype="multipart/form-data">
<center>
<button onclick="return confirm('WARNING: Your existing profile picture will be overridden!');" class="btn btn-outline-primary btn-block" type="submit">Link Discord (BETA)</button>
<button onclick="return confirm('WARNING: Your existing profile picture will be overridden!');" class="btn btn-outline-primary btn-block" type="submit">Link Discord</button>
<br>
</center>
<br>
Expand Down

0 comments on commit c6017f2

Please sign in to comment.