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