1 | <?php |
---|
2 | // Warning: Don't left any character outside PHP code. |
---|
3 | // |
---|
4 | // Choose a file on this directory to download via Apache. |
---|
5 | |
---|
6 | include_once("../includes/ctrlacc.php"); |
---|
7 | include_once("../clases/AdoPhp.php"); |
---|
8 | include_once("../includes/CreaComando.php"); |
---|
9 | include_once("../idiomas/php/".$idioma."/descargas_".$idioma.".php"); |
---|
10 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando |
---|
11 | if (!$cmd) |
---|
12 | header('Location: '.$pagerror.'?herror=2'); // Error de conexión con servidor B.D. |
---|
13 | |
---|
14 | // Security tip: change to local directory. |
---|
15 | $oldpwd=getcwd(); |
---|
16 | chdir(dirname(__FILE__)); |
---|
17 | if (isset($_POST['file'])) { |
---|
18 | // Send file. |
---|
19 | sendFile ($_POST['file']); |
---|
20 | } else { |
---|
21 | // Show files list. |
---|
22 | echo '<!DOCTYPE html>'."\n"; |
---|
23 | echo '<html><head>'."\n"; |
---|
24 | echo ' <link rel="stylesheet" type="text/css" href="../estilos.css" />'."\n"; |
---|
25 | echo '</head><body>'."\n"; |
---|
26 | echo '<div align="center" class="tabla_datos">'."\n"; |
---|
27 | echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">'."\n"; |
---|
28 | echo ' <table>'."\n"; |
---|
29 | echo ' <tr><th>'.$TbMsg['DOWNLOADS'].':</th></tr>'."\n"; |
---|
30 | echo ' <tr><td><select name="file">'."\n"; |
---|
31 | $filelist = glob("*"); |
---|
32 | foreach ($filelist as $f) { |
---|
33 | // Skip this file. |
---|
34 | if ($f == basename(__FILE__)) continue; |
---|
35 | echo ' <option value="'.$f.'">'.$f.'</option>'."\n"; |
---|
36 | } |
---|
37 | echo ' </select>'."\n"; |
---|
38 | echo ' <input type="submit" value="" style="width:20px; background:url(../images/boton_confirmar.gif);"></td></tr>'."\n"; |
---|
39 | echo '</table>'."\n"; |
---|
40 | echo '</form>'."\n"; |
---|
41 | echo '</body></html>'."\n"; |
---|
42 | } |
---|
43 | // Change again to source directory. |
---|
44 | chdir($oldpwd); |
---|
45 | |
---|
46 | |
---|
47 | // Send a file. |
---|
48 | function sendFile($file) { |
---|
49 | // Check if file exists in current directory and it isn't this file. |
---|
50 | if (file_exists($file) and strpos($file,"/") === false and $file !== basename(__FILE__)) { |
---|
51 | $file_info = apache_lookup_uri($file); |
---|
52 | header('Content-Type: ' . $file_info->content_type); |
---|
53 | header('Content-Length: ' . filesize($file)); |
---|
54 | header('Content-Disposition: attachment; filename="' . $file . '"'); |
---|
55 | virtual($file); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | // Warning: Don't left any character outside PHP code. |
---|
60 | ?> |
---|