5 function array_to_combo($a) {
6 foreach($a as $k => $v){
7 echo "<option value=\"{$v}\">{$v}</option>";
11 function prettify($s,$name) {
12 if (preg_match("/^[0-9]{12}$/",$s)) {
13 $year = substr($s,0,4);
14 $month = substr($s,4,2);
15 $day = substr($s,6,2);
16 $hour = substr($s,8,2);
17 $minute = substr($s,10,2);
18 return $day . "/" . $month . "/" . $year . " " . $hour . ":" . $minute;
19 } else if (preg_match("/time/",$name)){
20 $min = floor($s / 6000);
21 $sec = floor(($s - $min * 6000) / 100);
23 return $min . "m" . $sec . "." . $cents . "s";
33 foreach( $q as $name => $txt) {
34 echo "<th>$name</th>";
39 echo "<tr class=\"even\">";
41 echo "<tr class=\"odd\">";
42 foreach( $q as $name => $txt) {
43 echo "<td>" . prettify($txt,$name) . "</td>";
50 function query($q,$f) {
51 $db = mysql_pconnect("localhost","helm");
52 mysql_select_db("matita");
53 $q = ltrim(rtrim(preg_replace("/\n/"," ",$q)));
54 if (!preg_match("/^(select|describe)[^\n;]*;?$/i",$q)) {
55 die("Query not allowed!<pre>" . $q . "</pre>");
58 $rc = mysql_query($q,$db);
60 die("Query failed: " . mysql_error());
62 while( $row = mysql_fetch_array($rc, MYSQL_ASSOC)){
65 mysql_free_result($rc);
69 function time_2_cents($t) {
71 $rex = "/^(\d+)m(\d\d?)\.(\d{2})s$/";
72 $m = preg_match($rex,$t,$matches);
73 if ( $m == 0 ) exit(1);
74 $t_minutes = $matches[1];
75 $t_secs = $matches[2];
76 $t_cents = $matches[3];
77 return ((int) $t_cents) + ((int) $t_secs) * 100 + ((int)$t_minutes) * 6000 ;