1 |
<?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 |
var $db_ac = "libdata"; |
21 |
var $db_ac_srv = "localhost"; |
22 |
var $db_ac_usr = "libdata"; |
23 |
var $db_ac_pwd = "libdatapw"; |
24 |
|
25 |
/********************************************************** |
26 |
Constructor Method: accessClass |
27 |
Author: Paul Bramscher |
28 |
Last Modified: 10.09.2002 |
29 |
*********************************************************** |
30 |
Comments: |
31 |
Sets the properties. |
32 |
**********************************************************/ |
33 |
function accessClass($sessionClass) { |
34 |
|
35 |
// Set the database connection variables |
36 |
$this->con_ac = @mysql_connect ( $this->db_ac_srv, $this->db_ac_usr, $this->db_ac_pwd ) |
37 |
or die ( "ERROR: Could not connect to database server!" ); |
38 |
$this->result_ac = mysql_select_db ( $this->db_ac, $this->con_ac ) |
39 |
or die ( "ERROR: Could not connect to database!" ); |
40 |
|
41 |
|
42 |
// Initialize for security purposes |
43 |
$valid = 0; |
44 |
$access_level = 0; |
45 |
$access = ""; |
46 |
$current_ip = ""; |
47 |
$user_ip = ""; |
48 |
$first_name = ""; |
49 |
$last_name = ""; |
50 |
$staff_id = 0; |
51 |
|
52 |
// Fetch current user ip |
53 |
$current_ip = $GLOBALS["REMOTE_ADDR"]; |
54 |
|
55 |
// Pull out some properties from the incoming sessionClass object |
56 |
$valid = $sessionClass->valid; |
57 |
$staff_account = $sessionClass->staff_account; |
58 |
$user_ip = $sessionClass->user_ip; |
59 |
|
60 |
// Look the user up in staff table |
61 |
if ($valid > 0 && strlen($staff_account) > 0 && $current_ip == $user_ip) { |
62 |
$sql = "SELECT a.access_level, a.access, s.staff_id, s.last_name, s.first_name |
63 |
FROM staff s, access a WHERE s.access_id = a.access_id AND s.staff_account = '" |
64 |
. $staff_account |
65 |
. "'"; |
66 |
$rs = mysql_query($sql, $this->con_ac); |
67 |
$row = mysql_fetch_array ($rs); |
68 |
$access_level = $row["access_level"]; |
69 |
$access = $row["access"]; |
70 |
$first_name = $row["first_name"]; |
71 |
$last_name = $row["last_name"]; |
72 |
$staff_id = $row["staff_id"]; |
73 |
|
74 |
// Set valid equal to the access level |
75 |
$valid = $access_level; |
76 |
|
77 |
} |
78 |
|
79 |
|
80 |
// Set the object properties |
81 |
$this->setProperties($access, $first_name, $last_name, $staff_id, $valid); |
82 |
|
83 |
} |
84 |
|
85 |
|
86 |
/********************************************************** |
87 |
Method: bailout |
88 |
Author: Paul Bramscher |
89 |
Last Modified: 10.04.2001 |
90 |
*********************************************************** |
91 |
Comments: |
92 |
Attempt to gracefully finish out HTML in the event of a |
93 |
severe mySQL database problem. |
94 |
**********************************************************/ |
95 |
function bailout() { |
96 |
die ( "Bailing Out!<br>\n</body></html>\n" ); |
97 |
} |
98 |
|
99 |
|
100 |
/********************************************************** |
101 |
Method: setProperties |
102 |
Author: Paul Bramscher |
103 |
Last Modified: 10.09.2002 |
104 |
*********************************************************** |
105 |
Comments: |
106 |
This member function sets the $access_level, $time_human, |
107 |
$user_up, and $staff_account properties of an instantiation of the |
108 |
credentialsClass object. It is called whenever the class is |
109 |
instantiated. |
110 |
**********************************************************/ |
111 |
function setProperties($access, $first_name, $last_name, $staff_id, $valid) { |
112 |
|
113 |
// Valid session, load all of the member properties. |
114 |
if ($valid > 0) { |
115 |
$this->access_level = $valid; |
116 |
$this->access = $access; |
117 |
$this->first_name = $first_name; |
118 |
$this->last_name = $last_name; |
119 |
$this->staff_id = $staff_id; |
120 |
} |
121 |
// Expired or invalid. Reset all of the member properties. |
122 |
else { |
123 |
$this->access_level = 0; |
124 |
$this->access = ""; |
125 |
$this->first_name = ""; |
126 |
$this->last_name = ""; |
127 |
$this->staff_id = 0; |
128 |
} |
129 |
} |
130 |
|
131 |
} // end of class |
132 |
?> |