]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/scripts/public_html/common.php
Snapshot.
[helm.git] / helm / software / matita / scripts / public_html / common.php
1 <?php
2
3 $i = 0;
4   
5 function array_to_combo($a) {
6   foreach($a as $k => $v){
7     echo "<option value=\"{$v}\">{$v}</option>";
8   }
9 }
10
11 function query($q,$f) {
12   $db = mysql_pconnect("localhost","helm");
13   mysql_select_db("matita");
14   $rc = mysql_query($q,$db);
15   if(!$rc) {
16     die("Query failed: " . mysql_error());
17   }
18   while( $row = mysql_fetch_array($rc, MYSQL_ASSOC)){
19     $f($row);
20   }
21   mysql_free_result($rc);
22   mysql_close($db);
23 }
24
25 function time_2_cents($t) {
26   $matches = array();
27   $rex = "/^(\d+)m(\d\d?)\.(\d{2})s$/";
28   $m = preg_match($rex,$t,$matches);
29   if ( $m == 0 ) exit(1);
30   $t_minutes = $matches[1];
31   $t_secs = $matches[2];
32   $t_cents = $matches[3];
33   return ((int) $t_cents) + ((int) $t_secs) * 100 + ((int)$t_minutes) * 6000 ;
34 }
35
36 ?>