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

Tiny edits
author Paul Issott <paul@slitaz.org>
date Fri Mar 23 22:06:42 2012 +0000 (2012-03-23)
parents b7c1161ffef7
children 82786012f589
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
40 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
41 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
42 <head>
43 <title>SliTaz Boot Floppies</title>
44 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
45 <meta name="description" content="slitaz boot floppies" />
46 <meta name="robots" content="index, nofollow" />
47 <meta name="author" content="SliTaz Contributors" />
48 <link rel="shortcut icon" href="../css/favicon.ico" />
49 <link rel="stylesheet" type="text/css" href="../css/slitaz.css" />
50 <style type="text/css">
51 #copy {
52 text-align: center;
53 }
55 #bottom {
56 text-align: center;
57 }
59 </style>
60 </head>
61 <body bgcolor="#ffffff">
62 <!-- Header -->
63 <div id="header">
64 <a name="top"></a>
65 <div id="logo"></div>
66 <div id="network">
67 <a href="http://www.slitaz.org/">
68 <img src="/css/pics/network.png" alt="network.png" /></a>
69 <a href="../boot/floppy-grub4dos" title="Boot tools">Generic boot floppy</a> |
70 <a href="http://tiny.slitaz.org/" title="SliTaz in one floppy !">Tiny SliTaz</a> |
71 <a href="index-loram.html" title="Floppy image sets for low ram systems">Loram floppies</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 <h1><a href="http://www.slitaz.org/">Boot floppies</a></h1>
76 </div>
78 <!-- Block -->
79 <div id="block">
80 <!-- Navigation -->
81 <div id="block_nav">
82 <h4><img src="pics/floppy.png" alt="@" />Download 1.44Mb images for <?php $dir = explode('/',$_POST["iso"]); echo $dir[1]; ?></h4>
83 <table width="100%">
84 <?php
85 $max = floor((my_filesize("../".$_POST["iso"]) + $fdsz - 1 + $cpiopad) / $fdsz);
86 for ($i = 1; $i <= $max ; $i++) {
87 if ($i % 4 == 1) echo "<tr>\n";
88 echo " <td><a href=\"download.php?file=$i&amp;iso=".
89 urlencode($_POST["iso"])."\">fdiso".sprintf("%02d",$i);
90 if ($max < 100) echo ".img";
91 echo "</a></td>\n";
92 if ($i % 4 == 0) echo "</tr>\n";
93 }
94 if ($max % 4 != 0) {
95 while ($max % 4 != 3) { echo "<td></td>"; $max++; }
96 }
97 else echo "<tr>\n";
98 echo " <td><a href=\"download.php?file=md5sum&amp;iso=".
99 urlencode($_POST["iso"])."\">md5sum</a></td>\n</tr>";
100 ?>
101 </table>
102 </div>
103 <!-- Information/image -->
104 <div id="block_info">
105 <h4>Available boot floppies</h4>
106 <ul>
107 <li><a href="index-3.0.html">SliTaz 3.0</a></li>
108 <li><a href="index-loram-3.0.html">SliTaz loram 3.0</a></li>
109 <li><a href="index-2.0.html">SliTaz 2.0</a></li>
110 <li><a href="index-1.0.html">SliTaz 1.0</a></li>
111 </ul>
112 </div>
113 </div>
115 <!-- Content top. -->
116 <div id="content_top">
117 <div class="top_left"></div>
118 <div class="top_right"></div>
119 </div>
121 <!-- Content -->
122 <div id="content">
124 <h2>ISO image floppy set</h2>
126 <p>
127 You can restore the <a href="../<?php echo $_POST['iso'].
128 '">'.basename($_POST['iso']); ?></a> ISO image on your hard disk using :
129 </p>
130 <pre>
131 # dd if=/dev/fd0 of=fdiso01.img
132 # dd if=/dev/fd0 of=fdiso02.img
133 # ...
134 # cat fdiso*.img | cpio -i
135 </pre>
137 <!-- End of content with round corner -->
138 </div>
139 <div id="content_bottom">
140 <div class="bottom_left"></div>
141 <div class="bottom_right"></div>
142 </div>
144 <!-- Start of footer and copy notice -->
145 <div id="copy">
146 <p>
147 Copyright &copy; <span class="year"></span> <a href="http://www.slitaz.org/">SliTaz</a> -
148 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
149 </p>
150 <!-- End of copy -->
151 </div>
153 <!-- Bottom and logos -->
154 <div id="bottom">
155 <p>
156 <a href="http://validator.w3.org/check?uri=referer"><img src="../css/pics/website/xhtml10.png" alt="Valid XHTML 1.0" title="Code validé XHTML 1.0" style="width: 80px; height: 15px;" /></a>
157 </p>
158 </div>
160 </body>
161 </html>