| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /**
 
     | 
  
  
    | 
      3
     | 
    
       *
 
     | 
  
  
    | 
      4
     | 
    
       * @category        frontend
 
     | 
  
  
    | 
      5
     | 
    
       * @package         framework
 
     | 
  
  
    | 
      6
     | 
    
       * @author          Ryan Djurovich (2004-2009), WebsiteBaker Project
 
     | 
  
  
    | 
      7
     | 
    
       * @copyright       2009-2012, WebsiteBaker Org. e.V.
 
     | 
  
  
    | 
      8
     | 
    
       * @link			http://www.websitebaker2.org/
 
     | 
  
  
    | 
      9
     | 
    
       * @license         http://www.gnu.org/licenses/gpl.html
 
     | 
  
  
    | 
      10
     | 
    
       * @platform        WebsiteBaker 2.8.x
 
     | 
  
  
    | 
      11
     | 
    
       * @requirements    PHP 5.2.2 and higher
 
     | 
  
  
    | 
      12
     | 
    
       * @version         $Id: class.frontend.php 2070 2014-01-03 01:21:42Z darkviper $
 
     | 
  
  
    | 
      13
     | 
    
       * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/framework/class.frontend.php $
 
     | 
  
  
    | 
      14
     | 
    
       * @lastmodified    $Date: 2014-01-03 02:21:42 +0100 (Fri, 03 Jan 2014) $
 
     | 
  
  
    | 
      15
     | 
    
       *
 
     | 
  
  
    | 
      16
     | 
    
       */
 
     | 
  
  
    | 
      17
     | 
    
      /* -------------------------------------------------------- */
 
     | 
  
  
    | 
      18
     | 
    
      // Must include code to stop this file being accessed directly
 
     | 
  
  
    | 
      19
     | 
    
      if(!defined('WB_PATH')) {
     | 
  
  
    | 
      20
     | 
    
      	require_once(dirname(__FILE__).'/globalExceptionHandler.php');
 
     | 
  
  
    | 
      21
     | 
    
      	throw new IllegalFileException();
 
     | 
  
  
    | 
      22
     | 
    
      }
 
     | 
  
  
    | 
      23
     | 
    
      /* -------------------------------------------------------- */
 
     | 
  
  
    | 
      24
     | 
    
      //require_once(WB_PATH.'/framework/class.wb.php');
 
     | 
  
  
    | 
      25
     | 
    
      //require_once(WB_PATH.'/framework/SecureForm.php');
 
     | 
  
  
    | 
      26
     | 
    
      if(!class_exists('wb', false)){ require(WB_PATH.'/framework/class.wb.php'); }
     | 
  
  
    | 
      27
     | 
    
      if(!class_exists('admin', false)){ require(WB_PATH.'/framework/class.admin.php'); }
     | 
  
  
    | 
      28
     | 
    
      
 
     | 
  
  
    | 
      29
     | 
    
      class frontend extends wb {
     | 
  
  
    | 
      30
     | 
    
      	// defaults
 
     | 
  
  
    | 
      31
     | 
    
      	public $default_link,$default_page_id;
 
     | 
  
  
    | 
      32
     | 
    
      	// when multiple blocks are used, show home page blocks on
 
     | 
  
  
    | 
      33
     | 
    
      	// pages where no content is defined (search, login, ...)
 
     | 
  
  
    | 
      34
     | 
    
      	public $default_block_content=true;
 
     | 
  
  
    | 
      35
     | 
    
      
 
     | 
  
  
    | 
      36
     | 
    
      	// page details
 
     | 
  
  
    | 
      37
     | 
    
      	// page database row
 
     | 
  
  
    | 
      38
     | 
    
      	public $page;
 
     | 
  
  
    | 
      39
     | 
    
      	public $page_id,$page_code,$page_title,$menu_title,$parent,$root_parent,$level,$position,$visibility;
 
     | 
  
  
    | 
      40
     | 
    
      	public $page_description,$page_keywords,$page_link, $page_icon, $menu_icon_0, $menu_icon_1, $tooltip;
 
     | 
  
  
    | 
      41
     | 
    
      	public $page_trail=array();
 
     | 
  
  
    | 
      42
     | 
    
      
 
     | 
  
  
    | 
      43
     | 
    
      	public $page_access_denied;
 
     | 
  
  
    | 
      44
     | 
    
      	public $page_no_active_sections;
 
     | 
  
  
    | 
      45
     | 
    
      
 
     | 
  
  
    | 
      46
     | 
    
      	// website settings
 
     | 
  
  
    | 
      47
     | 
    
      	public $website_title,$website_description,$website_keywords,$website_header,$website_footer;
 
     | 
  
  
    | 
      48
     | 
    
      
 
     | 
  
  
    | 
      49
     | 
    
      	// ugly database stuff
 
     | 
  
  
    | 
      50
     | 
    
      	public $extra_where_sql, $sql_where_language;
 
     | 
  
  
    | 
      51
     | 
    
      
 
     | 
  
  
    | 
      52
     | 
    
      // do not chnage if working in frontend account
 
     | 
  
  
    | 
      53
     | 
    
          public $FrontendLanguage;
 
     | 
  
  
    | 
      54
     | 
    
      
 
     | 
  
  
    | 
      55
     | 
    
      	public function __construct($value=true) {
     | 
  
  
    | 
      56
     | 
    
      		parent::__construct(SecureForm::FRONTEND);
 
     | 
  
  
    | 
      57
     | 
    
              $this->FrontendLanguage = isset($value) ? $value : true;
 
     | 
  
  
    | 
      58
     | 
    
      	}
 
     | 
  
  
    | 
      59
     | 
    
      
 
     | 
  
  
    | 
      60
     | 
    
          public function ChangeFrontendLanguage( $value=true ) {
     | 
  
  
    | 
      61
     | 
    
              $this->FrontendLanguage=$value;
 
     | 
  
  
    | 
      62
     | 
    
          }
 
     | 
  
  
    | 
      63
     | 
    
      
 
     | 
  
  
    | 
      64
     | 
    
      	public function page_select() {
     | 
  
  
    | 
      65
     | 
    
      		global $database, $page_id,$no_intro;
 
     | 
  
  
    | 
      66
     | 
    
      /*
 
     | 
  
  
    | 
      67
     | 
    
      		// set by user statusflag and maintance enabled select in options
 
     | 
  
  
    | 
      68
     | 
    
      		// if maintance flag is set registered user can see normal pages
 
     | 
  
  
    | 
      69
     | 
    
      		// otherwise show show maintance message
 
     | 
  
  
    | 
      70
     | 
    
      
 
     | 
  
  
    | 
      71
     | 
    
      		if($maintance == true)
 
     | 
  
  
    | 
      72
     | 
    
      		{
     | 
  
  
    | 
      73
     | 
    
      			$this->print_under_construction();
 
     | 
  
  
    | 
      74
     | 
    
      			return false;
 
     | 
  
  
    | 
      75
     | 
    
      		}
 
     | 
  
  
    | 
      76
     | 
    
      */
 
     | 
  
  
    | 
      77
     | 
    
      
 
     | 
  
  
    | 
      78
     | 
    
      /**
 
     | 
  
  
    | 
      79
     | 
    
       * Store installed languages in SESSION
 
     | 
  
  
    | 
      80
     | 
    
       */
 
     | 
  
  
    | 
      81
     | 
    
      
 
     | 
  
  
    | 
      82
     | 
    
              if( $this->get_session('session_started') ) {
     | 
  
  
    | 
      83
     | 
    
                  $_SESSION['USED_LANGUAGES'] = $this->getLanguagesInUsed();
 
     | 
  
  
    | 
      84
     | 
    
              }
 
     | 
  
  
    | 
      85
     | 
    
      
 
     | 
  
  
    | 
      86
     | 
    
      		$maintance = ( defined('SYSTEM_LOCKED') && (SYSTEM_LOCKED==true) ? true : false );
     | 
  
  
    | 
      87
     | 
    
      
 
     | 
  
  
    | 
      88
     | 
    
      		if( ($maintance==true) || $this->get_session('USER_ID')!= 1 )
     | 
  
  
    | 
      89
     | 
    
      		{
     | 
  
  
    | 
      90
     | 
    
             	//  check for show maintenance screen and terminate if needed
 
     | 
  
  
    | 
      91
     | 
    
          		$this->ShowMaintainScreen('locked');
     | 
  
  
    | 
      92
     | 
    
              }
 
     | 
  
  
    | 
      93
     | 
    
      		// We have no page id and are supposed to show the intro page
 
     | 
  
  
    | 
      94
     | 
    
      		if((INTRO_PAGE && ($maintance != true) && !isset($no_intro)) && (!isset($page_id) || !is_numeric($page_id)))
 
     | 
  
  
    | 
      95
     | 
    
      		{
     | 
  
  
    | 
      96
     | 
    
      			// Since we have no page id check if we should go to intro page or default page
 
     | 
  
  
    | 
      97
     | 
    
      			// Get intro page content
 
     | 
  
  
    | 
      98
     | 
    
      			$sIntroFilename = PAGES_DIRECTORY.'/intro'.PAGE_EXTENSION;
 
     | 
  
  
    | 
      99
     | 
    
      			if(file_exists(WB_PATH.$sIntroFilename)) {
     | 
  
  
    | 
      100
     | 
    
                      // send intro.php as header to allow parsing of php statements
 
     | 
  
  
    | 
      101
     | 
    
      				header("Location: ".WB_URL.$sIntroFilename."");
     | 
  
  
    | 
      102
     | 
    
      				exit();
 
     | 
  
  
    | 
      103
     | 
    
      			}
 
     | 
  
  
    | 
      104
     | 
    
      		}
 
     | 
  
  
    | 
      105
     | 
    
      
 
     | 
  
  
    | 
      106
     | 
    
      		// Check if we should add page language sql code
 
     | 
  
  
    | 
      107
     | 
    
      		if(PAGE_LANGUAGES) {
     | 
  
  
    | 
      108
     | 
    
      			$this->sql_where_language = ' AND `language`=\''.LANGUAGE.'\'';
 
     | 
  
  
    | 
      109
     | 
    
      		}
 
     | 
  
  
    | 
      110
     | 
    
      		// Get default page
 
     | 
  
  
    | 
      111
     | 
    
      		// Check for a page id
 
     | 
  
  
    | 
      112
     | 
    
      		$table_p = TABLE_PREFIX.'pages';
 
     | 
  
  
    | 
      113
     | 
    
      		$table_s = TABLE_PREFIX.'sections';
 
     | 
  
  
    | 
      114
     | 
    
      		$now = time();
 
     | 
  
  
    | 
      115
     | 
    
      		$sql  = 'SELECT `p`.`page_id`, `link` ';
 
     | 
  
  
    | 
      116
     | 
    
      		$sql .= 'FROM `'.$table_p.'` AS `p` INNER JOIN `'.$table_s.'` USING(`page_id`) ';
 
     | 
  
  
    | 
      117
     | 
    
      		$sql .= 'WHERE `parent`=0 AND `visibility`=\'public\' ';
 
     | 
  
  
    | 
      118
     | 
    
      		$sql .=     'AND (('.$now.'>=`publ_start` OR `publ_start`=0) ';
     | 
  
  
    | 
      119
     | 
    
      		$sql .=     'AND ('.$now.'<=`publ_end` OR `publ_end`=0)) ';
     | 
  
  
    | 
      120
     | 
    
      		if(trim($this->sql_where_language) != '') {
     | 
  
  
    | 
      121
     | 
    
      			$sql .= trim($this->sql_where_language).' ';
 
     | 
  
  
    | 
      122
     | 
    
      		}
 
     | 
  
  
    | 
      123
     | 
    
      		$sql .= 'ORDER BY `p`.`position` ASC';
 
     | 
  
  
    | 
      124
     | 
    
      		if($get_default = $database->query($sql)) {
     | 
  
  
    | 
      125
     | 
    
      
 
     | 
  
  
    | 
      126
     | 
    
          		$default_num_rows = $get_default->numRows();
 
     | 
  
  
    | 
      127
     | 
    
          		if(!isset($page_id) OR !is_numeric($page_id)){
     | 
  
  
    | 
      128
     | 
    
          			// Go to or show default page
 
     | 
  
  
    | 
      129
     | 
    
          			if($default_num_rows > 0) {
     | 
  
  
    | 
      130
     | 
    
          				$fetch_default = $get_default->fetchRow(MYSQL_ASSOC);
 
     | 
  
  
    | 
      131
     | 
    
          				$this->default_link = $fetch_default['link'];
 
     | 
  
  
    | 
      132
     | 
    
          				$this->default_page_id = $fetch_default['page_id'];
 
     | 
  
  
    | 
      133
     | 
    
          				// Check if we should redirect or include page inline
 
     | 
  
  
    | 
      134
     | 
    
          				if(HOMEPAGE_REDIRECTION) {
     | 
  
  
    | 
      135
     | 
    
          					// Redirect to page
 
     | 
  
  
    | 
      136
     | 
    
          //					header("Location: ".$this->page_link($this->default_link));
     | 
  
  
    | 
      137
     | 
    
          //					exit();
 
     | 
  
  
    | 
      138
     | 
    
          					$this->send_header($this->page_link($this->default_link));
 
     | 
  
  
    | 
      139
     | 
    
          				} else {
     | 
  
  
    | 
      140
     | 
    
          					// Include page inline
 
     | 
  
  
    | 
      141
     | 
    
          					$this->page_id = $this->default_page_id;
 
     | 
  
  
    | 
      142
     | 
    
          				}
 
     | 
  
  
    | 
      143
     | 
    
          			} else {
     | 
  
  
    | 
      144
     | 
    
          		   		// No pages have been added, so print under construction page
 
     | 
  
  
    | 
      145
     | 
    
          //				if(trim($this->sql_where_language) == '') {
     | 
  
  
    | 
      146
     | 
    
          //					$this->ShowMaintainScreen('new');
     | 
  
  
    | 
      147
     | 
    
          //    				exit();
 
     | 
  
  
    | 
      148
     | 
    
          //				}
 
     | 
  
  
    | 
      149
     | 
    
          				$this->ShowMaintainScreen('new');
     | 
  
  
    | 
      150
     | 
    
          //				$this->print_under_construction();
 
     | 
  
  
    | 
      151
     | 
    
          				exit();
 
     | 
  
  
    | 
      152
     | 
    
          			}
 
     | 
  
  
    | 
      153
     | 
    
          		} else {
     | 
  
  
    | 
      154
     | 
    
          			$this->page_id=$page_id;
 
     | 
  
  
    | 
      155
     | 
    
          		}
 
     | 
  
  
    | 
      156
     | 
    
          		// Get default page link
 
     | 
  
  
    | 
      157
     | 
    
          		if(!isset($fetch_default)) {
     | 
  
  
    | 
      158
     | 
    
          		  	$fetch_default = $get_default->fetchRow(MYSQL_ASSOC);
 
     | 
  
  
    | 
      159
     | 
    
          	 		$this->default_link = $fetch_default['link'];
 
     | 
  
  
    | 
      160
     | 
    
          			$this->default_page_id = $fetch_default['page_id'];
 
     | 
  
  
    | 
      161
     | 
    
          		}
 
     | 
  
  
    | 
      162
     | 
    
          		return true;
 
     | 
  
  
    | 
      163
     | 
    
      
 
     | 
  
  
    | 
      164
     | 
    
      		} else {
     | 
  
  
    | 
      165
     | 
    
      			$this->ShowMaintainScreen('new');
     | 
  
  
    | 
      166
     | 
    
      			exit();
 
     | 
  
  
    | 
      167
     | 
    
          	}
 
     | 
  
  
    | 
      168
     | 
    
      
 
     | 
  
  
    | 
      169
     | 
    
      	}
 
     | 
  
  
    | 
      170
     | 
    
      
 
     | 
  
  
    | 
      171
     | 
    
      	public function get_page_details() {
     | 
  
  
    | 
      172
     | 
    
      		global $database;
 
     | 
  
  
    | 
      173
     | 
    
      
 
     | 
  
  
    | 
      174
     | 
    
      		$bCanRedirect = false;
 
     | 
  
  
    | 
      175
     | 
    
      // set defaults 
 
     | 
  
  
    | 
      176
     | 
    
      		$aLanguagesDetailsInUsed = $this->getLanguagesDetailsInUsed();
 
     | 
  
  
    | 
      177
     | 
    
      		$_SESSION['HTTP_REFERER'] = WB_URL;
 
     | 
  
  
    | 
      178
     | 
    
      		$_SESSION['PAGE_ID'] = $this->page_id;
 
     | 
  
  
    | 
      179
     | 
    
      		if($this->page_id != 0) {
     | 
  
  
    | 
      180
     | 
    
      			// Query page details
 
     | 
  
  
    | 
      181
     | 
    
      			$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.(int)$this->page_id;
 
     | 
  
  
    | 
      182
     | 
    
      			$get_page = $database->query($sql);
 
     | 
  
  
    | 
      183
     | 
    
      			// Make sure page was found in database
 
     | 
  
  
    | 
      184
     | 
    
      			if($get_page->numRows() == 0) {
     | 
  
  
    | 
      185
     | 
    
      				// Print page not found message
 
     | 
  
  
    | 
      186
     | 
    
      				exit("Page not found");
     | 
  
  
    | 
      187
     | 
    
      			}
 
     | 
  
  
    | 
      188
     | 
    
      			// Fetch page details
 
     | 
  
  
    | 
      189
     | 
    
      			$this->page = $get_page->fetchRow(MYSQL_ASSOC);
 
     | 
  
  
    | 
      190
     | 
    
      
 
     | 
  
  
    | 
      191
     | 
    
      		//  Check if the page language is also the selected language. If not, send headers again.
 
     | 
  
  
    | 
      192
     | 
    
      			if (($this->page['language'] != LANGUAGE) && $this->FrontendLanguage && ($this->_oReg->PageLanguages) )
 
     | 
  
  
    | 
      193
     | 
    
                  {
     | 
  
  
    | 
      194
     | 
    
                  //  check if there is an query-string
 
     | 
  
  
    | 
      195
     | 
    
      				if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') {
     | 
  
  
    | 
      196
     | 
    
      					header('Location: '.$this->page_link($this->page['link']).'?'.$_SERVER['QUERY_STRING'].'&lang='.$this->page['language']);
     | 
  
  
    | 
      197
     | 
    
      				} else {
     | 
  
  
    | 
      198
     | 
    
      					header('Location: '.$this->page_link($this->page['link']).'?lang='.$this->page['language']);
     | 
  
  
    | 
      199
     | 
    
      				}
 
     | 
  
  
    | 
      200
     | 
    
      				exit();
 
     | 
  
  
    | 
      201
     | 
    
      			}
 
     | 
  
  
    | 
      202
     | 
    
      
 
     | 
  
  
    | 
      203
     | 
    
      			// Begin code to set details as either variables of constants
 
     | 
  
  
    | 
      204
     | 
    
      			// Page ID
 
     | 
  
  
    | 
      205
     | 
    
      			if(!defined('PAGE_ID')) {define('PAGE_ID', $this->page['page_id']);}
     | 
  
  
    | 
      206
     | 
    
      			// Page Code
 
     | 
  
  
    | 
      207
     | 
    
      			if(!defined('PAGE_CODE')) {define('PAGE_CODE', $this->page['page_code']);}
     | 
  
  
    | 
      208
     | 
    
      			$this->page_code = PAGE_CODE;
 
     | 
  
  
    | 
      209
     | 
    
      			// Page Title
 
     | 
  
  
    | 
      210
     | 
    
      			if(!defined('PAGE_TITLE')) {define('PAGE_TITLE', $this->page['page_title']);}
     | 
  
  
    | 
      211
     | 
    
      			$this->page_title=PAGE_TITLE;
 
     | 
  
  
    | 
      212
     | 
    
      			// Menu Title
 
     | 
  
  
    | 
      213
     | 
    
      			$menu_title = $this->page['menu_title'];
 
     | 
  
  
    | 
      214
     | 
    
      			if($menu_title != '') {
     | 
  
  
    | 
      215
     | 
    
      				if(!defined('MENU_TITLE')) {define('MENU_TITLE', $menu_title);}
     | 
  
  
    | 
      216
     | 
    
      			} else {
     | 
  
  
    | 
      217
     | 
    
      				if(!defined('MENU_TITLE')) {define('MENU_TITLE', PAGE_TITLE);}
     | 
  
  
    | 
      218
     | 
    
      			}
 
     | 
  
  
    | 
      219
     | 
    
      			$this->menu_title = MENU_TITLE;
 
     | 
  
  
    | 
      220
     | 
    
      			$this->page_icon = $this->page['page_icon'];
 
     | 
  
  
    | 
      221
     | 
    
      			$this->menu_icon_0 = $this->page['menu_icon_0'];
 
     | 
  
  
    | 
      222
     | 
    
      			$this->menu_icon_1 = $this->page['menu_icon_1'];
 
     | 
  
  
    | 
      223
     | 
    
      			$this->tooltip = $this->page['tooltip'];
 
     | 
  
  
    | 
      224
     | 
    
      			// Page parent
 
     | 
  
  
    | 
      225
     | 
    
      			if(!defined('PARENT')) {define('PARENT', $this->page['parent']);}
     | 
  
  
    | 
      226
     | 
    
      			$this->parent=$this->page['parent'];
 
     | 
  
  
    | 
      227
     | 
    
      			// Page root parent
 
     | 
  
  
    | 
      228
     | 
    
      			if(!defined('ROOT_PARENT')) {define('ROOT_PARENT', $this->page['root_parent']);}
     | 
  
  
    | 
      229
     | 
    
      			$this->root_parent=$this->page['root_parent'];
 
     | 
  
  
    | 
      230
     | 
    
      			// Page level
 
     | 
  
  
    | 
      231
     | 
    
      			if(!defined('LEVEL')) {define('LEVEL', $this->page['level']);}
     | 
  
  
    | 
      232
     | 
    
      			$this->level=$this->page['level'];
 
     | 
  
  
    | 
      233
     | 
    
      			// Page position
 
     | 
  
  
    | 
      234
     | 
    
      			$this->level=$this->page['position'];
 
     | 
  
  
    | 
      235
     | 
    
      			// Page visibility
 
     | 
  
  
    | 
      236
     | 
    
      			if(!defined('VISIBILITY')) {define('VISIBILITY', $this->page['visibility']);}
     | 
  
  
    | 
      237
     | 
    
      			$this->visibility=$this->page['visibility'];
 
     | 
  
  
    | 
      238
     | 
    
      			// Page trail
 
     | 
  
  
    | 
      239
     | 
    
      			foreach(explode(',', $this->page['page_trail']) AS $pid) {
     | 
  
  
    | 
      240
     | 
    
      				$this->page_trail[$pid]=$pid;
 
     | 
  
  
    | 
      241
     | 
    
      			}
 
     | 
  
  
    | 
      242
     | 
    
      			// Page description
 
     | 
  
  
    | 
      243
     | 
    
      			$this->page_description=$this->page['description'];
 
     | 
  
  
    | 
      244
     | 
    
      			if($this->page_description != '') {
     | 
  
  
    | 
      245
     | 
    
      				define('PAGE_DESCRIPTION', $this->page_description);
     | 
  
  
    | 
      246
     | 
    
      			} else {
     | 
  
  
    | 
      247
     | 
    
      				define('PAGE_DESCRIPTION', WEBSITE_DESCRIPTION);
     | 
  
  
    | 
      248
     | 
    
      			}
 
     | 
  
  
    | 
      249
     | 
    
      			// Page keywords
 
     | 
  
  
    | 
      250
     | 
    
      			$this->page_keywords=$this->page['keywords'];
 
     | 
  
  
    | 
      251
     | 
    
      			// Page link
 
     | 
  
  
    | 
      252
     | 
    
      
 
     | 
  
  
    | 
      253
     | 
    
      			$bCanRedirect = ($this->visibility == 'registered' || $this->visibility == 'privat');
 
     | 
  
  
    | 
      254
     | 
    
      
 
     | 
  
  
    | 
      255
     | 
    
      			$this->link=$this->page_link($this->page['link']);
 
     | 
  
  
    | 
      256
     | 
    
      
 
     | 
  
  
    | 
      257
     | 
    
      			$_SESSION['PAGE_ID'] = $this->page_id;
 
     | 
  
  
    | 
      258
     | 
    
      			$_SESSION['HTTP_REFERER'] = $bCanRedirect != true ? $this->link : WB_URL;
 
     | 
  
  
    | 
      259
     | 
    
      			$_SESSION['HTTP_REFERER'] = !$this->is_authenticated() ? $this->link : $_SESSION['HTTP_REFERER'];
 
     | 
  
  
    | 
      260
     | 
    
      
 
     | 
  
  
    | 
      261
     | 
    
      		// End code to set details as either variables of constants
 
     | 
  
  
    | 
      262
     | 
    
      		}
 
     | 
  
  
    | 
      263
     | 
    
      
 
     | 
  
  
    | 
      264
     | 
    
      		// Figure out what template to use
 
     | 
  
  
    | 
      265
     | 
    
      		if(!defined('TEMPLATE')) {
     | 
  
  
    | 
      266
     | 
    
      			if(isset($this->page['template']) AND $this->page['template'] != '') {
     | 
  
  
    | 
      267
     | 
    
      				if(file_exists(WB_PATH.'/templates/'.$this->page['template'].'/index.php')) {
     | 
  
  
    | 
      268
     | 
    
      					define('TEMPLATE', $this->page['template']);
     | 
  
  
    | 
      269
     | 
    
      				} else {
     | 
  
  
    | 
      270
     | 
    
      					define('TEMPLATE', DEFAULT_TEMPLATE);
     | 
  
  
    | 
      271
     | 
    
      				}
 
     | 
  
  
    | 
      272
     | 
    
      			} else {
     | 
  
  
    | 
      273
     | 
    
      				define('TEMPLATE', DEFAULT_TEMPLATE);
     | 
  
  
    | 
      274
     | 
    
      			}
 
     | 
  
  
    | 
      275
     | 
    
      		}
 
     | 
  
  
    | 
      276
     | 
    
      		// Set the template dir
 
     | 
  
  
    | 
      277
     | 
    
      		define('TEMPLATE_DIR', WB_URL.'/templates/'.TEMPLATE);
     | 
  
  
    | 
      278
     | 
    
      
 
     | 
  
  
    | 
      279
     | 
    
      		// Check if user is allowed to view this page
 
     | 
  
  
    | 
      280
     | 
    
      		if($this->page && $this->page_is_visible($this->page) == false) {
     | 
  
  
    | 
      281
     | 
    
      			if(VISIBILITY == 'deleted' OR VISIBILITY == 'none') {
     | 
  
  
    | 
      282
     | 
    
      				// User isnt allowed on this page so tell them
 
     | 
  
  
    | 
      283
     | 
    
      				$this->page_access_denied=true;
 
     | 
  
  
    | 
      284
     | 
    
      			} elseif(VISIBILITY == 'private' OR VISIBILITY == 'registered') {
     | 
  
  
    | 
      285
     | 
    
      				// Check if the user is authenticated
 
     | 
  
  
    | 
      286
     | 
    
      				if($this->is_authenticated() == false) {
     | 
  
  
    | 
      287
     | 
    
      					// User needs to login first
 
     | 
  
  
    | 
      288
     | 
    
      					header("Location: ".WB_URL."/account/login.php?redirect=".$this->link);
     | 
  
  
    | 
      289
     | 
    
      					exit(0);
 
     | 
  
  
    | 
      290
     | 
    
      				} else {
     | 
  
  
    | 
      291
     | 
    
      					// User isnt allowed on this page so tell them
 
     | 
  
  
    | 
      292
     | 
    
      					$this->page_access_denied=true;
 
     | 
  
  
    | 
      293
     | 
    
      				}
 
     | 
  
  
    | 
      294
     | 
    
      			}
 
     | 
  
  
    | 
      295
     | 
    
      		}
 
     | 
  
  
    | 
      296
     | 
    
      		// check if there is at least one active section
 
     | 
  
  
    | 
      297
     | 
    
      		if($this->page && $this->page_is_active($this->page) == false) {
     | 
  
  
    | 
      298
     | 
    
      			$this->page_no_active_sections=true;
 
     | 
  
  
    | 
      299
     | 
    
      		}
 
     | 
  
  
    | 
      300
     | 
    
      	}
 
     | 
  
  
    | 
      301
     | 
    
      
 
     | 
  
  
    | 
      302
     | 
    
      	public function get_website_settings()
 
     | 
  
  
    | 
      303
     | 
    
          {
     | 
  
  
    | 
      304
     | 
    
      		global $database;
 
     | 
  
  
    | 
      305
     | 
    
      
 
     | 
  
  
    | 
      306
     | 
    
      		// set visibility SQL code
 
     | 
  
  
    | 
      307
     | 
    
      		// never show no-vis, hidden or deleted pages
 
     | 
  
  
    | 
      308
     | 
    
      		$this->extra_where_sql = '`visibility`!=\'none\' AND `visibility`!=\'hidden\' AND `visibility`!=\'deleted\'';
 
     | 
  
  
    | 
      309
     | 
    
      		// Set extra private sql code
 
     | 
  
  
    | 
      310
     | 
    
      		if($this->is_authenticated()==false) {
     | 
  
  
    | 
      311
     | 
    
      			// if user is not authenticated, don't show private pages either
 
     | 
  
  
    | 
      312
     | 
    
      			$this->extra_where_sql .= ' AND `visibility`!=\'private\'';
 
     | 
  
  
    | 
      313
     | 
    
      			// and 'registered' without frontend login doesn't make much sense!
 
     | 
  
  
    | 
      314
     | 
    
      			if (FRONTEND_LOGIN==false) {
     | 
  
  
    | 
      315
     | 
    
      				$this->extra_where_sql .= ' AND `visibility`!=\'registered\'';
 
     | 
  
  
    | 
      316
     | 
    
      			}
 
     | 
  
  
    | 
      317
     | 
    
      		}
 
     | 
  
  
    | 
      318
     | 
    
      		$this->extra_where_sql .= $this->sql_where_language;
 
     | 
  
  
    | 
      319
     | 
    
      
 
     | 
  
  
    | 
      320
     | 
    
      		// Work-out if any possible in-line search boxes should be shown
 
     | 
  
  
    | 
      321
     | 
    
      		if(SEARCH == 'public') {
     | 
  
  
    | 
      322
     | 
    
      			define('SHOW_SEARCH', true);
     | 
  
  
    | 
      323
     | 
    
      		} elseif(SEARCH == 'private' AND VISIBILITY == 'private') {
     | 
  
  
    | 
      324
     | 
    
      			define('SHOW_SEARCH', true);
     | 
  
  
    | 
      325
     | 
    
      		} elseif(SEARCH == 'private' AND $this->is_authenticated() == true) {
     | 
  
  
    | 
      326
     | 
    
      			define('SHOW_SEARCH', true);
     | 
  
  
    | 
      327
     | 
    
      		} elseif(SEARCH == 'registered' AND $this->is_authenticated() == true) {
     | 
  
  
    | 
      328
     | 
    
      			define('SHOW_SEARCH', true);
     | 
  
  
    | 
      329
     | 
    
      		} else {
     | 
  
  
    | 
      330
     | 
    
      			define('SHOW_SEARCH', false);
     | 
  
  
    | 
      331
     | 
    
      		}
 
     | 
  
  
    | 
      332
     | 
    
      		// Work-out if menu should be shown
 
     | 
  
  
    | 
      333
     | 
    
      		if(!defined('SHOW_MENU')) {
     | 
  
  
    | 
      334
     | 
    
      			define('SHOW_MENU', true);
     | 
  
  
    | 
      335
     | 
    
      		}
 
     | 
  
  
    | 
      336
     | 
    
      		// Work-out if login menu constants should be set
 
     | 
  
  
    | 
      337
     | 
    
      		if(FRONTEND_LOGIN) {
     | 
  
  
    | 
      338
     | 
    
      			// Set login menu constants
 
     | 
  
  
    | 
      339
     | 
    
      			define('LOGIN_URL', WB_URL.'/account/login.php');
     | 
  
  
    | 
      340
     | 
    
      			define('LOGOUT_URL', WB_URL.'/account/logout.php');
     | 
  
  
    | 
      341
     | 
    
      			define('FORGOT_URL', WB_URL.'/account/forgot.php');
     | 
  
  
    | 
      342
     | 
    
      			define('PREFERENCES_URL', WB_URL.'/account/preferences.php');
     | 
  
  
    | 
      343
     | 
    
      			define('SIGNUP_URL', WB_URL.'/account/signup.php');
     | 
  
  
    | 
      344
     | 
    
      		}
 
     | 
  
  
    | 
      345
     | 
    
      	}
 
     | 
  
  
    | 
      346
     | 
    
      
 
     | 
  
  
    | 
      347
     | 
    
      /*
 
     | 
  
  
    | 
      348
     | 
    
       * replace all "[wblink{page_id}]" with real links
     | 
  
  
    | 
      349
     | 
    
       * @param string &$content : reference to global $content
 
     | 
  
  
    | 
      350
     | 
    
       * @return void
 
     | 
  
  
    | 
      351
     | 
    
       * @history 100216 17:00:00 optimise errorhandling, speed, SQL-strict
 
     | 
  
  
    | 
      352
     | 
    
       */
 
     | 
  
  
    | 
      353
     | 
    
           public function preprocess(&$content)
 
     | 
  
  
    | 
      354
     | 
    
           {
     | 
  
  
    | 
      355
     | 
    
          //   do nothing
 
     | 
  
  
    | 
      356
     | 
    
           }
 
     | 
  
  
    | 
      357
     | 
    
      
 
     | 
  
  
    | 
      358
     | 
    
      	public function menu() {
     | 
  
  
    | 
      359
     | 
    
      		global $wb;
 
     | 
  
  
    | 
      360
     | 
    
      	   if (!isset($wb->menu_number)) {
     | 
  
  
    | 
      361
     | 
    
      	   	$wb->menu_number = 1;
 
     | 
  
  
    | 
      362
     | 
    
      	   }
 
     | 
  
  
    | 
      363
     | 
    
      	   if (!isset($wb->menu_start_level)) {
     | 
  
  
    | 
      364
     | 
    
      	   	$wb->menu_start_level = 0;
 
     | 
  
  
    | 
      365
     | 
    
      	   }
 
     | 
  
  
    | 
      366
     | 
    
      	   if (!isset($wb->menu_recurse)) {
     | 
  
  
    | 
      367
     | 
    
      	   	$wb->menu_recurse = -1;
 
     | 
  
  
    | 
      368
     | 
    
      	   }
 
     | 
  
  
    | 
      369
     | 
    
      	   if (!isset($wb->menu_collapse)) {
     | 
  
  
    | 
      370
     | 
    
      	   	$wb->menu_collapse = true;
 
     | 
  
  
    | 
      371
     | 
    
      	   }
 
     | 
  
  
    | 
      372
     | 
    
      	   if (!isset($wb->menu_item_template)) {
     | 
  
  
    | 
      373
     | 
    
      	   	$wb->menu_item_template = '<li><span[class]>[a] [menu_title] [/a]</span>';
 
     | 
  
  
    | 
      374
     | 
    
      	   }
 
     | 
  
  
    | 
      375
     | 
    
      	   if (!isset($wb->menu_item_footer)) {
     | 
  
  
    | 
      376
     | 
    
      	   	$wb->menu_item_footer = '</li>';
 
     | 
  
  
    | 
      377
     | 
    
      	   }
 
     | 
  
  
    | 
      378
     | 
    
      	   if (!isset($wb->menu_header)) {
     | 
  
  
    | 
      379
     | 
    
      	   	$wb->menu_header = '<ul>';
 
     | 
  
  
    | 
      380
     | 
    
      	   }
 
     | 
  
  
    | 
      381
     | 
    
      	   if (!isset($wb->menu_footer)) {
     | 
  
  
    | 
      382
     | 
    
      	   	$wb->menu_footer = '</ul>';
 
     | 
  
  
    | 
      383
     | 
    
      	   }
 
     | 
  
  
    | 
      384
     | 
    
      	   if (!isset($wb->menu_default_class)) {
     | 
  
  
    | 
      385
     | 
    
      	   	$wb->menu_default_class = ' class="menu_default"';
 
     | 
  
  
    | 
      386
     | 
    
      	   }
 
     | 
  
  
    | 
      387
     | 
    
      	   if (!isset($wb->menu_current_class)) {
     | 
  
  
    | 
      388
     | 
    
      	   	$wb->menu_current_class = ' class="menu_current"';
 
     | 
  
  
    | 
      389
     | 
    
      	   }
 
     | 
  
  
    | 
      390
     | 
    
      	   if (!isset($wb->menu_parent)) {
     | 
  
  
    | 
      391
     | 
    
      	   	$wb->menu_parent = 0;
 
     | 
  
  
    | 
      392
     | 
    
      	   }
 
     | 
  
  
    | 
      393
     | 
    
      	   $wb->show_menu();
 
     | 
  
  
    | 
      394
     | 
    
      	}
 
     | 
  
  
    | 
      395
     | 
    
      
 
     | 
  
  
    | 
      396
     | 
    
      	public function show_menu() {
     | 
  
  
    | 
      397
     | 
    
      		global $database;
 
     | 
  
  
    | 
      398
     | 
    
      		if ($this->menu_start_level>0) {
     | 
  
  
    | 
      399
     | 
    
      			$key_array=array_keys($this->page_trail);
 
     | 
  
  
    | 
      400
     | 
    
      			if (isset($key_array[$this->menu_start_level-1])) {
     | 
  
  
    | 
      401
     | 
    
      				$real_start=$key_array[$this->menu_start_level-1];
 
     | 
  
  
    | 
      402
     | 
    
      				$this->menu_parent=$real_start;
 
     | 
  
  
    | 
      403
     | 
    
      				$this->menu_start_level=0;
 
     | 
  
  
    | 
      404
     | 
    
      			} else {
     | 
  
  
    | 
      405
     | 
    
      				return;
 
     | 
  
  
    | 
      406
     | 
    
      			}
 
     | 
  
  
    | 
      407
     | 
    
      		}
 
     | 
  
  
    | 
      408
     | 
    
      		if ($this->menu_recurse==0)
 
     | 
  
  
    | 
      409
     | 
    
      	       return;
 
     | 
  
  
    | 
      410
     | 
    
      		// Check if we should add menu number check to query
 
     | 
  
  
    | 
      411
     | 
    
      		if($this->menu_parent == 0) {
     | 
  
  
    | 
      412
     | 
    
      			$menu_number = '`menu`='.intval($this->menu_number);
 
     | 
  
  
    | 
      413
     | 
    
      		} else {
     | 
  
  
    | 
      414
     | 
    
      			$menu_number = '1';
 
     | 
  
  
    | 
      415
     | 
    
      		}
 
     | 
  
  
    | 
      416
     | 
    
      		// Query pages
 
     | 
  
  
    | 
      417
     | 
    
      		$sql  = 'SELECT `page_id`,`menu_title`,`page_title`,`link`,`target`,`level`,';
 
     | 
  
  
    | 
      418
     | 
    
      		$sql .=        '`visibility`,viewing_groups,viewing_users ';
 
     | 
  
  
    | 
      419
     | 
    
      		$sql .= 'FROM `'.TABLE_PREFIX.'pages` ';
 
     | 
  
  
    | 
      420
     | 
    
      		$sql .= 'WHERE `parent`='.(int)$this->menu_parent.' AND '.$menu_number.' AND '.$this->extra_where_sql.' ';
 
     | 
  
  
    | 
      421
     | 
    
      		$sql .= 'ORDER BY `position` ASC';
 
     | 
  
  
    | 
      422
     | 
    
      		$query_menu = $database->query($sql);
 
     | 
  
  
    | 
      423
     | 
    
      		// Check if there are any pages to show
 
     | 
  
  
    | 
      424
     | 
    
      		if($query_menu->numRows() > 0) {
     | 
  
  
    | 
      425
     | 
    
      			// Print menu header
 
     | 
  
  
    | 
      426
     | 
    
      			echo "\n".$this->menu_header;
 
     | 
  
  
    | 
      427
     | 
    
      			// Loop through pages
 
     | 
  
  
    | 
      428
     | 
    
      			while($page = $query_menu->fetchRow()) {
     | 
  
  
    | 
      429
     | 
    
      				// check whether to show this menu-link
 
     | 
  
  
    | 
      430
     | 
    
      				if($this->page_is_active($page)==false && $page['link']!=$this->default_link && !INTRO_PAGE) {
     | 
  
  
    | 
      431
     | 
    
      					continue; // no active sections
 
     | 
  
  
    | 
      432
     | 
    
      				}
 
     | 
  
  
    | 
      433
     | 
    
      				if($this->page_is_visible($page)==false) {
     | 
  
  
    | 
      434
     | 
    
      					if($page['visibility'] != 'registered') // special case: page_to_visible() check wheter to show the page contents, but the menu should be visible allways
 
     | 
  
  
    | 
      435
     | 
    
      						continue;
 
     | 
  
  
    | 
      436
     | 
    
      				}
 
     | 
  
  
    | 
      437
     | 
    
      				// Create vars
 
     | 
  
  
    | 
      438
     | 
    
      				$vars = array('[class]','[a]', '[/a]', '[menu_title]', '[page_title]');
     | 
  
  
    | 
      439
     | 
    
      				// Work-out class
 
     | 
  
  
    | 
      440
     | 
    
      				if($page['page_id'] == PAGE_ID) {
     | 
  
  
    | 
      441
     | 
    
      					$class = $this->menu_current_class;
 
     | 
  
  
    | 
      442
     | 
    
      				} else {
     | 
  
  
    | 
      443
     | 
    
      					$class = $this->menu_default_class;
 
     | 
  
  
    | 
      444
     | 
    
      				}
 
     | 
  
  
    | 
      445
     | 
    
      				// Check if link is same as first page link, and if so change to WB URL
 
     | 
  
  
    | 
      446
     | 
    
      				if($page['link'] == $this->default_link AND !INTRO_PAGE) {
     | 
  
  
    | 
      447
     | 
    
      					$link = WB_URL;
 
     | 
  
  
    | 
      448
     | 
    
      				} else {
     | 
  
  
    | 
      449
     | 
    
      					$link = $this->page_link($page['link']);
 
     | 
  
  
    | 
      450
     | 
    
      				}
 
     | 
  
  
    | 
      451
     | 
    
      				// Create values
 
     | 
  
  
    | 
      452
     | 
    
      				$values = array($class,'<a href="'.$link.'" target="'.$page['target'].'" '.$class.'>', '</a>', $page['menu_title'], $page['page_title']);
 
     | 
  
  
    | 
      453
     | 
    
      				// Replace vars with value and print
 
     | 
  
  
    | 
      454
     | 
    
      				echo "\n".str_replace($vars, $values, $this->menu_item_template);
 
     | 
  
  
    | 
      455
     | 
    
      				// Generate sub-menu
 
     | 
  
  
    | 
      456
     | 
    
      				if($this->menu_collapse==false OR ($this->menu_collapse==true AND isset($this->page_trail[$page['page_id']]))) {
     | 
  
  
    | 
      457
     | 
    
      					$this->menu_recurse--;
 
     | 
  
  
    | 
      458
     | 
    
      					$this->menu_parent=$page['page_id'];
 
     | 
  
  
    | 
      459
     | 
    
      					$this->show_menu();
 
     | 
  
  
    | 
      460
     | 
    
      				}
 
     | 
  
  
    | 
      461
     | 
    
      				echo "\n".$this->menu_item_footer;
 
     | 
  
  
    | 
      462
     | 
    
      			}
 
     | 
  
  
    | 
      463
     | 
    
      			// Print menu footer
 
     | 
  
  
    | 
      464
     | 
    
      			echo "\n".$this->menu_footer;
 
     | 
  
  
    | 
      465
     | 
    
      		}
 
     | 
  
  
    | 
      466
     | 
    
      	}
 
     | 
  
  
    | 
      467
     | 
    
      
 
     | 
  
  
    | 
      468
     | 
    
      
 
     | 
  
  
    | 
      469
     | 
    
      	// Function to show the "Under Construction" page
 
     | 
  
  
    | 
      470
     | 
    
      	public function print_under_construction() {
     | 
  
  
    | 
      471
     | 
    
      		$this->ShowMaintainScreen('new');
     | 
  
  
    | 
      472
     | 
    
      		exit();
 
     | 
  
  
    | 
      473
     | 
    
      	}
 
     | 
  
  
    | 
      474
     | 
    
      }
 
     | 
  
  
    | 
      475
     | 
    
      
 
     |