slitaz-dev-tools view mirror-tools/slitaz/mirror/floppies/download.php @ rev 302

Update floppies
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Sep 01 17:28:05 2017 +0200 (2017-09-01)
parents 82786012f589
children 4f6e22d6c85e
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 bs=$fdsz ".
30 "count=1 2> /dev/null | md5sum | ".
31 "sed \"s/-\\\$/\$(printf 'fdiso%02d.img' \$i)/\"; done";
32 download("md5sum", 46 * $max, $cmd);
33 }
34 else {
35 $cmd .= "| dd bs=".$fdsz." count=1 skip=".($_GET['file'] - 1)." ";
36 download(sprintf("fdiso%02d.img",$_GET['file']), $fdsz, $cmd);
37 }
38 }
39 ?><!DOCTYPE html>
40 <html lang="en">
41 <head>
42 <meta charset="UTF-8">
43 <title>SliTaz Boot Floppies</title>
44 <meta name="description" content="slitaz boot floppies">
45 <meta name="robots" content="index, nofollow">
46 <meta name="author" content="SliTaz Contributors">
47 <link rel="shortcut icon" href="static/favicon.ico">
48 <link rel="stylesheet" href="static/slitaz.min.css">
49 <style type="text/css">
50 .block_info { width: 40%; }
51 nav table { margin: 6px 0 0 0; }
52 nav table a { color: #215090; }
53 nav header::before { content: url(pics/floppy.png); vertical-align: middle; padding: 0 6px 0 0; }
54 pre, tt, code { font-size: 0.9rem; }
55 </style>
56 </head>
57 <body>
59 <script>de=document.documentElement;de.className+=(("ontouchstart" in de)?' touch':' no-touch');</script>
61 <header>
62 <h1 id="top"><a href="http://www.slitaz.org/">Boot floppies</a></h1>
64 <div class="network">
65 <a href="http://www.slitaz.org/" class="home"></a>
66 <a href="floppy-grub4dos" title="Boot tools">Generic boot floppy</a>
67 <a href="http://tiny.slitaz.org/" title="SliTaz in one floppy !">Tiny SliTaz</a>
68 <a href="builder/index.php" title="Build floppies with your own kernel and initramfs">Floppy set web builder</a>
69 <a href="builder/bootloader" title="Build your floppy sets without Internet">Shell builder</a>
70 </div>
71 </header>
73 <!-- Block -->
74 <div class="block"><div>
76 <!-- Information/image -->
77 <div class="block_info">
78 <header>Available boot floppies</header>
79 <ul>
80 <?php
81 for ($i = 1; file_exists("index-$i.0.html") ; $i++);
82 while (--$i > 0) {
83 echo " <li><a href=\"index-$i.0.html\">SliTaz $i.0</a>";
84 if (file_exists("index-loram-".$i.".0.html"))
85 echo " · <a href=\"index-loram-$i.0.html\">loram</a>";
86 echo " </li>\n";
87 }
88 ?>
89 </ul>
90 </div>
93 <!-- Navigation -->
94 <nav>
95 <header>Download 1.44MB images for <?php $dir = explode('/',$_POST["iso"]); echo $dir[1]; ?></header>
96 <table>
97 <?php
98 $max = floor((my_filesize("../".$_POST["iso"]) + $fdsz - 1 + $cpiopad) / $fdsz);
99 for ($i = 1; $i <= $max ; $i++) {
100 if ($i % 6 == 1) echo " <tr>\n";
101 echo " <td><a href=\"download.php?file=$i&amp;iso=".
102 urlencode($_POST["iso"])."\">fdiso".sprintf("%02d",$i);
103 echo "</a></td>\n";
104 if ($i % 6 == 0) echo " </tr>\n";
105 }
106 if ($max % 6 != 0) {
107 while ($max % 6 != 5) { echo " <td> </td>"; $max++; }
108 }
109 else echo " <tr>\n";
110 echo " <td><a href=\"download.php?file=md5sum&amp;iso=".
111 urlencode($_POST["iso"])."\">md5</a></td>\n </tr>";
112 ?>
113 </table>
114 </nav>
115 </div></div>
118 <!-- Content -->
119 <main>
121 <h2>ISO image floppy set</h2>
123 <p>You can restore the <a href="../<?php echo $_POST['iso'].
124 '">'.basename($_POST['iso']); ?></a> ISO image on your hard disk using:</p>
126 <pre>
127 # dd if=/dev/fd0 of=fdiso01.img
128 # dd if=/dev/fd0 of=fdiso02.img
129 # ...
130 # cat fdiso*.img | cpio -i
131 </pre>
134 <!-- End of content -->
135 </main>
138 <script>
139 function QRCodePNG(str, obj) {
140 try {
141 obj.height = obj.width += 300;
142 return QRCode.generatePNG(str, {ecclevel: 'H'});
143 }
144 catch (any) {
145 var element = document.createElement("script");
146 element.src = "/static/qrcode.min.js";
147 element.type = "text/javascript";
148 element.onload = function() {
149 obj.src = QRCode.generatePNG(str, {ecclevel: 'H'});
150 };
151 document.body.appendChild(element);
152 }
153 }
154 </script>
156 <footer>
157 <div>
158 Copyright © <span class="year"></span>
159 <a href="http://www.slitaz.org/">SliTaz</a>
160 </div>
161 <div>
162 Network:
163 <a href="http://scn.slitaz.org/">Community</a> ·
164 <a href="http://doc.slitaz.org/">Doc</a> ·
165 <a href="http://forum.slitaz.org/">Forum</a> ·
166 <a href="http://pkgs.slitaz.org/">Packages</a> ·
167 <a href="http://bugs.slitaz.org">Bugs</a> ·
168 <a href="http://hg.slitaz.org/?sort=lastchange">Hg</a>
169 </div>
170 <div>
171 SliTaz @
172 <a href="http://twitter.com/slitaz">Twitter</a> ·
173 <a href="http://www.facebook.com/slitaz">Facebook</a> ·
174 <a href="http://distrowatch.com/slitaz">Distrowatch</a> ·
175 <a href="http://en.wikipedia.org/wiki/SliTaz">Wikipedia</a> ·
176 <a href="http://flattr.com/profile/slitaz">Flattr</a>
177 </div>
178 <img src="/static/qr.png" alt="#" onmouseover="this.title = location.href"
179 onclick="this.src = QRCodePNG(location.href, this)"/>
180 </footer>
182 </body>
183 </html>