-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule.php
93 lines (80 loc) · 2.47 KB
/
module.php
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
<?php
do {
$filename = rex_request('xmediapool_password_filename');
$filepath = rtrim($REX['MEDIAFOLDER'], '/\\').'/'.$filename;
// Wenn die Datei nicht existiert oder keine Dateiname übergeben wurde, Abbruch
if(empty($filename) OR !file_exists($filepath))
{
echo rex_warning('Die angegebene Datei wurde nicht gefunden.');
break;
}
$m = OOMedia::getMediaByFilename($filename);
if(empty($m) OR !is_object($m))
{
echo rex_warning('Die angegebene Datei wurde nicht gefunden.');
break;
}
$title = $m->getTitle();
if(empty($title))
$title = $filename;
$description = $m->getDescription();
if(OOAddon::isActivated('textile') AND function_exists('rex_a79_textile'))
$description = rex_a79_textile($description);
else
$description = nl2br($description);
if(!empty($description))
$description = '<div class="description">'.$description.'</div>';
echo '
<form id="xmediapool-download-form" action="redaxo://REX_ARTICLE_ID" method="post">
<fieldset>
<input type="hidden" name="xmediapool_password_filename" value="'.htmlspecialchars($filename).'" />
<legend>Download <em>'.$title.'</em></legend>';
// Falls das Formular abgeschickt wurde
if($_SERVER['REQUEST_METHOD'] == 'POST' OR rex_get('download', 'bool'))
{
// Passwort überprüfen
if(rex_request('xmediapool_password') != $m->getValue('med_xmediapool_password_password'))
{
echo rex_warning('Das Passwort ist falsch.');
break;
}
if(rex_get('download', 'bool'))
{
// Outputbuffer leeren
while(ob_end_clean());
// Passenden Datentyp erzeugen.
header('Content-Type: application/octet-stream');
// Datei senden
header('Content-Disposition: attachment; filename="'.$filename.'"');
// Datei ausgeben.
readfile($filepath);
exit;
}
else
{
echo '<p>
<strong>Glückwunsch! </strong></p>
<p>Sie haben sich erfolgreich eingeloggt. Die angeforderte Datei wurde heruntergeladen.</p>
<script type="text/javascript">
(function($)
{
$(document).ready(function()
{
document.location.href=("'.rex_geturl('', '', array('xmediapool_password_filename' => $filename, 'xmediapool_password' => rex_request('xmediapool_password'), 'download' => 1), '&').'");
});
}(jQuery));
</script>';
}
}
else
{
echo $description;
}
?>
<p><label for="xmediapool_password">Passwort:</label> <input type="password" id="xmediapool_password" name="xmediapool_password" /></p>
<input type="submit" value="Datei herunterladen" />
</fieldset>
</form><?php
} while(false);
}
?>