| 1 |
1397
|
Luisehahne
|
<?php
|
| 2 |
|
|
/**
|
| 3 |
|
|
*
|
| 4 |
|
|
* @category admin
|
| 5 |
|
|
* @package start
|
| 6 |
1804
|
Luisehahne
|
* @author Ryan Djurovich (2004-2009), WebsiteBaker Project
|
| 7 |
1907
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
| 8 |
|
|
* @link http://www.websitebaker.org/
|
| 9 |
1397
|
Luisehahne
|
* @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$
|
| 13 |
1907
|
Luisehahne
|
* @filesource $HeadURL$
|
| 14 |
1397
|
Luisehahne
|
* @lastmodified $Date$
|
| 15 |
|
|
*
|
| 16 |
1711
|
Luisehahne
|
*/
|
| 17 |
1804
|
Luisehahne
|
|
| 18 |
2098
|
darkviper
|
if (!defined('WB_URL')) {
|
| 19 |
|
|
require_once('../../config.php');
|
| 20 |
1804
|
Luisehahne
|
}
|
| 21 |
2098
|
darkviper
|
$oDb = WbDatabase::getInstance();
|
| 22 |
|
|
$oTrans = Translate::getInstance();
|
| 23 |
|
|
$oTrans->enableAddon('admin\\start');
|
| 24 |
|
|
//$template->set_var($oTrans->getLangArray());
|
| 25 |
1397
|
Luisehahne
|
$admin = new admin('Start','start');
|
| 26 |
1479
|
Luisehahne
|
// ---------------------------------------
|
| 27 |
1711
|
Luisehahne
|
// $database = WbDatabase::getInstance();
|
| 28 |
1560
|
Luisehahne
|
|
| 29 |
1989
|
Luisehahne
|
require_once(WB_PATH.'/framework/functions.php');
|
| 30 |
1479
|
Luisehahne
|
if(defined('FINALIZE_SETUP')) {
|
| 31 |
|
|
$dirs = array( 'modules' => WB_PATH.'/modules/',
|
| 32 |
|
|
'templates' => WB_PATH.'/templates/',
|
| 33 |
|
|
'languages' => WB_PATH.'/languages/'
|
| 34 |
|
|
);
|
| 35 |
|
|
foreach($dirs AS $type => $dir) {
|
| 36 |
|
|
if( ($handle = opendir($dir)) ) {
|
| 37 |
|
|
while(false !== ($file = readdir($handle))) {
|
| 38 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
| 39 |
|
|
// Get addon type
|
| 40 |
|
|
if($type == 'modules') {
|
| 41 |
|
|
load_module($dir.'/'.$file, true);
|
| 42 |
|
|
// Pretty ugly hack to let modules run $admin->set_error
|
| 43 |
|
|
// See dummy class definition admin_dummy above
|
| 44 |
|
|
if(isset($admin->error) && $admin->error != '') {
|
| 45 |
|
|
$admin->print_error($admin->error);
|
| 46 |
|
|
}
|
| 47 |
|
|
} elseif($type == 'templates') {
|
| 48 |
|
|
load_template($dir.'/'.$file);
|
| 49 |
|
|
} elseif($type == 'languages') {
|
| 50 |
|
|
load_language($dir.'/'.$file);
|
| 51 |
|
|
}
|
| 52 |
|
|
}
|
| 53 |
|
|
}
|
| 54 |
|
|
closedir($handle);
|
| 55 |
|
|
}
|
| 56 |
|
|
}
|
| 57 |
2098
|
darkviper
|
$sql = 'DELETE FROM `'.$oDb-TablePrefix.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
|
| 58 |
|
|
$oDb->doQuery($sql);
|
| 59 |
1479
|
Luisehahne
|
}
|
| 60 |
|
|
// ---------------------------------------
|
| 61 |
1560
|
Luisehahne
|
// check if it is neccessary to start the uograde-script
|
| 62 |
1907
|
Luisehahne
|
|
| 63 |
1778
|
Luisehahne
|
$msg = '';
|
| 64 |
2098
|
darkviper
|
$msg .= (is_readable(WB_PATH.'/install/')) ? $oTrans->MESSAGE_START_INSTALL_DIR_EXISTS.'<br />' : $msg;
|
| 65 |
1984
|
Luisehahne
|
$aReplace =array(
|
| 66 |
|
|
'file' => '<a style="font-weight:bold;" href="'.WB_URL.'/upgrade-script.php">upgrade-script.php</a>'
|
| 67 |
|
|
);
|
| 68 |
2098
|
darkviper
|
$msg .= (is_readable(WB_PATH.'/upgrade-script.php') ? replace_vars($oTrans->MESSAGE_START_UPGRADE_SCRIPT_EXISTS.'<br />',$aReplace) : '');
|
| 69 |
1711
|
Luisehahne
|
|
| 70 |
|
|
// ---------------------------------------
|
| 71 |
|
|
// check if it is neccessary to start the uograde-script
|
| 72 |
|
|
// ---------------------------------------
|
| 73 |
1562
|
Luisehahne
|
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
|
| 74 |
1561
|
Luisehahne
|
// check if it is neccessary to start the uograde-script
|
| 75 |
2099
|
darkviper
|
$sql = 'SELECT `value` FROM `'.$oDb->TablePrefix.'settings` WHERE `name`=\'wb_revision\'';
|
| 76 |
2098
|
darkviper
|
$wb_revision = $oDb->getOne($sql);
|
| 77 |
1589
|
Luisehahne
|
if (version_compare($wb_revision, REVISION ) < 0) {
|
| 78 |
1822
|
Luisehahne
|
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 |
1560
|
Luisehahne
|
}
|
| 101 |
|
|
}
|
| 102 |
1711
|
Luisehahne
|
// ---------------------------------------
|
| 103 |
|
|
// workout to upgrade the groups system_permissions
|
| 104 |
|
|
// ---------------------------------------
|
| 105 |
2098
|
darkviper
|
if( ($admin->get_user_id()==1) && file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
|
| 106 |
1711
|
Luisehahne
|
{
|
| 107 |
|
|
// check if it is neccessary to start the uograde-script
|
| 108 |
2098
|
darkviper
|
$sql = 'SELECT `value` FROM `'.$oDb-TablePrefix.'settings` WHERE `name`=\'wb_revision\'';
|
| 109 |
|
|
$wb_revision = $database->get_one($sql);
|
| 110 |
1727
|
Luisehahne
|
if ((version_compare($wb_revision, '1800' ) < 0)&& !defined('GROUPS_UPDATED')) {
|
| 111 |
1711
|
Luisehahne
|
require_once (ADMIN_PATH.'/groups/upgradePermissions.php');
|
| 112 |
|
|
// build new or changed $sTempPermissions
|
| 113 |
|
|
if(upgrade_group_system_permissions()){
|
| 114 |
|
|
$cfg = array(
|
| 115 |
|
|
'groups_updated' => time()
|
| 116 |
|
|
);
|
| 117 |
|
|
if(db_update_key_value( 'settings', $cfg )) {
|
| 118 |
|
|
echo "<div class=\"note center rounded\"><h3>Hello Systemadministrator!</h3>".
|
| 119 |
|
|
"<p style=\"text-align:center;\">".
|
| 120 |
|
|
"The <strong>Administrator Groups Rights </strong> were updated automatically.\n" .
|
| 121 |
|
|
"Please click <a style=\"font-weight:bold;\" " .
|
| 122 |
|
|
"href=\"".ADMIN_URL."/logout/index.php\">on this link</a> to login again!</p>\n".
|
| 123 |
|
|
"<h3>Upgrading only start, if groups rights are not up to date!</h3></div>";
|
| 124 |
|
|
// Print admin footer
|
| 125 |
|
|
$admin->print_footer();
|
| 126 |
|
|
exit(0);
|
| 127 |
|
|
|
| 128 |
|
|
}
|
| 129 |
|
|
}
|
| 130 |
|
|
}
|
| 131 |
|
|
}
|
| 132 |
|
|
|
| 133 |
1804
|
Luisehahne
|
/**
|
| 134 |
|
|
* delete Outdated Confirmations
|
| 135 |
|
|
*/
|
| 136 |
2099
|
darkviper
|
$sql = 'DELETE FROM `'.$oDb->TablePrefix.'users` WHERE `confirm_timeout` BETWEEN 1 AND '.time();
|
| 137 |
2098
|
darkviper
|
$oDb->doQuery($sql);
|
| 138 |
1804
|
Luisehahne
|
|
| 139 |
1809
|
Luisehahne
|
/**
|
| 140 |
1984
|
Luisehahne
|
* delete stored ip adresses default after 60 days
|
| 141 |
1809
|
Luisehahne
|
*/
|
| 142 |
2099
|
darkviper
|
$sql = 'UPDATE `'.$oDb->TablePrefix.'users` SET `login_ip` = \'\' WHERE `login_when` < '.(time()-(60*84600));
|
| 143 |
2098
|
darkviper
|
$oDb->doQuery($sql);
|
| 144 |
1809
|
Luisehahne
|
|
| 145 |
1711
|
Luisehahne
|
// ---------------------------------------
|
| 146 |
1529
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
| 147 |
|
|
// Create new template object
|
| 148 |
1711
|
Luisehahne
|
$oTpl = new Template(dirname($admin->correct_theme_source('start.htt')),'keep');
|
| 149 |
|
|
$oTpl->set_file('page', 'start.htt');
|
| 150 |
|
|
$oTpl->set_block('page', 'main_block', 'main');
|
| 151 |
2098
|
darkviper
|
$oTpl->set_var($oTrans->getLangArray());
|
| 152 |
1397
|
Luisehahne
|
// Insert values into the template object
|
| 153 |
1711
|
Luisehahne
|
$oTpl->set_var(array(
|
| 154 |
2098
|
darkviper
|
'WELCOME_MESSAGE' => $oTrans->MESSAGE_START_WELCOME_MESSAGE,
|
| 155 |
|
|
'CURRENT_USER' => $oTrans->MESSAGE_START_CURRENT_USER,
|
| 156 |
|
|
'DISPLAY_NAME' => $admin->get_display_name(),
|
| 157 |
1777
|
Luisehahne
|
'DISPLAY_WARNING' => '',
|
| 158 |
2098
|
darkviper
|
'WARNING' => '',
|
| 159 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
| 160 |
|
|
'WB_URL' => WB_URL,
|
| 161 |
|
|
'THEME_URL' => THEME_URL,
|
| 162 |
|
|
'WB_VERSION' => WB_VERSION,
|
| 163 |
|
|
'NO_CONTENT' => ''
|
| 164 |
1457
|
Luisehahne
|
)
|
| 165 |
|
|
);
|
| 166 |
1397
|
Luisehahne
|
|
| 167 |
|
|
// Insert permission values into the template object
|
| 168 |
1711
|
Luisehahne
|
$oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
|
| 169 |
1397
|
Luisehahne
|
if($admin->get_permission('pages') != true)
|
| 170 |
|
|
{
|
| 171 |
1711
|
Luisehahne
|
$oTpl->set_block('show_pages', '');
|
| 172 |
|
|
} else {
|
| 173 |
|
|
$oTpl->parse('show_pages', 'show_pages_block', true);
|
| 174 |
1397
|
Luisehahne
|
}
|
| 175 |
1711
|
Luisehahne
|
|
| 176 |
|
|
$oTpl->set_block('main_block', 'show_addons_block', 'show_addons');
|
| 177 |
|
|
if($admin->get_permission('addons') != true)
|
| 178 |
|
|
{
|
| 179 |
|
|
$oTpl->set_block('show_addons', '');
|
| 180 |
|
|
} else {
|
| 181 |
|
|
$oTpl->parse('show_addons', 'show_addons_block', true);
|
| 182 |
|
|
}
|
| 183 |
|
|
|
| 184 |
|
|
$oTpl->set_block('main_block', 'show_settings_block', 'show_settings');
|
| 185 |
|
|
if($admin->get_permission('settings') != true)
|
| 186 |
|
|
{
|
| 187 |
|
|
$oTpl->set_block('show_settings', '');
|
| 188 |
|
|
} else {
|
| 189 |
|
|
$oTpl->parse('show_settings', 'show_settings_block', true);
|
| 190 |
|
|
}
|
| 191 |
|
|
|
| 192 |
|
|
$oTpl->set_block('main_block', 'show_access_block', 'show_access');
|
| 193 |
|
|
if($admin->get_permission('access') != true)
|
| 194 |
|
|
{
|
| 195 |
|
|
$oTpl->set_block('show_access', '');
|
| 196 |
|
|
} else {
|
| 197 |
|
|
$oTpl->parse('show_access', 'show_access_block', true);
|
| 198 |
|
|
}
|
| 199 |
|
|
|
| 200 |
|
|
$oTpl->set_block('main_block', 'show_media_block', 'show_media');
|
| 201 |
1397
|
Luisehahne
|
if($admin->get_permission('media') != true)
|
| 202 |
|
|
{
|
| 203 |
1711
|
Luisehahne
|
$oTpl->set_block('show_media', '');
|
| 204 |
|
|
} else {
|
| 205 |
|
|
$oTpl->parse('show_media', 'show_media_block', true);
|
| 206 |
1397
|
Luisehahne
|
}
|
| 207 |
1711
|
Luisehahne
|
|
| 208 |
|
|
$oTpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
|
| 209 |
|
|
if($admin->get_permission('admintools') != true)
|
| 210 |
|
|
{
|
| 211 |
|
|
$oTpl->set_block('show_admintools', '');
|
| 212 |
|
|
} else {
|
| 213 |
|
|
$oTpl->parse('show_admintools', 'show_admintools_block', true);
|
| 214 |
|
|
}
|
| 215 |
|
|
|
| 216 |
|
|
$oTpl->set_block('main_block', 'show_preferences_block', 'show_preferences');
|
| 217 |
|
|
if($admin->get_permission('preferences') != true)
|
| 218 |
|
|
{
|
| 219 |
|
|
$oTpl->set_block('show_preferences', '');
|
| 220 |
|
|
} else {
|
| 221 |
|
|
$oTpl->parse('show_preferences', 'show_preferences_block', true);
|
| 222 |
|
|
}
|
| 223 |
|
|
|
| 224 |
1778
|
Luisehahne
|
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
|
| 225 |
|
|
if($admin->get_user_id() != 1)
|
| 226 |
|
|
{
|
| 227 |
|
|
$oTpl->parse('show_install', '');
|
| 228 |
1397
|
Luisehahne
|
} else {
|
| 229 |
1778
|
Luisehahne
|
|
| 230 |
|
|
// Check if installation directory still exists
|
| 231 |
|
|
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
|
| 232 |
|
|
// Check if user is part of Adminstrators group
|
| 233 |
|
|
if($admin->get_user_id()==1)
|
| 234 |
|
|
{
|
| 235 |
|
|
$oTpl->set_var('WARNING', $msg );
|
| 236 |
|
|
} else {
|
| 237 |
|
|
$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
|
| 238 |
|
|
}
|
| 239 |
|
|
} else {
|
| 240 |
|
|
$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
|
| 241 |
|
|
}
|
| 242 |
|
|
|
| 243 |
|
|
$oTpl->parse('show_install', 'show_install_block', true);
|
| 244 |
1397
|
Luisehahne
|
}
|
| 245 |
|
|
|
| 246 |
|
|
// Insert "Add-ons" section overview (pretty complex compared to normal)
|
| 247 |
2098
|
darkviper
|
$addons_overview = $oTrans->TEXT_MANAGE.' ';
|
| 248 |
1397
|
Luisehahne
|
$addons_count = 0;
|
| 249 |
|
|
if($admin->get_permission('modules') == true)
|
| 250 |
|
|
{
|
| 251 |
2098
|
darkviper
|
$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$oTrans->MENU_MODULES.'</a>';
|
| 252 |
1397
|
Luisehahne
|
$addons_count = 1;
|
| 253 |
|
|
}
|
| 254 |
|
|
if($admin->get_permission('templates') == true)
|
| 255 |
|
|
{
|
| 256 |
|
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
| 257 |
2098
|
darkviper
|
$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$oTrans->MENU_TEMPLATES.'</a>';
|
| 258 |
1397
|
Luisehahne
|
$addons_count = 1;
|
| 259 |
|
|
}
|
| 260 |
|
|
if($admin->get_permission('languages') == true)
|
| 261 |
|
|
{
|
| 262 |
|
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
| 263 |
2098
|
darkviper
|
$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$oTrans->MENU_LANGUAGES.'</a>';
|
| 264 |
1397
|
Luisehahne
|
}
|
| 265 |
|
|
|
| 266 |
|
|
// Insert "Access" section overview (pretty complex compared to normal)
|
| 267 |
2098
|
darkviper
|
$access_overview = $oTrans->TEXT_MANAGE.' ';
|
| 268 |
1397
|
Luisehahne
|
$access_count = 0;
|
| 269 |
|
|
if($admin->get_permission('users') == true) {
|
| 270 |
2098
|
darkviper
|
$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$oTrans->MENU_USERS.'</a>';
|
| 271 |
1397
|
Luisehahne
|
$access_count = 1;
|
| 272 |
|
|
}
|
| 273 |
|
|
if($admin->get_permission('groups') == true) {
|
| 274 |
|
|
if($access_count == 1) { $access_overview .= ', '; }
|
| 275 |
2098
|
darkviper
|
$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$oTrans->MENU_GROUPS.'</a>';
|
| 276 |
1397
|
Luisehahne
|
$access_count = 1;
|
| 277 |
|
|
}
|
| 278 |
|
|
|
| 279 |
|
|
// Insert section names and descriptions
|
| 280 |
1711
|
Luisehahne
|
$oTpl->set_var(array(
|
| 281 |
2098
|
darkviper
|
'PAGES' => $oTrans->MENU_PAGES,
|
| 282 |
|
|
'MEDIA' => $oTrans->MENU_MEDIA,
|
| 283 |
|
|
'ADDONS' => $oTrans->MENU_ADDONS,
|
| 284 |
|
|
'ACCESS' => $oTrans->MENU_ACCESS,
|
| 285 |
|
|
'PREFERENCES' => $oTrans->MENU_PREFERENCES,
|
| 286 |
|
|
'SETTINGS' => $oTrans->MENU_SETTINGS,
|
| 287 |
|
|
'ADMINTOOLS' => $oTrans->MENU_ADMINTOOLS,
|
| 288 |
|
|
'HOME_OVERVIEW' => $oTrans->OVERVIEW_START,
|
| 289 |
|
|
'PAGES_OVERVIEW' => $oTrans->OVERVIEW_PAGES,
|
| 290 |
|
|
'MEDIA_OVERVIEW' => $oTrans->OVERVIEW_MEDIA,
|
| 291 |
|
|
'ADDONS_OVERVIEW' => $addons_overview,
|
| 292 |
|
|
'ACCESS_OVERVIEW' => $access_overview,
|
| 293 |
|
|
'PREFERENCES_OVERVIEW' => $oTrans->OVERVIEW_PREFERENCES,
|
| 294 |
|
|
'SETTINGS_OVERVIEW' => $oTrans->OVERVIEW_SETTINGS,
|
| 295 |
|
|
'ADMINTOOLS_OVERVIEW' => $oTrans->OVERVIEW_ADMINTOOLS
|
| 296 |
1457
|
Luisehahne
|
)
|
| 297 |
|
|
);
|
| 298 |
1397
|
Luisehahne
|
|
| 299 |
|
|
// Parse template object
|
| 300 |
1711
|
Luisehahne
|
$oTpl->parse('main', 'main_block', false);
|
| 301 |
|
|
$oTpl->pparse('output', 'page');
|
| 302 |
1397
|
Luisehahne
|
|
| 303 |
|
|
// Print admin footer
|
| 304 |
|
|
$admin->print_footer();
|