tiny-slitaz view download.php @ rev 32

Do not suggest packages twice
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Sep 26 13:55:40 2019 +0200 (2019-09-26)
parents cb1743f12df8
children
line source
1 <?php
3 function download($file,$name='')
4 {
5 $files = explode(" ",$file);
6 $file = $files[0];
7 if ($name == '')
8 $name = basename($file);
9 if (isset($_POST['tmp_dir']))
10 $file = $_POST['tmp_dir'].$file;
11 $cmd = "cat ".$file;
12 $size = filesize($file);
13 header("Content-Type: application/octet-stream");
14 header("Content-Length: ".$size);
15 header("Content-Disposition: attachment; filename=".$name);
16 print `$cmd`;
17 exit;
18 }
20 if (isset($_POST['download'])) {
21 switch (substr($_POST['download'],0,6)) {
22 case "Kernel" : download("fs/boot/bzImage","kernel");
23 case "Rootfs" : download("rootfs.gz");
24 case "packag" : download("fs/etc/packages.conf");
25 case "Config" : shell_exec("sudo ./helper --mkcfg ".$_POST['tmp_dir']);
26 download("config_files.cpio.gz");
27 case "Floppy" : $n=substr($_POST['download'],6,1);
28 if ($n == " ") $n="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 default : download("fs/boot/".strtolower($_POST['download']));
41 }
42 }
43 if (isset($_GET['dl'])) {
44 download(shell_exec("./helper --get-pkg ".$_GET['dl']." ".$_GET['tmp']));
45 }
46 ?>