1
|
<?php
|
2
|
|
3
|
// $Id: class.wb.php 11 2005-09-04 09:20:29Z ryan $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2005, Ryan Djurovich
|
9
|
|
10
|
Website Baker is free software; you can redistribute it and/or modify
|
11
|
it under the terms of the GNU General Public License as published by
|
12
|
the Free Software Foundation; either version 2 of the License, or
|
13
|
(at your option) any later version.
|
14
|
|
15
|
Website Baker is distributed in the hope that it will be useful,
|
16
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
GNU General Public License for more details.
|
19
|
|
20
|
You should have received a copy of the GNU General Public License
|
21
|
along with Website Baker; if not, write to the Free Software
|
22
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
|
24
|
*/
|
25
|
|
26
|
/*
|
27
|
|
28
|
wb class
|
29
|
|
30
|
This class is the basis for admin and frontend classes.
|
31
|
|
32
|
*/
|
33
|
|
34
|
|
35
|
class wb
|
36
|
{
|
37
|
function wb() {
|
38
|
}
|
39
|
|
40
|
// Check whether we should show a page or not (for front-end)
|
41
|
function show_page($page) {
|
42
|
// First check if the page is set to private
|
43
|
if($page['visibility'] == 'private' OR $page['visibility'] == 'registered') {
|
44
|
// Check if the user is logged in
|
45
|
if($this->is_authenticated() == true) {
|
46
|
// Now check if the user has perms to view it
|
47
|
$viewing_groups = explode(',', $page['viewing_groups']);
|
48
|
$viewing_users = explode(',', $page['viewing_users']);
|
49
|
if(is_numeric(array_search($this->get_group_id(), $viewing_groups)) OR is_numeric(array_search($this->get_user_id(), $viewing_users))) {
|
50
|
return true;
|
51
|
} else {
|
52
|
return false;
|
53
|
}
|
54
|
} else {
|
55
|
return false;
|
56
|
}
|
57
|
} elseif($page['visibility'] == 'public') {
|
58
|
return true;
|
59
|
} else {
|
60
|
return false;
|
61
|
}
|
62
|
}
|
63
|
|
64
|
// Check if the user is already authenticated or not
|
65
|
function is_authenticated() {
|
66
|
if(isset($_SESSION['USER_ID']) AND $_SESSION['USER_ID'] != "" AND is_numeric($_SESSION['USER_ID'])) {
|
67
|
return true;
|
68
|
} else {
|
69
|
return false;
|
70
|
}
|
71
|
}
|
72
|
|
73
|
// Get POST data
|
74
|
function get_post($field) {
|
75
|
if(isset($_POST[$field])) {
|
76
|
return $_POST[$field];
|
77
|
} else {
|
78
|
return null;
|
79
|
}
|
80
|
}
|
81
|
|
82
|
// Get GET data
|
83
|
function get_get($field) {
|
84
|
if(isset($_GET[$field])) {
|
85
|
return $_GET[$field];
|
86
|
} else {
|
87
|
return null;
|
88
|
}
|
89
|
}
|
90
|
|
91
|
// Get SESSION data
|
92
|
function get_session($field) {
|
93
|
if(isset($_SESSION[$field])) {
|
94
|
return $_SESSION[$field];
|
95
|
} else {
|
96
|
return null;
|
97
|
}
|
98
|
}
|
99
|
|
100
|
// Get SERVER data
|
101
|
function get_server($field) {
|
102
|
if(isset($_SERVER[$field])) {
|
103
|
return $_SERVER[$field];
|
104
|
} else {
|
105
|
return null;
|
106
|
}
|
107
|
}
|
108
|
|
109
|
// Get the current users id
|
110
|
function get_user_id() {
|
111
|
return $_SESSION['USER_ID'];
|
112
|
}
|
113
|
|
114
|
// Get the current users group id
|
115
|
function get_group_id() {
|
116
|
return $_SESSION['GROUP_ID'];
|
117
|
}
|
118
|
|
119
|
// Get the current users group name
|
120
|
function get_group_name() {
|
121
|
return $_SESSION['GROUP_NAME'];
|
122
|
}
|
123
|
|
124
|
// Get the current users username
|
125
|
function get_username() {
|
126
|
return $_SESSION['USERNAME'];
|
127
|
}
|
128
|
|
129
|
// Get the current users display name
|
130
|
function get_display_name() {
|
131
|
return stripslashes($_SESSION['DISPLAY_NAME']);
|
132
|
}
|
133
|
|
134
|
// Get the current users email address
|
135
|
function get_email() {
|
136
|
return $_SESSION['EMAIL'];
|
137
|
}
|
138
|
|
139
|
// Get the current users home folder
|
140
|
function get_home_folder() {
|
141
|
return $_SESSION['HOME_FOLDER'];
|
142
|
}
|
143
|
|
144
|
// Get the current users timezone
|
145
|
function get_timezone() {
|
146
|
if(!isset($_SESSION['USE_DEFAULT_TIMEZONE'])) {
|
147
|
return $_SESSION['TIMEZONE'];
|
148
|
} else {
|
149
|
return '-72000';
|
150
|
}
|
151
|
}
|
152
|
|
153
|
// Validate supplied email address
|
154
|
function validate_email($email) {
|
155
|
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
|
156
|
return true;
|
157
|
} else {
|
158
|
return false;
|
159
|
}
|
160
|
}
|
161
|
|
162
|
|
163
|
}
|
164
|
?>
|