1 |
dpavlin |
31 |
<?php |
2 |
|
|
class accessClass { |
3 |
|
|
|
4 |
|
|
/********************************************************** |
5 |
|
|
accessClass Properties |
6 |
|
|
Author: Paul Bramscher |
7 |
|
|
Last Modified: 05.05.2003 |
8 |
|
|
*********************************************************** |
9 |
|
|
Comments: |
10 |
|
|
For documentation, see separate Word-format .DOC file. |
11 |
|
|
**********************************************************/ |
12 |
|
|
var $access_level; |
13 |
|
|
var $access; |
14 |
|
|
var $first_name; |
15 |
|
|
var $last_name; |
16 |
|
|
var $staff_id; |
17 |
|
|
|
18 |
|
|
|
19 |
|
|
// Database variables |
20 |
dpavlin |
50 |
#var $access_dsn = 'mysql://libdata:libdatapw@localhost/libdata'; |
21 |
|
|
var $access_dsn = 'pgsql://dpavlin@/libdata'; |
22 |
dpavlin |
31 |
|
23 |
|
|
/********************************************************** |
24 |
|
|
Constructor Method: accessClass |
25 |
|
|
Author: Paul Bramscher |
26 |
|
|
Last Modified: 10.09.2002 |
27 |
|
|
*********************************************************** |
28 |
|
|
Comments: |
29 |
|
|
Sets the properties. |
30 |
|
|
**********************************************************/ |
31 |
|
|
function accessClass($sessionClass) { |
32 |
|
|
|
33 |
|
|
// Set the database connection variables |
34 |
dpavlin |
50 |
global $dsn_options; |
35 |
|
|
$this->con_ac =& DB::connect($this->access_dsn, $dsn_options); |
36 |
|
|
if (DB::isError($db)) { |
37 |
|
|
# XXX remove this! |
38 |
|
|
print $db->getDebugInfo(); |
39 |
|
|
|
40 |
|
|
die($db->getMessage()); |
41 |
|
|
} |
42 |
dpavlin |
31 |
|
43 |
|
|
// Initialize for security purposes |
44 |
|
|
$valid = 0; |
45 |
|
|
$access_level = 0; |
46 |
|
|
$access = ""; |
47 |
|
|
$current_ip = ""; |
48 |
|
|
$user_ip = ""; |
49 |
|
|
$first_name = ""; |
50 |
|
|
$last_name = ""; |
51 |
|
|
$staff_id = 0; |
52 |
|
|
|
53 |
|
|
// Fetch current user ip |
54 |
|
|
$current_ip = $GLOBALS["REMOTE_ADDR"]; |
55 |
|
|
|
56 |
|
|
// Pull out some properties from the incoming sessionClass object |
57 |
|
|
$valid = $sessionClass->valid; |
58 |
|
|
$staff_account = $sessionClass->staff_account; |
59 |
|
|
$user_ip = $sessionClass->user_ip; |
60 |
|
|
|
61 |
|
|
// Look the user up in staff table |
62 |
|
|
if ($valid > 0 && strlen($staff_account) > 0 && $current_ip == $user_ip) { |
63 |
|
|
$sql = "SELECT a.access_level, a.access, s.staff_id, s.last_name, s.first_name |
64 |
|
|
FROM staff s, access a WHERE s.access_id = a.access_id AND s.staff_account = '" |
65 |
|
|
. $staff_account |
66 |
|
|
. "'"; |
67 |
dpavlin |
50 |
$rs = xx_query($sql, $this->con_ac); |
68 |
|
|
$row = xx_fetch_array ($rs); |
69 |
dpavlin |
31 |
$access_level = $row["access_level"]; |
70 |
|
|
$access = $row["access"]; |
71 |
|
|
$first_name = $row["first_name"]; |
72 |
|
|
$last_name = $row["last_name"]; |
73 |
|
|
$staff_id = $row["staff_id"]; |
74 |
|
|
|
75 |
|
|
// Set valid equal to the access level |
76 |
|
|
$valid = $access_level; |
77 |
|
|
|
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
|
81 |
|
|
// Set the object properties |
82 |
|
|
$this->setProperties($access, $first_name, $last_name, $staff_id, $valid); |
83 |
|
|
|
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
|
87 |
|
|
/********************************************************** |
88 |
|
|
Method: bailout |
89 |
|
|
Author: Paul Bramscher |
90 |
|
|
Last Modified: 10.04.2001 |
91 |
|
|
*********************************************************** |
92 |
|
|
Comments: |
93 |
|
|
Attempt to gracefully finish out HTML in the event of a |
94 |
|
|
severe mySQL database problem. |
95 |
|
|
**********************************************************/ |
96 |
|
|
function bailout() { |
97 |
|
|
die ( "Bailing Out!<br>\n</body></html>\n" ); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
|
101 |
|
|
/********************************************************** |
102 |
|
|
Method: setProperties |
103 |
|
|
Author: Paul Bramscher |
104 |
|
|
Last Modified: 10.09.2002 |
105 |
|
|
*********************************************************** |
106 |
|
|
Comments: |
107 |
|
|
This member function sets the $access_level, $time_human, |
108 |
|
|
$user_up, and $staff_account properties of an instantiation of the |
109 |
|
|
credentialsClass object. It is called whenever the class is |
110 |
|
|
instantiated. |
111 |
|
|
**********************************************************/ |
112 |
|
|
function setProperties($access, $first_name, $last_name, $staff_id, $valid) { |
113 |
|
|
|
114 |
|
|
// Valid session, load all of the member properties. |
115 |
|
|
if ($valid > 0) { |
116 |
|
|
$this->access_level = $valid; |
117 |
|
|
$this->access = $access; |
118 |
|
|
$this->first_name = $first_name; |
119 |
|
|
$this->last_name = $last_name; |
120 |
|
|
$this->staff_id = $staff_id; |
121 |
|
|
} |
122 |
|
|
// Expired or invalid. Reset all of the member properties. |
123 |
|
|
else { |
124 |
|
|
$this->access_level = 0; |
125 |
|
|
$this->access = ""; |
126 |
|
|
$this->first_name = ""; |
127 |
|
|
$this->last_name = ""; |
128 |
|
|
$this->staff_id = 0; |
129 |
|
|
} |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
} // end of class |
133 |
|
|
?> |