-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcover_upload.php
More file actions
139 lines (117 loc) · 4.87 KB
/
cover_upload.php
File metadata and controls
139 lines (117 loc) · 4.87 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
130
131
132
133
134
135
136
137
138
139
<?php
require "include/bittorrent.php";
require_once("include/secrets.php");
global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;
$con_link = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
dbconn();
loggedinorreturn();
if (get_user_class() < UC_UPLOADER)
site_error_message("Foutmelding", "U ben niet bevoegd om deze pagina te bekijken.");
$serverpath = "covers/";
$urltoimages = $BASEURL."/covers";
$maxsize = 1024 * 1024;
if (!mkglobal("id"))
site_error_message("Foutmelding", "Geen torrent ID ontvangen.");
$id = 0 + $id;
if (!$id)
site_error_message("Foutmelding", "Geen torrent ID ontvangen.");
$res = mysqli_query($con_link, "SELECT name FROM torrents WHERE id = $id") or sqlerr();
$row = mysqli_fetch_array($res);
if (!$row)
site_error_message("Foutmelding", "Geen torrent ontvangen.");
$torrent_name = $row['name'];
$mode = @$_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "upload")
{
$file = $_FILES['file']['name'];
// Als je een eigen extensie wilt toelaten, voeg deze hier toe, vergeet niet om OOK een hoofdletter extensie toe te voegen.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "PNG";
$res = mysqli_query($con_link, "SELECT name FROM torrents WHERE id = $id") or sqlerr();
$row = mysqli_fetch_array($res);
if (!$row)
site_error_message("Foutmelding", "Geen torrent ontvangen.");
$torrent_name = $row['name'];
$i = strrpos($file, ".");
$ext = strtolower(substr($file, $i));
$file = strtolower($id . $ext);
// print $file; die;
// print $file . $i . $ext . " - " . $tmp; die;
if($_FILES['file']['size'] > $maxsize)
site_error_message("Foutmelding", "Bestand is te groot. Verklein het bestand en probeer het opnieuw.");
else
{
$path = $serverpath."/".$file;
foreach($allowedfiles as $allowedfile)
{
$tmp = strtolower($CURUSER['username'] . "." . $allowedfile);
$tmppath = $serverpath."/".$tmp;
if (file_exists($tmppath) && $path !== $tmppath)
unlink($covers_dir."/".$tmp);
if (@$done <> "yes")
{
if (file_exists($path))
unlink($covers_dir."/".$file);
}
if (substr($file, -3) == $allowedfile)
{
$cover_file = $_FILES['file']['tmp_name'];
$cover_file = str_replace(" ","_",$cover_file);
$path = str_replace(" ","_",$path);
move_uploaded_file($cover_file, "$path");
$cover_send = $urltoimages . "/" . $file;
$cover_send = str_replace(" ","_",$cover_send);
$cover_send = sqlesc($cover_send);
$cover_by = $CURUSER['id'];
mysqli_query($con_link, "UPDATE torrents SET cover = $cover_send, cover_by = $cover_by WHERE id=$id") or err("Database error");
$done = "yes";
header("Location: $BASEURL/details.php?id=$id");
die;
}
}
if ($done <> "yes")
site_error_message("Foutmelding", "<b>Error:</b> Jouw afbeelding is NIET geupload. De extensie is niet herkend. Probeer het opnieuw AUB.");
}
}
site_header("Cover");
print("<table class=bottom width=80% border=0 cellspacing=0 cellpadding=0>");
print("<tr>");
print("<td align=center class=embedded><div align=center>");
tabel_top("Cover plaatsen voor torrent " . $torrent_name);
print("<table background=pics/system/tabel_achtergrond.gif width=100% border=0 cellspacing=0 cellpadding=0>");
print("<tr>");
print("<td align=center class=embedded><div align=center><br>");
if ($mode == "form") {
print "<form method=post action=\"?mode=upload\" enctype=\"multipart/form-data\">";
print "<table class=bottom width=75% border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>";
if (get_cover($id))
print "<center><font color=blue>Huidige cover<br><br><img height=250 src=" . get_cover($id) . ">";
else
print "<center>Geen gevonden";
print "<br><br><center>";
print "Alleen plaatjes met de extensie <b>JPG GIF PNG</b> worden geacepteerd, en de cover mag niet groter zijn dan 1 Mb";
print "<br>De bestandsnaam wordt gewijzigd op de server naar $id.jpg, $id.gif of $id.png";
print "</td></tr></table><br>";
print "<table width=80% border=1 cellspacing=0 cellpadding=8>";
print "<tr><td bgcolor=white class=rowhead>Bestand</td><td bgcolor=white align=center><input type=file name=file size=80></td></tr>";
print "<tr>";
print "<td bgcolor=white colspan=2 align=center>";
print "<table class=bottom border=0><tr><td class=embedded>";
print "</td><td class=embedded> ";
print "<input type=hidden name=id value=" . $id . ">";
print "<input type=submit name=Submit value=\"Verzenden\" class=btn>";
print("</td></tr></table>");
print "</td></tr>";
print "</table></form><p>";
print("<br></td></tr></table><br>");
}
print("</td></tr></table>");
site_footer();
?>