slitaz-forge rev 204

Add usbkey
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Mar 23 09:07:29 2012 +0100 (2012-03-23)
parents f465ca36b178
children fd08fdffece4
files usbkey/en/index.php usbkey/fr/index.php usbkey/head.php usbkey/helper.sh usbkey/img/IMAG0111.jpg usbkey/img/IMAG0111small.jpg usbkey/img/IMAG0209.jpg usbkey/img/IMAG0209small.jpg usbkey/img/IMAG0222.jpg usbkey/img/IMAG0222small.jpg usbkey/img/IMAG0224.jpg usbkey/img/IMAG0224small.jpg usbkey/img/IMAG0225.jpg usbkey/img/IMAG0225small.jpg usbkey/index.php usbkey/main.php usbkey/preorder.php usbkey/tail.php
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/usbkey/en/index.php	Fri Mar 23 09:07:29 2012 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +<?php
     1.5 +$howto =<<<EOM
     1.6 +<h4>Howto get this USB key ?</h4>
     1.7 +		<p>
     1.8 +The SliTaz team have designed the <a href="#pictures">prototype</a> of a USB key.
     1.9 +The manufacturer's minimal order is 1000 pieces.
    1.10 +Fill out <a href="#form">the pre-order form</a> below.
    1.11 +A confirmation email will be sent.
    1.12 +Do not send any money now.
    1.13 +We will launch production when enough pre-orders have been registered.
    1.14 +		</p>
    1.15 +EOM;
    1.16 +$characteristics =<<<EOM
    1.17 +<h4>Characteristics</h4>
    1.18 +		<ul>
    1.19 +	<li>4Gb or 8Gb - you may order a custom size</li>
    1.20 +	<li>Full SliTaz 4.0 installed with packages &amp; sources</li>
    1.21 +	<li>minimum 25&euro; including shipment (4 Gb key)</li>
    1.22 +		</ul>
    1.23 +EOM;
    1.24 +$stats = " pre-orders registered today";
    1.25 +$pictures = "<h2>Prototype pictures</h2>";
    1.26 +$note = "The shell and the legs are in rubber. Insertion is easy without any extension.";
    1.27 +$form = "<h2>Pre-order form</h2>";
    1.28 +$enter_email = "Please enter your email address";
    1.29 +$enter_name = "Please enter your name";
    1.30 +$enter_surname = "Please enter your surname";
    1.31 +$enter_address = "Please enter your address";
    1.32 +$enter_city = "Please enter your city";
    1.33 +$enter_country = "Please enter your country";
    1.34 +$lang = "en";
    1.35 +$surname = "Surname";
    1.36 +$name = "Name";
    1.37 +$email = "Email";
    1.38 +$address = "Address";
    1.39 +$zip = "ZIP";
    1.40 +$city = "City";
    1.41 +$country = "Country";
    1.42 +$count = "Quantity";
    1.43 +$size = "Size";
    1.44 +$shell = "The shell only";
    1.45 +$gb = "Gb";
    1.46 +$soft = "Software";
    1.47 +$none = "Nothing";
    1.48 +$core = "A core (&lt; 50Mb)";
    1.49 +$pkgs = "A core + packages";
    1.50 +$web = "A core + packages + websites";
    1.51 +$all = "Everything !";
    1.52 +$comments = "Comments";
    1.53 +$register = "register";
    1.54 +
    1.55 +include("../main.php");
    1.56 +?>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/usbkey/fr/index.php	Fri Mar 23 09:07:29 2012 +0100
     2.3 @@ -0,0 +1,55 @@
     2.4 +<?php
     2.5 +$howto =<<<EOM
     2.6 +<h4>Comment obtenir cette cl&eacute; USB ?</h4>
     2.7 +		<p>
     2.8 +L'&eacute;quipe SliTaz &agrave; cr&eacute;&eacute; le <a href="#pictures">prototype</a>
     2.9 +de cl&eacute; USB.
    2.10 +La production sera lanc&eacute;e avec une commande minimum de 1000 pi&egrave;ces.
    2.11 +Veuillez remplir <a href="#form">le formulaire</a> ci-dessous.
    2.12 +Un email de confirmation vous sera envoy&eacute;.
    2.13 +N'envoyez pas d'argent pour l'instant.
    2.14 +Nous lancerons la production quand suffisament de pr&eacute;-enregistrements seront
    2.15 +valid&eacute;s.
    2.16 +		</p>
    2.17 +EOM;
    2.18 +$characteristics =<<<EOM
    2.19 +<h4>Caract&eacute;ristics</h4>
    2.20 +		<ul>
    2.21 +	<li>4Go ou 8Go - vous pouvez aussi demander une autre taille</li>
    2.22 +	<li>Une SliTaz 4.0 compl&egrave;te install&eacute;e avec les paquets &amp; les sources</li>
    2.23 +	<li>minimum 25&euro; incluant les frais d'envoi (pour un cl&eacute; de 4 Go)</li>
    2.24 +		</ul>
    2.25 +EOM;
    2.26 +$stats = " pr&eacute;-commandes enregistr&eacute;es";
    2.27 +$pictures = "<h2>Photos du Prototype</h2>";
    2.28 +$note = "La coque et les pattes sont en caoutchouc. On peut l'ins&eacute;rer facilement sans rallonge.";
    2.29 +$form = "<h2>Formulaire de pr&eacute;-commande</h2>";
    2.30 +$enter_email = "Veuillez enter votre adresse email";
    2.31 +$enter_name = "Veuillez enter votre nom";
    2.32 +$enter_surname = "Veuillez entrer votre pr&eacute;nom";
    2.33 +$enter_address = "Veuillez entrer votre adresse";
    2.34 +$enter_city = "Veuillez entrer votre ville";
    2.35 +$enter_country = "Veuillez entrer votre pays";
    2.36 +$lang = "fr";
    2.37 +$surname = "Pr&eacute;nom";
    2.38 +$name = "Nom";
    2.39 +$email = "Email";
    2.40 +$address = "Adresse";
    2.41 +$zip = "Code postal";
    2.42 +$city = "Ville";
    2.43 +$country = "Pays";
    2.44 +$count = "Quantit&eacute;";
    2.45 +$size = "Taille";
    2.46 +$shell = "Seulement la coque";
    2.47 +$gb = "Go";
    2.48 +$soft = "Logiciel";
    2.49 +$none = "Aucun";
    2.50 +$core = "Une core (&lt; 50Mo)";
    2.51 +$pkgs = "Une core + paquets";
    2.52 +$web = "UNe core + paquets + sites web";
    2.53 +$all = "Tout !";
    2.54 +$comments = "Remarques";
    2.55 +$register = "Enregistrer";
    2.56 +
    2.57 +include("../main.php");
    2.58 +?>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/usbkey/head.php	Fri Mar 23 09:07:29 2012 +0100
     3.3 @@ -0,0 +1,36 @@
     3.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     3.5 +	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     3.6 +<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
     3.7 +<head>
     3.8 +	<title>SliTaz USB key project</title>
     3.9 +	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    3.10 +	<meta name="description" content="SliTaz USB key project" />
    3.11 +	<meta name="robots" content="index, nofollow" />
    3.12 +	<meta name="author" content="SliTaz Contributors" />
    3.13 +	<link rel="shortcut icon" href="/static/favicon.ico" />
    3.14 +	<link rel="stylesheet" type="text/css" href="/static/slitaz.css" />
    3.15 +	<style type="text/css">
    3.16 +#copy {
    3.17 +	text-align: center;
    3.18 +}
    3.19 +
    3.20 +#bottom {
    3.21 +	text-align: center;
    3.22 +}
    3.23 +.cfrm { // capcha
    3.24 +	display: none;
    3.25 +}
    3.26 +	</style>
    3.27 +</head>
    3.28 +<body bgcolor="#ffffff">
    3.29 +<!-- Header -->
    3.30 +<div id="header">
    3.31 +    <a name="top"></a>
    3.32 +	<div id="logo"></div>
    3.33 +	<div id="network">
    3.34 +		<a href="http://www.slitaz.org/">
    3.35 +		<img src="/static/home.png" alt="[ home ]" /></a>
    3.36 +		<!--a href="http://dvd.slitaz.org/" title="Create your own SliTaz DVD or USB key">DVD/USB-Key content builder</a-->
    3.37 +	</div>
    3.38 +	<h1><a href="http://www.slitaz.org/">SliTaz&nbsp;USB&nbsp;key&nbsp;project</a></h1>
    3.39 +</div>   
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/usbkey/helper.sh	Fri Mar 23 09:07:29 2012 +0100
     4.3 @@ -0,0 +1,78 @@
     4.4 +#!/bin/sh
     4.5 +
     4.6 +if [ "$1" == "--stats" ]; then
     4.7 +	dir=$(dirname $0)/$2
     4.8 +	if [ -n "$3" ]; then
     4.9 +		sed 's/.*"\([0-9]* Gb\)".*/\1/' $dir/?/* | sort | awk '{
    4.10 +	if ($0 != last && last != "") {
    4.11 +		print last " : " n
    4.12 +		n = 0
    4.13 +	}
    4.14 +	last = $0
    4.15 +	n++
    4.16 +}
    4.17 +END {
    4.18 +	print last " : " n
    4.19 +}'
    4.20 +	else
    4.21 +		ls $dir/?/* 2> /dev/null | wc -l
    4.22 +	fi
    4.23 +	exit	
    4.24 +fi
    4.25 +
    4.26 +DOMAIN="slitaz.org"
    4.27 +SERVER="127.0.0.1"
    4.28 +SUBJECT="usbkey.slitaz.org confirmation"
    4.29 +BCC="pascal.bellard@slitaz.org"
    4.30 +
    4.31 +SENDTO="$1"
    4.32 +SURNAME="$2"
    4.33 +KEYSIZE="$3"
    4.34 +HASH="$4"
    4.35 +
    4.36 +body()
    4.37 +{
    4.38 +	cat <<EOT
    4.39 +From: usbkey-preorder@$DOMAIN
    4.40 +Reply-To: no-reply@$DOMAIN
    4.41 +To: $SENDTO
    4.42 +Date: $(date '+%a, %d %b %Y %H:%M:%S %z')
    4.43 +Subject: $SUBJECT
    4.44 +
    4.45 +Hello $SURNAME,
    4.46 +
    4.47 +A $KEYSIZE SliTaz USB key will be reserved for you.
    4.48 +Would you mind confirm the pre-ordering with the following link
    4.49 +http://usbkey.slitaz.org/?confirm=$HASH
    4.50 +
    4.51 +Or cancel the registration with the following link
    4.52 +http://usbkey.slitaz.org/?cancel=$HASH
    4.53 +
    4.54 +Thanks,
    4.55 +The SliTaz team.
    4.56 +EOT
    4.57 +}
    4.58 +
    4.59 +send()
    4.60 +{
    4.61 +	if [ -x /usr/sbin/sendmail ]; then
    4.62 +		body | /usr/sbin/sendmail $SENDTO
    4.63 +	else
    4.64 +		/usr/bin/nc $SERVER 25 <<EOT
    4.65 +HELO $SERVER
    4.66 +MAIL FROM:<usbkey-preorder@$DOMAIN>
    4.67 +RCPT TO:$SENDTO
    4.68 +DATA
    4.69 +$(body)
    4.70 +
    4.71 +.
    4.72 +QUIT
    4.73 +EOT
    4.74 +	fi
    4.75 +}
    4.76 +
    4.77 +send
    4.78 +SUBJECT="[bcc of $SENDTO] $SUBJECT"
    4.79 +for SENDTO in $BCC ; do
    4.80 +	send
    4.81 +done
     5.1 Binary file usbkey/img/IMAG0111.jpg has changed
     6.1 Binary file usbkey/img/IMAG0111small.jpg has changed
     7.1 Binary file usbkey/img/IMAG0209.jpg has changed
     8.1 Binary file usbkey/img/IMAG0209small.jpg has changed
     9.1 Binary file usbkey/img/IMAG0222.jpg has changed
    10.1 Binary file usbkey/img/IMAG0222small.jpg has changed
    11.1 Binary file usbkey/img/IMAG0224.jpg has changed
    12.1 Binary file usbkey/img/IMAG0224small.jpg has changed
    13.1 Binary file usbkey/img/IMAG0225.jpg has changed
    14.1 Binary file usbkey/img/IMAG0225small.jpg has changed
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/usbkey/index.php	Fri Mar 23 09:07:29 2012 +0100
    15.3 @@ -0,0 +1,40 @@
    15.4 +<?php
    15.5 +foreach (array("confirm", "cancel", "show") as $action) {
    15.6 +	if (!isset($_GET[$action]))
    15.7 +		continue;
    15.8 +	$hash = $_GET[$action];
    15.9 +	if ($hash == "")
   15.10 +		continue;
   15.11 +	$data = unserialize(file_get_contents("pending/".
   15.12 +		substr($hash,0,1)."/".$hash));
   15.13 +	if (!isset($data))
   15.14 +		continue;
   15.15 +	if ($action == "confirm") {
   15.16 +		@mkdir("confirmed/".substr($hash,0,1),0777,TRUE);
   15.17 +		rename("pending/".substr($hash,0,1)."/".$hash,
   15.18 +			"confirmed/".substr($hash,0,1)."/".$hash);
   15.19 +	}
   15.20 +	if ($action == "cancel") {
   15.21 +		unlink("pending/".substr($hash,0,1)."/".$hash);
   15.22 +	}
   15.23 +	include("head.php");
   15.24 +	echo "<div id=\"content\">\n";
   15.25 +	echo "<h2>SliTaz USB key pre-order ".$action."ed.</h2>\n<p><table>\n";
   15.26 +	foreach ($data as $key => $value) 
   15.27 +		echo "<tr><td>".$key."</td><td><b>".$value."</b></td></tr>\n"; 
   15.28 +	echo "</table></p>\n";
   15.29 +	echo "</div>\n";
   15.30 +	include("tail.php");
   15.31 +	exit;
   15.32 +}
   15.33 +
   15.34 +foreach (explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]) as $lang) {
   15.35 +	foreach (array(';',' ','-') as $char) {
   15.36 +		if (($n = strpos($lang, $char)) !== false)
   15.37 +			$lang = substr($lang,0,$n);
   15.38 +	}
   15.39 +	if (is_dir($lang)) break;
   15.40 +	$lang = "en"; 
   15.41 +}
   15.42 +header("Location: $lang/");
   15.43 +?>
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/usbkey/main.php	Fri Mar 23 09:07:29 2012 +0100
    16.3 @@ -0,0 +1,144 @@
    16.4 +<?php include("../head.php"); ?>
    16.5 +<!-- Block -->
    16.6 +<div id="block">
    16.7 +	<!-- Navigation -->
    16.8 +	<div id="block_nav">
    16.9 +		<?php echo $howto ?>
   16.10 +	</div>
   16.11 +	<!-- Information/image -->
   16.12 +	<div id="block_info">
   16.13 +		<?php echo $characteristics ?>
   16.14 +		<h4><?php system("../helper.sh --stats confirmed"); echo $stats ?></h4>
   16.15 +	</div>
   16.16 +</div>
   16.17 +		
   16.18 +<!-- Content top. -->
   16.19 +<div id="content_top">
   16.20 +<div class="top_left"></div>
   16.21 +<div class="top_right"></div>
   16.22 +</div>
   16.23 +
   16.24 +<!-- Content -->
   16.25 +<div id="content">
   16.26 +
   16.27 +<a name="pictures"></a>
   16.28 +<?php echo $pictures ?>
   16.29 +<a href="../img/IMAG0222.jpg"><img src="../img/IMAG0222small.jpg" alt="Wide" width="19%" /></a>
   16.30 +<a href="../img/IMAG0224.jpg"><img src="../img/IMAG0224small.jpg" alt="Close" width="19%" /></a>
   16.31 +<a href="../img/IMAG0111.jpg"><img src="../img/IMAG0111small.jpg" alt="Close" width="19%" /></a>
   16.32 +<a href="../img/IMAG0225.jpg"><img src="../img/IMAG0225small.jpg" alt="Closer" width="19%" /></a>
   16.33 +<a href="../img/IMAG0209.jpg"><img src="../img/IMAG0209small.jpg" alt="Detail" width="19%" /></a>
   16.34 +<p>
   16.35 +<?php echo $note ?>
   16.36 +</p>
   16.37 +	
   16.38 +<a name="form"></a>
   16.39 +<?php echo $form ?>
   16.40 +
   16.41 +<script language="javascript">
   16.42 +function valid(f)
   16.43 +{
   16.44 +	if (f.email.value.indexOf("@",0) < 0) {
   16.45 +		alert("<?php echo $enter_email ?>")
   16.46 +		f.email.focus()
   16.47 +		return
   16.48 +	}
   16.49 +	if (f.name.value == "") {
   16.50 +		alert("<?php echo $enter_name ?>")
   16.51 +		f.name.focus()
   16.52 +		return
   16.53 +	}
   16.54 +	if (f.surname.value == "") {
   16.55 +		alert("<?php echo $enter_surname ?>")
   16.56 +		f.surname.focus()
   16.57 +		return
   16.58 +	}
   16.59 +	if (f.address.value == "") {
   16.60 +		alert("<?php echo $enter_address ?>")
   16.61 +		f.address.focus()
   16.62 +		return
   16.63 +	}
   16.64 +	if (f.city.value == "") {
   16.65 +		alert("<?php echo $enter_city ?>")
   16.66 +		f.city.focus()
   16.67 +		return
   16.68 +	}
   16.69 +	if (f.country.value == "") {
   16.70 +		alert("<?php echo $enter_country ?>")
   16.71 +		f.country.focus()
   16.72 +		return
   16.73 +	}
   16.74 +	if (true) {
   16.75 +		f.submit()
   16.76 +	}
   16.77 +}
   16.78 +</script>
   16.79 +<form method="post" action="../preorder.php">
   16.80 +<input type="hidden" name="lang" value="<?php echo $lang ?>" />
   16.81 +<table width="100%">
   16.82 +<tbody>
   16.83 +	<tr>
   16.84 +		<td align="right">&nbsp;<?php echo $name ?></td>
   16.85 +		<td><input type="text" name="name" /></td>
   16.86 +	</tr>
   16.87 +	<tr>
   16.88 +		<td align="right"><?php echo $surname ?></td>
   16.89 +		<td><input type="text" name="surname" /></td>
   16.90 +	</tr>
   16.91 +	<tr>
   16.92 +		<td align="right"><?php echo $email ?></td>
   16.93 +		<td><input type="text" name="email" /></td>
   16.94 +	</tr>
   16.95 +	<tr>
   16.96 +		<td align="right"><?php echo $address ?></td>
   16.97 +		<td><input type="text" name="address" /></td>
   16.98 +	</tr>
   16.99 +	<tr>
  16.100 +		<td align="right"><?php echo "$zip <br /> $city"; ?></td>
  16.101 +		<td><input type="text" name="zip" style="width: 80px;" />
  16.102 +		<input type="text" name="city" style="width: 363px;" /></td>
  16.103 +	</tr>
  16.104 +	<tr>
  16.105 +		<td align="right"><?php echo $country ?></td>
  16.106 +		<td><input type="text" name="country" /></td>
  16.107 +	</tr>
  16.108 +	<tr>
  16.109 +		<td align="right"><?php echo $count ?></td>
  16.110 +		<td><input type="text" name="count" value="1" size="5" 
  16.111 +			onFocus="if (this.value < 1) {this.value='1'}" style="width: 80px;"/>
  16.112 +		<?php echo $size ?>
  16.113 +		<select name="size">
  16.114 +			<option><?php echo $shell ?></option>
  16.115 +			<option selected="selected">4 <?php echo $gb ?></option>
  16.116 +			<option>8 <?php echo $gb ?></option>
  16.117 +			<option>16 <?php echo $gb ?></option>
  16.118 +			<option>32 <?php echo $gb ?></option>
  16.119 +			<option>64 <?php echo $gb ?></option>
  16.120 +		</select>
  16.121 +		</td>
  16.122 +	</tr>
  16.123 +	<tr>
  16.124 +		<td align="right"><?php echo $soft ?></td>
  16.125 +		<td>
  16.126 +			<select name="soft">
  16.127 +				<option value="none"><?php echo $none ?></option>
  16.128 +				<option value="core"><?php echo $core ?></option>
  16.129 +				<option value="pkgs"><?php echo $pkgs ?></option>
  16.130 +				<option value="web"><?php echo $web ?></option>
  16.131 +				<option selected="selected" value="all"><?php echo $all ?></option>
  16.132 +			</select>
  16.133 +		</td>
  16.134 +	</tr>
  16.135 +	<tr>
  16.136 +		<td align="right"><?php echo $comments ?></td>
  16.137 +		<td colspan="4"><textarea name="comments" rows="5" cols="70%"></textarea></td>
  16.138 +	</tr>
  16.139 +</tbody>
  16.140 +</table>
  16.141 +<input type="submit" name="register" value="<?php echo "$register" ?>" />
  16.142 +</form>
  16.143 +
  16.144 +<!-- End of content with round corner -->
  16.145 +</div>
  16.146 +
  16.147 +<?php include("../tail.php"); ?>
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/usbkey/preorder.php	Fri Mar 23 09:07:29 2012 +0100
    17.3 @@ -0,0 +1,18 @@
    17.4 +<?php
    17.5 +include("./head.php");
    17.6 +
    17.7 +echo '<div id="content">';
    17.8 +$data = serialize($_POST);
    17.9 +$hash = md5($data);
   17.10 +@mkdir("pending/".substr($hash,0,1),0777,TRUE);
   17.11 +$fp = fopen("pending/".substr($hash,0,1)."/".$hash, "w");
   17.12 +fwrite($fp,$data);
   17.13 +fclose($fp);
   17.14 +
   17.15 +system(dirname($_SERVER["SCRIPT_FILENAME"])."/helper.sh '".
   17.16 +	  $_POST['email']."' '".$_POST['surname']."' '".$_POST['size'].
   17.17 +	  "' ".$hash);
   17.18 +echo "Thanks ".$_POST['surname'].".<br>\nAn email has been send to ".$_POST['email'].".";
   17.19 +echo '</div>';
   17.20 +include("./tail.php");
   17.21 +?>
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/usbkey/tail.php	Fri Mar 23 09:07:29 2012 +0100
    18.3 @@ -0,0 +1,18 @@
    18.4 +<!-- Start of footer and copy notice -->
    18.5 +<div id="copy">
    18.6 +<p>
    18.7 +Copyright &copy; <span class="year"></span> <a href="http://www.slitaz.org/">SliTaz</a> -
    18.8 +<a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
    18.9 +</p>
   18.10 +<!-- End of copy -->
   18.11 +</div>
   18.12 +
   18.13 +<!-- Bottom and logo's -->
   18.14 +<div id="bottom">
   18.15 +<p>
   18.16 +<a href="http://validator.w3.org/check?uri=referer"><img src="/static/xhtml10.png" alt="Valid XHTML 1.0" title="Code validé XHTML 1.0" style="width: 80px; height: 15px;" /></a>
   18.17 +</p>
   18.18 +</div>
   18.19 +
   18.20 +</body>
   18.21 +</html>