tiny-slitaz annotate 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 |
rev | line source |
---|---|
pascal@0 | 1 <?php |
pascal@0 | 2 |
pascal@0 | 3 function download($file,$name='') |
pascal@0 | 4 { |
pascal@0 | 5 if ($name == '') |
pascal@0 | 6 $name = basename($file); |
pascal@0 | 7 if (isset($_POST['tmp_dir'])) |
pascal@0 | 8 $file = $_POST['tmp_dir'].$file; |
pascal@0 | 9 $cmd = "cat ".$file; |
pascal@0 | 10 $size = filesize($file); |
pascal@0 | 11 header("Content-Type: application/octet-stream"); |
pascal@0 | 12 header("Content-Length: ".$size); |
pascal@0 | 13 header("Content-Disposition: attachment; filename=".$name); |
pascal@0 | 14 print `$cmd`; |
pascal@0 | 15 exit; |
pascal@0 | 16 } |
pascal@0 | 17 |
pascal@0 | 18 if (isset($_POST['download'])) { |
pascal@0 | 19 switch (substr($_POST['download'],0,6)) { |
pascal@0 | 20 case "Kernel" : download("fs/boot/bzImage","kernel"); |
pascal@21 | 21 case "Memtes" : download("fs/boot/memtest"); |
pascal@21 | 22 case "GPXE (" : download("fs/boot/gpxe"); |
pascal@21 | 23 case "IPXE (" : download("fs/boot/ipxe"); |
pascal@0 | 24 case "Rootfs" : download("rootfs.gz"); |
pascal@0 | 25 case "packag" : download("fs/etc/packages.conf"); |
pascal@0 | 26 case "Config" : shell_exec("sudo ./helper --mkcfg ".$_POST['tmp_dir']); |
pascal@0 | 27 download("config_files.cpio.gz"); |
pascal@27 | 28 case "Floppy" : $n=substr($_POST['download'],6,1); |
pascal@27 | 29 shell_exec("./helper --mkimg ".$_POST['tmp_dir']." ". |
pascal@27 | 30 $_POST['fdsize']." ".$n); |
pascal@27 | 31 download("floppy".$n.".img"); |
pascal@5 | 32 case "DOS/EX" : shell_exec("./helper --mkexe ".$_POST['tmp_dir']); |
pascal@5 | 33 download("slitaz.exe"); |
pascal@0 | 34 case "ISO im" : shell_exec("sudo ./helper --mkiso ".$_POST['tmp_dir']); |
pascal@0 | 35 download("slitaz.iso"); |
pascal@0 | 36 case "System" : download("fs/boot/System.map"); |
pascal@0 | 37 case "linux." : download("fs/boot/config","linux.config"); |
pascal@0 | 38 case "busybo" : download("fs/boot/config-busybox","busybox.config"); |
pascal@0 | 39 case "post_i" : download("post_install.log"); |
pascal@0 | 40 } |
pascal@0 | 41 } |
pascal@0 | 42 if (isset($_GET['dl'])) { |
pascal@0 | 43 download(shell_exec("./helper --get-pkg ".$_GET['dl']." ".$_GET['tmp'])); |
pascal@0 | 44 } |
pascal@0 | 45 ?> |