Project

General

Profile

« Previous | Next » 

Revision 1782

Added by Dietmar about 12 years ago

+ add maintance modus in backend

View differences:

class.admin.php
1 1
<?php
2 2
/**
3 3
 *
4
 * @category        framewotk
5
 * @package         backend admin
6
 * @author          Ryan Djurovich, WebsiteBaker Project
4
 * @category        backend
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
......
28 28

  
29 29
// Include EditArea wrapper functions
30 30
// require_once(WB_PATH . '/include/editarea/wb_wrapper_edit_area.php');
31
//require_once(WB_PATH . '/framework/SecureForm.php');
31
// require_once(WB_PATH . '/framework/SecureForm.php');
32 32

  
33 33

  
34 34
/**
......
53 53
	public function __construct($section_name= '##skip##', $section_permission = 'start', $auto_header = true, $auto_auth = true)
54 54
	{
55 55
		parent::__construct(SecureForm::BACKEND);
56
	if( $section_name != '##skip##' )
57
	{
58
		global $database, $MESSAGE;
59
		// Specify the current applications name
60
		$this->section_name = $section_name;
61
		$this->section_permission = $section_permission;
62
		// Authenticate the user for this application
63
		if($auto_auth == true)
64
		{
65
			// First check if the user is logged-in
66
			if($this->is_authenticated() == false)
56
    	if( $section_name != '##skip##' )
57
    	{
58
    		global $database, $MESSAGE;
59
    		// Specify the current applications name
60
    		$this->section_name = $section_name;
61
    		$this->section_permission = $section_permission;
62
    		$maintance = ( defined('SYSTEM_LOCKED') && (SYSTEM_LOCKED==true) ? true : false );
63
    		// Authenticate the user for this application
64
    		if( ($auto_auth == true) )
65
    		{
66
    			// First check if the user is logged-in
67
    			if($this->is_authenticated() == false)
68
    			{
69
    				header('Location: '.ADMIN_URL.'/login/index.php');
70
    				exit(0);
71
    			}
72
    			// Now check if they are allowed in this section
73
    			if($this->get_permission($section_permission) == false) {
74
    				die($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
75
    			}
76
    		}
77

  
78
			if( ($maintance==true) || $this->get_session('USER_ID')!= 1 )
67 79
			{
68
				header('Location: '.ADMIN_URL.'/login/index.php');
69
				exit(0);
70
			}
80
           	//  check for show maintenance screen and terminate if needed
81
        		$this->ShowMaintainScreen('locked');
82
            }
71 83

  
72
			// Now check if they are allowed in this section
73
			if($this->get_permission($section_permission) == false) {
74
				die($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
75
			}
76
		}
84
    		// Check if the backend language is also the selected language. If not, send headers again.
85
    		$sql  = 'SELECT `language` FROM `'.TABLE_PREFIX.'users` ';
86
    		$sql .= 'WHERE `user_id`='.(int)$this->get_user_id();
87
    		$get_user_language = @$database->query($sql);
88
    		$user_language = ($get_user_language) ? $get_user_language->fetchRow() : '';
89
    		// prevent infinite loop if language file is not XX.php (e.g. DE_du.php)
90
    		$user_language = substr($user_language[0],0,2);
91
    		// obtain the admin folder (e.g. /admin)
92
    		$admin_folder = str_replace(WB_PATH, '', ADMIN_PATH);
77 93

  
78
		// Check if the backend language is also the selected language. If not, send headers again.
79
		$sql  = 'SELECT `language` FROM `'.TABLE_PREFIX.'users` ';
80
		$sql .= 'WHERE `user_id`='.(int)$this->get_user_id();
81
		$get_user_language = @$database->query($sql);
82
		$user_language = ($get_user_language) ? $get_user_language->fetchRow() : '';
83
		// prevent infinite loop if language file is not XX.php (e.g. DE_du.php)
84
		$user_language = substr($user_language[0],0,2);
85
		// obtain the admin folder (e.g. /admin)
86
		$admin_folder = str_replace(WB_PATH, '', ADMIN_PATH);
87
		if((LANGUAGE != $user_language) && file_exists(WB_PATH .'/languages/' .$user_language .'.php')
88
			&& strpos($_SERVER['PHP_SELF'],$admin_folder.'/') !== false) {
89
			// check if page_id is set
90
			$page_id_url = (isset($_GET['page_id'])) ? '&page_id=' .(int) $_GET['page_id'] : '';
91
			$section_id_url = (isset($_GET['section_id'])) ? '&section_id=' .(int) $_GET['section_id'] : '';
92
			if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') { // check if there is an query-string
93
				header('Location: '.$_SERVER['PHP_SELF'] .'?lang='.$user_language .$page_id_url .$section_id_url.'&'.$_SERVER['QUERY_STRING']);
94
			} else {
95
				header('Location: '.$_SERVER['PHP_SELF'] .'?lang='.$user_language .$page_id_url .$section_id_url);
96
			}
97
			exit();
98
		}
94
    		if( (LANGUAGE != $user_language) && file_exists(WB_PATH .'/languages/' .$user_language .'.php')
95
    			&& strpos($_SERVER['SCRIPT_NAME'],$admin_folder.'/') !== false) {
96
    			// check if page_id is set
97
    			$page_id_url = (isset($_GET['page_id'])) ? '&page_id=' .(int) $_GET['page_id'] : '';
98
    			$section_id_url = (isset($_GET['section_id'])) ? '&section_id=' .(int) $_GET['section_id'] : '';
99
    			 //  check if there is an query-string
100
    			if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') {
101
    				header('Location: '.$_SERVER['SCRIPT_NAME'] .'?lang='.$user_language .$page_id_url .$section_id_url.'&'.$_SERVER['QUERY_STRING']);
102
    			} else {
103
    				header('Location: '.$_SERVER['SCRIPT_NAME'] .'?lang='.$user_language .$page_id_url .$section_id_url);
104
    			}
105
    			exit();
106
    		}
99 107

  
100
		// Auto header code
101
		if($auto_header == true) {
102
			$this->print_header();
103
		}
108
    		// Auto header code
109
    		if($auto_header == true) {
110
    			$this->print_header();
111
    		}
112
    	}
104 113
	}
105
	}
106 114

  
107 115
	// Print the admin header
108 116
	/**
109
	 * admin::print_header()
110 117
	 *
111 118
	 * @param string $body_tags
112 119
	 * @return void
......
143 150
			$row = @$result->fetchRow();
144 151
			if($row) $view_url .= PAGES_DIRECTORY .$row['link']. PAGE_EXTENSION;
145 152
		}
153

  
154
        $HelpUrl = ((strtolower(LANGUAGE)!='de') ? '/en/help.php' : '/de/hilfe.php');
146 155
		$sServerAdress = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1';
147 156
		$header_template->set_var(	array(
148 157
							'SECTION_FORGOT' => $MENU['FORGOT'],
......
166 175
							'START_CLASS' => 'start',
167 176
							'TITLE_START' => $TEXT['READ_MORE'],
168 177
							'TITLE_VIEW' => $TEXT['WEBSITE'],
169
							'TITLE_HELP' => $MENU['HELP'],
178
							'TITLE_HELP' => 'WebsiteBaker '.$MENU['HELP'],
170 179
							'URL_VIEW' => $view_url,
171 180
							'TITLE_LOGOUT' => $MENU['LOGIN'],
172 181
							'LOGIN_DISPLAY_HIDDEN' => !$this->is_authenticated() ? 'hidden' : '',
......
174 183
							'LOGIN_LINK' => $_SERVER['SCRIPT_NAME'],
175 184
							'LOGIN_ICON' => 'login',
176 185
							'START_ICON' => 'blank',
177
							'URL_HELP' => 'http://www.websitebaker.org/',
186
							'URL_HELP' => 'http://www.websitebaker2.org'.$HelpUrl,
178 187
							'BACKEND_MODULE_CSS' => $this->register_backend_modfiles('css'),	// adds backend.css
179 188
							'BACKEND_MODULE_JS'  => $this->register_backend_modfiles('js')		// adds backend.js
180 189
						)
181 190
					);
191
		$header_template->set_block('header_block', 'maintenance_block', 'maintenance');
192
		if($this->get_user_id() == 1)
193
		{
194
			$sys_locked = (((int)(defined('SYSTEM_LOCKED') ? SYSTEM_LOCKED : 0)) == 1);
195
			$header_template->set_var('MAINTENANCE_MODE', ($sys_locked ? $TEXT['MAINTENANCE_OFF'] : $TEXT['MAINTENANCE_ON']));
196
			$header_template->set_var('MAINTENANCE_ICON', THEME_URL.'/images/'.($sys_locked ? 'lock' : 'unlock').'.png');
197
			$header_template->set_var('MAINTAINANCE_URL', ADMIN_URL.'/settings/locking.php');
198
			$header_template->parse('maintenance', 'maintenance_block', true);
199
		}else
200
		{
201
			$header_template->set_block('maintenance_block', '');
202
		}
182 203

  
183 204
		// Create the menu
205
        $UrlLang = ((strtolower(LANGUAGE)!='de') ? 'en' : strtolower(LANGUAGE));
184 206
		if(!$this->is_authenticated())
185 207
		{
186
		$header_template->set_var('STYLE', 'login');
187
		$menu = array(
208
    		$header_template->set_var('STYLE', 'login');
209
    		$menu = array(
188 210
//						array('http://www.websitebaker.org/', '_blank', 'WebsiteBaker Home', 'help', 0),
189 211
//						array($view_url, '_blank', $TEXT['FRONTEND'], '', 0),
190 212
//						array(ADMIN_URL.'/login/index.php', '', $MENU['LOGIN'], '', 0)
......
201 223
						'TITLE_START' => $MENU['START']
202 224
						)
203 225
					);
204
			// @array ( $url, $target, $title, $page_permission, $ppermission_required )
226

  
227
			// @array ( $url, $target, $title, $page_permission, $permission_required )
205 228
			$menu = array(
206 229
//					array(ADMIN_URL.'/index.php', '', $MENU['START'], 'start', 1 ),
207 230
					array(ADMIN_URL.'/pages/index.php', '', $MENU['PAGES'], 'pages', 1),
......
212 235
					array(ADMIN_URL.'/settings/index.php', '', $MENU['SETTINGS'], 'settings', 1),
213 236
					array(ADMIN_URL.'/admintools/index.php', '', $MENU['ADMINTOOLS'], 'admintools', 1),
214 237
					array(ADMIN_URL.'/access/index.php', '', $MENU['ACCESS'], 'access', 1),
238
//					array('http://addons.websitebaker2.org/', '', 'WB-Addons', 'preferences', 1),
239
//					array('http://template.websitebaker2.org/', '', 'WB-Template', 'preferences', 1),
215 240
//					array('http://www.websitebaker.org/', '_blank', 'WebsiteBaker Home', '', 0),
216 241
//					array(ADMIN_URL.'/logout/index.php', '', $MENU['LOGOUT'], '', 0)
217

  
218 242
					);
219 243
		}
220 244

  

Also available in: Unified diff