Odyssey
cuclock.prg
1 <?php
2 $monLibrary= dirname(__FILE__) . "/../library";
3 require_once("$monLibrary/cu_top.i");
4 require_once("$monLibrary/ck_hticket.i");
5 
6  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
7  // ** Permissions failed
8  // ** redirect to new page
9  header("Location: /hcuadm/hcu_noperm.prg");
10  exit;
11  }
12 $dms_ok=array('cu'=>'string');
13 dms_import($dms_ok);
14 
15 $localzone="US/Mountain";
16 $clock="";
17 
18 $dbh = $link;
19 $sql = "select trim(tz) from cuadmin where user_name='$cu'";
20 $sth = db_query($sql,$dbh);
21 if($sth) { list($tz) = db_fetch_array($sth,0); }
22 if ("$tz" == "") {
23  $clock = "No Timezone";
24 } else {
25  if(strpos("$tz","/") === false) $tz = "US/$tz";
26  $sql = "set time zone '$tz'; select time(0) without time zone 'now';";
27  $sth = db_query($sql,$dbh);
28  if($sth) {
29  list($clock) = db_fetch_array($sth,0);
30  // ** Format the time
31  $clock = dateformat("g:i:s A", $clock);
32  }
33  $sth = db_query("set time zone '$localzone'",$dbh);
34 
35 }
36 $clock = ("$clock" == "" ? "Clock Failed" : "<font face='Helvetica' size='3'><b>$clock</b></font>");
37 print "$clock";
38 ?>