X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Fscripts%2Fpublic_html%2Fcommon.php;h=0e7962abfae84b2aff4a64c1f9031dc2583e7258;hb=0a2a17e3a4d180ff8a23ef4bd56a5d05f2a303aa;hp=5b9f51e5dc68cc488bb66d2b4ee79528a2ebf3bc;hpb=ddd6b48d99c2f3ed13458732baa03ee23138fc94;p=helm.git diff --git a/helm/software/matita/scripts/public_html/common.php b/helm/software/matita/scripts/public_html/common.php index 5b9f51e5d..0e7962abf 100644 --- a/helm/software/matita/scripts/public_html/common.php +++ b/helm/software/matita/scripts/public_html/common.php @@ -1,8 +1,60 @@ $v){ + echo ""; + } +} + +function prettify($s,$name) { + if (preg_match("/^[0-9]{12}$/",$s)) { + $year = substr($s,0,4); + $month = substr($s,4,2); + $day = substr($s,6,2); + $hour = substr($s,8,2); + $minute = substr($s,10,2); + return $day . "/" . $month . "/" . $year . " " . $hour . ":" . $minute; + } else if (preg_match("/time/",$name)){ + $min = floor($s / 6000); + $sec = floor(($s - $min * 6000) / 100); + $cents = $s % 100; + return $min . "m" . $sec . "." . $cents . "s"; + } else + return rtrim($s); +} + + +function printer($q){ + global $i; + echo ""; + if ( $i == 0) { + foreach( $q as $name => $txt) { + echo "$name"; + } + } + echo "\n"; + if ( $i%2 == 0) + echo ""; + else + echo ""; + foreach( $q as $name => $txt) { + echo "" . prettify($txt,$name) . ""; + } + echo "\n"; + $i++; +} + + function query($q,$f) { $db = mysql_pconnect("localhost","helm"); mysql_select_db("matita"); + $q = preg_replace("/\n/"," ",$q); + if (!preg_match("/^(select|describe)[^\n;]*;?$/i",$q)) { + die("Query not allowed!
" . $q . "
"); + return; + } $rc = mysql_query($q,$db); if(!$rc) { die("Query failed: " . mysql_error()); @@ -25,15 +77,4 @@ function time_2_cents($t) { return ((int) $t_cents) + ((int) $t_secs) * 100 + ((int)$t_minutes) * 6000 ; } -function array_to_combo($l,$a) { - echo ""; -} - ?>