tiny-slitaz view download.php @ rev 5

refresh
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Oct 07 23:37:02 2015 +0200 (2015-10-07)
parents 55f97ee147e8
children 038499e4d7db
line source
1 <?php
3 function download($file,$name='')
4 {
5 if ($name == '')
6 $name = basename($file);
7 if (isset($_POST['tmp_dir']))
8 $file = $_POST['tmp_dir'].$file;
9 $cmd = "cat ".$file;
10 $size = filesize($file);
11 header("Content-Type: application/octet-stream");
12 header("Content-Length: ".$size);
13 header("Content-Disposition: attachment; filename=".$name);
14 print `$cmd`;
15 exit;
16 }
18 if (isset($_POST['download'])) {
19 switch (substr($_POST['download'],0,6)) {
20 case "Kernel" : download("fs/boot/bzImage","kernel");
21 case "Rootfs" : download("rootfs.gz");
22 case "packag" : download("fs/etc/packages.conf");
23 case "Config" : shell_exec("sudo ./helper --mkcfg ".$_POST['tmp_dir']);
24 download("config_files.cpio.gz");
25 case "Floppy" : shell_exec("./helper --mkimg ".$_POST['tmp_dir']);
26 download("slitaz.img");
27 case "DOS/EX" : shell_exec("./helper --mkexe ".$_POST['tmp_dir']);
28 download("slitaz.exe");
29 case "ISO im" : shell_exec("sudo ./helper --mkiso ".$_POST['tmp_dir']);
30 download("slitaz.iso");
31 case "System" : download("fs/boot/System.map");
32 case "linux." : download("fs/boot/config","linux.config");
33 case "busybo" : download("fs/boot/config-busybox","busybox.config");
34 case "post_i" : download("post_install.log");
35 }
36 }
37 if (isset($_GET['dl'])) {
38 download(shell_exec("./helper --get-pkg ".$_GET['dl']." ".$_GET['tmp']));
39 }
40 ?>