Project

General

Profile

« Previous | Next » 

Revision 55

Added by stefan about 19 years ago

Removed initialize.php, moved initialization code to class wb constructor. Changed attribute no_default_content to default_block_content and changed behavior.

View differences:

trunk/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.6.0 -------------------------------------
14
09-Sep-2005 Stefan Braunewell
15
#	Fixed bug when changing a page's parent
16
!	Changed the way blocks are treated. Added new frontend class attribute
17
	default_block_content that controls what is shown on pages such as
18
	search, login, etc. (Ticket #16)
19
+	Added support for WYSIWYG editor modules (wysiwygmod)
20
+	When trying to access a registered page, user is automatically redirected
21
	there on successful login.
22
#	Fixed various issues with system search (mainly related to stripslashes()
23
#	Removed stripslashes() in many places in the code. Added check for
24
	magic_quotes_gpc to new wb class method add_slashes(). Now database contest
25
	is independent of magic_quotes setting..
14 26
05-Sep-2005 Stefan Braunewell
15 27
#	Fixed bug concerning direct access of preferences page.
16
#	Reworked page visibility and menu item visibility code (frontend login problem).
28
#	Reworked page visibility and menu item visibility code (frontend login
29
	problem).
17 30
#	Pages in link list in htmlarea popup are now correctly ordered.
18 31
#	Fixed bug where group with existing name can be added.
19 32
04-Sep-2005 Ryan Djurovich
trunk/wb/framework/initialize.php
1
<?php
2

  
3
// $Id$
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
	Initializations common to frontend and backend
28
*/
29
if(!defined('WB_URL')) {
30
	header('Location: ../index.php');
31
}
32

  
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
// 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
// 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
?>
95 0

  
trunk/wb/framework/class.admin.php
36 36
	header('Location: ../index.php');
