-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathupload_emblem.php
More file actions
129 lines (125 loc) · 3.82 KB
/
upload_emblem.php
File metadata and controls
129 lines (125 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
require 'memory.php';
require 'header.inc';
check_auth($_SERVER['PHP_SELF']); // checks for required access
if (!is_dir("emblem")) {
// Creates the emblem folder if it doesn't exist
mkdir("emblem");
}
// Determines root location, and adds the emblem folder to destination
if ($POST_guild_id) {
$destination = dirname($_SERVER['SCRIPT_FILENAME']) . "/emblem/$POST_guild_id.bmp";
}
else {
$destination = dirname($_SERVER['SCRIPT_FILENAME']) . "/emblem/$GET_guild_id.bmp";
}
if (!$POST_action) {
if (!$GET_guild_id) {
redir("index.php", "Invalid Guild");
}
// Makes sure that the user is on the right guild page, otherwise, kicks them out
$query = sprintf(CHECK_MASTER, $CONFIG_passphrase, $GET_guild_id);
$result = execute_query($query, "upload_emblem.php");
if ($result->RowCount() > 0) {
$line = $result->FetchRow();
$guildmaster_name = $line[0];
// Checks if the account is the master of the current guild.
if (account_of_character($guildmaster_name) != $STORED_id) {
add_exploit_entry("Tried to access another guild that was not theirs.");
redir("index.php", "This is not your guild!");
}
}
else {
redir("index.php", "Invalid Guild");
}
EchoHead(50);
echo "
<tr class=mytitle>
<td colspan=2>Upload A Guild Emblem</td>
</tr>
";
if (file_exists($destination)) {
echo "
<tr class=mycell>
<td colspan=2>Here is your current logo:</td>
</tr>
<tr class=mycell>
<td colspan=2><img src=\"emblem\\$GET_guild_id.bmp\"></td>
</tr>
<tr class=mycell>
<td colspan=2>You can upload another one, if you wish.</td>
</tr>
";
}
else {
echo "
<tr class=mycell>
<td colspan=2>You do not have an emblem uploaded! You can upload one below:</td>
</tr>
";
}
display_upload_form();
}
else {
if(!empty($_FILES["binFile"])) {
if($_FILES['binFile']['name'] == '') {
redir("upload_emblem.php?guild_id=$POST_guild_id", "You did not upload a file!");
}
elseif($_FILES['binFile']['size'] == 0) {
redir("upload_emblem.php?guild_id=$POST_guild_id", "There appears to be a problem with the logo your are uploading");
}
elseif($_FILES['binFile']['size'] > $POST_MAX_FILE_SIZE) {
redir("upload_emblem.php?guild_id=$POST_guild_id", "The photo you selected is too large");
}
elseif(!getimagesize($_FILES['binFile']['tmp_name'])) {
redir("upload_emblem.php?guild_id=$POST_guild_id", "You did not upload a proper image file!");
}
else {
$image_data = getimagesize($_FILES['binFile']['tmp_name']);
$width = $image_data[0];
$height = $image_data[1];
if ($width != 24 or $height != 24) {
//require 'header.inc';
redir("upload_emblem.php?guild_id=$POST_guild_id", "The image must be 24x24!");
}
else {
// The source of the upload
// Uploads the file to final position
if (move_uploaded_file($_FILES['binFile']['tmp_name'], $destination)) {
redir("upload_emblem.php?guild_id=$POST_guild_id", "Upload file success!");
}
else {
print_r($_FILES);
redir("upload_emblem.php?guild_id=$POST_guild_id", "There was a problem uploading your file.");
}
}
}
}
else {
redir("index.php", "You did not upload a file!");
}
}
require 'footer.inc';
function display_upload_form() {
global $GET_guild_id;
echo '
<form method="POST" ACTION="upload_emblem.php" ENCTYPE="multipart/form-data">
';
echo "
<input type=\"hidden\" NAME=\"guild_id\" value=\"$GET_guild_id\">
";
echo '
<input type="hidden" NAME="MAX_FILE_SIZE" value="1000000">
<input type="hidden" NAME="action" value="upload">
<tr class=mycell>
<td>File:</td>
<td><input type="file" NAME="binFile" class=myctl></td>
</tr>
<tr class=mycell>
<td colspan="2" align="center"><input type="submit" name="upload" value="Upload" class=myctl></td>
</tr>
</form>
</table>
';
}
?>