source: admin/WebConsole/descargas/index.php @ a52f983

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since a52f983 was b6ec162, checked in by Ramón M. Gómez <ramongomez@…>, 6 years ago

#834: Remove all redundant PHP closing tags.

  • Property mode set to 100644
File size: 2.2 KB
Line 
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
6include_once("../includes/ctrlacc.php");
7include_once("../clases/AdoPhp.php");
8include_once("../includes/CreaComando.php");
9include_once("../idiomas/php/".$idioma."/descargas_".$idioma.".php");
10$cmd=CreaComando($cadenaconexion); // Crea objeto comando
11if (!$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();
16chdir(dirname(__FILE__));
17if (isset($_POST['file'])) {
18        // Send file.
19        sendFile ($_POST['file']);
20} else {
21        // Show list of files.
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        $filelist = glob("*");
31        $data = "";
32        foreach ($filelist as $f) {
33                // Get only readable files, except this one.
34                if ($f !== basename(__FILE__) and is_file($f) and is_readable($f)) {
35                        $data .= '      <option value="'.$f.'">'.$f.'</option>'."\n";
36                }
37        }
38        if (empty($data)) {
39                // Show warning message if there is no files to download.
40                echo '    <tr><td>'.$TbMsg['NOFILES'].'</td></tr>'."\n";
41        } else {
42                // Show available files.
43                echo '    <tr><td><select name="file">'."\n";
44                echo $data;
45                echo '      </select>'."\n";
46                echo '      <input type="submit" value="" style="width:20px; background:url(../images/boton_confirmar.gif);"></td></tr>'."\n";
47        }
48        echo '</table>'."\n";
49        echo '</form>'."\n";
50        echo '</body></html>'."\n";
51}
52// Change again to source directory.
53chdir($oldpwd);
54
55
56// Send a file.
57function sendFile($file) {
58        // Check if file exists in current directory and it isn't this file.
59        if (file_exists($file) and strpos($file,"/") === false and $file !== basename(__FILE__)) {
60                header('Content-Type: ' . mime_content_type($file));
61                header('Content-Length: ' . filesize($file));
62                header('Content-Disposition: attachment; filename="' . $file . '"');
63                readfile($file);
64        }
65}
66
67// Warning: Don't left any character outside PHP code.
68
Note: See TracBrowser for help on using the repository browser.