Project

General

Profile

1 5 stefan
<?php
2
3 11 ryan
// $Id$
4
5 5 stefan
/*
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
	Initializations common to frontend and backend
28
*/
29 18 stefan
if(!defined('WB_URL')) {
30
	header('Location: ../index.php');
31
}
32 5 stefan
33
// Setup database object
34
require_once(WB_PATH.'/framework/class.database.php');
35
if (!defined('DATABASE_CLASS_LOADED')) {
36
  	define('DATABASE_CLASS_LOADED',true);
37
}
38
if(!isset($database)) {
39
	$database = new database();
40
}
41
42
// Start a session
43
if(!defined('SESSION_STARTED')) {
44
	session_name(APP_NAME.'_session_id');
45
	session_start();
46
	define('SESSION_STARTED', true);
47
}
48
49
// Get users language
50
if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
51
  	define('LANGUAGE', strtoupper($_GET['lang']));
52
	$_SESSION['LANGUAGE']=LANGUAGE;
53
} else {
54
	if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
55
		define('LANGUAGE', $_SESSION['LANGUAGE']);
56
	} else {
57
		define('LANGUAGE', DEFAULT_LANGUAGE);
58
	}
59
}
60
61
// Get users timezone
62
if(!defined('TIMEZONE')) {
63
	if(isset($_SESSION['TIMEZONE'])) {
64
		define('TIMEZONE', $_SESSION['TIMEZONE']);
65
	} else {
66
		define('TIMEZONE', DEFAULT_TIMEZONE);
67
	}
68
}
69
// Get users date format
70
if(!defined('DATE_FORMAT')) {
71
	if(isset($_SESSION['DATE_FORMAT'])) {
72
		define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
73
	} else {
74
		define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
75
	}
76
}
77 7 stefan
// Get users time format
78
if(!defined('TIME_FORMAT')) {
79
	if(isset($_SESSION['TIME_FORMAT'])) {
80
		define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
81
	} else {
82
		define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
83
	}
84
}
85 5 stefan
// Load Language file
86
if(!defined('LANGUAGE_LOADED')) {
87
	if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
88
		exit('Error loading language file '.LANGUAGE.', please check configuration');
89
	} else {
90
		require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
91
	}
92
}
93
94
?>