Project

General

Profile

« Previous | Next » 

Revision 27

Added by stefan over 19 years ago

Reworked visibility and menu code (frontend login problem)

View differences:

trunk/wb/account/forgot.php
37 37
define('MENU_TITLE', $MENU['FORGOT']);
38 38
define('VISIBILITY', 'public');
39 39

  
40
if(FRONTEND_LOGIN != 'enabled') {
41
	header('Location: '.WB_URL.'/pages/index'.PAGE_EXTENSION);
40
if(!FRONTEND_LOGIN) {
41
	if(INTRO_PAGE) {
42
		header('Location: '.WB_URL.PAGES_DIRECTORY.'/index'.PAGE_EXTENSION);
43
	} else {
44
		header('Location: '.WB_URL.'/index'.PAGE_EXTENSION);
45
	}
42 46
}
43 47

  
44 48
// Set the page content include file
trunk/wb/account/signup.php
1 1
<?php
2 2

  
3
// $Id: signup.php,v 1.3 2005/04/02 06:25:37 rdjurovich Exp $
3
// $Id$
4 4

  
5 5
/*
6 6

  
......
25 25

  
26 26
require('../config.php');
27 27

  
28
if(!is_numeric(FRONTEND_SIGNUP)) {
29
	if(INTRO_PAGE) {
30
		header('Location: '.WB_URL.PAGES_DIRECTORY.'/index'.PAGE_EXTENSION);
31
	} else {
32
		header('Location: '.WB_URL.'/index'.PAGE_EXTENSION);
33
	}
34
}
35

  
28 36
// Load the language file
29 37
if(!file_exists(WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php')) {
30 38
	exit('Error loading language file '.DEFAULT_LANGUAGE.', please check configuration');
......
33 41
	$load_language = false;
34 42
}
35 43

  
44

  
36 45
// Required page details
37 46
$page_id = 0;
38 47
$page_description = '';
......
46 55
define('MODULE', '');
47 56
define('VISIBILITY', 'public');
48 57

  
49
if(!is_numeric(FRONTEND_SIGNUP)) {
50
	header('Location: '.WB_URL.'/pages/index'.PAGE_EXTENSION);
51
}
52

  
53 58
// Set the page content include file
54 59
if(isset($_POST['username'])) {
55 60
	define('PAGE_CONTENT', WB_PATH.'/account/signup2.php');
trunk/wb/framework/compatibility.php
94 94
$page_keywords=&$wb->page_keywords;
95 95
$page_link=&$wb->link;
96 96

  
97
// extra_sql is not used anymore - this is basically a register_globals exploit prevention...
97 98
$extra_sql=&$wb->extra_sql;
98 99
$extra_where_sql=&$wb->extra_where_sql;
99 100

  
trunk/wb/framework/class.frontend.php
53 53
	var $website_title,$website_description,$website_keywords,$website_header,$website_footer;
54 54

  
55 55
	// ugly database stuff
56
	var $extra_sql,$extra_where_sql;
56
	var $extra_where_sql;
57 57

  
58 58
	function frontend() {
59 59
		$this->wb();
......
216 216
		define('TEMPLATE_DIR', WB_URL.'/templates/'.TEMPLATE);
217 217

  
218 218
		// Check if user is allow to view this page
219
		if(FRONTEND_LOGIN AND VISIBILITY == 'private' OR FRONTEND_LOGIN AND VISIBILITY == 'registered') {
220
			// Double-check front-end login is enabled
221
			if(FRONTEND_LOGIN != true) {
222
				// Users shouldnt be allowed to view private pages
223
				header("Location: ".WB_URL.PAGES_DIRECTORY."/index".PAGE_EXTENSION);
224
			}
219
		if(VISIBILITY == 'private' OR VISIBILITY == 'registered') {
225 220
			// Check if the user is authenticated
226 221
			if($this->is_authenticated() == false) {
227 222
				// User needs to login first
......
231 226
			if($this->show_page($this->page) == false) {
232 227
				$this->page_access_denied=true;
233 228
			}
234
			// Set extra private sql code
235
			$this->extra_sql = ",viewing_groups,viewing_users";
236
			$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted'";
237
		} elseif(!FRONTEND_LOGIN AND VISIBILITY == 'private' OR !FRONTEND_LOGIN AND VISIBILITY == 'registered') {
229
		} elseif(VISIBILITY == 'deleted' OR VISIBILITY == 'none') {
238 230
			// User isnt allowed on this page so tell them
239 231
			$this->page_access_denied=true;
240
		} elseif(VISIBILITY == 'deleted') {
241
			// User isnt allowed on this page so tell them
242
			$this->page_access_denied=true;
243 232
		}
244
		if(!isset($this->extra_sql)) {
245
			// Set extra private sql code
246
			if(FRONTEND_LOGIN == 'enabled') {
247
				if($this->is_authenticated()) {
248
					$this->extra_sql = '';
249
					$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted'";
250
				} else {
251
					$this->extra_sql = '';
252
					$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted' AND visibility != 'private'";
253
				}
254
			} else {
255
				$this->extra_sql = '';
256
				$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted' AND visibility != 'private' AND visibility != 'registered'";
233
		// never show no-vis, hidden or deleted pages
234
		$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted'";
235
		// Set extra private sql code
236
		if($this->is_authenticated()==false) {
237
			// if user is not authenticated, don't show private pages either
238
			$this->extra_where_sql .= " AND visibility != 'private'";
239
			// and 'registered' without frontend login doesn't make much sense!
240
			if (FRONTEND_LOGIN==false) {
241
				$this->extra_where_sql .= " AND visibility != 'registered'";
257 242
			}
258 243
		}
259 244
		$this->extra_where_sql .= $this->sql_where_language;
......
381 366
	      $menu_number = '1';
382 367
	   }
383 368
	   // Query pages
384
	   $query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility$this->extra_sql FROM ".
369
	   $query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility FROM ".
385 370
	TABLE_PREFIX."pages WHERE parent = '$this->menu_parent' AND $menu_number AND $this->extra_where_sql ORDER BY position ASC");
386 371
	   // Check if there are any pages to show
387 372
	   if($query_menu->numRows() > 0) {

Also available in: Unified diff