| 1 |
2
|
Manuela
|
<?php
|
| 2 |
|
|
/**
|
| 3 |
|
|
*
|
| 4 |
|
|
* @category admin
|
| 5 |
|
|
* @package start
|
| 6 |
|
|
* @author WebsiteBaker Project
|
| 7 |
|
|
* @copyright Ryan Djurovich
|
| 8 |
|
|
* @copyright WebsiteBaker Org. e.V.
|
| 9 |
|
|
* @link http://websitebaker.org/
|
| 10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
| 11 |
|
|
* @platform WebsiteBaker 2.8.3
|
| 12 |
|
|
* @requirements PHP 5.3.6 and higher
|
| 13 |
|
|
* @version $Id$
|
| 14 |
|
|
* @filesource $HeadURL$
|
| 15 |
|
|
* @lastmodified $Date$
|
| 16 |
|
|
*
|
| 17 |
|
|
*/
|
| 18 |
|
|
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
|
| 19 |
|
|
if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
|
| 20 |
|
|
$admin = new admin('Start','start');
|
| 21 |
|
|
// ---------------------------------------
|
| 22 |
|
|
|
| 23 |
|
|
if(defined('FINALIZE_SETUP')) {
|
| 24 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
| 25 |
|
|
$dirs = array( 'modules' => WB_PATH.'/modules/',
|
| 26 |
|
|
'templates' => WB_PATH.'/templates/',
|
| 27 |
|
|
'languages' => WB_PATH.'/languages/'
|
| 28 |
|
|
);
|
| 29 |
|
|
foreach($dirs AS $type => $dir) {
|
| 30 |
|
|
if( ($handle = opendir($dir)) ) {
|
| 31 |
|
|
while(false !== ($file = readdir($handle))) {
|
| 32 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
| 33 |
|
|
// Get addon type
|
| 34 |
|
|
if($type == 'modules') {
|
| 35 |
|
|
load_module($dir.'/'.$file, true);
|
| 36 |
|
|
// Pretty ugly hack to let modules run $admin->set_error
|
| 37 |
|
|
// See dummy class definition admin_dummy above
|
| 38 |
|
|
if(isset($admin->error) && $admin->error != '') {
|
| 39 |
|
|
$admin->print_error($admin->error);
|
| 40 |
|
|
}
|
| 41 |
|
|
} elseif($type == 'templates') {
|
| 42 |
|
|
load_template($dir.'/'.$file);
|
| 43 |
|
|
} elseif($type == 'languages') {
|
| 44 |
|
|
load_language($dir.'/'.$file);
|
| 45 |
|
|
}
|
| 46 |
|
|
}
|
| 47 |
|
|
}
|
| 48 |
|
|
closedir($handle);
|
| 49 |
|
|
}
|
| 50 |
|
|
}
|
| 51 |
|
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
|
| 52 |
|
|
if($database->query($sql)) { }
|
| 53 |
|
|
}
|
| 54 |
|
|
// ---------------------------------------
|
| 55 |
|
|
$msg = '<br />';
|
| 56 |
|
|
// check if it is neccessary to start the uograde-script
|
| 57 |
|
|
if(($admin->ami_group_member('1')) && file_exists(WB_PATH.'/upgrade-script.php')) {
|
| 58 |
|
|
// check if it is neccessary to start the uograde-script
|
| 59 |
|
|
$oldVersion = '';
|
| 60 |
|
|
/*
|
| 61 |
|
|
$oldVersion = ''.WB_VERSION.(@WB_SP ? : '');
|
| 62 |
|
|
$newVersion = ''.VERSION.( @SP ? : '');
|
| 63 |
|
|
*/
|
| 64 |
|
|
$oldVersion = trim(''.WB_VERSION.'+'.WB_REVISION.'+'.( defined('WB_SP') ? WB_SP : ''), '+');
|
| 65 |
|
|
$newVersion = trim(''.VERSION.'+'.REVISION.'+'.( defined('SP') ? SP : ''), '+');
|
| 66 |
|
|
if ( version_compare($oldVersion, $newVersion, '<') === true ) {
|
| 67 |
|
|
if(!headers_sent()) {
|
| 68 |
|
|
header('Location: '.WB_URL.'/upgrade-script.php');
|
| 69 |
|
|
exit;
|
| 70 |
|
|
} else {
|
| 71 |
|
|
echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
|
| 72 |
|
|
"Please click <a style=\"font-weight:bold;\" " .
|
| 73 |
|
|
"href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
|
| 74 |
|
|
exit;
|
| 75 |
|
|
}
|
| 76 |
|
|
}
|
| 77 |
|
|
// $msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
|
| 78 |
|
|
}
|
| 79 |
|
|
|
| 80 |
|
|
/**
|
| 81 |
|
|
* delete stored ip adresses default after 60 days
|
| 82 |
|
|
*/
|
| 83 |
|
|
$sql = 'UPDATE `'.TABLE_PREFIX.'users` SET `login_ip` = \'\' WHERE `login_when` < '.(time()-(60*84600));
|
| 84 |
|
|
$database->query($sql);
|
| 85 |
|
|
|
| 86 |
|
|
// Setup template object, parse vars to it, then parse it
|
| 87 |
|
|
// Create new template object
|
| 88 |
|
|
$template = new Template(dirname($admin->correct_theme_source('start.htt')));
|
| 89 |
|
|
$template->set_file('page', 'start.htt');
|
| 90 |
|
|
$template->set_block('page', 'main_block', 'main');
|
| 91 |
|
|
|
| 92 |
|
|
// Insert values into the template object
|
| 93 |
|
|
$template->set_var(array(
|
| 94 |
|
|
'WELCOME_MESSAGE' => $MESSAGE['START_WELCOME_MESSAGE'],
|
| 95 |
|
|
'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
|
| 96 |
|
|
'DISPLAY_NAME' => $admin->get_display_name(),
|
| 97 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
| 98 |
|
|
'WB_URL' => WB_URL,
|
| 99 |
|
|
'THEME_URL' => THEME_URL,
|
| 100 |
|
|
'WB_VERSION' => WB_VERSION,
|
| 101 |
|
|
'START_LIST' => ' '
|
| 102 |
|
|
)
|
| 103 |
|
|
);
|
| 104 |
|
|
// Insert permission values into the template object
|
| 105 |
|
|
$get_permission = (function($type='preferences', $ParentBlock='main_block') use ($admin, $template){
|
| 106 |
|
|
$template->set_block($ParentBlock, 'show_'.$type.'_block', 'show_'.$type);
|
| 107 |
|
|
if ($admin->get_permission($type) != true) {
|
| 108 |
|
|
$template->set_block('show_'.$type, '');
|
| 109 |
|
|
return false;
|
| 110 |
|
|
} else {
|
| 111 |
|
|
$template->parse('show_'.$type, 'show_'.$type.'_block', true);
|
| 112 |
|
|
}
|
| 113 |
|
|
return true;
|
| 114 |
|
|
});
|
| 115 |
|
|
$get_permission ('pages');
|
| 116 |
|
|
$get_permission ('media');
|
| 117 |
|
|
$get_permission ('addons');
|
| 118 |
|
|
$get_permission ('settings');
|
| 119 |
|
|
$get_permission ('admintools');
|
| 120 |
|
|
$get_permission ('access');
|
| 121 |
|
|
|
| 122 |
|
|
//$msg .= (file_exists(WB_PATH.'/install/')) ? $MESSAGE['START_INSTALL_DIR_EXISTS'] : $msg;
|
| 123 |
|
|
|
| 124 |
|
|
// Check if installation directory still exists
|
| 125 |
|
|
if (file_exists(WB_PATH.'/upgrade-script.php') ) {
|
| 126 |
|
|
// Check if user is part of Adminstrators group / better be a Systemadministrator
|
| 127 |
|
|
// if ($admin->ami_group_member(1)){
|
| 128 |
|
|
if ($admin->get_user_id() == 1) {
|
| 129 |
|
|
$template->set_var('WARNING', $msg );
|
| 130 |
|
|
} else {
|
| 131 |
|
|
$template->set_var('DISPLAY_WARNING', 'display:none;');
|
| 132 |
|
|
}
|
| 133 |
|
|
} else {
|
| 134 |
|
|
$template->set_var('DISPLAY_WARNING', 'display:none;');
|
| 135 |
|
|
}
|
| 136 |
|
|
|
| 137 |
|
|
// Insert "Add-ons" section overview (pretty complex compared to normal)
|
| 138 |
|
|
$addons_overview = $TEXT['MANAGE'].' ';
|
| 139 |
|
|
$addons_count = 0;
|
| 140 |
|
|
if($admin->get_permission('modules') == true)
|
| 141 |
|
|
{
|
| 142 |
|
|
$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
|
| 143 |
|
|
$addons_count = 1;
|
| 144 |
|
|
}
|
| 145 |
|
|
if($admin->get_permission('templates') == true)
|
| 146 |
|
|
{
|
| 147 |
|
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
| 148 |
|
|
$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
|
| 149 |
|
|
$addons_count = 1;
|
| 150 |
|
|
}
|
| 151 |
|
|
if($admin->get_permission('languages') == true)
|
| 152 |
|
|
{
|
| 153 |
|
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
| 154 |
|
|
$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
|
| 155 |
|
|
}
|
| 156 |
|
|
|
| 157 |
|
|
// Insert "Access" section overview (pretty complex compared to normal)
|
| 158 |
|
|
$access_overview = $TEXT['MANAGE'].' ';
|
| 159 |
|
|
$access_count = 0;
|
| 160 |
|
|
if($admin->get_permission('users') == true) {
|
| 161 |
|
|
$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
|
| 162 |
|
|
$access_count = 1;
|
| 163 |
|
|
}
|
| 164 |
|
|
if($admin->get_permission('groups') == true) {
|
| 165 |
|
|
if($access_count == 1) { $access_overview .= ', '; }
|
| 166 |
|
|
$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
|
| 167 |
|
|
$access_count = 1;
|
| 168 |
|
|
}
|
| 169 |
|
|
|
| 170 |
|
|
// Insert section names and descriptions
|
| 171 |
|
|
$template->set_var(array(
|
| 172 |
|
|
'PAGES' => $MENU['PAGES'],
|
| 173 |
|
|
'MEDIA' => $MENU['MEDIA'],
|
| 174 |
|
|
'ADDONS' => $MENU['ADDONS'],
|
| 175 |
|
|
'ACCESS' => $MENU['ACCESS'],
|
| 176 |
|
|
'PREFERENCES' => $MENU['PREFERENCES'],
|
| 177 |
|
|
'SETTINGS' => $MENU['SETTINGS'],
|
| 178 |
|
|
'ADMINTOOLS' => $MENU['ADMINTOOLS'],
|
| 179 |
|
|
'HOME_OVERVIEW' => $OVERVIEW['START'],
|
| 180 |
|
|
'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
|
| 181 |
|
|
'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
|
| 182 |
|
|
'ADDONS_OVERVIEW' => $addons_overview,
|
| 183 |
|
|
'ACCESS_OVERVIEW' => $access_overview,
|
| 184 |
|
|
'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
|
| 185 |
|
|
'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
|
| 186 |
|
|
'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
|
| 187 |
|
|
)
|
| 188 |
|
|
);
|
| 189 |
|
|
|
| 190 |
|
|
// Parse template object
|
| 191 |
|
|
$template->parse('main', 'main_block', false);
|
| 192 |
|
|
$template->pparse('output', 'page');
|
| 193 |
|
|
|
| 194 |
|
|
// Print admin footer
|
| 195 |
|
|
$admin->print_footer();
|