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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (7 years, 11 months ago) by dashley
File size: 17147 byte(s)
Initial commit.
1 <?php
2 //$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/phplib/dbx.inc,v 1.3 2006/07/16 01:56:55 dashley Exp $
3 //--------------------------------------------------------------------------------------------------------------
4 //dbx.inc--FboPrime Database Functions Not Required in the Day View Scheduler
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 contains constants and functions used to operate on the MySQL database
22 //as a whole.
23 //--------------------------------------------------------------------------------------------------------------
24 require_once("db.inc");
25 require_once("usrs.inc");
26 //
27 //--------------------------------------------------------------------------------------------------------------
28 //Gathers the group of database statistics necessary for the statistics page. The database is
29 //locked for the operation to ensure consistency of the results returned.
30 //
31 //An associative array is returned with the following elements (all integers).
32 // loge : Number of elements in loge table.
33 // logemaxidx : Maximum index from the loge table.
34 // resv : Number of elements in resv table.
35 // rscs : Number of elements in resources table.
36 // sess : Number of elements in sess table.
37 // usrs : Number of elements in usrs table.
38 // usrsactive : Active users.
39 // usrsinactive : Inactive users.
40 // usrsmale : Male users, both active and inactive.
41 // usrsfemale : Female users, both active and inactive.
42 // usrssexunspecifed : Users with gender unspecified.
43 // usrsmaleactive : Male users, active.
44 // usrsmaleinactive : Male users, inactive.
45 // usrsfemaleactive : Female users, active.
46 // usrsfemaleinactive : Female users, inactive.
47 // usrssexunspecifiedactive : Users with gender unspecified, active.
48 // usrssexunspecifiedinactive : Users with gender unspecified, inactive.
49 //
50 function DB_stats_statspage_01()
51 {
52 global $GLOBAL_dblocked;
53 global $GLOBAL_dbhandle;
54
55 //Lock the database to ensure consistent snapshot statistics.
56 $db_was_locked = $GLOBAL_dblocked;
57 if (! $GLOBAL_dblocked)
58 {
59 DB_db_lock();
60 $GLOBAL_dblocked = TRUE;
61 }
62
63 //-----------------------------------------------
64 //loge
65 //
66 $query_string = "SELECT COUNT(*) FROM loge";
67
68 $result = mysql_query($query_string, $GLOBAL_dbhandle);
69
70 if ($result === FALSE)
71 {
72 //Unknown query failure. Return 0.
73 $rv["loge"] = 0;
74 }
75 else
76 {
77 if (mysql_num_rows($result) > 0)
78 {
79 $row = mysql_fetch_array($result, MYSQL_NUM);
80 $rv["loge"] = $row[0];
81 }
82 else
83 {
84 //Unexplained why this query would return no rows.
85 $rv["loge"] = 0;
86 }
87
88 mysql_free_result($result);
89 }
90
91 //-----------------------------------------------
92 //logemaxidx
93 //
94 $query_string = "SELECT MAX(idx) FROM loge";
95
96 $result = mysql_query($query_string, $GLOBAL_dbhandle);
97
98 if ($result === FALSE)
99 {
100 //Unknown query failure. Return 0.
101 $rv["logemaxidx"] = 0;
102 }
103 else
104 {
105 if (mysql_num_rows($result) > 0)
106 {
107 $row = mysql_fetch_array($result, MYSQL_NUM);
108 $rv["logemaxidx"] = $row[0];
109 }
110 else
111 {
112 //Unexplained why this query would return no rows.
113 $rv["logemaxidx"] = 0;
114 }
115
116 mysql_free_result($result);
117 }
118
119 //-----------------------------------------------
120 //resv
121 //
122 $query_string = "SELECT COUNT(*) FROM resv";
123
124 $result = mysql_query($query_string, $GLOBAL_dbhandle);
125
126 if ($result === FALSE)
127 {
128 //Unknown query failure. Return 0.
129 $rv["resv"] = 0;
130 }
131 else
132 {
133 if (mysql_num_rows($result) > 0)
134 {
135 $row = mysql_fetch_array($result, MYSQL_NUM);
136 $rv["resv"] = $row[0];
137 }
138 else
139 {
140 //Unexplained why this query would return no rows.
141 $rv["resv"] = 0;
142 }
143
144 mysql_free_result($result);
145 }
146
147 //-----------------------------------------------
148 //rscs
149 //
150 $query_string = "SELECT COUNT(*) FROM rscs";
151
152 $result = mysql_query($query_string, $GLOBAL_dbhandle);
153
154 if ($result === FALSE)
155 {
156 //Unknown query failure. Return 0.
157 $rv["rscs"] = 0;
158 }
159 else
160 {
161 if (mysql_num_rows($result) > 0)
162 {
163 $row = mysql_fetch_array($result, MYSQL_NUM);
164 $rv["rscs"] = $row[0];
165 }
166 else
167 {
168 //Unexplained why this query would return no rows.
169 $rv["rscs"] = 0;
170 }
171
172 mysql_free_result($result);
173 }
174
175 //-----------------------------------------------
176 //sess
177 //
178 $query_string = "SELECT COUNT(*) FROM sess";
179
180 $result = mysql_query($query_string, $GLOBAL_dbhandle);
181
182 if ($result === FALSE)
183 {
184 //Unknown query failure. Return 0.
185 $rv["sess"] = 0;
186 }
187 else
188 {
189 if (mysql_num_rows($result) > 0)
190 {
191 $row = mysql_fetch_array($result, MYSQL_NUM);
192 $rv["sess"] = $row[0];
193 }
194 else
195 {
196 //Unexplained why this query would return no rows.
197 $rv["sess"] = 0;
198 }
199
200 mysql_free_result($result);
201 }
202
203 //-----------------------------------------------
204 //usrs
205 //
206 $query_string = "SELECT COUNT(*) FROM usrs";
207
208 $result = mysql_query($query_string, $GLOBAL_dbhandle);
209
210 if ($result === FALSE)
211 {
212 //Unknown query failure. Return 0.
213 $rv["usrs"] = 0;
214 }
215 else
216 {
217 if (mysql_num_rows($result) > 0)
218 {
219 $row = mysql_fetch_array($result, MYSQL_NUM);
220 $rv["usrs"] = $row[0];
221 }
222 else
223 {
224 //Unexplained why this query would return no rows.
225 $rv["usrs"] = 0;
226 }
227
228 mysql_free_result($result);
229 }
230
231 //-----------------------------------------------
232 //usrsactive
233 //
234 $query_string = "SELECT COUNT(*) FROM usrs WHERE status=\"" . (string)USRS_STATUS_ACTIVE . "\"";
235
236 $result = mysql_query($query_string, $GLOBAL_dbhandle);
237
238 if ($result === FALSE)
239 {
240 //Unknown query failure. Return 0.
241 $rv["usrsactive"] = 0;
242 }
243 else
244 {
245 if (mysql_num_rows($result) > 0)
246 {
247 $row = mysql_fetch_array($result, MYSQL_NUM);
248 $rv["usrsactive"] = $row[0];
249 }
250 else
251 {
252 //Unexplained why this query would return no rows.
253 $rv["usrsactive"] = 0;
254 }
255
256 mysql_free_result($result);
257 }
258
259 //-----------------------------------------------
260 //usrsinactive
261 //
262 $query_string = "SELECT COUNT(*) FROM usrs WHERE status=\"" . (string)USRS_STATUS_INACTIVE . "\"";
263
264 $result = mysql_query($query_string, $GLOBAL_dbhandle);
265
266 if ($result === FALSE)
267 {
268 //Unknown query failure. Return 0.
269 $rv["usrsinactive"] = 0;
270 }
271 else
272 {
273 if (mysql_num_rows($result) > 0)
274 {
275 $row = mysql_fetch_array($result, MYSQL_NUM);
276 $rv["usrsinactive"] = $row[0];
277 }
278 else
279 {
280 //Unexplained why this query would return no rows.
281 $rv["usrsinactive"] = 0;
282 }
283
284 mysql_free_result($result);
285 }
286
287 //-----------------------------------------------
288 //usrsmale
289 //
290 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_MALE . "\"";
291
292 $result = mysql_query($query_string, $GLOBAL_dbhandle);
293
294 if ($result === FALSE)
295 {
296 //Unknown query failure. Return 0.
297 $rv["usrsmale"] = 0;
298 }
299 else
300 {
301 if (mysql_num_rows($result) > 0)
302 {
303 $row = mysql_fetch_array($result, MYSQL_NUM);
304 $rv["usrsmale"] = $row[0];
305 }
306 else
307 {
308 //Unexplained why this query would return no rows.
309 $rv["usrsmale"] = 0;
310 }
311
312 mysql_free_result($result);
313 }
314
315 //-----------------------------------------------
316 //usrsfemale
317 //
318 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_FEMALE . "\"";
319
320 $result = mysql_query($query_string, $GLOBAL_dbhandle);
321
322 if ($result === FALSE)
323 {
324 //Unknown query failure. Return 0.
325 $rv["usrsfemale"] = 0;
326 }
327 else
328 {
329 if (mysql_num_rows($result) > 0)
330 {
331 $row = mysql_fetch_array($result, MYSQL_NUM);
332 $rv["usrsfemale"] = $row[0];
333 }
334 else
335 {
336 //Unexplained why this query would return no rows.
337 $rv["usrsfemale"] = 0;
338 }
339
340 mysql_free_result($result);
341 }
342
343 //-----------------------------------------------
344 //usrssexunspecified
345 //
346 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_UNSPECIFIED . "\"";
347
348 $result = mysql_query($query_string, $GLOBAL_dbhandle);
349
350 if ($result === FALSE)
351 {
352 //Unknown query failure. Return 0.
353 $rv["usrssecunspecified"] = 0;
354 }
355 else
356 {
357 if (mysql_num_rows($result) > 0)
358 {
359 $row = mysql_fetch_array($result, MYSQL_NUM);
360 $rv["usrssexunspecified"] = $row[0];
361 }
362 else
363 {
364 //Unexplained why this query would return no rows.
365 $rv["usrssexunspecified"] = 0;
366 }
367
368 mysql_free_result($result);
369 }
370
371 //-----------------------------------------------
372 //usrsmaleactive
373 //
374 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_MALE
375 . "\" AND status=\"" . (string)USRS_STATUS_ACTIVE . "\"";
376
377 $result = mysql_query($query_string, $GLOBAL_dbhandle);
378
379 if ($result === FALSE)
380 {
381 //Unknown query failure. Return 0.
382 $rv["usrsmaleactive"] = 0;
383 }
384 else
385 {
386 if (mysql_num_rows($result) > 0)
387 {
388 $row = mysql_fetch_array($result, MYSQL_NUM);
389 $rv["usrsmaleactive"] = $row[0];
390 }
391 else
392 {
393 //Unexplained why this query would return no rows.
394 $rv["usrsmaleactive"] = 0;
395 }
396
397 mysql_free_result($result);
398 }
399
400 //-----------------------------------------------
401 //usrsfemaleactive
402 //
403 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_FEMALE
404 . "\" AND status=\"" . (string)USRS_STATUS_ACTIVE . "\"";
405
406 $result = mysql_query($query_string, $GLOBAL_dbhandle);
407
408 if ($result === FALSE)
409 {
410 //Unknown query failure. Return 0.
411 $rv["usrsfemaleactive"] = 0;
412 }
413 else
414 {
415 if (mysql_num_rows($result) > 0)
416 {
417 $row = mysql_fetch_array($result, MYSQL_NUM);
418 $rv["usrsfemaleactive"] = $row[0];
419 }
420 else
421 {
422 //Unexplained why this query would return no rows.
423 $rv["usrsfemaleactive"] = 0;
424 }
425
426 mysql_free_result($result);
427 }
428
429 //-----------------------------------------------
430 //usrssexunspecifiedactive
431 //
432 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_UNSPECIFIED
433 . "\" AND status=\"" . (string)USRS_STATUS_ACTIVE . "\"";
434
435 $result = mysql_query($query_string, $GLOBAL_dbhandle);
436
437 if ($result === FALSE)
438 {
439 //Unknown query failure. Return 0.
440 $rv["usrssexunspecifiedactive"] = 0;
441 }
442 else
443 {
444 if (mysql_num_rows($result) > 0)
445 {
446 $row = mysql_fetch_array($result, MYSQL_NUM);
447 $rv["usrssexunspecifiedactive"] = $row[0];
448 }
449 else
450 {
451 //Unexplained why this query would return no rows.
452 $rv["usrssexunspecifiedactive"] = 0;
453 }
454
455 mysql_free_result($result);
456 }
457
458 //-----------------------------------------------
459 //usrsmaleinactive
460 //
461 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_MALE
462 . "\" AND status=\"" . (string)USRS_STATUS_INACTIVE . "\"";
463
464 $result = mysql_query($query_string, $GLOBAL_dbhandle);
465
466 if ($result === FALSE)
467 {
468 //Unknown query failure. Return 0.
469 $rv["usrsmaleinactive"] = 0;
470 }
471 else
472 {
473 if (mysql_num_rows($result) > 0)
474 {
475 $row = mysql_fetch_array($result, MYSQL_NUM);
476 $rv["usrsmaleinactive"] = $row[0];
477 }
478 else
479 {
480 //Unexplained why this query would return no rows.
481 $rv["usrsmaleinactive"] = 0;
482 }
483
484 mysql_free_result($result);
485 }
486
487 //-----------------------------------------------
488 //usrsfemaleinactive
489 //
490 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_FEMALE
491 . "\" AND status=\"" . (string)USRS_STATUS_INACTIVE . "\"";
492
493 $result = mysql_query($query_string, $GLOBAL_dbhandle);
494
495 if ($result === FALSE)
496 {
497 //Unknown query failure. Return 0.
498 $rv["usrsfemaleinactive"] = 0;
499 }
500 else
501 {
502 if (mysql_num_rows($result) > 0)
503 {
504 $row = mysql_fetch_array($result, MYSQL_NUM);
505 $rv["usrsfemaleinactive"] = $row[0];
506 }
507 else
508 {
509 //Unexplained why this query would return no rows.
510 $rv["usrsfemaleinactive"] = 0;
511 }
512
513 mysql_free_result($result);
514 }
515
516 //-----------------------------------------------
517 //usrssexunspecifiedinactive
518 //
519 $query_string = "SELECT COUNT(*) FROM usrs WHERE sex=\"" . (string)USRS_SEX_UNSPECIFIED
520 . "\" AND status=\"" . (string)USRS_STATUS_INACTIVE . "\"";
521
522 $result = mysql_query($query_string, $GLOBAL_dbhandle);
523
524 if ($result === FALSE)
525 {
526 //Unknown query failure. Return 0.
527 $rv["usrssexunspecifiedinactive"] = 0;
528 }
529 else
530 {
531 if (mysql_num_rows($result) > 0)
532 {
533 $row = mysql_fetch_array($result, MYSQL_NUM);
534 $rv["usrssexunspecifiedinactive"] = $row[0];
535 }
536 else
537 {
538 //Unexplained why this query would return no rows.
539 $rv["usrssexunspecifiedinactive"] = 0;
540 }
541
542 mysql_free_result($result);
543 }
544
545 //-----------------------------------------------
546 //Unlock the database.
547 //
548 if (! $db_was_locked)
549 {
550 DB_db_unlock();
551 $GLOBAL_dblocked = FALSE;
552 }
553
554 //Return the return value.
555 return($rv);
556 }
557 //--------------------------------------------------------------------------------------------------------------
558 //Parses an input argument to be sure it is a suitable short index for a table. "zna" = Zero is not allowed.
559 // This means it must be either:
560 // a)A positive integer.
561 // b)A string representing a positive integer <= (2^32 - 1).
562 //
563 //Returns TRUE if valid or FALSE if not.
564 //
565 function DB_table_index_short_validity_check_zna($idx_in)
566 {
567 if (is_int($idx_in))
568 {
569 if ($idx_in > 0)
570 {
571 return(TRUE);
572 }
573 else
574 {
575 return(FALSE);
576 }
577 }
578 else if (is_string($idx_in))
579 {
580 $temp = intval($idx_in);
581
582 if ($temp === FALSE)
583 {
584 return(FALSE);
585 }
586 else if ($temp > 0)
587 {
588 return(TRUE);
589 }
590 else
591 {
592 return(FALSE);
593 }
594 }
595 else
596 {
597 //Unknown type.
598 return(FALSE);
599 }
600 }
601 //--------------------------------------------------------------------------------------------------------------
602 //End of $RCSfile: dbx.inc,v $.
603 //--------------------------------------------------------------------------------------------------------------
604 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25