/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/fboprime/global.inc
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_library/fboprime/global.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (6 years, 3 months ago) by dashley
File size: 8019 byte(s)
Initial commit.
1 <?php
2 //$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/phplib/global.inc,v 1.5 2006/04/30 16:06:27 dashley Exp $
3 //********************************************************************************
4 //global.inc--FboPrime Global Variable Definition and Initialization
5 //Copyright (C) 2006 David T. Ashley
6 //
7 //This program is free software; you can redistribute it and/or
8 //modify it under the terms of the GNU General Public License
9 //as published by the Free Software Foundation; either version 2
10 //of the License, or (at your option) any later version.
11 //
12 //This program is distributed in the hope that it will be useful,
13 //but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 //GNU General Public License for more details.
16 //
17 //You should have received a copy of the GNU General Public License
18 //along with this program; if not, write to the Free Software
19 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 //********************************************************************************
21 //This file defines and initializes the global variables used by the
22 //application (there are very few of these).
23 //--------------------------------------------------------------------------------
24 require_once("config.inc");
25 require_once("strfunc.inc");
26 require_once("timeraw.inc");
27 //
28 //--------------------------------------------------------------------------------
29 //FULL LIST OF GLOBAL VARIABLES
30 //-----------------------------
31 // GLOBAL_dbhandle
32 // The handle to the MySQL database. This is used because there is only
33 // one database, and it would add a lot of typing to pass it as a formal
34 // parameter always. If a connection to the database can't be made
35 // (very near the start of nearly every script), and error screen is
36 // displayed and the script gracefully aborts.
37 //
38 // GLOBAL_dblocked
39 // TRUE if the database is locked, or FALSE if not. As mentioned in
40 // the manual, one can use a global variable of this type to implement
41 // a protocol that allows critical sections within critical sections
42 // with no risk of unlocking the database prematurely.
43 //
44 // GLOBAL_html_indent_level
45 // The indent level of HTML output. The no-indent level is 0, and the
46 // successive levels are 1, 2, 3, etc. This is used to create HTML
47 // output that is human-friendly so it can be proofread. It also allows
48 // functions to be used in multiple contexts and they will pick up the
49 // correct indent level.
50 //
51 // GLOBAL_client_ip
52 // The IP address as reported by the server (a string).
53 //--------------------------------------------------------------------------------
54 // Note: The values below are derived from a common time snapshot in order
55 // to ensure they are absolutely consistent. The snapshot is obtained
56 // at approximately the start of page execution.
57 //
58 // GLOBAL_utime_sec
59 // The Unix integer time, expressed as a string. A string format
60 // is used due to the uncertainty surrounding the 2037 Unix epoch issue.
61 //
62 // GLOBAL_utime_sec_11
63 // The Unix integer time, expressed as a string, zero-padded on the left
64 // out to 11 characters. This is provided because with a constant-length
65 // string, the lexical sort order (i.e. strcmp) is the same as the
66 // numerical order.
67 //
68 // GLOBAL_utime_nsec
69 // The Unix integer nanoseconds associated with the integer seconds above.
70 // An integer format is used because the Unix epoch issue does not affect
71 // the fractional part of the seconds.
72 //
73 // GLOBAL_utime_ut
74 // A string in the UTIME format as described in the manual, describing
75 // the time at the approximate page load time.
76 //
77 // GLOBAL_stime_year
78 // The integer year (2000-2999) in the FBO locale.
79 //
80 // GLOBAL_stime_month
81 // The integer month (1-12) in the FBO locale.
82 //
83 // GLOBAL_stime_day
84 // The integer day of the month (1-31) in the FBO locale.
85 //
86 // GLOBAL_stime_hour
87 // The integer hour (0-23) in the FBO locale.
88 //
89 // GLOBAL_stime_minute
90 // The integer minute (0-59) in the FBO locale.
91 //
92 // GLOBAL_stime_second
93 // The integer second (0-59) in the FBO locale.
94 //
95 // GLOBAL_stime_usec
96 // The integer microseconds (0-999,999) in the
97 // FBO locale.
98 //
99 // GLOBAL_stime_dow
100 // The day of the week, an integer, 0-6, 0=Sunday, 1=Monday, etc.
101 // in the FBO locale.
102 //
103 // GLOBAL_stime_string
104 // A string in the STIME format as described in the manual.
105 //--------------------------------------------------------------------------------
106 //Initializes global variables to correct starting values.
107 //
108 function GLOBAL_init()
109 {
110 global $GLOBAL_dbhandle;
111 global $GLOBAL_dblocked;
112 global $GLOBAL_html_indent_level;
113 global $GLOBAL_client_ip;
114 global $GLOBAL_utime_sec;
115 global $GLOBAL_utime_sec_11;
116 global $GLOBAL_utime_nsec;
117 global $GLOBAL_utime_ut;
118 global $GLOBAL_stime_year;
119 global $GLOBAL_stime_month;
120 global $GLOBAL_stime_day;
121 global $GLOBAL_stime_hour;
122 global $GLOBAL_stime_minute;
123 global $GLOBAL_stime_second;
124 global $GLOBAL_stime_usec;
125 global $GLOBAL_stime_dow;
126 global $GLOBAL_stime_string;
127
128 $GLOBAL_dbhandle = FALSE;
129 $GLOBAL_dblocked = FALSE;
130 $GLOBAL_html_indent_level = 0;
131
132 //Grab the client IP as known to the server and sanitize it.
133 if (isset($_SERVER["REMOTE_ADDR"]))
134 $GLOBAL_client_ip = $_SERVER["REMOTE_ADDR"];
135 else
136 $GLOBAL_client_ip = "";
137 $GLOBAL_client_ip= STRFUNC_force_stringtype_subset_truncate($GLOBAL_client_ip, ".0123456789", 40);
138
139 //Obtain a Unix timestamp.
140 $timestamp = TIMERAW_time_precision_mixed_array_2();
141 $GLOBAL_utime_sec = $timestamp[0];
142 $GLOBAL_utime_nsec = $timestamp[1];
143
144 //Provide the left-zero-padded version of the Unix seconds.
145 $GLOBAL_utime_sec_11 = STRFUNC_pad_left_zero($GLOBAL_utime_sec, 11);
146
147 //Provide the UTIME.
148 $GLOBAL_utime_ut = "UT" . $GLOBAL_utime_sec_11 . STRFUNC_pad_left_zero((string)$GLOBAL_utime_nsec, 9);
149
150 //Run the Unix timestamp through a conversion to get the time details
151 //in the locale. The time details in the locale are maintained as integers
152 //for efficient calculation. The Unix epoch issue does not affect locale
153 //time maintained in this way.
154 CONFIG_unix_sched_time_map(
155 $GLOBAL_utime_sec,
156 $GLOBAL_utime_nsec,
157 $GLOBAL_stime_year,
158 $GLOBAL_stime_month,
159 $GLOBAL_stime_day,
160 $GLOBAL_stime_hour,
161 $GLOBAL_stime_minute,
162 $GLOBAL_stime_second,
163 $GLOBAL_stime_usec,
164 $GLOBAL_stime_dow
165 );
166
167 //From the values obtained, form an STIME string that is consistent with the
168 //Unix time and the integer values.
169 $GLOBAL_stime_string = "ST"
170 . sprintf("%04d", $GLOBAL_stime_year)
171 . sprintf("%02d", $GLOBAL_stime_month)
172 . sprintf("%02d", $GLOBAL_stime_day)
173 . sprintf("%02d", $GLOBAL_stime_hour)
174 . sprintf("%02d", $GLOBAL_stime_minute)
175 . sprintf("%02d", $GLOBAL_stime_second)
176 . sprintf("%06d", $GLOBAL_stime_usec);
177 //echo " + " . $GLOBAL_stime_string . " + ";
178 }
179 //
180 //--------------------------------------------------------------------------------
181 //End of $RCSfile: global.inc,v $.
182 //--------------------------------------------------------------------------------
183 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25