-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
364 lines (299 loc) · 15.1 KB
/
upload.php
File metadata and controls
364 lines (299 loc) · 15.1 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<?PHP
/*
01-Gallery - Copyright 2003-2014 by Michael Lorer - 01-Scripts.de
Lizenz: Creative-Commons: Namensnennung-Keine kommerzielle Nutzung-Weitergabe unter gleichen Bedingungen 3.0 Deutschland
Weitere Lizenzinformationen unter: http://www.01-scripts.de/lizenz.php
Modul: 01gallery
Dateiinfo: Upload und Import von Bildern in Galerien
#fv.211#
*/
if($userdata['uploadpics'] >= 1){
// Bilder importieren
if(isset($_GET['action']) && $_GET['action'] == "import" && isset($_GET['galid']) && !empty($_GET['galid']) && is_numeric($_GET['galid']) &&
isset($_GET['send']) && !empty($_GET['send'])){
$list = $mysqli->query("SELECT galpassword,uid FROM ".$mysql_tables['gallery']." WHERE id = '".$mysqli->escape_string($_GET['galid'])."' LIMIT 1");
$statrow = $list->fetch_assoc();
$dir = _01gallery_getGalDir($_GET['galid'],$statrow['galpassword']);
// Zugriffsberechtigung?
if($userdata['uploadpics'] == 2 || $userdata['uploadpics'] == 1 && $statrow['uid'] == $userdata['id']){
echo "<h2>Bilder importieren</h2>";
// Vorhandene Bildnamen in Array einlesen
$pictures = array();
$x = 0;
$new_sortid = 0;
$list = $mysqli->query("SELECT sortorder,filename FROM ".$mysql_tables['pics']." WHERE galid = '".$mysqli->escape_string($_GET['galid'])."' ORDER BY sortorder DESC");
while($row = $list->fetch_assoc()){
if($x == 0) $new_sortid = ($row['sortorder']+1);
$pictures[] = stripslashes($row['filename']);
$split = explode('.', stripslashes($row['filename']));
$pictures[] = stripslashes($split[0]."_big.".$split[1]);
$pictures[] = stripslashes($split[0]."_tb.".$split[1]);
$pictures[] = stripslashes($split[0]."_acptb.".$split[1]);
$x = 1;
}
// Verzeichnisinhalt auflisten und alle Dateien, die nicht in $pictures enthalen sind umbennnen und aufnehmen
$verz = opendir($modulpath.$galdir.$dir);
$cup = 0;
$imported = "";
$not_imported = "";
$imported_files = array();
while($file = readdir($verz)){
if($file != "." && $file != ".."){
// Überprüfen ob Bild schon in DB ist und ob die Dateiendung zulässig ist
if(!in_array($file,$pictures) && in_array(getEndung($file),$supported_pictypes)){
@clearstatcache();
@chmod($modulpath.$galdir.$dir."/".$file, 0777);
$newname = _01gallery_makeFilename($file,$cup).".".getEndung($file);
if(rename($modulpath.$galdir.$dir."/".$file,$modulpath.$galdir.$dir."/".$newname)){
$imported .= $file."<br />\n";
$imported_files[] = $newname;
$split = explode(".", strtolower($newname));
// Image-Resize?
$info = @getimagesize($modulpath.$galdir.$dir."/".$newname);
if(_01gallery_checkResize($info)){
// Filename als zu Filename_big umbenennen
copy($modulpath.$galdir.$dir."/".$newname,$modulpath.$galdir.$dir."/".$split[0]."_big.".$split[1]);
_01gallery_makeThumbs($modulpath.$galdir.$dir."/",$newname,true,"",$settings['resize_maxpicsize'],"dyn");
$pictures[] = stripslashes($split[0]."_big.".$split[1]);
}
// ggf. eigenen Bildtitel berücksichtigen
if(isset($_GET['bildtitle']) && $_GET['bildtitle'] == "own" && isset($_GET['owntitle']) && !empty($_GET['owntitle']))
$title = $mysqli->escape_string($_GET['owntitle']);
else
$title = $mysqli->escape_string($file);
//Eintragung in Datenbank vornehmen:
$sql_insert = "INSERT INTO ".$mysql_tables['pics']." (galid,sortorder,pictimestamp,orgname,filename,title,pictext,uid) VALUES (
'".$mysqli->escape_string($_GET['galid'])."',
'".$new_sortid."',
'".time()."',
'".$mysqli->escape_string($file)."',
'".$mysqli->escape_string($newname)."',
'".$title."',
'',
'".$userdata['id']."'
)";
$mysqli->query($sql_insert) OR die($mysqli->error);
$cup++;
$new_sortid++;
_01gallery_makeThumbs($modulpath.$galdir.$dir."/",$newname); // Standard-Thumbnail _tb
_01gallery_makeThumbs($modulpath.$galdir.$dir."/",$newname,false,"_acptb",ACP_GAL_TB_WIDTH,"dyn");
// Soeben umbenannte und generierte Bilder in den Array einfügen, damit die Bilder nicht auch gleich importiert werden
$pictures[] = stripslashes($newname);
$pictures[] = stripslashes($split[0]."_tb.".$split[1]);
$pictures[] = stripslashes($split[0]."_acptb.".$split[1]);
}
else{
echo "<p class=\"meldung_error\"><b>Fehler:</b><br />
Bilddatei ".$file." konnte zum importieren nicht umbenannt werden.<br />
Bitte stellen Sie sicher, dass die Datei die Chmod-Rechte 0777 besitzt.</p>";
break;
}
}
elseif(!in_array($file,$pictures))
$not_imported .= $file."<br />\n";
}
// Nach $import_max_count reload der Seite verlangen
if($cup == $import_max_count){
echo "<p class=\"meldung_erfolg\"><b>".$cup." Bilder wurden erfolgreich importiert</b>.<br />
Es werden <b>automatisch</b> alle weiteren Bilder importiert. Wenn nicht, klicken Sie <a href=\"javascript:location.reload();\">hier</a>.</p>";
echo "<script type=\"text/javascript\">location.reload();</script>";
echo "<p class=\"meldung_hinweis\">Folgende Bilder wurden importiert:<br />
".$imported."</p>";
break;
}
}
if($cup > 0 && $cup < $import_max_count || $cup == 0){
echo "<p class=\"meldung_erfolg\"><b>Alle Bilder wurden in die gewählte Galerie importiert!</b><br />
<br />
<a href=\"_loader.php?modul=".$modul."&loadpage=showpics&action=show_pics&galid=".$_GET['galid']."\">Bilder verwalten »</a>
</p>";
_01gallery_countPics($_GET['galid']);
// Importierte Bilder sortieren
$mysqli->query("SET @pos=0");
$mysqli->query("UPDATE ".$mysql_tables['pics']." SET sortorder= ( SELECT @pos := @pos +1 ) WHERE galid = '".$mysqli->escape_string($_GET['galid'])."' ORDER BY orgname DESC");
}
if(!empty($not_imported))
echo "<p class=\"meldung_error\"><b>Folgende Dateien konnte nicht importiert werden:</b><br />
".$not_imported."
Dies kann unter anderem an nicht unterstützen Dateiendungen oder fehlenden Chmod-Rechten (0777) liegen.</p>";
}
else
$flag_loginerror = true;
}
// Neue Bilder hochladen / importieren (Formular)
elseif(isset($_GET['action']) && $_GET['action'] == "upload_pic" && isset($_GET['galid']) && !empty($_GET['galid']) && is_numeric($_GET['galid'])){
$list = $mysqli->query("SELECT galpassword,galeriename,uid FROM ".$mysql_tables['gallery']." WHERE id = '".$mysqli->escape_string($_GET['galid'])."' LIMIT 1");
$row = $list->fetch_assoc();
$dir = _01gallery_getGalDir($_GET['galid'],$row['galpassword']);
// Zugriffsberechtigung?
if($userdata['uploadpics'] == 2 || $userdata['uploadpics'] == 1 && $row['uid'] == $userdata['id']){
// Bilder hochladen (classic Uploader)
if(isset($_POST['send']) && !empty($_POST['send'])){
$count_erfolg = 0;
$count_error = 0;
for($x=0;$x<$max_uploads;$x++){
if(isset($_FILES['file_'.$x]['name']) && !empty($_FILES['file_'.$x]['name'])){
$upload_info = _01gallery_upload_2Gallery($_GET['galid'],"file_".$x,$_POST['title_'.$x],$_POST['beschreibung_'.$x]);
if($upload_info['status'] == 1){
$count_erfolg++;
$uploaded_pics[] = $upload_info['filename'];
}
else{
$count_error++;
$sammel_errors[] = $upload_info;
}
}
}
_01gallery_countPics($_GET['galid']);
// Bilder sortieren
$mysqli->query("SET @pos=0");
$mysqli->query("UPDATE ".$mysql_tables['pics']." SET sortorder= ( SELECT @pos := @pos +1 ) WHERE galid = '".$mysqli->escape_string($_GET['galid'])."' ORDER BY orgname DESC");
}
?>
<h1><?PHP echo stripslashes($row['galeriename']); ?> » Bilder hochladen</h1>
<?PHP echo _01gallery_echoActionButtons_Gal(); ?>
<h2><input type="radio" name="type" value="upload" onclick="hide_always('import1');hide_always('import2');show_always('upload1');" checked="checked" /> Bilder per Web-Upload hochladen</h2>
<?PHP
// Fehler- und Erfolgsmeldungen vom Upload ausgeben
if(isset($count_error) && $count_error > 0){
echo "<p class=\"meldung_error\"><b>Beim Upload von ".($count_erfolg+$count_error)." Bildern traten ".$count_error." Fehlermeldungen auf:</b><br />";
foreach($sammel_errors as $error){
echo "• ".$error['error']." <i>(Bild: ".$error['name'].")</i><br />";
}
echo "</p>";
}
if(isset($count_erfolg) && $count_erfolg > 0){
echo "<p class=\"meldung_erfolg\"><b>Es wurden ".$count_erfolg." Bilder erfolgreich in die Galerie
<i>".stripslashes($row['galeriename'])."</i> hochgeladen!</b><br />
Sie können jetzt weitere Bilder hochladen.<br />
<br />
<a href=\"_loader.php?modul=".$modul."&loadpage=showpics&action=show_pics&galid=".$_GET['galid']."\">Bilder verwalten »</a>
</p>";
echo "<ul class=\"cssgallery\">";
foreach($uploaded_pics as $pic){
echo "<li><a href=\"".$modulpath.$galdir.$dir."/".$pic."\" class=\"lightbox\">"._01gallery_getThumb($modulpath.$galdir.$dir."/",$pic,"_acptb")."</a></li>\n";
}
echo "</ul>\n<br />";
}
?>
<div id="upload1" style="display:block;">
<p class="meldung_hinweis">
<b>Bitte nutzen Sie nachfolgendes Upload-Formular</b> und wählen Sie nach
einem Klick auf '<b>Bilder auswählen</b>' eine oder mehrere Bilddateien aus!<br />
<br />
Mit einem Klick auf '<b>Bilder jetzt hochladen</b>' werden alle Bilder in der Warteschlange
automatisch nacheinander hochgeladen.<br />
Die Statusbalken geben Ihnen Auskunft über den Fortschritt.
</p>
<?php if(!strchr($_SERVER['HTTP_USER_AGENT'],"MSIE 6.0")){ ?>
<form action="_ajaxloader.php?SID=<?php echo htmlspecialchars(session_id(),$htmlent_flags,$htmlent_encoding_acp); ?>&modul=<?php echo $modul; ?>&ajaxaction=fancyupload&galid=<?PHP echo $_GET['galid']; ?><?php if($flag_sessionbugfix){ echo "&sessiondata=".urlencode(session_encode()); } ?>" method="post" enctype="multipart/form-data" id="fancy-form">
<div id="fancy-status" class="hide">
<p>
<a href="#" id="fancy-browse">Bilder auswählen</a> |
<a href="#" id="fancy-clear">Warteschlange löschen</a> |
<a href="#" id="fancy-upload">Bilder jetzt hochladen</a>
</p>
<div>
<strong class="overall-title"></strong><br />
<img src="images/fancy/bar.gif" class="progress overall-progress" />
</div>
<div>
<strong class="current-title"></strong><br />
<img src="images/fancy/bar.gif" class="progress current-progress" />
</div>
<div class="current-text"></div>
</div>
<ul id="fancy-list"></ul>
</form>
<?php } ?>
<!-- Fallback-Lösung! -->
<div id="fancy-fallback">
<p class="meldung_hinweis">
Bitte beachten Sie:<br />
<b>Bei dem nachfolgenden Upload-Formular handelt es sich lediglich um eine Notlösung</b>,
die für den Bildupload genutzt werden kann, wenn der Flash-Uploader oberhalb dieser Meldung
auf Ihrem PC nicht genutzt werden kann.<br />
Bitte nutzen Sie wenn möglich den Flash-Uploader und aktivieren Sie dafür JavaScript und
installieren Sie einen geeigneten Flash-Player für Ihren Browser.
</p>
<form action="<?PHP echo $filename; ?>&action=upload_pic&galid=<?PHP echo $_GET['galid']; ?>" enctype="multipart/form-data" method="post">
<table border="0" align="center" width="100%" cellpadding="3" cellspacing="5" class="rundrahmen">
<tr>
<td class="tra" valign="top"><b>Bild auswählen:</b></td>
<td class="tra"><b>Bildtitel</b><br /><span class="small">Leer lassen um Dateinamen als Titel zu übernehmen</span></td>
<td class="tra" valign="top"><b>Bildbeschreibung:</b></td>
</tr>
<?PHP
// $max_uploads Dateifelder ausgeben
$count = 0;
for($x=0;$x<$max_uploads;$x++){
if($count == 1){ $class = "tra"; $count--; }else{ $class = "trb"; $count++; }
echo " <tr>
<td class=\"".$class."\"><input type=\"file\" name=\"file_".$x."\" /></td>
<td class=\"".$class."\"><input type=\"text\" name=\"title_".$x."\" size=\"25\" maxlength=\"100\" /></td>
<td class=\"".$class."\"><textarea name=\"beschreibung_".$x."\" rows=\"2\" cols=\"45\" class=\"input_textarea\" style=\"font-size:9px;\"></textarea></td>
</tr>\n";
}
if($count == 1){ $class = "tra"; $count--; }else{ $class = "trb"; $count++; }
?>
<tr>
<td class="<?PHP echo $class; ?>" colspan="2">Unterstützte Dateiendungen: <b><?PHP echo implode(",",$supported_pictypes); ?></b></td>
<td class="<?PHP echo $class; ?>" align="right"><input type="submit" name="send" value="Bilder jetzt hochladen »" onclick="hide_unhide('loading');" class="input" /></td>
</tr>
</table>
</form>
</div>
</div>
<div id="loading" style="display:none; text-align:center;">
<img src="images/icons/loading.gif" alt="Lade-Animation" title="Dateien werden zum Server übertragen - bitte warten..." /><br />
<span class="small">Bilder werden übetragen...</span>
</div>
<h2><input type="radio" name="type" value="import" onclick="show_always('import1');show_always('import2');hide_always('upload1');" /> Bilder per FTP hochladen und importieren</h2>
<form action="<?PHP echo $filename; ?>" method="get">
<table border="0" align="center" width="100%" cellpadding="3" cellspacing="5" class="rundrahmen" id="import1" style="display:none;">
<tr>
<td class="tra" colspan="3"><b class="bigger">1.</b> Laden Sie die gewünschten Bilddateien (Thumbnails werden automatisch generiert!)
per FTP-Programm in folgendes Verzeichnis hoch:</td>
</tr>
<tr>
<td class="tra"></td>
<td class="tra" colspan="2"><b>Verzeichnis:</b> <?PHP echo "01scripts/01module/".$modul."/galerien/<b>"._01gallery_getGalDir($_GET['galid'],$row['galpassword'])."</b>/"; ?></td>
</tr>
<tr>
<td class="tra" colspan="3"><b class="bigger">2.</b></td>
</tr>
<tr>
<td class="trb" align="center" width="25"><input type="radio" name="bildtitle" value="auto" checked="checked" /></td>
<td class="trb"><b>Jeweils Dateiname als Bildtitel verwenden</b></td>
<td class="trb"> </td>
</tr>
<tr>
<td class="tra" align="center"><input type="radio" name="bildtitle" value="own" /></td>
<td class="tra"><b>Eigenen Bildtitel für alle verwenden:</b></td>
<td class="tra"><input type="text" name="owntitle" size="25" maxlength="100" /> <span class="small">(später ändern)</span></td>
</tr>
<tr>
<td class="tra" colspan="3"><b class="bigger">3.</b> Klicken Sie auf <i>"Bilder importieren »"</i> um den Import zu starten.</td>
</tr>
<tr>
<td class="trb" align="right" colspan="3"><input type="submit" name="send" value="Bilder importieren »" class="input" /></td>
</tr>
</table>
<input type="hidden" name="action" value="import" />
<input type="hidden" name="galid" value="<?PHP echo $_GET['galid']; ?>" />
<input type="hidden" name="loadpage" value="upload" />
<input type="hidden" name="modul" value="<?PHP echo $modul; ?>" />
</form>
<p class="meldung_hinweis" id="import2" style="display:none;"><b>Hinweis:</b><br />
• Die hochgeladenen Bilder benötigen die <b>Chmod-Rechte 0777</b>!<br />
• Es werden nur Bilder importiert, die noch nicht im Album enthalten sind.<br />
• <b>Starten Sie den Import-Vorgang erst, wenn der FTP-Upload komplett abgeschlossen ist!</b>
</p>
<?PHP
}
else
$flag_loginerror = true;
}
}
else $flag_loginerror = true;
?>