Revision 1782
Added by Dietmar about 12 years ago
class.frontend.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
/** |
3 | 3 |
* |
4 |
* @category framework
|
|
5 |
* @package frontend
|
|
6 |
* @author Ryan Djurovich, WebsiteBaker Project |
|
4 |
* @category frontend
|
|
5 |
* @package framework
|
|
6 |
* @author Ryan Djurovich (2004-2009), WebsiteBaker Project
|
|
7 | 7 |
* @copyright 2009-2012, WebsiteBaker Org. e.V. |
8 | 8 |
* @link http://www.websitebaker2.org/ |
9 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
... | ... | |
13 | 13 |
* @filesource $HeadURL$ |
14 | 14 |
* @lastmodified $Date$ |
15 | 15 |
* |
16 |
*/ |
|
16 |
*/
|
|
17 | 17 |
/* -------------------------------------------------------- */ |
18 | 18 |
// Must include code to stop this file being accessed directly |
19 | 19 |
if(!defined('WB_PATH')) { |
... | ... | |
21 | 21 |
throw new IllegalFileException(); |
22 | 22 |
} |
23 | 23 |
/* -------------------------------------------------------- */ |
24 |
require_once(WB_PATH.'/framework/class.wb.php'); |
|
24 |
//require_once(WB_PATH.'/framework/class.wb.php');
|
|
25 | 25 |
//require_once(WB_PATH.'/framework/SecureForm.php'); |
26 |
if(!class_exists('wb', false)){ require(WB_PATH.'/framework/class.wb.php'); } |
|
26 | 27 |
|
27 | 28 |
class frontend extends wb { |
28 | 29 |
// defaults |
... | ... | |
47 | 48 |
// ugly database stuff |
48 | 49 |
public $extra_where_sql, $sql_where_language; |
49 | 50 |
|
50 |
public function __construct() { |
|
51 |
// do not chnage if working in frontend account |
|
52 |
public $FrontendLanguage; |
|
53 |
|
|
54 |
public function __construct($value=true) { |
|
51 | 55 |
parent::__construct(SecureForm::FRONTEND); |
56 |
$this->FrontendLanguage = isset($value) ? $value : true; |
|
52 | 57 |
} |
53 | 58 |
|
59 |
public function ChangeFrontendLanguage( $value=true ) { |
|
60 |
$this->FrontendLanguage=$value; |
|
61 |
} |
|
62 |
|
|
54 | 63 |
public function page_select() { |
55 |
global $page_id,$no_intro; |
|
56 |
global $database; |
|
64 |
global $database, $page_id,$no_intro; |
|
65 |
/* |
|
66 |
// set by user statusflag and maintance enabled select in options |
|
67 |
// if maintance flag is set registered user can see normal pages |
|
68 |
// otherwise show show maintance message |
|
69 |
|
|
70 |
if($maintance == true) |
|
71 |
{ |
|
72 |
$this->print_under_construction(); |
|
73 |
return false; |
|
74 |
} |
|
75 |
*/ |
|
76 |
|
|
77 |
/** |
|
78 |
* Store installed languages in SESSION |
|
79 |
*/ |
|
80 |
|
|
81 |
if( $this->get_session('session_started') ) { |
|
82 |
$_SESSION['USED_LANGUAGES'] = $this->GetLanguagesInUsed(); |
|
83 |
} |
|
84 |
|
|
85 |
$maintance = ( defined('SYSTEM_LOCKED') && (SYSTEM_LOCKED==true) ? true : false ); |
|
57 | 86 |
// We have no page id and are supposed to show the intro page |
58 |
if((INTRO_PAGE AND !isset($no_intro)) AND (!isset($page_id) OR !is_numeric($page_id))) { |
|
87 |
if((INTRO_PAGE && ($maintance != true) && !isset($no_intro)) && (!isset($page_id) || !is_numeric($page_id))) |
|
88 |
{ |
|
59 | 89 |
// Since we have no page id check if we should go to intro page or default page |
60 | 90 |
// Get intro page content |
61 |
$filename = WB_PATH.PAGES_DIRECTORY.'/intro'.PAGE_EXTENSION; |
|
62 |
if(file_exists($filename)) { |
|
63 |
$handle = @fopen($filename, "r"); |
|
64 |
$content = @fread($handle, filesize($filename)); |
|
65 |
@fclose($handle); |
|
66 |
$this->preprocess($content); |
|
67 |
header("Location: ".WB_URL.PAGES_DIRECTORY."/intro".PAGE_EXTENSION.""); // send intro.php as header to allow parsing of php statements |
|
68 |
echo ($content); |
|
69 |
return false; |
|
91 |
$sIntroFilename = PAGES_DIRECTORY.'/intro'.PAGE_EXTENSION; |
|
92 |
if(file_exists(WB_PATH.$sIntroFilename)) { |
|
93 |
// send intro.php as header to allow parsing of php statements |
|
94 |
header("Location: ".WB_URL.$sIntroFilename.""); |
|
95 |
exit(); |
|
70 | 96 |
} |
71 | 97 |
} |
98 |
|
|
72 | 99 |
// Check if we should add page language sql code |
73 | 100 |
if(PAGE_LANGUAGES) { |
74 | 101 |
$this->sql_where_language = ' AND `language`=\''.LANGUAGE.'\''; |
... | ... | |
87 | 114 |
$sql .= trim($this->sql_where_language).' '; |
88 | 115 |
} |
89 | 116 |
$sql .= 'ORDER BY `p`.`position` ASC'; |
90 |
$get_default = $database->query($sql); |
|
91 |
$default_num_rows = $get_default->numRows(); |
|
92 |
if(!isset($page_id) OR !is_numeric($page_id)){ |
|
93 |
// Go to or show default page |
|
94 |
if($default_num_rows > 0) { |
|
95 |
$fetch_default = $get_default->fetchRow(); |
|
96 |
$this->default_link = $fetch_default['link']; |
|
97 |
$this->default_page_id = $fetch_default['page_id']; |
|
98 |
// Check if we should redirect or include page inline |
|
99 |
if(HOMEPAGE_REDIRECTION) { |
|
100 |
// Redirect to page |
|
101 |
// header("Location: ".$this->page_link($this->default_link)); |
|
102 |
// exit(); |
|
103 |
$this->send_header($this->page_link($this->default_link)); |
|
104 |
} else { |
|
105 |
// Include page inline |
|
106 |
$this->page_id = $this->default_page_id; |
|
107 |
} |
|
108 |
} else { |
|
109 |
// No pages have been added, so print under construction page |
|
110 |
$this->print_under_construction(); |
|
111 |
exit(); |
|
112 |
} |
|
117 |
if($get_default = $database->query($sql)) { |
|
118 |
|
|
119 |
$default_num_rows = $get_default->numRows(); |
|
120 |
if(!isset($page_id) OR !is_numeric($page_id)){ |
|
121 |
// Go to or show default page |
|
122 |
if($default_num_rows > 0) { |
|
123 |
$fetch_default = $get_default->fetchRow(MYSQL_ASSOC); |
|
124 |
$this->default_link = $fetch_default['link']; |
|
125 |
$this->default_page_id = $fetch_default['page_id']; |
|
126 |
// Check if we should redirect or include page inline |
|
127 |
if(HOMEPAGE_REDIRECTION) { |
|
128 |
// Redirect to page |
|
129 |
// header("Location: ".$this->page_link($this->default_link)); |
|
130 |
// exit(); |
|
131 |
$this->send_header($this->page_link($this->default_link)); |
|
132 |
} else { |
|
133 |
// Include page inline |
|
134 |
$this->page_id = $this->default_page_id; |
|
135 |
} |
|
136 |
} else { |
|
137 |
// No pages have been added, so print under construction page |
|
138 |
// if(trim($this->sql_where_language) == '') { |
|
139 |
// $this->ShowMaintainScreen('new'); |
|
140 |
// exit(); |
|
141 |
// } |
|
142 |
$this->ShowMaintainScreen('new'); |
|
143 |
// $this->print_under_construction(); |
|
144 |
exit(); |
|
145 |
} |
|
146 |
} else { |
|
147 |
$this->page_id=$page_id; |
|
148 |
} |
|
149 |
// Get default page link |
|
150 |
if(!isset($fetch_default)) { |
|
151 |
$fetch_default = $get_default->fetchRow(MYSQL_ASSOC); |
|
152 |
$this->default_link = $fetch_default['link']; |
|
153 |
$this->default_page_id = $fetch_default['page_id']; |
|
154 |
} |
|
155 |
return true; |
|
156 |
|
|
113 | 157 |
} else { |
114 |
$this->page_id=$page_id; |
|
115 |
} |
|
116 |
// Get default page link |
|
117 |
if(!isset($fetch_default)) { |
|
118 |
$fetch_default = $get_default->fetchRow(); |
|
119 |
$this->default_link = $fetch_default['link']; |
|
120 |
$this->default_page_id = $fetch_default['page_id']; |
|
121 |
} |
|
122 |
return true; |
|
158 |
$this->ShowMaintainScreen('new'); |
|
159 |
exit(); |
|
160 |
} |
|
161 |
|
|
123 | 162 |
} |
124 | 163 |
|
125 | 164 |
public function get_page_details() { |
... | ... | |
134 | 173 |
exit("Page not found"); |
135 | 174 |
} |
136 | 175 |
// Fetch page details |
137 |
$this->page = $get_page->fetchRow(); |
|
138 |
// Check if the page language is also the selected language. If not, send headers again. |
|
139 |
if ($this->page['language']!=LANGUAGE) { |
|
140 |
if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') { // check if there is an query-string |
|
176 |
$this->page = $get_page->fetchRow(MYSQL_ASSOC); |
|
177 |
|
|
178 |
// Check if the page language is also the selected language. If not, send headers again. |
|
179 |
if (($this->page['language'] != LANGUAGE) && $this->FrontendLanguage ) |
|
180 |
{ |
|
181 |
// check if there is an query-string |
|
182 |
if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') { |
|
141 | 183 |
header('Location: '.$this->page_link($this->page['link']).'?'.$_SERVER['QUERY_STRING'].'&lang='.$this->page['language']); |
142 | 184 |
} else { |
143 | 185 |
header('Location: '.$this->page_link($this->page['link']).'?lang='.$this->page['language']); |
144 | 186 |
} |
145 | 187 |
exit(); |
146 | 188 |
} |
189 |
|
|
147 | 190 |
// Begin code to set details as either variables of constants |
148 | 191 |
// Page ID |
149 | 192 |
if(!defined('PAGE_ID')) {define('PAGE_ID', $this->page['page_id']);} |
... | ... | |
233 | 276 |
// User isnt allowed on this page so tell them |
234 | 277 |
$this->page_access_denied=true; |
235 | 278 |
} |
236 |
|
|
237 | 279 |
} |
238 | 280 |
} |
239 | 281 |
// check if there is at least one active section |
... | ... | |
411 | 453 |
|
412 | 454 |
// Function to show the "Under Construction" page |
413 | 455 |
public function print_under_construction() { |
414 |
global $MESSAGE; |
|
415 |
require_once(WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php'); |
|
416 |
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
417 |
<head><title>'.$MESSAGE['GENERIC']['WEBSITE_UNDER_CONSTRUCTION'].'</title> |
|
418 |
<style type="text/css"><!-- body{ font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px; background-image: url("'.THEME_URL.'/images/background.png");background-repeat: repeat-x; background-color: #A8BCCB; text-align: center; } |
|
419 |
h1 { margin: 0; padding: 0; font-size: 18px; color: #000; text-transform: uppercase; |
|
420 |
}--></style></head><body> |
|
421 |
<br /><h1>'.$MESSAGE['GENERIC']['WEBSITE_UNDER_CONSTRUCTION'].'</h1><br /> |
|
422 |
'.$MESSAGE['GENERIC']['PLEASE_CHECK_BACK_SOON'].'</body></html>'; |
|
456 |
$this->ShowMaintainScreen('new'); |
|
457 |
exit(); |
|
423 | 458 |
} |
424 | 459 |
} |
425 | 460 |
|
Also available in: Unified diff
+ add maintance modus in backend