tiny-slitaz view download.php @ rev 27

Multi floppy support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Sep 17 08:38:04 2019 +0200 (2019-09-17)
parents 038499e4d7db
children 26423b57df46
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 "Memtes" : download("fs/boot/memtest");
22 case "GPXE (" : download("fs/boot/gpxe");
23 case "IPXE (" : download("fs/boot/ipxe");
24 case "Rootfs" : download("rootfs.gz");
25 case "packag" : download("fs/etc/packages.conf");
26 case "Config" : shell_exec("sudo ./helper --mkcfg ".$_POST['tmp_dir']);
27 download("config_files.cpio.gz");
28 case "Floppy" : $n=substr($_POST['download'],6,1);
29 shell_exec("./helper --mkimg ".$_POST['tmp_dir']." ".
30 $_POST['fdsize']." ".$n);
31 download("floppy".$n.".img");
32 case "DOS/EX" : shell_exec("./helper --mkexe ".$_POST['tmp_dir']);
33 download("slitaz.exe");
34 case "ISO im" : shell_exec("sudo ./helper --mkiso ".$_POST['tmp_dir']);
35 download("slitaz.iso");
36 case "System" : download("fs/boot/System.map");
37 case "linux." : download("fs/boot/config","linux.config");
38 case "busybo" : download("fs/boot/config-busybox","busybox.config");
39 case "post_i" : download("post_install.log");
40 }
41 }
42 if (isset($_GET['dl'])) {
43 download(shell_exec("./helper --get-pkg ".$_GET['dl']." ".$_GET['tmp']));
44 }
45 ?>