/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/fboprime/dbcreate.php
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_library/fboprime/dbcreate.php

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: 42836 byte(s)
Initial commit.
1 #!/usr/bin/php -q
2 <?php
3 //$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/standalone/dbcreate.php,v 1.31 2006/11/05 18:26:05 dashley Exp $
4 //--------------------------------------------------------------------------------
5 //dbcreate.php--Creates The FBO-Prime Database (Unpopulated)
6 //Copyright (C) 2006 David T. Ashley
7 //
8 //This program is free software; you can redistribute it and/or
9 //modify it under the terms of the GNU General Public License
10 //as published by the Free Software Foundation; either version 2
11 //of the License, or (at your option) any later version.
12 //
13 //This program is distributed in the hope that it will be useful,
14 //but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 //GNU General Public License for more details.
17 //
18 //You should have received a copy of the GNU General Public License
19 //along with this program; if not, write to the Free Software
20 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 //--------------------------------------------------------------------------------
22 //Set the include file path. This is necessary to get to the configuration
23 //information, including how to try to connect to the database.
24 set_include_path("/var/www/php_library/fboprime");
25 //
26 //Include the configuration information.
27 require_once("config.inc");
28 //
29 //--------------------------------------------------------------------------------
30 //Writes a horizontal line.
31 //
32 function hline()
33 {
34 for ($i=0; $i<80; $i++)
35 {
36 echo "-";
37 }
38 echo "\n";
39 }
40 //
41 //--------------------------------------------------------------------------------
42 //Errors out.
43 //
44 function error_out()
45 {
46 echo "FATAL ERROR\n";
47 exit(1);
48 }
49 //
50 //--------------------------------------------------------------------------------
51 //Returns a version control string. Used for randomness.
52 //
53 function vc_info()
54 {
55 return("\$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/standalone/dbcreate.php,v 1.31 2006/11/05 18:26:05 dashley Exp $");
56 }
57 //
58 //--------------------------------------------------------------------------------
59 //
60 function populate_db($handle, $dbdesign)
61 {
62 //Figure out how many tables are in the database, and get their names.
63 hline();
64
65 $result = mysql_query("show tables", $handle);
66
67 if ($result === FALSE)
68 error_out();
69
70 //Figure out the results.
71 $ntables = mysql_num_rows($result);
72 for ($i=0; $i<$ntables; $i++)
73 {
74 $temp = mysql_fetch_row($result);
75 $tables_array[$i] = $temp[0];
76 }
77
78 //$ntables = count($tables_array);
79
80 //Tell how many tables.
81 if ($ntables > 1)
82 echo $ntables . " tables found in database:\n";
83 else if ($ntables == 1)
84 echo $ntables . " table found in database:\n";
85 else
86 echo "No tables found in database.\n";
87
88 //Emit the table names.
89 for ($i = 0; $i < $ntables; $i++)
90 {
91 echo " " . $tables_array[$i] . "\n";
92 }
93
94 //Loop through the necessary database design. For any tables that do not
95 //exist, create them in their entirety. Every row in the lookup table that
96 //is used (i.e. implemented) is marked by changing the fifth column
97 //to "Y".
98 for ($i = 0; $i < count($dbdesign); $i += 5)
99 {
100 if ($dbdesign[$i+4] != "Y")
101 {
102 if ($ntables)
103 $found = array_search($dbdesign[$i], $tables_array);
104 else
105 $found = FALSE;
106
107 if (($found === FALSE) || ($found === NULL))
108 {
109 //The cited table does not exist. Form the SQL query to make it.
110 $query = "create table " . $dbdesign[$i] . " (";
111 $first = 1;
112
113 for ($j = 0; $j < count($dbdesign); $j += 5)
114 {
115 if ($dbdesign[$j] == $dbdesign[$i])
116 {
117 if (! $first)
118 {
119 $query .= " , ";
120 }
121 else
122 {
123 $first = 0;
124 }
125
126 $query = $query . " " . $dbdesign[$j+1] . " " . $dbdesign[$j+2] . " " . $dbdesign[$j+3] . " ";
127
128 $dbdesign[$j+4] = "Y";
129 }
130 }
131
132 $query .= " )";
133
134 //Echo the query to the console for review.
135 hline();
136 echo "The table \"" . $dbdesign[$i] . "\" does not exist and will be created. The SQL query is:\n\n";
137 echo $query . "\n";
138
139 //Run the query and bug out if it fails.
140 $result = mysql_query($query, $handle);
141
142 if ($result === FALSE)
143 error_out();
144 }
145 } //end if not marked
146 } // end for
147 }
148 //
149 //--------------------------------------------------------------------------------
150 //--------------------------------------------------------------------------------
151 //--------------------------------------------------------------------------------
152 //------ M A I N S C R I P T ------------------------------------------------
153 //--------------------------------------------------------------------------------
154 //--------------------------------------------------------------------------------
155 //--------------------------------------------------------------------------------
156 //
157 //
158 //This describes the overall database design. The parts are:
159 // a)Table name.
160 // b)Field name.
161 // c)Field type.
162 // d)Field attributes.
163 //
164 $dbdesign = array
165 (
166 //=====================================================================================================
167 //=====================================================================================================
168 //==== U S R S ======================================================================================
169 //=====================================================================================================
170 //=====================================================================================================
171 //One record for each user.
172 //=====================================================================================================
173 "usrs", "idx", "int", "AUTO_INCREMENT NOT NULL PRIMARY KEY", "",
174 //The integer index of the user. This is used as a key throughout the software to uniquely
175 //identify a user (for example, in "edit user" screens and so on). MySQL ensures that the
176 //first index will be 1, so 0 can be used as an error code or for other special flags.
177 "usrs", "status", "int", "", "",
178 //An integer describing the status of the user. This is an integer constant defined in the
179 //source code. Possible values are active or inactive. The transition to inactive based on
180 //expiration of BFR time or medical can be done only in maintenance scripts or manually--
181 //automatic actions involving this kind of state change are not taken during normal
182 //page viewing.
183 "usrs", "seclvl", "int", "", "",
184 //The security level of the user. This is defined by integer constants in the CONFIG.INC file.
185 //The general scheme is that a user may not modify information about a user with a security
186 //integer equal to or less than the user's. A lesser integer means a higher security level.
187 "usrs", "userid", "varchar(20)", "", "",
188 //The ID of the user when logging in. This is stored in the database in all lower case, but in
189 //logins a user may accidentally mix case, so this is treated as case-insensitive when
190 //authenticating.
191 //
192 //Restrictions:
193 // a)Id as stored may contain only a-z and 0-9 (i.e. no weird characters).
194 // b)Must be at least of length 1.
195 // c)Must begin with a letter (not a number).
196 // d)Must be unique.
197 "usrs", "role", "int", "", "",
198 //An integer describing the role of the user (flight instructor, user, whatever). The values
199 //are defined by constants in the CONFIG.INC file. This integer is used for description only
200 //and does not affect the privileges of the user in any way.
201 "usrs", "perm", "varchar(2000)", "", "",
202 //A permission string expressing the precise database permissions the user has. This is an
203 //unordered set of values separated by backslashes. The string format is used because it combines
204 //simplicity with speed. String operations, which call into 'C'-compiled code, are fast.
205 "usrs", "sex", "int", "", "",
206 //The gender of the user. The possible values of this integer are defined in constants in the
207 //code.
208 "usrs", "title", "varchar(20)", "", "",
209 //The title of the user (optional), including a trailing ".", if appropriate. Titles are strings
210 //such as "Dr.", "Mr.", etc. This may have 'a-z', 'A-Z', spaces, apostrophes, "," and ".".
211 "usrs", "fname", "varchar(20)", "", "",
212 //The first name of the user (optional). No casing is enforced due to the possibility of foreign names such as
213 //"ug Limu" (I made that up). Spaces are allowed in the name (only one contiguously) to accommodate
214 //foreign names. Before storage in the database:
215 // a)Must have no leading or trailing spaces.
216 // b)Must be at least of length 1.
217 // c)May contain only 'a-z', 'A-Z', spaces, and apostrophes.
218 // d)If spaces appear within the name, there can be only one contiguously.
219 "usrs", "mname", "varchar(20)", "", "",
220 //The middle name of the user (optional), or the middle initial, or the middle initial followed by
221 //a period. Characters allowed are 'a-z', 'A-Z', spaces, and apostrophes, with no more than one
222 //contiguous space.
223 "usrs", "lname", "varchar(20)", "", "",
224 //The last name of the user. No casing is enforced due to the possibility of foreign names such as
225 //"de Raspide". Spaces are allowed in the name (only one contiguously) to accommodate foreign names.
226 //Before storage in the database:
227 // a)Must have no leading or trailing spaces.
228 // b)Must be at least of length 1.
229 // c)May contain only 'a-z', 'A-Z', spaces, and apostrophes.
230 // d)If spaces appear within the name, there can be only one contiguously.
231 "usrs", "suffix", "varchar(20)", "", "",
232 //The suffix, such as "Jr.", "Sr.", etc. (optional). This may have 'a-z', 'A-Z', spaces,
233 //apostrophes, commas, and periods, with no more than one contiguous space.
234 "usrs", "adl1", "varchar(50)", "", "",
235 //The first line of the street address of the user. This may include 'a-z', 'A-Z', digits, spaces,
236 //apostrophes, periods, and '#', with no more than one contiguous space. Optional.
237 "usrs", "adl2", "varchar(50)", "", "",
238 //Second line of address. Same rules as first.
239 "usrs", "city", "varchar(20)", "", "",
240 //City (optional). Same rules as first name and last name.
241 "usrs", "stateprovince", "varchar(20)", "", "",
242 //Same rules as last name/first name. For someone in a foreign country, this may not be a 2-letter
243 //code. Optional.
244 "usrs", "zippostalcode", "varchar(20)", "", "",
245 //Postal code. Same rules as address lines. Optional. In the case of foreign countries, the
246 //zip/postal code may be longer than 9 digits or contain letters, etc.
247 "usrs", "country", "varchar(20)", "", "",
248 //The country, in English. Same rules as first or last names. Optional.
249 "usrs", "pwhash", "varchar(64)", "", "",
250 //The salt and hash of the primary password. The primary password is the one the user normally
251 //uses to log in. If both this and the lostpwhash are not set, it would not be possible to log in.
252 "usrs", "lostpwhash", "varchar(64)", "", "",
253 //The salt and hash of the password that may be e-mailed to the user if the password is lost.
254 //It is done that way to avoid e-mailing existing passwords in the clear (the password mailed
255 //to the user is a randomly-generated one).
256 "usrs", "lostpwgentime", "varchar(22)", "", "",
257 //A UTIME flagging the time at which the e-mailed password was generated. There are two behaviors
258 //associated with this:
259 // a)A new password cannot be e-mailed too often (i.e. there needs to be a minimum spacing).
260 // b)A password that is e-mailed is only valid for a finite period of time.
261 "usrs", "ratings", "varchar(200)", "", "",
262 //A string describing the ratings that the user has. The format of this is up to the FBO.
263 //Generally, this would be a comma-separated list of acronyms. For storage in the database,
264 //blanks and tabs would be trimmed from both ends.
265 "usrs", "bfrlicexpdate", "varchar(8)", "", "",
266 //The date, as a DT8, on which the user's license becomes invalid if the pilot does not receive
267 //a BFR.
268 "usrs", "medexpdate", "varchar(8)", "", "",
269 //The date, as a DT8, on which the user's medical becomes invalid. The user must obtain a new
270 //medical by this date or can't fly as PIC or required crewmember.
271 "usrs", "restrictions", "varchar(2000)", "", "",
272 //A textual description of the restrictions that the user is under. A typical string might be
273 //"Medical prohibits user from flying at night.". The format of this is up to the FBO.
274 "usrs", "dayphone", "varchar(50)", "", "",
275 //The daytime phone number of the user. This is essentially the work phone number.
276 //All phone numbers are optional. Character set and rules same as address lines.
277 "usrs", "eveningphone", "varchar(50)", "", "",
278 //The evening phone number of the user. This is essentially the home phone number.
279 "usrs", "cellphone", "varchar(50)", "", "",
280 //The mobile phone number of the user.
281 "usrs", "em1", "varchar(100)", "", "",
282 //First notification e-mail address of the user.
283 "usrs", "em2", "varchar(100)", "", "",
284 //Second notification e-mail address of the user.
285 "usrs", "acctexpdate", "varchar(8)", "", "",
286 //The date, as a DT8, on which the user's account should expire. On this date the user becomes
287 //inactive and can't log in any more.
288 "usrs", "mostrecentlogin", "varchar(8)", "", "",
289 //The date on which the most recent login by the user occurred.
290 "usrs", "schedalonerscs", "varchar(2000)", "", "",
291 //A comma-separated integer list of resources that the user can schedule without a flight
292 //instructor. (All resources can be scheduled WITH a flight instructor.) The first character
293 //will be a comma and the final entry will be ended with a comma, subject to the rules of
294 //comma-separated integer lists.
295 "usrs", "fboremarks", "varchar(4000)", "", "",
296 "usrs", "userremarks", "varchar(4000)", "", "",
297 //Remarks editable by the FBO and user respectively. Both sets of remarks are visible by both
298 //parties, but the FBO remarks can be edited only by the FBO and the user remarks can be edited
299 //only by the user.
300 "usrs", "crmodsguid", "varchar(32)", "", "",
301 //The SGUID from when the record was created or last modified. This may be used to avoid browser
302 //editing collisions. The way that collisions are avoided is that when the record is modified
303 //(perhaps by another user while a given user has the record displayed in a browser form), a new
304 //SGUID is placed in the record. When a new commit of the record is attempted, the lower-level
305 //functions will detect that the underlying SGUID has changed, as they will compare the
306 //one provided by the browser (usually stored as a hidden field) against the one currently
307 //in the database. The two will definitely be different, as SGUIDs have guaranteed uniqueness
308 //throughout the lifetime of the server.
309 //=====================================================================================================
310 //=====================================================================================================
311 //==== R E S V ======================================================================================
312 //=====================================================================================================
313 //=====================================================================================================
314 //One record for each reservation. A reservation can consist of multiple slots.
315 //=====================================================================================================
316 "resv", "idx", "int", "AUTO_INCREMENT NOT NULL PRIMARY KEY", "",
317 //The integer index of reservation. Used to identify it uniquely.
318 "resv", "type", "int", "", "",
319 //An integer identifying the type of the reservation. This is defined by constants in source
320 //code. Possibilities are:
321 // 0 : Banner reservation. This does nothing, interferes with nothing, etc. It just
322 // displays information that is visible.
323 // 1 : Ordinary reservation that is active (not standby).
324 // 2 : Standby reservation. This is an ordinary reservation that can't be made active
325 // because of a conflict.
326 "resv", "crsguid", "varchar(32)", "", "",
327 //An SGUID identifying the time at which the reservation was created. This is used to break any
328 //ties for priority. Because of the way an SGUID is constructed, this is guaranteed to be
329 //unique. After the reservation is created, this SGUID is not modified
330 "resv", "createtimest", "varchar(22)", "", "",
331 //An STIME identifying the time at which the reservation is created. This is used for reporting
332 //the date and time in human-friendly terms (but can't be used for tie-breaking).
333 "resv", "useridx", "int", "", "",
334 //An integer identifying the owner of the reservation. As every reservation must have an owner,
335 //this index must be > 0.
336 "resv", "alias", "int", "", "",
337 //Integer identifying the alias, if any. Alias is the pseudo-name that should be displayed as the
338 //owner, such as "Line", "Maintenance", etc. A value of zero here indicates no alias to be used.
339 "resv", "finstid", "int", "", "",
340 //An integer identifying the resource record (not the user record!) corresponding to the flight
341 //instructor for the reservation. If no flight instructor is included in the reservation, 0 is
342 //stored.
343 "resv", "finsttimestart", "varchar(22)", "", "",
344 //The STIME corresponding to the start with the instructor. If no instructor on the reservation,
345 //this should be the empty string.
346 "resv", "finsttimeend", "varchar(22)", "", "",
347 //The STIME corresponding to the with the instructor. If no instructor on the reservation,
348 //this should be the empty string.
349 "resv", "acftsimid", "int", "", "",
350 //An integer identifying the resource record corresponding to the aircraft or simulator that is
351 //being reserved. If no aircraft or simulator is included in the reservation, 0 is stored.
352 "resv", "acftsimtimestart","varchar(22)", "", "",
353 //The STIME corresponding to the start with the aircraft or simulator. If no aircraft or simulator
354 //is on the reservation, this should be the empty string.
355 "resv", "acftsimtimeend", "varchar(22)", "", "",
356 //The STIME corresponding to the end the aircraft or simulator. If no aircraft or simulator is on
357 //the reservation, this should be the empty string.
358 "resv", "resvtimestart", "varchar(22)", "", "",
359 //The STIME corresponding to the start time of the reservation. The start time is the minimum of
360 //the start of the flight instructor, if any, and the aircraft or simulator, if any. For any
361 //reservation, this always exists, because the reservation must have a flight instructor or
362 //aircraft/simulator. This database field is provided to simplify some queries.
363 "resv", "resvtimeend", "varchar(22)", "", "",
364 //The STIME corresponding to the end time of the reservation. The start time is the maximum of
365 //the end of the flight instructor, if any, and the aircraft or simulator, if any. For any
366 //reservation, this always exists, because the reservation must have a flight instructor or
367 //aircraft/simulator. This database field is provided to simplify some queries.
368 "resv", "usrprivdesc", "varchar(4000)", "", "",
369 //User-private textual description of the appointment. This can only appear on reservations
370 //where:
371 // a)The reservation does not involve an aircraft.
372 // b)The reservation is by a flight instructor reserving the resource corresponding to
373 // themselves.
374 //
375 //User-private text is intended to allow for doctor's appointments, etc. and to keep the details
376 //of this absolutely private to the individual private.
377 "resv", "fboprivdesc", "varchar(4000)", "", "",
378 //Description private to the FBO employees (not shared with the general user population).
379 //Note that a reservation (such as a doctor's appointment) may have a certain description that is
380 //user private, but a separate description for the FBO employees.
381 "resv", "comprivdesc", "varchar(4000)", "", "",
382 //Description private to the user community (those with login accounts who are logged in).
383 //Note that any reservation may have an FBO-private component and a community-private
384 //component.
385 "resv", "publicdesc", "varchar(4000)", "", "",
386 //Description that is fully public (visible to web page visitors who have not logged in).
387 //Currently only banner reservations support this field.
388 //
389 "resv", "crmodsguid", "varchar(32)", "", "",
390 //An SGUID from whenever the reservation is created or modified. This is used to detect editing
391 //collisions. This field is modified whenever the record is committed back (unlike the field
392 //somewhat earlier in the definition that is never changed after record creation).
393 //
394 //=====================================================================================================
395 //==== R S C S ======================================================================================
396 //=====================================================================================================
397 //=====================================================================================================
398 //The resources (aircraft, simulators, flight instructors).
399 //=====================================================================================================
400 "rscs", "idx", "int", "AUTO_INCREMENT NOT NULL PRIMARY KEY", "",
401 //The integer index of the resource. This can be a unique way to identify the record.
402 "rscs", "type", "int", "", "",
403 //The type of the resource. This is an integer constant defined in the code. The values may be
404 //aircraft, simulator, or flight instructor.
405 "rscs", "status", "int", "", "",
406 //The status of the resource. This is an integer constant defined in the code. The values
407 //may be online or offline.
408 "rscs", "disporder", "int", "", "",
409 //An integer used to govern the order in which resources are displayed, smallest integer first.
410 //This is used (as it is also in ORS) because the preferred display order (for the scheduler
411 //and other places) may not correlate with any other fields.
412 "rscs", "initials", "varchar(25)", "", "",
413 //The shortest description, i.e. "N12345" or "J.F.".
414 "rscs", "shortdesc", "varchar(50)", "", "",
415 //A shorter description, i.e. "N12345" or "J. Flightinstructor".
416 "rscs", "longdesc", "varchar(100)", "", "",
417 //The long description of the resource.
418 //
419 //For a flight instructor, this would normally be the full name, i.e. "Flightinstructor, Jane Q.".
420 //For a simulator I'm not sure how it would typically be described. For an aircraft, this would
421 //typically be the tail number followed by the aircraft model number, i.e. "N12345 Cessna 172P".
422 //
423 //In any case, this field is up to the discretion of the FBO, except that it cannot contain
424 //any HTML markup.
425 "rscs", "rstdtime", "varchar(48)", "", "",
426 //An array of 48 characters, each of which should be a R or a U, and corresponding to the
427 //half-hour time slots during a day. The first character corresponds to the slot between
428 //12:00 a.m. and 12:30 a.m., the second character to the time slot between 12:30 a.m. and 1:00 a.m.,
429 //etc. A "R" in the corresponding position indicates that the time slot is restricted and that
430 //there must be some interaction with the FBO to schedule the time slot. A "U" in the
431 //position indicates that the time slot may be scheduled freely. For flight instructors,
432 //this may be set up to prevent students from arbitrarily scheduling appointments in the
433 //middle of the night. For aircraft, it is unclear how this would help. For simulators, this
434 //would prevent users from scheduling the simulator when it is unavailable (such as when the
435 //building it is in is closed for business).
436 "rscs", "schedaheadhrs", "int", "", "",
437 //For a resource, the minimum number of hours that a user must schedule it ahead of time
438 //with no interaction with the FBO. There is also a similar limit in CONFIG.INC. The
439 //scheduling software uses the more restrictive (i.e. larger) of the two.
440 "rscs", "usercorres", "int", "", "",
441 //For a resource that is a flight instructor, the index of the user corresponding to the
442 //resource. For other types of resources, this will be 0.
443 "rscs", "crmodsguid", "varchar(32)", "", "",
444 //The SGUID from when the record was created or last modified. This may be used to avoid browser
445 //editing collisions. The way that collisions are avoided is that when the record is modified
446 //(perhaps by another user while a given user has the record displayed in a browser form), a new
447 //SGUID is placed in the record. When a new commit of the record is attempted, the lower-level
448 //functions will detect that the underlying SGUID has changed, as they will compare the
449 //one provided by the browser (usually stored as a hidden field) against the one currently
450 //in the database. The two will definitely be different, as SGUIDs have guaranteed uniqueness
451 //throughout the lifetime of the server.
452 //
453 //=====================================================================================================
454 //=====================================================================================================
455 //==== S E S S ======================================================================================
456 //=====================================================================================================
457 //=====================================================================================================
458 //One record for each active session. If a user does not explicitly log out or get canned for a page
459 //hit after expiry, these are reaped by cron processes.
460 //=====================================================================================================
461 "sess", "idx", "int", "AUTO_INCREMENT NOT NULL PRIMARY KEY", "",
462 //The integer index of session.
463 "sess", "usrsidx", "int", "", "",
464 //The integer index of the user with whom the session is associated.
465 "sess", "sguid", "char(32)", "", "",
466 //An SGUID created when the session is opened. This is guaranteed to be unique. This is never
467 //revealed to the client. The reason it isn't revealed is that it may be used in cases
468 //as part of a hash key.
469 "sess", "ip", "varchar(32)", "", "",
470 //The connecting IP as known to the server. This is the string provided by the server. With
471 //IPV6, there can be up to 31 characters.
472 "sess", "sid", "varchar(66)", "", "",
473 //The session identifier. This is formed when the session is opened and never changed
474 //thereafter until the session is reaped. This is provided to the user's browser as a cookie.
475 "sess", "revaltime", "char(22)", "", "",
476 //The time at which the session was created or revalidated (revalidation occurs when another page is
477 //loaded with a valid SID), expressed as a UTIME. This allows a user to continue activity
478 //and as long as there is activity the session won't expire.
479 "sess", "lifetime", "int", "", "",
480 //The lifetime of the session. This is effectively the allowed inactivity time before an automatic
481 //logout. This lifetime could, in principle, be a function of who the user is. In any case,
482 //the lifetime can be modified in some cases to give a longer time until logout (useful for
483 //line employees).
484 "sess", "loginfailures", "int", "", "",
485 //The number of consecutive times during the session that the wrong password for the userid has
486 //been entered (on pages that perform sensitive operations where the operation must be
487 //confirmed. After a certain number of consecutive bad password entries, the user is forcibly
488 //logged out. The purpose of this behavior is to allow one or two typos without trashing a
489 //user's typing in a form, but to not allow password guessing to go on indefinitely. This counter
490 //is reset back to zero on a successful correct password entry.
491 "sess", "menulvl", "int", "", "",
492 //The menu level at which the session is currently operating. "0" is the default menu level, and
493 //larger integers represent more options displayed on the menu.
494 "sess", "pagereloadtime", "int", "", "",
495 //If this value is >0, is the interval (in seconds) at which certain scheduling pages should be
496 //automatically reloaded. This is to assist line employees who might open the dayview scheduling
497 //page and want it to refresh with changes periodically.
498 "sess", "sddt", "varchar(8)", "", "",
499 //The date, as a DT8, carried through as we decide which information to display. This avoids
500 //to tacking GET parameters on everywhere. On the scheduler pages that will display with no user
501 //logged in, the GET/POST parameters take precedence over anything stored in the session
502 //state record, if any. If this doesn't apply, the empty string is stored.
503 "sess", "sdtim", "varchar(4)", "", "",
504 //The time, as a T4, carried through as we decide which information to display. This avoids
505 //to tacking GET parameters on everywhere. On the scheduler pages that will display with no user
506 //logged in, the GET/POST parameters take precedence over anything stored in the session
507 //state record, if any. If this doesn't apply, the empty string is stored.
508 "sess", "logicalpage", "int", "", "",
509 //An enumerated constant, identifying which logical page in the tree of pages is the current page.
510 //This is set on traversals by the "logpage=" GET/POST parameter. A given physical page may
511 //exist at more than location in the logical page hierarchy. The entire hierarchy is on a
512 //diagram in the documentation. If there is no current context, the value of 0 is stored.
513 "sess", "curuser", "int", "", "",
514 //The user that is currently being edited or is otherwise of interest, by the index. If there is
515 //no user of interest, zero is stored.
516 "sess", "userlistactive", "int", "", "",
517 //1 if the user list to return to is the active user list, or 0 if the list to return to is the
518 //inactive user list.
519 "sess", "curresource", "int", "", "",
520 //The resource that is currently being edited or is otherwise of interest, by the index. If there
521 //is no resource of interest, zero is stored.
522 "sess", "curreservation", "int", "", "",
523 //The reservation that is currently being edited or is otherwise of interest, by the index. If
524 //there is no reservation of interest, zero is stored.
525 //=====================================================================================================
526 //=====================================================================================================
527 //==== L O G E ======================================================================================
528 //=====================================================================================================
529 //=====================================================================================================
530 //One record for each log entry. This table should be pruned by the daily maintenance script, so that
531 //it stays a reasonable size.
532 //=====================================================================================================
533 "loge", "idx", "int", "AUTO_INCREMENT NOT NULL PRIMARY KEY", "",
534 //The integer index of the log entry. This is used for uniqueness and to give an ordering.
535 //An SGUID could also be used.
536 "loge", "type", "int", "", "",
537 //An integer (these constants are defined in log.inc and/or logview.inc) giving what type of
538 //record this is. There are many differen types.
539 "loge", "utime", "varchar(22)", "", "",
540 //A UTIME stamp gathered at the time the log entry is made. This is a definitive reference
541 //as to Unix time. If for some reason a UTIME is not available, the empty string is used.
542 "loge", "stime", "varchar(22)", "", "",
543 //An STIME stamp gathered at the time the script starts execution. Note that this time is more
544 //sloppy than the Unix time, because it is gathered at the start of the page. The UTIME
545 //above is authoritative. If there are any extremely weird problems (such as a page hanging
546 //or executing slowly, the UTIME would give more insight than this STIME.
547 "loge", "ip", "varchar(40)", "", "",
548 //The IP address as reported by the server. With IP version 6 coming up, the IP
549 //address could be over 20 characters--define it as 40 to be safe.
550 "loge", "userid", "varchar(20)", "", "",
551 //The userid of anyone authenticated at the time the entry is made. If nobody is
552 //authenticated, the empty string is used.
553 "loge", "sid", "varchar(66)", "", "",
554 //Any session identifier that was passed in by cookie or was swapped in by authentication
555 //at the time the log entry was made.
556 "loge", "scriptfile", "varchar(1024)", "", "",
557 //The main file being executed, including the path from the document root. This will be one
558 //of the main script files of FBO-Prime.
559 "loge", "getpostpars", "varchar(1024)", "", "",
560 //The GET and/or POST parameters that are relevant to the log entry.
561 "loge", "phpfilek", "varchar(1024)", "", "",
562 //The caller's value of __FILE__ when the log-making function is called.
563 "loge", "phplinek", "int", "", "",
564 //The caller's value of __LINE__ when the log-making function is called.
565 "loge", "logentry", "varchar(4000)", "", ""
566 //The text of the log entry. This adds any needed description to the event.
567 ) ;
568
569 if ($argc == 1)
570 {
571 //The no-parameters case, as expected.
572
573 $handle = mysql_connect(CONFIG_MYSQL_SERVER, CONFIG_MYSQL_USERNAME, CONFIG_MYSQL_PASSWORD);
574 $handle_copy = $handle;
575 if ($handle === FALSE)
576 {
577 echo "ERROR: Unable to connect and/or authenticate to MySQL database.\n";
578 exit(1);
579 }
580
581 $result = mysql_select_db(CONFIG_MYSQL_DATABASE, $handle);
582 if ($result === FALSE)
583 {
584 echo "ERROR: Unable to select MySQL database \"" . CONFIG_MYSQL_DATABASE . "\".\n";
585 exit(1);
586 }
587
588 populate_db($handle, $dbdesign);
589 hline();
590
591 $result = mysql_close($handle);
592 if ($result === FALSE)
593 {
594 echo "ERROR: Unable to close MySQL connection.\n";
595 exit(1);
596 }
597
598 exit(0);
599 }
600 else
601 {
602 echo "ERROR: This command accepts no command-line parameters.\n";
603 exit(1);
604 }
605
606 //If we're here, success. Per the standard Unix way of thinking
607 //say nothing. Silence means OK.
608 exit(0);
609 //
610 //--------------------------------------------------------------------------------
611 //End of $RCSfile: dbcreate.php,v $.
612 //--------------------------------------------------------------------------------
613 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25