Removed /usr/local from CDPATH
[clearscm.git] / clients / GD / FSMon / Fsutils.php
1 <?php
2 ////////////////////////////////////////////////////////////////////////////////
3 //
4 // File:        Fsutils.php
5 // Description: Utility funcitons
6 // Author:      Andrew@ClearSCM.com
7 // Created:     Mon Apr 28 15:20:06 MST 2008
8 // Modified:    
9 // Language:    PHP
10 //
11 // (c) Copyright 2008, ClearSCM, Inc., all rights reserved.
12 //
13 ////////////////////////////////////////////////////////////////////////////////
14 // Constants
15 define (VERSION, "1.0");
16
17 define ("BYTE",                      1);
18 define ("KBYTE",        BYTE    * 1024);
19 define ("MEG",          KBYTE   * 1024);
20 define ("GIG",          MEG     * 1024);
21
22 function debug ($msg) {
23   global $debug;
24
25   if ($debug == 1) {
26     print "<font color=red>DEBUG:</font> $msg<br>";
27   } // if
28 } // debug
29
30 function dumpObject ($object) {
31   print "<pre>";
32   print_r ($object);
33   print "</pre>";
34 } // dumpObject
35
36 function error ($msg, $errno = 0) {
37   print "<p><font color=\"red\">ERROR:</font> $msg";
38
39   if ($errno != 0) {
40     print " ($errno)</p>";
41     exit;
42   } else {
43     print "</p>";
44   } // if
45 } // error
46   
47 function banner () {
48   return $banner;
49 } // banner
50
51 function YMD2MDY ($date) {
52   return substr ($date, 5, 2) . "/" .
53          substr ($date, 8, 2) . "/" .
54          substr ($date, 0, 4);
55 } // YMD2MDY
56
57 function MDY2YMD ($date) {
58   return substr ($date, 6, 4) . "-" .
59          substr ($date, 0, 2) . "-" .
60          substr ($date, 3, 2);
61 } // MDY2YMD
62
63 function copyright () {
64   $year = date ("Y");
65
66   $thisFile     = "$_SERVER[DOCUMENT_ROOT]/$_SERVER[PHP_SELF]";
67   $lastModified = date ("F d Y @ g:i a", filemtime ($thisFile));
68
69   $copyright .= <<<END
70 <div class=copyright>
71 Fsmon Version 
72 END;
73   $copyright .= VERSION;
74   $copyright .= <<<END
75 <br>Last Modified: $lastModified<br>
76 Copyright $year &copy; <a href="http://clearscm.com">ClearSCM, Inc.</a>, all rights reserved<br>
77 <a href="/"><img border=0 src="/images/HomeSmall.gif">Home</a>
78 </div>
79 END;
80
81   return $copyright;
82 } // copyright
83
84 function Today2SQLDatetime () {
85   return date ("Y-m-d H:i:s");
86 } // Today2SQLDatetime
87
88 function getPeriods () {
89   return array (
90     "hourly",
91     "daily",
92     "weekly",
93     "monthly"
94   );
95 } // getPeriods
96
97 function getScales () {
98   return array (
99     "byte",
100     "kbyte",
101     "meg",
102     "gig"
103   );
104 } // getScales
105 ?>