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

may resize qrcode
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jun 26 09:27:30 2014 +0200 (2014-06-26)
parents dea449c5be89
children a37f4ff3d549
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="static/favicon.ico" />
49 <link rel="stylesheet" type="text/css" href="static/slitaz.css" />
50 <style type="text/css">
51 table {
52 background-color: inherit;
53 margin: 10px 0px 0px 0px;
54 }
55 #copy {
56 text-align: center;
57 }
59 #bottom {
60 text-align: center;
61 }
63 </style>
64 </head>
65 <body bgcolor="#ffffff">
66 <!-- Header -->
67 <div id="header">
68 <a name="top"></a>
69 <div id="logo"></div>
70 <div id="network">
71 <a href="http://www.slitaz.org/">
72 <img src="static/home.png" alt="[ home ]" /></a>
73 <a href="floppy-grub4dos" title="Boot tools">Generic boot floppy</a>
74 <a href="http://tiny.slitaz.org/" title="SliTaz in one floppy !">Tiny SliTaz</a>
75 <a href="builder/index.php" title="Build floppies with your own kernel and initramfs">Floppy set web builder</a>
76 <a href="builder/bootloader" title="Build your floppy sets without Internet">Shell builder</a>
77 </div>
78 <h1><a href="http://www.slitaz.org/">Boot floppies</a></h1>
79 </div>
81 <!-- Block -->
82 <div id="block">
83 <!-- Navigation -->
84 <div id="block_nav">
85 <h4><img src="pics/floppy.png" alt="@" />Download 1.44Mb images for <?php $dir = explode('/',$_POST["iso"]); echo $dir[1]; ?></h4>
86 <table width="100%">
87 <?php
88 $max = floor((my_filesize("../".$_POST["iso"]) + $fdsz - 1 + $cpiopad) / $fdsz);
89 for ($i = 1; $i <= $max ; $i++) {
90 if ($i % 6 == 1) echo "<tr>\n";
91 echo " <td> <a href=\"download.php?file=$i&amp;iso=".
92 urlencode($_POST["iso"])."\">fdiso".sprintf("%02d",$i);
93 echo "</a> </td>\n";
94 if ($i % 6 == 0) echo "</tr>\n";
95 }
96 if ($max % 6 != 0) {
97 while ($max % 6 != 5) { echo "<td></td>"; $max++; }
98 }
99 else echo "<tr>\n";
100 echo " <td><a href=\"download.php?file=md5sum&amp;iso=".
101 urlencode($_POST["iso"])."\">md5</a></td>\n</tr>";
102 ?>
103 </table>
104 </div>
105 <!-- Information/image -->
106 <div id="block_info">
107 <h4>Available boot floppies</h4>
108 <ul>
109 <?php
110 for ($i = 1; file_exists("index-$i.0.html") ; $i++);
111 while (--$i > 0) {
112 echo " <li><a href=\"index-$i.0.html\">SliTaz $i.0</a>";
113 if (file_exists("index-loram-".$i.".0.html"))
114 echo " - <a href=\"index-loram-$i.0.html\">loram</a>";
115 echo "</li>\n";
116 }
117 ?>
118 </ul>
119 </div>
120 </div>
122 <!-- Content top. -->
123 <div id="content_top">
124 <div class="top_left"></div>
125 <div class="top_right"></div>
126 </div>
128 <!-- Content -->
129 <div id="content">
131 <h2>ISO image floppy set</h2>
133 <p>
134 You can restore the <a href="../<?php echo $_POST['iso'].
135 '">'.basename($_POST['iso']); ?></a> ISO image on your hard disk using :
136 </p>
137 <pre>
138 # dd if=/dev/fd0 of=fdiso01.img
139 # dd if=/dev/fd0 of=fdiso02.img
140 # ...
141 # cat fdiso*.img | cpio -i
142 </pre>
144 <!-- End of content with round corner -->
145 </div>
146 <div id="content_bottom">
147 <div class="bottom_left"></div>
148 <div class="bottom_right"></div>
149 </div>
151 <!-- Start of footer and copy notice -->
152 <div id="copy">
153 <p>
154 Copyright &copy; <span class="year"></span> <a href="http://www.slitaz.org/">SliTaz</a> -
155 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
156 </p>
157 <!-- End of copy -->
158 </div>
160 <!-- Bottom and logo's -->
161 <div id="bottom">
162 <p>
163 <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>
164 </p>
165 </div>
167 </body>
168 </html>