slitaz-forge view mirror/floppies/download.php @ rev 696

Fix floppies/download.php
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jun 24 21:59:25 2018 +0200 (2018-06-24)
parents 4ea260d6c590
children
line source
1 <?php
3 $fdsz=80*18*1024;
4 $cpiopad=512;
5 function download($name, $size, $cmd)
6 {
7 header("Content-Type: application/octet-stream");
8 header("Content-Length: ".$size);
9 header("Content-Disposition: attachment; filename=".$name);
10 echo `$cmd 2> /dev/null`;
11 exit;
12 }
14 function my_filesize($path) // 2G+ file support
15 {
16 return rtrim(shell_exec("stat -c %s '".$path."'"));
17 }
19 if (isset($_GET['iso']))
20 $_POST['iso'] = $_GET['iso'];
22 if (isset($_GET['file']))
23 {
24 $max = floor((my_filesize("../".$_GET["iso"]) + $fdsz - 1 + $cpiopad) / $fdsz);
25 $cmd = "cd ../".dirname($_GET['iso'])."; ls ".
26 basename($_GET['iso'],".iso").".*".
27 " | cpio -o -H newc | cat - /dev/zero ";
28 if ($_GET['file'] == "md5sum") {
29 $cmd .= "| for i in \$(seq 1 $max); do dd conv=sync bs=4k ".
30 "count=".($fdsz/4096)." 2> /dev/null | md5sum | ".
31 "sed \"s/-\\\$/\$(printf 'fdiso%02d.img' \$i)/\"; done";
32 $len = 46 * $max;
33 $cmd .= "; md5sum ".basename($_GET['iso']);
34 $len += strlen(basename($_GET['iso'])) + 35;
35 download("md5sum", $len, $cmd);
36 }
37 else {
38 $cmd .= "| dd bs=4k count=".($fdsz/4096)." conv=sync skip=".
39 (($_GET['file'] - 1)*($fdsz/4096))." ";
40 download(sprintf("fdiso%02d.img",$_GET['file']), $fdsz, $cmd);
41 }
42 }
43 ?><!DOCTYPE html>
44 <html lang="en">
45 <head>
46 <meta charset="UTF-8">
47 <title>SliTaz Boot Floppies</title>
48 <meta name="description" content="slitaz boot floppies">
49 <meta name="robots" content="index, nofollow">
50 <meta name="author" content="SliTaz Contributors">
51 <link rel="shortcut icon" href="static/favicon.ico">
52 <link rel="stylesheet" href="static/slitaz.min.css">
53 <style type="text/css">
54 .block_info { width: 40%; }
55 nav table { margin: 6px 0 0 0; }
56 nav table a { color: #215090; }
57 nav header::before { content: url(pics/floppy.png); vertical-align: middle; padding: 0 6px 0 0; }
58 pre, tt, code { font-size: 0.9rem; }
59 </style>
60 </head>
61 <body>
63 <script>de=document.documentElement;de.className+=(("ontouchstart" in de)?' touch':' no-touch');</script>
65 <header>
66 <h1 id="top"><a href="http://www.slitaz.org/">Boot floppies</a></h1>
68 <div class="network">
69 <a href="http://www.slitaz.org/" class="home"></a>
70 <a href="floppy-grub4dos" title="Boot tools">Generic boot floppy</a>
71 <a href="http://tiny.slitaz.org/" title="SliTaz in one floppy !">Tiny SliTaz</a>
72 <a href="builder/index.php" title="Build floppies with your own kernel and initramfs">Floppy set web builder</a>
73 <a href="builder/bootloader" title="Build your floppy sets without Internet">Shell builder</a>
74 </div>
75 </header>
77 <!-- Block -->
78 <div class="block"><div>
80 <!-- Information/image -->
81 <div class="block_info">
82 <header>Available boot floppies</header>
83 <ul>
84 <?php
85 for ($i = 1; file_exists("index-$i.0.html") ; $i++);
86 while (--$i > 0) {
87 echo " <li><a href=\"index-$i.0.html\">SliTaz $i.0</a>";
88 foreach (array("loram","web","mini") as $flavor)
89 if (file_exists("index-".$flavor."-".$i.".0.html"))
90 echo " &middot; <a href=\"index-".$flavor."-$i.0.html\">".$flavor."</a>";
91 echo " </li>\n";
92 }
93 ?>
94 </ul>
95 </div>
98 <!-- Navigation -->
99 <nav>
100 <header>Download 1.44MB images for <?php $dir = explode('/',$_POST["iso"]); echo $dir[1]; ?></header>
101 <table>
102 <?php
103 $max = floor((my_filesize("../".$_POST["iso"]) + $fdsz - 1 + $cpiopad) / $fdsz);
104 for ($i = 1; $i <= $max ; $i++) {
105 if ($i % 6 == 1) echo " <tr>\n";
106 echo " <td><a href=\"download.php?file=$i&amp;iso=".
107 urlencode($_POST["iso"])."\">fdiso".sprintf("%02d",$i);
108 echo "</a></td>\n";
109 if ($i % 6 == 0) echo " </tr>\n";
110 }
111 if ($max % 6 != 0) {
112 while ($max % 6 != 5) { echo " <td> </td>"; $max++; }
113 }
114 else echo " <tr>\n";
115 echo " <td><a href=\"download.php?file=md5sum&amp;iso=".
116 urlencode($_POST["iso"])."\">md5</a></td>\n </tr>";
117 ?>
118 </table>
119 </nav>
120 </div></div>
123 <!-- Content -->
124 <main>
126 <h2>ISO image floppy set</h2>
128 <p>You can restore the <a href="../<?php echo $_POST['iso'].
129 '">'.basename($_POST['iso']); ?></a> ISO image on your hard disk using:</p>
131 <pre>
132 # dd if=/dev/fd0 of=fdiso01.img
133 # dd if=/dev/fd0 of=fdiso02.img
134 # ...
135 # cat fdiso*.img | cpio -i
136 </pre>
139 <!-- End of content -->
140 </main>
143 <script>
144 function QRCodePNG(str, obj) {
145 try {
146 obj.height = obj.width += 300;
147 return QRCode.generatePNG(str, {ecclevel: 'H'});
148 }
149 catch (any) {
150 var element = document.createElement("script");
151 element.src = "/static/qrcode.min.js";
152 element.type = "text/javascript";
153 element.onload = function() {
154 obj.src = QRCode.generatePNG(str, {ecclevel: 'H'});
155 };
156 document.body.appendChild(element);
157 }
158 }
159 </script>
161 <footer>
162 <div>
163 Copyright &copy; <span class="year"></span>
164 <a href="http://www.slitaz.org/">SliTaz</a>
165 </div>
166 <div>
167 Network:
168 <a href="http://scn.slitaz.org/">Community</a> &middot;
169 <a href="http://doc.slitaz.org/">Doc</a> &middot;
170 <a href="http://forum.slitaz.org/">Forum</a> &middot;
171 <a href="http://pkgs.slitaz.org/">Packages</a> &middot;
172 <a href="http://bugs.slitaz.org">Bugs</a> &middot;
173 <a href="http://hg.slitaz.org/?sort=lastchange">Hg</a>
174 </div>
175 <div>
176 SliTaz @
177 <a href="http://twitter.com/slitaz">Twitter</a> &middot;
178 <a href="http://www.facebook.com/slitaz">Facebook</a> &middot;
179 <a href="http://distrowatch.com/slitaz">Distrowatch</a> &middot;
180 <a href="http://en.wikipedia.org/wiki/SliTaz">Wikipedia</a> &middot;
181 <a href="http://flattr.com/profile/slitaz">Flattr</a>
182 </div>
183 <img src="/static/qr.png" alt="#" onmouseover="this.title = location.href"
184 onclick="this.src = QRCodePNG(location.href, this)"/>
185 </footer>
187 </body>
188 </html>