| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        admin
 | 
  
    | 5 |  * @package         start
 | 
  
    | 6 |  * @author          Ryan Djurovich (2004-2009), WebsiteBaker Project
 | 
  
    | 7 |  * @copyright       2009-2013, WebsiteBaker Org. e.V.
 | 
  
    | 8 |  * @link            http://www.websitebaker.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: index.php 1907 2013-06-07 02:30:42Z Luisehahne $
 | 
  
    | 13 |  * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
 | 
  
    | 14 |  * @lastmodified    $Date: 2013-06-07 04:30:42 +0200 (Fri, 07 Jun 2013) $
 | 
  
    | 15 |  *
 | 
  
    | 16 |  */
 | 
  
    | 17 | 
 | 
  
    | 18 | $config_file = realpath('../../config.php');
 | 
  
    | 19 | if(file_exists($config_file) && !defined('WB_URL'))
 | 
  
    | 20 | {
 | 
  
    | 21 | 	require_once($config_file);
 | 
  
    | 22 | }
 | 
  
    | 23 | 
 | 
  
    | 24 | if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
 | 
  
    | 25 | 
 | 
  
    | 26 | $admin = new admin('Start','start');
 | 
  
    | 27 | // ---------------------------------------
 | 
  
    | 28 | //	$database = WbDatabase::getInstance();
 | 
  
    | 29 | 
 | 
  
    | 30 | if(defined('FINALIZE_SETUP')) {
 | 
  
    | 31 | 	require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 32 | 	$dirs = array( 'modules'   => WB_PATH.'/modules/',
 | 
  
    | 33 | 	               'templates' => WB_PATH.'/templates/',
 | 
  
    | 34 | 	               'languages' => WB_PATH.'/languages/'
 | 
  
    | 35 | 	             );
 | 
  
    | 36 | 	foreach($dirs AS $type => $dir) {
 | 
  
    | 37 | 		if( ($handle = opendir($dir)) ) {
 | 
  
    | 38 | 			while(false !== ($file = readdir($handle))) {
 | 
  
    | 39 | 				if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
 | 
  
    | 40 | 					// Get addon type
 | 
  
    | 41 | 					if($type == 'modules') {
 | 
  
    | 42 | 						load_module($dir.'/'.$file, true);
 | 
  
    | 43 | 						// Pretty ugly hack to let modules run $admin->set_error
 | 
  
    | 44 | 						// See dummy class definition admin_dummy above
 | 
  
    | 45 | 						if(isset($admin->error) && $admin->error != '') {
 | 
  
    | 46 | 							$admin->print_error($admin->error);
 | 
  
    | 47 | 						}
 | 
  
    | 48 | 					} elseif($type == 'templates') {
 | 
  
    | 49 | 						load_template($dir.'/'.$file);
 | 
  
    | 50 | 					} elseif($type == 'languages') {
 | 
  
    | 51 | 						load_language($dir.'/'.$file);
 | 
  
    | 52 | 					}
 | 
  
    | 53 | 				}
 | 
  
    | 54 | 			}
 | 
  
    | 55 | 		closedir($handle);
 | 
  
    | 56 | 		}
 | 
  
    | 57 | 	}
 | 
  
    | 58 | 	$sql = 'DELETE FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
 | 
  
    | 59 | 	if($database->query($sql)) { }
 | 
  
    | 60 | }
 | 
  
    | 61 | // ---------------------------------------
 | 
  
    | 62 | // check if it is neccessary to start the uograde-script
 | 
  
    | 63 | 
 | 
  
    | 64 | $msg  = '';
 | 
  
    | 65 | $msg .= (is_readable(WB_PATH.'/install/')) ?  $MESSAGE['START_INSTALL_DIR_EXISTS'].'<br />' : $msg;
 | 
  
    | 66 | $msg .= (is_readable(WB_PATH.'/upgrade-script.php')) ?  $MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />' : '';
 | 
  
    | 67 | //$msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
 | 
  
    | 68 | 
 | 
  
    | 69 | // ---------------------------------------
 | 
  
    | 70 | // check if it is neccessary to start the uograde-script
 | 
  
    | 71 | // ---------------------------------------
 | 
  
    | 72 | if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
 | 
  
    | 73 | 	// check if it is neccessary to start the uograde-script
 | 
  
    | 74 | 	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
 | 
  
    | 75 | 	if($wb_revision=$database->get_one($sql)) {
 | 
  
    | 76 | 	}
 | 
  
    | 77 | 	if (version_compare($wb_revision, REVISION ) < 0) {
 | 
  
    | 78 | echo "<p style=\"text-align:center;\"> If the <strong>upgrade script</strong> could not be start automatically.\n" .
 | 
  
    | 79 |      "Please click <a style=\"font-weight:bold;\" " .
 | 
  
    | 80 |      "href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
 | 
  
    | 81 | 
 | 
  
    | 82 | echo "<script type=\"text/javascript\">
 | 
  
    | 83 | <!--
 | 
  
    | 84 | // Get the location object
 | 
  
    | 85 | var locationObj = document.location;
 | 
  
    | 86 | // Set the value of the location object
 | 
  
    | 87 | document.location = '".WB_URL."/upgrade-script.php';
 | 
  
    | 88 | -->
 | 
  
    | 89 | </script>";
 | 
  
    | 90 | 
 | 
  
    | 91 | //		if(!headers_sent()) {
 | 
  
    | 92 | //			header('Location: '.WB_URL.'/upgrade-script.php');
 | 
  
    | 93 | //		    exit;
 | 
  
    | 94 | //		} else {
 | 
  
    | 95 | //		    echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
 | 
  
    | 96 | //		         "Please click <a style=\"font-weight:bold;\" " .
 | 
  
    | 97 | //		         "href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
 | 
  
    | 98 | //		    exit;
 | 
  
    | 99 | //		}
 | 
  
    | 100 | 	}
 | 
  
    | 101 | }
 | 
  
    | 102 | // ---------------------------------------
 | 
  
    | 103 | // workout to upgrade the groups system_permissions
 | 
  
    | 104 | // ---------------------------------------
 | 
  
    | 105 | if( ($admin->get_user_id()==1) &&
 | 
  
    | 106 | 	file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
 | 
  
    | 107 | {
 | 
  
    | 108 | 	// check if it is neccessary to start the uograde-script
 | 
  
    | 109 | 	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
 | 
  
    | 110 | 	if($wb_revision = $database->get_one($sql)) {
 | 
  
    | 111 | 
 | 
  
    | 112 | 	}
 | 
  
    | 113 | 
 | 
  
    | 114 | 	if ((version_compare($wb_revision, '1800' )  < 0)&& !defined('GROUPS_UPDATED')) {
 | 
  
    | 115 | 		require_once (ADMIN_PATH.'/groups/upgradePermissions.php');
 | 
  
    | 116 | 		// build new or changed $sTempPermissions
 | 
  
    | 117 | 		if(upgrade_group_system_permissions()){
 | 
  
    | 118 | 			$cfg = array(
 | 
  
    | 119 | 				'groups_updated' => time()
 | 
  
    | 120 | 			);
 | 
  
    | 121 | 			if(db_update_key_value( 'settings', $cfg )) {
 | 
  
    | 122 | 			    echo "<div class=\"note center rounded\"><h3>Hello Systemadministrator!</h3>".
 | 
  
    | 123 | 				     "<p style=\"text-align:center;\">".
 | 
  
    | 124 | 				     "The <strong>Administrator Groups Rights </strong> were updated automatically.\n" .
 | 
  
    | 125 | 			         "Please click <a style=\"font-weight:bold;\" " .
 | 
  
    | 126 | 			         "href=\"".ADMIN_URL."/logout/index.php\">on this link</a> to login again!</p>\n".
 | 
  
    | 127 | 			         "<h3>Upgrading only start, if groups rights are not up to date!</h3></div>";
 | 
  
    | 128 | 				// Print admin footer
 | 
  
    | 129 | 				$admin->print_footer();
 | 
  
    | 130 | 			    exit(0);
 | 
  
    | 131 | 
 | 
  
    | 132 | 			}
 | 
  
    | 133 | 		}
 | 
  
    | 134 | 	}
 | 
  
    | 135 | }
 | 
  
    | 136 | 
 | 
  
    | 137 | /**
 | 
  
    | 138 |  * delete Outdated Confirmations
 | 
  
    | 139 |  */
 | 
  
    | 140 | $sql = 'DELETE FROM `'.TABLE_PREFIX.'users` WHERE `confirm_timeout` BETWEEN 1 AND '.time();
 | 
  
    | 141 | WbDatabase::getInstance()->query($sql);
 | 
  
    | 142 | 
 | 
  
    | 143 | /**
 | 
  
    | 144 |  * delete Outdated Confirmations
 | 
  
    | 145 |  */
 | 
  
    | 146 | $sql = 'UPDATE `'.TABLE_PREFIX.'users` SET `login_ip` = \'\' WHERE `login_when` < '.(time()-(60*84600));
 | 
  
    | 147 | WbDatabase::getInstance()->query($sql);
 | 
  
    | 148 | 
 | 
  
    | 149 | // ---------------------------------------
 | 
  
    | 150 | // Setup template object, parse vars to it, then parse it
 | 
  
    | 151 | // Create new template object
 | 
  
    | 152 | $oTpl = new Template(dirname($admin->correct_theme_source('start.htt')),'keep');
 | 
  
    | 153 | $oTpl->set_file('page', 'start.htt');
 | 
  
    | 154 | $oTpl->set_block('page', 'main_block', 'main');
 | 
  
    | 155 | 
 | 
  
    | 156 | // Insert values into the template object
 | 
  
    | 157 | $oTpl->set_var(array(
 | 
  
    | 158 | 					'WELCOME_MESSAGE' => $MESSAGE['START_WELCOME_MESSAGE'],
 | 
  
    | 159 | 					'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
 | 
  
    | 160 | 					'DISPLAY_NAME' => $admin->get_display_name(),
 | 
  
    | 161 |                     'DISPLAY_WARNING' => '',
 | 
  
    | 162 |                     'WARNING' => '',
 | 
  
    | 163 | 					'ADMIN_URL' => ADMIN_URL,
 | 
  
    | 164 | 					'WB_URL' => WB_URL,
 | 
  
    | 165 | 					'THEME_URL' => THEME_URL,
 | 
  
    | 166 | 					'WB_VERSION' => WB_VERSION,
 | 
  
    | 167 | 					'NO_CONTENT' => ''
 | 
  
    | 168 | 				)
 | 
  
    | 169 | 			);
 | 
  
    | 170 | 
 | 
  
    | 171 | // Insert permission values into the template object
 | 
  
    | 172 | $oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
 | 
  
    | 173 | if($admin->get_permission('pages') != true)
 | 
  
    | 174 | {
 | 
  
    | 175 | 	$oTpl->set_block('show_pages', '');
 | 
  
    | 176 | } else {
 | 
  
    | 177 | 	$oTpl->parse('show_pages', 'show_pages_block', true);
 | 
  
    | 178 | }
 | 
  
    | 179 | 
 | 
  
    | 180 | $oTpl->set_block('main_block', 'show_addons_block', 'show_addons');
 | 
  
    | 181 | if($admin->get_permission('addons') != true)
 | 
  
    | 182 | {
 | 
  
    | 183 | 	$oTpl->set_block('show_addons', '');
 | 
  
    | 184 | } else {
 | 
  
    | 185 | 	$oTpl->parse('show_addons', 'show_addons_block', true);
 | 
  
    | 186 | }
 | 
  
    | 187 | 
 | 
  
    | 188 | $oTpl->set_block('main_block', 'show_settings_block', 'show_settings');
 | 
  
    | 189 | if($admin->get_permission('settings') != true)
 | 
  
    | 190 | {
 | 
  
    | 191 | 	$oTpl->set_block('show_settings', '');
 | 
  
    | 192 | } else {
 | 
  
    | 193 | 	$oTpl->parse('show_settings', 'show_settings_block', true);
 | 
  
    | 194 | }
 | 
  
    | 195 | 
 | 
  
    | 196 | $oTpl->set_block('main_block', 'show_access_block', 'show_access');
 | 
  
    | 197 | if($admin->get_permission('access') != true)
 | 
  
    | 198 | {
 | 
  
    | 199 | 	$oTpl->set_block('show_access', '');
 | 
  
    | 200 | } else {
 | 
  
    | 201 | 	$oTpl->parse('show_access', 'show_access_block', true);
 | 
  
    | 202 | }
 | 
  
    | 203 | 
 | 
  
    | 204 | $oTpl->set_block('main_block', 'show_media_block', 'show_media');
 | 
  
    | 205 | if($admin->get_permission('media') != true)
 | 
  
    | 206 | {
 | 
  
    | 207 | 	$oTpl->set_block('show_media', '');
 | 
  
    | 208 | } else {
 | 
  
    | 209 | 	$oTpl->parse('show_media', 'show_media_block', true);
 | 
  
    | 210 | }
 | 
  
    | 211 | 
 | 
  
    | 212 | $oTpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
 | 
  
    | 213 | if($admin->get_permission('admintools') != true)
 | 
  
    | 214 | {
 | 
  
    | 215 | 	$oTpl->set_block('show_admintools', '');
 | 
  
    | 216 | } else {
 | 
  
    | 217 | 	$oTpl->parse('show_admintools', 'show_admintools_block', true);
 | 
  
    | 218 | }
 | 
  
    | 219 | 
 | 
  
    | 220 | $oTpl->set_block('main_block', 'show_preferences_block', 'show_preferences');
 | 
  
    | 221 | if($admin->get_permission('preferences') != true)
 | 
  
    | 222 | {
 | 
  
    | 223 | 	$oTpl->set_block('show_preferences', '');
 | 
  
    | 224 | } else {
 | 
  
    | 225 | 	$oTpl->parse('show_preferences', 'show_preferences_block', true);
 | 
  
    | 226 | }
 | 
  
    | 227 | 
 | 
  
    | 228 | 
 | 
  
    | 229 | /*
 | 
  
    | 230 | if($admin->get_permission('pages') != true)
 | 
  
    | 231 | {
 | 
  
    | 232 | 	$oTpl->set_var('DISPLAY_PAGES', 'display:none;');
 | 
  
    | 233 | }
 | 
  
    | 234 | if($admin->get_permission('media') != true)
 | 
  
    | 235 | {
 | 
  
    | 236 | 	$oTpl->set_var('DISPLAY_MEDIA', 'display:none;');
 | 
  
    | 237 | }
 | 
  
    | 238 | if($admin->get_permission('addons') != true)
 | 
  
    | 239 | {
 | 
  
    | 240 | 	$oTpl->set_var('DISPLAY_ADDONS', 'display:none;');
 | 
  
    | 241 | }
 | 
  
    | 242 | if($admin->get_permission('access') != true)
 | 
  
    | 243 | {
 | 
  
    | 244 | 	$oTpl->set_var('DISPLAY_ACCESS', 'display:none;');
 | 
  
    | 245 | }
 | 
  
    | 246 | if($admin->get_permission('settings') != true)
 | 
  
    | 247 | {
 | 
  
    | 248 | 	$oTpl->set_var('DISPLAY_SETTINGS', 'display:none;');
 | 
  
    | 249 | }
 | 
  
    | 250 | if($admin->get_permission('admintools') != true)
 | 
  
    | 251 | {
 | 
  
    | 252 | 	$oTpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
 | 
  
    | 253 | }
 | 
  
    | 254 | */
 | 
  
    | 255 | 
 | 
  
    | 256 | 
 | 
  
    | 257 | $oTpl->set_block('main_block', 'show_install_block', 'show_install');
 | 
  
    | 258 | if($admin->get_user_id() != 1)
 | 
  
    | 259 | {
 | 
  
    | 260 | 	$oTpl->parse('show_install', '');
 | 
  
    | 261 | } else {
 | 
  
    | 262 | 
 | 
  
    | 263 |     // Check if installation directory still exists
 | 
  
    | 264 |     if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
 | 
  
    | 265 |     	// Check if user is part of Adminstrators group
 | 
  
    | 266 |     	if($admin->get_user_id()==1)
 | 
  
    | 267 |         {
 | 
  
    | 268 |     		$oTpl->set_var('WARNING', $msg );
 | 
  
    | 269 |     	} else {
 | 
  
    | 270 |     		$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
 | 
  
    | 271 |     	}
 | 
  
    | 272 |     } else {
 | 
  
    | 273 |     	$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
 | 
  
    | 274 |     }
 | 
  
    | 275 | 
 | 
  
    | 276 | 	$oTpl->parse('show_install', 'show_install_block', true);
 | 
  
    | 277 | }
 | 
  
    | 278 | 
 | 
  
    | 279 | // Insert "Add-ons" section overview (pretty complex compared to normal)
 | 
  
    | 280 | $addons_overview = $TEXT['MANAGE'].' ';
 | 
  
    | 281 | $addons_count = 0;
 | 
  
    | 282 | if($admin->get_permission('modules') == true)
 | 
  
    | 283 | {
 | 
  
    | 284 | 	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
 | 
  
    | 285 | 	$addons_count = 1;
 | 
  
    | 286 | }
 | 
  
    | 287 | if($admin->get_permission('templates') == true)
 | 
  
    | 288 | {
 | 
  
    | 289 | 	if($addons_count == 1) { $addons_overview .= ', '; }
 | 
  
    | 290 | 	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
 | 
  
    | 291 | 	$addons_count = 1;
 | 
  
    | 292 | }
 | 
  
    | 293 | if($admin->get_permission('languages') == true)
 | 
  
    | 294 | {
 | 
  
    | 295 | 	if($addons_count == 1) { $addons_overview .= ', '; }
 | 
  
    | 296 | 	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
 | 
  
    | 297 | }
 | 
  
    | 298 | 
 | 
  
    | 299 | // Insert "Access" section overview (pretty complex compared to normal)
 | 
  
    | 300 | $access_overview = $TEXT['MANAGE'].' ';
 | 
  
    | 301 | $access_count = 0;
 | 
  
    | 302 | if($admin->get_permission('users') == true) {
 | 
  
    | 303 | 	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
 | 
  
    | 304 | 	$access_count = 1;
 | 
  
    | 305 | }
 | 
  
    | 306 | if($admin->get_permission('groups') == true) {
 | 
  
    | 307 | 	if($access_count == 1) { $access_overview .= ', '; }
 | 
  
    | 308 | 	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
 | 
  
    | 309 | 	$access_count = 1;
 | 
  
    | 310 | }
 | 
  
    | 311 | 
 | 
  
    | 312 | // Insert section names and descriptions
 | 
  
    | 313 | $oTpl->set_var(array(
 | 
  
    | 314 | 					'PAGES' => $MENU['PAGES'],
 | 
  
    | 315 | 					'MEDIA' => $MENU['MEDIA'],
 | 
  
    | 316 | 					'ADDONS' => $MENU['ADDONS'],
 | 
  
    | 317 | 					'ACCESS' => $MENU['ACCESS'],
 | 
  
    | 318 | 					'PREFERENCES' => $MENU['PREFERENCES'],
 | 
  
    | 319 | 					'SETTINGS' => $MENU['SETTINGS'],
 | 
  
    | 320 | 					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
 | 
  
    | 321 | 					'HOME_OVERVIEW' => $OVERVIEW['START'],
 | 
  
    | 322 | 					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
 | 
  
    | 323 | 					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
 | 
  
    | 324 | 					'ADDONS_OVERVIEW' => $addons_overview,
 | 
  
    | 325 | 					'ACCESS_OVERVIEW' => $access_overview,
 | 
  
    | 326 | 					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
 | 
  
    | 327 | 					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
 | 
  
    | 328 | 					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
 | 
  
    | 329 | 				)
 | 
  
    | 330 | 			);
 | 
  
    | 331 | 
 | 
  
    | 332 | // Parse template object
 | 
  
    | 333 | $oTpl->parse('main', 'main_block', false);
 | 
  
    | 334 | $oTpl->pparse('output', 'page');
 | 
  
    | 335 | 
 | 
  
    | 336 | // Print admin footer
 | 
  
    | 337 | $admin->print_footer();
 |