Revision 5
Added by stefan about 20 years ago
| class.admin.php | ||
|---|---|---|
| 32 | 32 |
|
| 33 | 33 |
*/ |
| 34 | 34 |
|
| 35 |
// Stop this file from being accessed directly |
|
| 36 |
if(!defined('WB_PATH')) { exit('Direct access to this file is not allowed'); }
|
|
| 37 | 35 |
|
| 38 |
// Say that this file has been loaded |
|
| 39 |
define('ADMIN_CLASS_LOADED', true);
|
|
| 40 |
|
|
| 41 |
// Load the other required class files if they are not already loaded |
|
| 42 |
require_once(WB_PATH.'/framework/class.database.php'); |
|
| 43 |
if(!isset($database)) {
|
|
| 44 |
$database = new database(); |
|
| 45 |
} |
|
| 46 | 36 |
|
| 37 |
require_once(WB_PATH.'/framework/class.wb.php'); |
|
| 38 |
|
|
| 39 |
require_once(WB_PATH.'/framework/initialize.php'); |
|
| 40 |
|
|
| 47 | 41 |
// Include PHPLIB template class |
| 48 | 42 |
require_once(WB_PATH."/include/phplib/template.inc"); |
| 49 | 43 |
|
| 50 |
// Start a session |
|
| 51 |
if(!defined('SESSION_STARTED')) {
|
|
| 52 |
session_name(APP_NAME.'_session_id'); |
|
| 53 |
session_start(); |
|
| 54 |
define('SESSION_STARTED', true);
|
|
| 55 |
} |
|
| 56 | 44 |
|
| 57 | 45 |
// Get WB version |
| 58 | 46 |
require_once(ADMIN_PATH.'/interface/version.php'); |
| ... | ... | |
| 60 | 48 |
/* |
| 61 | 49 |
Begin user changeable settings |
| 62 | 50 |
*/ |
| 63 |
if(!defined('FRONTEND_LOADED')) {
|
|
| 64 |
// Get users language |
|
| 65 |
if(!defined('LANGUAGE')) {
|
|
| 66 |
if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
|
|
| 67 |
define('LANGUAGE', $_SESSION['LANGUAGE']);
|
|
| 68 |
} else {
|
|
| 69 |
define('LANGUAGE', DEFAULT_LANGUAGE);
|
|
| 70 |
} |
|
| 71 |
} |
|
| 72 |
// Get users timezone |
|
| 73 |
if(!defined('TIMEZONE')) {
|
|
| 74 |
if(isset($_SESSION['TIMEZONE'])) {
|
|
| 75 |
define('TIMEZONE', $_SESSION['TIMEZONE']);
|
|
| 76 |
} else {
|
|
| 77 |
define('TIMEZONE', DEFAULT_TIMEZONE);
|
|
| 78 |
} |
|
| 79 |
} |
|
| 80 |
// Get users date format |
|
| 81 |
if(!defined('DATE_FORMAT')) {
|
|
| 82 |
if(isset($_SESSION['DATE_FORMAT'])) {
|
|
| 83 |
define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
|
|
| 84 |
} else {
|
|
| 85 |
define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
|
|
| 86 |
} |
|
| 87 |
} |
|
| 88 |
// Get users time format |
|
| 89 |
if(!defined('TIME_FORMAT')) {
|
|
| 90 |
if(isset($_SESSION['TIME_FORMAT'])) {
|
|
| 91 |
define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
|
|
| 92 |
} else {
|
|
| 93 |
define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
|
|
| 94 |
} |
|
| 95 |
} |
|
| 96 |
// Load the language file |
|
| 97 |
if(!defined('LANGUAGE_LOADED')) {
|
|
| 98 |
if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
|
|
| 99 |
exit('Error loading language file '.LANGUAGE.', please check configuration');
|
|
| 100 |
} else {
|
|
| 101 |
require(WB_PATH.'/languages/'.LANGUAGE.'.php'); |
|
| 102 |
} |
|
| 103 |
} |
|
| 104 |
} |
|
| 105 |
/* |
|
| 106 |
End user changeable settings |
|
| 107 |
*/ |
|
| 108 | 51 |
|
| 109 |
class admin {
|
|
| 52 |
class admin extends wb {
|
|
| 110 | 53 |
// Authenticate user then auto print the header |
| 111 | 54 |
function admin($section_name, $section_permission = 'start', $auto_header = true, $auto_auth = true) {
|
| 112 | 55 |
global $MESSAGE; |
| ... | ... | |
| 229 | 172 |
} |
| 230 | 173 |
exit(); |
| 231 | 174 |
} |
| 232 |
|
|
| 175 |
|
|
| 233 | 176 |
// Return a system permission |
| 234 | 177 |
function get_permission($name, $type = 'system') {
|
| 235 | 178 |
// Append to permission type |
| ... | ... | |
| 260 | 203 |
} |
| 261 | 204 |
} |
| 262 | 205 |
} |
| 263 |
|
|
| 206 |
|
|
| 264 | 207 |
// Returns a system permission for a menu link |
| 265 | 208 |
function get_link_permission($title) {
|
| 266 | 209 |
$title = str_replace('_blank', '', $title);
|
| ... | ... | |
| 280 | 223 |
} |
| 281 | 224 |
} |
| 282 | 225 |
} |
| 283 |
|
|
| 284 |
// Check whether we should show a page or not (for front-end) |
|
| 285 |
function show_page($page) {
|
|
| 286 |
// First check if the page is set to private |
|
| 287 |
if($page['visibility'] == 'private' OR $page['visibility'] == 'registered') {
|
|
| 288 |
// Check if the user is logged in |
|
| 289 |
if($this->is_authenticated() == true) {
|
|
| 290 |
// Now check if the user has perms to view it |
|
| 291 |
$viewing_groups = explode(',', $page['viewing_groups']);
|
|
| 292 |
$viewing_users = explode(',', $page['viewing_users']);
|
|
| 293 |
if(is_numeric(array_search($this->get_group_id(), $viewing_groups)) OR is_numeric(array_search($this->get_user_id(), $viewing_users))) {
|
|
| 294 |
return true; |
|
| 295 |
} else {
|
|
| 296 |
return false; |
|
| 297 |
} |
|
| 298 |
} else {
|
|
| 299 |
return false; |
|
| 300 |
} |
|
| 301 |
} elseif($page['visibility'] == 'public') {
|
|
| 302 |
return true; |
|
| 303 |
} else {
|
|
| 304 |
return false; |
|
| 305 |
} |
|
| 306 |
} |
|
| 307 |
|
|
| 308 |
// Check if the user is already authenticated or not |
|
| 309 |
function is_authenticated() {
|
|
| 310 |
if(isset($_SESSION['USER_ID']) AND $_SESSION['USER_ID'] != "" AND is_numeric($_SESSION['USER_ID'])) {
|
|
| 311 |
return true; |
|
| 312 |
} else {
|
|
| 313 |
return false; |
|
| 314 |
} |
|
| 315 |
} |
|
| 316 |
|
|
| 317 |
// Get POST data |
|
| 318 |
function get_post($field) {
|
|
| 319 |
if(isset($_POST[$field])) {
|
|
| 320 |
return $_POST[$field]; |
|
| 321 |
} else {
|
|
| 322 |
return null; |
|
| 323 |
} |
|
| 324 |
} |
|
| 325 |
|
|
| 326 |
// Get GET data |
|
| 327 |
function get_get($field) {
|
|
| 328 |
if(isset($_GET[$field])) {
|
|
| 329 |
return $_GET[$field]; |
|
| 330 |
} else {
|
|
| 331 |
return null; |
|
| 332 |
} |
|
| 333 |
} |
|
| 334 |
|
|
| 335 |
// Get SESSION data |
|
| 336 |
function get_session($field) {
|
|
| 337 |
if(isset($_SESSION[$field])) {
|
|
| 338 |
return $_SESSION[$field]; |
|
| 339 |
} else {
|
|
| 340 |
return null; |
|
| 341 |
} |
|
| 342 |
} |
|
| 343 |
|
|
| 344 |
// Get SERVER data |
|
| 345 |
function get_server($field) {
|
|
| 346 |
if(isset($_SERVER[$field])) {
|
|
| 347 |
return $_SERVER[$field]; |
|
| 348 |
} else {
|
|
| 349 |
return null; |
|
| 350 |
} |
|
| 351 |
} |
|
| 352 |
|
|
| 353 |
// Get the current users id |
|
| 354 |
function get_user_id() {
|
|
| 355 |
return $_SESSION['USER_ID']; |
|
| 356 |
} |
|
| 357 |
|
|
| 358 |
// Get the current users group id |
|
| 359 |
function get_group_id() {
|
|
| 360 |
return $_SESSION['GROUP_ID']; |
|
| 361 |
} |
|
| 362 |
|
|
| 363 |
// Get the current users group name |
|
| 364 |
function get_group_name() {
|
|
| 365 |
return $_SESSION['GROUP_NAME']; |
|
| 366 |
} |
|
| 367 |
|
|
| 368 |
// Get the current users username |
|
| 369 |
function get_username() {
|
|
| 370 |
return $_SESSION['USERNAME']; |
|
| 371 |
} |
|
| 372 |
|
|
| 373 |
// Get the current users display name |
|
| 374 |
function get_display_name() {
|
|
| 375 |
return stripslashes($_SESSION['DISPLAY_NAME']); |
|
| 376 |
} |
|
| 377 |
|
|
| 378 |
// Get the current users email address |
|
| 379 |
function get_email() {
|
|
| 380 |
return $_SESSION['EMAIL']; |
|
| 381 |
} |
|
| 382 |
|
|
| 383 |
// Get the current users home folder |
|
| 384 |
function get_home_folder() {
|
|
| 385 |
return $_SESSION['HOME_FOLDER']; |
|
| 386 |
} |
|
| 387 |
|
|
| 388 |
// Get the current users timezone |
|
| 389 |
function get_timezone() {
|
|
| 390 |
if(!isset($_SESSION['USE_DEFAULT_TIMEZONE'])) {
|
|
| 391 |
return $_SESSION['TIMEZONE']; |
|
| 392 |
} else {
|
|
| 393 |
return '-72000'; |
|
| 394 |
} |
|
| 395 |
} |
|
| 396 |
|
|
| 397 |
// Validate supplied email address |
|
| 398 |
function validate_email($email) {
|
|
| 399 |
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
|
|
| 400 |
return true; |
|
| 401 |
} else {
|
|
| 402 |
return false; |
|
| 403 |
} |
|
| 404 |
} |
|
| 405 |
|
|
| 406 | 226 |
} |
| 407 | 227 |
|
| 408 |
?> |
|
| 228 |
?> |
|
Also available in: Unified diff
Restructured frontend code and fixed various bugs