37 37
}
38 38

  
39

  
40 39
require_once(WB_PATH.'/framework/class.wb.php');
41 40

  
42
require_once(WB_PATH.'/framework/initialize.php');
41
//require_once(WB_PATH.'/framework/initialize.php');
43 42

  
44 43
// Include PHPLIB template class
45 44
require_once(WB_PATH."/include/phplib/template.inc");
......
52 51
Begin user changeable settings
53 52
*/
54 53

  
54

  
55 55
class admin extends wb {
56 56
	// Authenticate user then auto print the header
57 57
	function admin($section_name, $section_permission = 'start', $auto_header = true, $auto_auth = true) {
58
		$this->wb();
58 59
		global $MESSAGE;
59 60
		// Specify the current applications name
60 61
		$this->section_name = $section_name;
......
83 84
		global $MESSAGE;
84 85
		global $TEXT;
85 86
		// Connect to database and get website title
86
		$database = new database();
87
		$database = & $this->database;
87 88
		$get_title = $database->query("SELECT value FROM ".TABLE_PREFIX."settings WHERE name = 'title'");
88 89
		$title = $get_title->fetchRow();
89 90
		$header_template = new Template(ADMIN_PATH."/interface");
trunk/wb/framework/class.wb.php
32 32
*/
33 33

  
34 34
class wb
35
{
36
	function wb() {
35
{	
36
	// General initialization function 
37
	// performed when frontend or backend is loaded.
38
	function wb() {
39
		// set global database variable
40
		global $database;
41
		// Create database class
42
		require_once(WB_PATH.'/framework/class.database.php');
43
		$database = new database();
44
		$this->database = $database;
45

  
46
		// Start a session
47
		if(!defined('SESSION_STARTED')) {
48
			session_name(APP_NAME.'_session_id');
49
			session_start();
50
			define('SESSION_STARTED', true);
51
		}
52
		
53
		// Get users language
54
		if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
55
		  	define('LANGUAGE', strtoupper($_GET['lang']));
56
			$_SESSION['LANGUAGE']=LANGUAGE;
57
		} else {
58
			if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
59
				define('LANGUAGE', $_SESSION['LANGUAGE']);
60
			} else {
61
				define('LANGUAGE', DEFAULT_LANGUAGE);
62
			}
63
		}
64

  
65
		// make language variables globally accessible
66
		global $language_code, $language_name, $language_author, $language_version, $language_designed_for;
67
		global $MENU, $OVERVIEW, $TEXT, $HEADING, $MESSAGE;
68
		// Load Language file
69
		if(!defined('LANGUAGE_LOADED')) {
70
			if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
71
				exit('Error loading language file '.LANGUAGE.', please check configuration');
72
			} else {
73
				require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
74
			}
75
		}
76
		
77
		// Get users timezone
78
		if(!defined('TIMEZONE')) {
79
			if(isset($_SESSION['TIMEZONE'])) {
80
				define('TIMEZONE', $_SESSION['TIMEZONE']);
81
			} else {
82
				define('TIMEZONE', DEFAULT_TIMEZONE);
83
			}
84
		}
85
		// Get users date format
86
		if(!defined('DATE_FORMAT')) {
87
			if(isset($_SESSION['DATE_FORMAT'])) {
88
				define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
89
			} else {
90
				define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
91
			}
92
		}
93
		// Get users time format
94
		if(!defined('TIME_FORMAT')) {
95
			if(isset($_SESSION['TIME_FORMAT'])) {
96
				define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
97
			} else {
98
				define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
99
			}
100
		}
101
		
102
		set_magic_quotes_runtime(0);
37 103
	}
38 104

  
39 105
	// Check whether we should show a page or not (for front-end)
trunk/wb/framework/class.frontend.php
41 41
	var $default_link,$default_page_id;
42 42
	// when multiple blocks are used, show home page blocks on 
43 43
	// pages where no content is defined (search, login, ...)
44
	var $no_default_content=false;
44
	var $no_default_block_content=false;
45 45

  
46 46
	// page details
47 47
	// page database row
......
64 64
	
65 65
	function page_select() {
66 66
		global $page_id,$no_intro;
67
		global $database;
67
		$database=& $this->database;
68 68
		// We have no page id and are supposed to show the intro page
69 69
		if((INTRO_PAGE AND !isset($no_intro)) AND (!isset($page_id) OR !is_numeric($page_id))) {
70 70
			// Since we have no page id check if we should go to intro page or default page
......
121 121
	}
122 122

  
123 123
	function get_page_details() {
124
		global $database;
124
		$database = & $this->database;
125 125
	    if($this->page_id != 0) {
126 126
			// Query page details
127 127
			$query_page = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '{$this->page_id}'";
......
249 249
	}
250 250

  
251 251
	function get_website_settings() {
252
		global $database;
252
		$database = & $this->database;
253 253
		// Get website settings (title, keywords, description, header, and footer)
254 254
		$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
255 255
		$get_settings = $database->query($query_settings);
......
297 297
	}
298 298
	
299 299
	function preprocess(&$content) {
300
		global $database;
300
		$database = & $this->database;
301 301
		// Replace [wblink--PAGE_ID--] with real link
302 302
		$pattern = '/\[wblink(.+?)\]/s';
303 303
		preg_match_all($pattern,$content,$ids);
......
360 360
	}
361 361
	
362 362
	function show_menu() {
363
	   global $database;
363
	   $database = & $this->database;
364 364
	   if ($this->menu_recurse==0)
365 365
	       return;
366 366
	   // Check if we should add menu number check to query
......
412 412

  
413 413
	function page_content($block = 1) {
414 414
		// Get outside objects
415
		global $database,$admin,$TEXT,$MENU,$HEADING,$MESSAGE;
415
		global $TEXT,$MENU,$HEADING,$MESSAGE;
416 416
		global $globals;
417
		$database = & $this->database;
418
		$admin = & $this;
417 419
		if ($this->page_access_denied==true) {
418 420
            echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
419 421
			exit();
......
423 425
		if(!is_numeric($block)) { $block = 1; }
424 426
		// Include page content
425 427
		if(!defined('PAGE_CONTENT') OR $block!=1) {
426
			if ($this->page_id==0) {
427
				if ($block != 1 AND $this->no_default_content==true) {
428
			if ($this->page_id==0) {

429
				if ($this->default_block_content=='none') {
428 430
					return;
429 431
				}
430
				$page_id=$this->default_page_id;
432
				if (is_numeric($this->default_block_content)) {
433
					$page_id=$this->default_block_content;
434
				} else {
435
					$page_id=$this->default_page-id;
436
				}				
431 437
			} else {
432 438
				$page_id=$this->page_id;
433 439
			}
......
442 448
				}
443 449
			}
444 450
		} else {
445
			if($block == 1) {
446
				require(PAGE_CONTENT);
447
			}
451
			require(PAGE_CONTENT);
448 452
		}
449 453
	}
450 454

  
trunk/wb/index.php
35 35

  
36 36
require_once(WB_PATH.'/framework/class.frontend.php');
37 37
// Create new frontend object
38
$wb = new frontend();
38
// Perform general initializations
39
$wb = & new frontend();
39 40

  
40
// Perform general initializations:
41
// session start, language files loading, basic settings.
42
require_once(WB_PATH.'/framework/initialize.php');
43

  
44 41
// Figure out which page to display
45 42
// Stop processing if intro page was shown
46 43
$wb->page_select() or die();

Also available in: Unified diff