EGroupware /
egroupware
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * EGroupware Setup |
||||
| 4 | * |
||||
| 5 | * @link http://www.egroupware.org |
||||
| 6 | * @package setup |
||||
| 7 | * @author Miles Lott <[email protected]> |
||||
| 8 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
||||
| 9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
||||
| 10 | * @version $Id$ |
||||
| 11 | */ |
||||
| 12 | |||||
| 13 | use EGroupware\Api; |
||||
| 14 | use EGroupware\Api\Framework; |
||||
| 15 | |||||
| 16 | $GLOBALS['DEBUG'] = False; |
||||
| 17 | include('./inc/functions.inc.php'); |
||||
| 18 | |||||
| 19 | @set_time_limit(0); |
||||
| 20 | |||||
| 21 | $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); |
||||
| 22 | $setup_tpl = new Framework\Template($tpl_root); |
||||
| 23 | $setup_tpl->set_file(array |
||||
| 24 | ( |
||||
| 25 | 'T_head' => 'head.tpl', |
||||
| 26 | 'T_footer' => 'footer.tpl', |
||||
| 27 | 'T_alert_msg' => 'msg_alert_msg.tpl', |
||||
| 28 | 'T_login_main' => 'login_main.tpl', |
||||
| 29 | 'T_login_stage_header' => 'login_stage_header.tpl', |
||||
| 30 | 'T_setup_main' => 'setup_main.tpl', |
||||
| 31 | 'T_setup_db_blocks' => 'setup_db_blocks.tpl' |
||||
| 32 | )); |
||||
| 33 | |||||
| 34 | $setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain'); |
||||
| 35 | $setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain'); |
||||
| 36 | |||||
| 37 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_1','V_db_stage_1'); |
||||
| 38 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_1a','V_db_stage_1a'); |
||||
| 39 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_2','V_db_stage_2'); |
||||
| 40 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_3','V_db_stage_3'); |
||||
| 41 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_4','V_db_stage_4'); |
||||
| 42 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_5','V_db_stage_5'); |
||||
| 43 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_6_pre','V_db_stage_6_pre'); |
||||
| 44 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_6_post','V_db_stage_6_post'); |
||||
| 45 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_10','V_db_stage_10'); |
||||
| 46 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_default','V_db_stage_default'); |
||||
| 47 | |||||
| 48 | // Check header and authentication |
||||
| 49 | $GLOBALS['egw_info']['setup']['stage']['header'] = $GLOBALS['egw_setup']->detection->check_header(); |
||||
| 50 | if ($GLOBALS['egw_info']['setup']['stage']['header'] != '10') |
||||
| 51 | { |
||||
| 52 | if ($GLOBALS['egw_info']['setup']['stage']['header'] == 4) // header needs update, go there direct |
||||
| 53 | { |
||||
| 54 | Header('Location: manageheader.php'); |
||||
| 55 | } |
||||
| 56 | else // run check-install first |
||||
| 57 | { |
||||
| 58 | Header('Location: check_install.php?intro=1'); |
||||
| 59 | } |
||||
| 60 | exit; |
||||
| 61 | } |
||||
| 62 | elseif(!$GLOBALS['egw_setup']->auth('Config')) |
||||
| 63 | { |
||||
| 64 | $GLOBALS['egw_setup']->html->show_header(lang('Please login'),True); |
||||
| 65 | $GLOBALS['egw_setup']->html->login_form(); |
||||
| 66 | $GLOBALS['egw_setup']->html->show_footer(); |
||||
| 67 | exit; |
||||
| 68 | } |
||||
| 69 | |||||
| 70 | $GLOBALS['egw_setup']->loaddb(); |
||||
| 71 | |||||
| 72 | $GLOBALS['egw_setup']->html->show_header( |
||||
| 73 | $GLOBALS['egw_info']['setup']['header_msg'], |
||||
| 74 | False, |
||||
| 75 | 'config', |
||||
| 76 | $GLOBALS['egw_setup']->ConfigDomain . ' (' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].'://'. |
||||
| 77 | $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_user'].'@'. |
||||
| 78 | $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_host'].':'. |
||||
| 79 | $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_port'].'/'. |
||||
| 80 | $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_name'] . ')' |
||||
| 81 | ); |
||||
| 82 | /* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */ |
||||
| 83 | /* $GLOBALS['egw_setup']->clear_session_cache(); */ |
||||
| 84 | |||||
| 85 | // Database actions |
||||
| 86 | $setup_info = $GLOBALS['egw_setup']->detection->get_versions(); |
||||
| 87 | $GLOBALS['egw_info']['setup']['stage']['db'] = $GLOBALS['egw_setup']->detection->check_db($setup_info); |
||||
| 88 | if ($GLOBALS['egw_info']['setup']['stage']['db'] != 1) |
||||
| 89 | { |
||||
| 90 | $setup_info = $GLOBALS['egw_setup']->detection->get_db_versions( |
||||
| 91 | $GLOBALS['egw_setup']->detection->get_versions()); |
||||
| 92 | |||||
| 93 | $GLOBALS['egw_info']['setup']['stage']['db'] = $GLOBALS['egw_setup']->detection->check_db($setup_info); |
||||
| 94 | if($GLOBALS['DEBUG']) |
||||
| 95 | { |
||||
| 96 | _debug_array($setup_info); |
||||
| 97 | } |
||||
| 98 | } |
||||
| 99 | |||||
| 100 | if ($GLOBALS['DEBUG']) { echo 'Stage: ' . $GLOBALS['egw_info']['setup']['stage']['db']; } |
||||
| 101 | // begin DEBUG code |
||||
| 102 | //$GLOBALS['egw_info']['setup']['stage']['db'] = 0; |
||||
| 103 | //$action = 'Upgrade'; |
||||
| 104 | // end DEBUG code |
||||
| 105 | |||||
| 106 | switch($_POST['action']) |
||||
| 107 | { |
||||
| 108 | case 'Uninstall all applications': |
||||
| 109 | $subtitle = lang('Deleting Tables'); |
||||
| 110 | $submsg = lang('Are you sure you want to delete your existing tables and data?') . '.'; |
||||
| 111 | $subaction = lang('uninstall'); |
||||
| 112 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'predrop'; |
||||
| 113 | $GLOBALS['egw_info']['setup']['stage']['db'] = 5; |
||||
| 114 | break; |
||||
| 115 | case 'Create Database': |
||||
| 116 | $subtitle = lang('Create Database'); |
||||
| 117 | $submsg = lang('At your request, this script is going to attempt to create the database and assign the db user rights to it'); |
||||
| 118 | $subaction = lang('created'); |
||||
| 119 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'dbcreate'; |
||||
| 120 | $GLOBALS['egw_info']['setup']['stage']['db'] = 6; |
||||
| 121 | break; |
||||
| 122 | case 'REALLY Uninstall all applications': |
||||
| 123 | $subtitle = lang('Deleting Tables'); |
||||
| 124 | $submsg = lang('At your request, this script is going to take the evil action of uninstalling all your apps, which deletes your existing tables and data') . '.'; |
||||
| 125 | $subaction = lang('uninstalled'); |
||||
| 126 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'drop'; |
||||
| 127 | $GLOBALS['egw_info']['setup']['stage']['db'] = 6; |
||||
| 128 | break; |
||||
| 129 | case 'Upgrade': |
||||
| 130 | $subtitle = lang('Upgrading Tables'); |
||||
| 131 | $submsg = lang('At your request, this script is going to attempt to upgrade your old applications to the current versions').'.'; |
||||
| 132 | if ($_POST['backup']) |
||||
| 133 | { |
||||
| 134 | $submsg .= ' '.lang('After backing up your tables first.'); |
||||
| 135 | } |
||||
| 136 | $subaction = lang('upgraded'); |
||||
| 137 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
||||
| 138 | $GLOBALS['egw_info']['setup']['stage']['db'] = 6; |
||||
| 139 | break; |
||||
| 140 | case 'Install': |
||||
| 141 | $subtitle = lang('Creating Tables'); |
||||
| 142 | if ($_POST['upload']) |
||||
| 143 | { |
||||
| 144 | $submsg = lang('At your request, this script is going to attempt to install a previous backup').'.'; |
||||
| 145 | } |
||||
| 146 | else |
||||
| 147 | { |
||||
| 148 | $submsg = lang('At your request, this script is going to attempt to install the core tables and the admin and preferences applications for you').'.'; |
||||
| 149 | } |
||||
| 150 | $subaction = lang('installed'); |
||||
| 151 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'new'; |
||||
| 152 | $GLOBALS['egw_info']['setup']['stage']['db'] = 6; |
||||
| 153 | break; |
||||
| 154 | } |
||||
| 155 | $setup_tpl->set_var('subtitle',@$subtitle); |
||||
| 156 | $setup_tpl->set_var('submsg',@$submsg); |
||||
| 157 | $setup_tpl->set_var('subaction',@$subaction); |
||||
| 158 | |||||
| 159 | // Old PHP |
||||
| 160 | if ((float) PHP_VERSION < $GLOBALS['egw_setup']->required_php_version) |
||||
| 161 | { |
||||
| 162 | $GLOBALS['egw_setup']->html->show_header($GLOBALS['egw_info']['setup']['header_msg'],True); |
||||
| 163 | $GLOBALS['egw_setup']->html->show_alert_msg('Error', |
||||
| 164 | lang('You are using PHP version %1. EGroupware now requires %2 or later, recommended is PHP %3.', |
||||
| 165 | PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,$GLOBALS['egw_setup']->recommended_php_version)); |
||||
|
0 ignored issues
–
show
|
|||||
| 166 | $GLOBALS['egw_setup']->html->show_footer(); |
||||
| 167 | exit; |
||||
| 168 | } |
||||
| 169 | |||||
| 170 | // BEGIN setup page |
||||
| 171 | |||||
| 172 | //$GLOBALS['egw_setup']->app_status(); |
||||
| 173 | $GLOBALS['egw_info']['server']['app_images'] = 'templates/default/images'; |
||||
| 174 | $incomplete = $GLOBALS['egw_info']['server']['app_images'] . '/incomplete.png'; |
||||
| 175 | $completed = $GLOBALS['egw_info']['server']['app_images'] . '/completed.png'; |
||||
| 176 | |||||
| 177 | $setup_tpl->set_var('img_incomplete',$incomplete); |
||||
| 178 | $setup_tpl->set_var('img_completed',$completed); |
||||
| 179 | |||||
| 180 | $setup_tpl->set_var('db_step_text',lang('Step %1 - Simple Application Management', ++$num)); |
||||
| 181 | $setup_tpl->set_var('lang_system_charset',lang('<b>charset to use</b> (use utf-8 if you plan to use languages with different charsets):')); |
||||
| 182 | $setup_tpl->set_var('system_charset',str_replace('&','&', |
||||
| 183 | $GLOBALS['egw_setup']->translation->get_charsets('system_charset',$GLOBALS['egw_setup']->system_charset))); |
||||
| 184 | |||||
| 185 | switch($GLOBALS['egw_info']['setup']['stage']['db']) |
||||
| 186 | { |
||||
| 187 | case 1: |
||||
| 188 | $setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error); |
||||
| 189 | $setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set')); |
||||
| 190 | $setup_tpl->set_var('notcomplete',lang('not complete')); |
||||
| 191 | $setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly')); |
||||
| 192 | $setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>'); |
||||
| 193 | $setup_tpl->set_var('create_database',lang('Create database')); |
||||
| 194 | $setup_tpl->set_var('instr',''); |
||||
| 195 | $info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]; |
||||
| 196 | switch ($info['db_type']) |
||||
| 197 | { |
||||
| 198 | case 'mysql': |
||||
| 199 | case 'mysqli': |
||||
| 200 | case 'mysqlt': |
||||
| 201 | $set_charset = (float) $GLOBALS['egw_setup']->db->ServerInfo['version'] >= 4.1 ? ' DEFAULT CHARACTER SET utf8' : ''; |
||||
| 202 | $setup_tpl->set_var('instr', |
||||
| 203 | '<b>'.lang("Instructions for creating the database in %1:",'MySql').'</b>' |
||||
| 204 | . '<br />'.lang('Login to mysql -') |
||||
| 205 | . '<br /><i>[user@server user]# <b>mysql -u root -p</b></i><br />' |
||||
| 206 | . lang('Create the empty database and grant user permissions -') |
||||
| 207 | . "<br /><i>mysql> <b>CREATE DATABASE $info[db_name]$set_charset;</b></i>" |
||||
| 208 | . "<br /><i>mysql> <b>GRANT ALL ON " . $info['db_name'] |
||||
| 209 | . ".* TO " . $info['db_user'] . "@localhost IDENTIFIED BY '" . $info['db_pass'] . "';</b></i>"); |
||||
| 210 | $setup_tpl->parse('V_db_stage_1','B_db_stage_1'); |
||||
| 211 | break; |
||||
| 212 | case 'pgsql': |
||||
| 213 | $ip = $info['db_host'] == 'localhost' ? '127.0.0.1' : '<ip-address webserver>'; |
||||
| 214 | $setup_tpl->set_var('instr', |
||||
| 215 | '<b>'.lang('Instructions for creating the database in %1:','PostgreSQL').'</b>' |
||||
| 216 | . '<br />'.lang('Login as user postgres, eg. by using su as root') |
||||
| 217 | . "<br /><i>[root@server /root]# <b>su - postgres</b></i><br />" |
||||
| 218 | . lang('Create the empty database and grant user permissions -') |
||||
| 219 | . "<br /><i>[postgres@server /var/lib/pgsql]\$ <b>createuser --no-adduser --no-createdb -P " . $info['db_user'] . "</b></i>" |
||||
| 220 | . "<br /><i>Enter password for new user: <b>" . $info['db_pass'] . "</b></i>" |
||||
| 221 | . "<br /><i>[postgres@server /var/lib/pgsql]\$ <b>createdb --encoding=utf-8 --owner " . $info['db_user'] . ' ' . $info['db_name'] . "</b></i>" |
||||
| 222 | . '<br />'.lang('to allow password authentification add the following line to your pg_hba.conf (above all others) AND restart postgres:') |
||||
| 223 | . '<br /><i># TYPE DATABASE USER CIDR-ADDRESS METHOD</i>' |
||||
| 224 | .($info['db_host'] ? "<br /><i><b>host $info[db_name] $info[db_user] $ip/32 password</b></i>" : |
||||
| 225 | "<br /><i><b>local $info[db_name] $info[db_user] password</b></i>")); |
||||
| 226 | //$setup_tpl->parse('V_db_stage_1','B_db_stage_1'); |
||||
| 227 | //break; |
||||
| 228 | default: |
||||
| 229 | $setup_tpl->parse('V_db_stage_1','B_db_stage_1a'); |
||||
| 230 | } |
||||
| 231 | $db_filled_block = $setup_tpl->get_var('V_db_stage_1'); |
||||
| 232 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 233 | break; |
||||
| 234 | case 2: |
||||
| 235 | $setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of EGroupware.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.')); |
||||
| 236 | $setup_tpl->set_var('notcomplete',lang('not complete')); |
||||
| 237 | $setup_tpl->parse('V_db_stage_2','B_db_stage_2'); |
||||
| 238 | $db_filled_block = $setup_tpl->get_var('V_db_stage_2'); |
||||
| 239 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 240 | break; |
||||
| 241 | case 3: |
||||
| 242 | $setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>'); |
||||
| 243 | $setup_tpl->set_var('install',lang('Install')); |
||||
| 244 | $setup_tpl->set_var('proceed',lang('We can proceed')); |
||||
| 245 | $setup_tpl->set_var('coreapps',lang('all applications')); |
||||
| 246 | $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
||||
| 247 | $setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.')); |
||||
| 248 | $setup_tpl->set_var('upload','<input type="file" name="uploaded" /> '. |
||||
| 249 | '<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />'); |
||||
| 250 | $setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>'); |
||||
| 251 | $setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'. |
||||
| 252 | lang('Convert backup to charset selected above').'</label>'); |
||||
| 253 | $setup_tpl->parse('V_db_stage_3','B_db_stage_3'); |
||||
| 254 | $db_filled_block = $setup_tpl->get_var('V_db_stage_3'); |
||||
| 255 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 256 | break; |
||||
| 257 | case 4: |
||||
| 258 | $setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__))); |
||||
| 259 | $setup_tpl->set_var('oldver',lang('You appear to be running version %1 of EGroupware', |
||||
| 260 | isset($setup_info['api']['currentver']) ? $setup_info['api']['currentver'] : $setup_info['phpgwapi']['currentver'])); |
||||
| 261 | $setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['api']['version'])); |
||||
| 262 | $setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>')); |
||||
| 263 | $setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB')); |
||||
| 264 | $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
||||
| 265 | $setup_tpl->set_var('upgrade',lang('Upgrade')); |
||||
| 266 | $setup_tpl->set_var('goto',lang('Go to')); |
||||
| 267 | $setup_tpl->set_var('configuration',lang('configuration')); |
||||
| 268 | $setup_tpl->set_var('admin_account',lang('Create admin account')); |
||||
| 269 | $setup_tpl->set_var('applications',lang('Manage Applications')); |
||||
| 270 | $setup_tpl->set_var('db_backup',lang('DB backup and restore')); |
||||
| 271 | $setup_tpl->set_var('language_management',lang('Manage Languages')); |
||||
| 272 | $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
||||
| 273 | $setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data')); |
||||
| 274 | $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
||||
| 275 | |||||
| 276 | $setup_tpl->parse('V_db_stage_4','B_db_stage_4'); |
||||
| 277 | $db_filled_block = $setup_tpl->get_var('V_db_stage_4'); |
||||
| 278 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 279 | break; |
||||
| 280 | case 5: |
||||
| 281 | $setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__))); |
||||
| 282 | $setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?')); |
||||
| 283 | $setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications')); |
||||
| 284 | $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
||||
| 285 | $setup_tpl->set_var('cancel',lang('cancel')); |
||||
| 286 | $setup_tpl->parse('V_db_stage_5','B_db_stage_5'); |
||||
| 287 | $db_filled_block = $setup_tpl->get_var('V_db_stage_5'); |
||||
| 288 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 289 | break; |
||||
| 290 | case 6: |
||||
| 291 | $setup_tpl->set_var('status',lang('Status')); |
||||
| 292 | $setup_tpl->set_var('notcomplete',lang('not complete')); |
||||
| 293 | $setup_tpl->set_var('tblchange',lang('Table Change Messages')); |
||||
| 294 | $setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre'); |
||||
| 295 | $db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre'); |
||||
| 296 | $setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been')); |
||||
| 297 | |||||
| 298 | try { // catch DB errors to report them |
||||
| 299 | switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi']) |
||||
| 300 | { |
||||
| 301 | case 'dbcreate': |
||||
| 302 | $GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'], 'utf8', // create all new db's with utf8 |
||||
| 303 | !preg_match('/^[0-9.a-z_]+$/i', $_POST['db_grant_host']) ? 'localhost' : $_POST['db_grant_host']); |
||||
| 304 | break; |
||||
| 305 | case 'drop': |
||||
| 306 | Api\Csrf::validate($_POST['csrf_token'], __FILE__); |
||||
| 307 | $setup_info = $GLOBALS['egw_setup']->process->droptables( |
||||
| 308 | $GLOBALS['egw_setup']->detection->get_versions($setup_info)); |
||||
| 309 | break; |
||||
| 310 | case 'new': |
||||
| 311 | // use uploaded backup, instead installing from scratch |
||||
| 312 | if ($_POST['upload']) |
||||
| 313 | { |
||||
| 314 | $db_backup = new Api\Db\Backup(); |
||||
| 315 | if (is_array($_FILES['uploaded']) && !$_FILES['uploaded']['error'] && |
||||
| 316 | is_uploaded_file($_FILES['uploaded']['tmp_name'])) |
||||
| 317 | { |
||||
| 318 | if (preg_match('/\.(bz2|gz)$/i',$_FILES['uploaded']['name'],$matches)) |
||||
| 319 | { |
||||
| 320 | $ext = '.'.$matches[1]; |
||||
| 321 | move_uploaded_file($_FILES['uploaded']['tmp_name'],$_FILES['uploaded']['tmp_name'].$ext); |
||||
| 322 | $_FILES['uploaded']['tmp_name'] .= $ext; |
||||
| 323 | } |
||||
| 324 | if (is_resource($f = $db_backup->fopen_backup($_FILES['uploaded']['tmp_name'],true))) |
||||
| 325 | { |
||||
| 326 | echo '<p align="center">'.lang('restore started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096); |
||||
| 327 | $db_backup->restore($f,$_POST['convert_charset'],$_FILES['uploaded']['tmp_name'],false); |
||||
| 328 | fclose($f); |
||||
| 329 | echo '<p align="center">'.lang('restore finished')."</p>\n"; |
||||
| 330 | unlink($_FILES['uploaded']['tmp_name']); |
||||
| 331 | } |
||||
| 332 | else // backup failed ==> dont start the upgrade |
||||
| 333 | { |
||||
| 334 | $setup_tpl->set_var('submsg',lang('Restore failed')); |
||||
| 335 | $setup_tpl->set_var('tableshave','<b>'.$f.'</b>'); |
||||
| 336 | $setup_tpl->set_var('subaction',''); |
||||
| 337 | } |
||||
| 338 | } |
||||
| 339 | } |
||||
| 340 | else |
||||
| 341 | { |
||||
| 342 | $s_info = $GLOBALS['egw_setup']->detection->upgrade_exclude($setup_info); |
||||
| 343 | // Set the DB's client charset if a system-charset is set |
||||
| 344 | if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) |
||||
| 345 | { |
||||
| 346 | $GLOBALS['egw_setup']->system_charset = $_REQUEST['system_charset']; |
||||
| 347 | $GLOBALS['egw_setup']->db->Link_ID->SetCharSet($_REQUEST['system_charset']); |
||||
| 348 | } |
||||
| 349 | $setup_info = $GLOBALS['egw_setup']->process->pass($s_info,'new',$_REQUEST['debug'],True); |
||||
| 350 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
||||
| 351 | } |
||||
| 352 | break; |
||||
| 353 | case 'oldversion': |
||||
| 354 | Api\Csrf::validate($_POST['csrf_token'], __FILE__); |
||||
| 355 | // create a backup, before upgrading the tables |
||||
| 356 | if ($_POST['backup']) |
||||
| 357 | { |
||||
| 358 | $db_backup = new Api\Db\Backup(); |
||||
| 359 | if (is_resource($f = $db_backup->fopen_backup())) |
||||
| 360 | { |
||||
| 361 | echo '<p align="center">'.lang('backup started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096); |
||||
| 362 | $db_backup->backup($f); |
||||
| 363 | fclose($f); |
||||
| 364 | echo '<p align="center">'.lang('backup finished')."</p>\n"; |
||||
| 365 | } |
||||
| 366 | else // backup failed ==> dont start the upgrade |
||||
| 367 | { |
||||
| 368 | $setup_tpl->set_var('submsg',lang('Backup failed')); |
||||
| 369 | $setup_tpl->set_var('tableshave','<b>'.$f.'</b>'); |
||||
| 370 | $setup_tpl->set_var('subaction',''); |
||||
| 371 | } |
||||
| 372 | } |
||||
| 373 | if (!@$_POST['backup'] || !is_string($f)) |
||||
| 374 | { |
||||
| 375 | $setup_info = $GLOBALS['egw_setup']->process->pass($setup_info,'upgrade',$_REQUEST['debug']); |
||||
| 376 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
||||
| 377 | } |
||||
| 378 | break; |
||||
| 379 | } |
||||
| 380 | } |
||||
| 381 | catch (Api\Db\Exception $e) |
||||
| 382 | { |
||||
| 383 | echo "<pre>".$e->getMessage()."</pre>\n"; |
||||
| 384 | } |
||||
| 385 | $setup_tpl->set_var('re-check_my_installation',lang('Re-Check My Installation')); |
||||
| 386 | $setup_tpl->set_var('system_charset',$GLOBALS['egw']->system_charset); |
||||
| 387 | $setup_tpl->parse('V_db_stage_6_post','B_db_stage_6_post'); |
||||
| 388 | $db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post'); |
||||
|
0 ignored issues
–
show
Are you sure
$db_filled_block of type array|string can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 389 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 390 | break; |
||||
| 391 | case 10: |
||||
| 392 | $setup_tpl->set_var('tablescurrent',lang('Your EGroupware API is current')); |
||||
| 393 | $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
||||
| 394 | $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
||||
| 395 | $setup_tpl->set_var('deletetables',lang('Uninstall all applications')); |
||||
| 396 | $setup_tpl->parse('V_db_stage_10','B_db_stage_10'); |
||||
| 397 | $db_filled_block = $setup_tpl->get_var('V_db_stage_10'); |
||||
| 398 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 399 | break; |
||||
| 400 | default: |
||||
| 401 | $setup_tpl->set_var('dbnotexist',lang('Your database does not exist')); |
||||
| 402 | $setup_tpl->parse('V_db_stage_default','B_db_stage_default'); |
||||
| 403 | $db_filled_block = $setup_tpl->get_var('V_db_stage_default'); |
||||
| 404 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
||||
| 405 | break; |
||||
| 406 | } |
||||
| 407 | |||||
| 408 | // Config Section |
||||
| 409 | $setup_tpl->set_var('config_step_text',lang('Step %1 - Configuration', ++$num)); |
||||
| 410 | $GLOBALS['egw_info']['setup']['stage']['config'] = $GLOBALS['egw_setup']->detection->check_config(); |
||||
| 411 | |||||
| 412 | // begin DEBUG code |
||||
| 413 | //$GLOBALS['egw_info']['setup']['stage']['config'] = 10; |
||||
| 414 | // end DEBUG code |
||||
| 415 | |||||
| 416 | $setup_tpl->set_var('config_status_img',$incomplete); |
||||
| 417 | $setup_tpl->set_var('config_status_alt',lang('not completed')); |
||||
| 418 | switch($GLOBALS['egw_info']['setup']['stage']['config']) |
||||
| 419 | { |
||||
| 420 | case 1: // AFAIK this dont happen any more, as we have setup_process::save_minimal_config() now -- RalfBecker |
||||
| 421 | $btn_config_now = $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
||||
| 422 | lang('Please configure EGroupware for your environment'), |
||||
| 423 | 'post','config.php', |
||||
| 424 | 'submit',lang('Configure Now'), |
||||
| 425 | ''); |
||||
| 426 | $setup_tpl->set_var('config_table_data',$btn_config_now); |
||||
| 427 | break; |
||||
| 428 | case 10: |
||||
| 429 | $setup_tpl->set_var('config_status_img',$completed); |
||||
| 430 | $setup_tpl->set_var('config_status_alt',lang('completed')); |
||||
| 431 | $config_msg = lang('Configuration completed'); |
||||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||||
| 432 | case 2: |
||||
| 433 | if ($GLOBALS['egw_info']['setup']['config_errors']) |
||||
| 434 | { |
||||
| 435 | $config_msg = implode('<br />',$GLOBALS['egw_info']['setup']['config_errors']); |
||||
| 436 | } |
||||
| 437 | $btn_edit_config = $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
||||
| 438 | $config_msg, |
||||
| 439 | 'post','config.php', |
||||
| 440 | 'submit',lang('Edit Current Configuration'), |
||||
| 441 | '' |
||||
| 442 | ); |
||||
| 443 | $setup_tpl->set_var('config_table_data',$btn_edit_config); |
||||
| 444 | break; |
||||
| 445 | default: |
||||
| 446 | $setup_tpl->set_var('config_status_img',$incomplete); |
||||
| 447 | $setup_tpl->set_var('config_status_alt',lang('not completed')); |
||||
| 448 | $setup_tpl->set_var('config_table_data',lang('Not ready for this stage yet')); |
||||
| 449 | break; |
||||
| 450 | } |
||||
| 451 | // Admin Account Section |
||||
| 452 | $setup_tpl->set_var('admin_step_text',lang('Step %1 - Admin Account', ++$num)); |
||||
| 453 | |||||
| 454 | switch($GLOBALS['egw_info']['setup']['stage']['config']) |
||||
| 455 | { |
||||
| 456 | case 10: |
||||
| 457 | // check if there is already a user account (not the anonymous account of sitemgr or a group) |
||||
| 458 | $no_accounts = !$GLOBALS['egw_setup']->accounts_exist(); |
||||
| 459 | $setup_tpl->set_var('admin_status_img',$no_accounts ? $incomplete : $completed); |
||||
| 460 | $setup_tpl->set_var('admin_status_alt',$no_accounts ? lang('not completed') : lang('completed')); |
||||
| 461 | $setup_tpl->set_var('admin_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple( |
||||
| 462 | $no_accounts ? lang('No accounts existing') : lang('Accounts existing'), |
||||
| 463 | 'post','admin_account.php', |
||||
| 464 | 'submit',lang('Create admin account'), |
||||
| 465 | '' |
||||
| 466 | )); |
||||
| 467 | break; |
||||
| 468 | default: |
||||
| 469 | $setup_tpl->set_var('admin_status_img',$incomplete); |
||||
| 470 | $setup_tpl->set_var('admin_status_alt',lang('not completed')); |
||||
| 471 | $setup_tpl->set_var('admin_table_data',lang('Not ready for this stage yet')); |
||||
| 472 | break; |
||||
| 473 | } |
||||
| 474 | |||||
| 475 | $setup_tpl->set_var('apps_step_text',lang('Step %1 - Advanced Application Management', ++$num)); |
||||
| 476 | // $GLOBALS['egw_info']['setup']['stage']['apps'] = $GLOBALS['egw_setup']->check_apps(); |
||||
| 477 | switch($GLOBALS['egw_info']['setup']['stage']['db']) |
||||
| 478 | { |
||||
| 479 | case 10: |
||||
| 480 | $setup_tpl->set_var('apps_status_img',$completed); |
||||
| 481 | $setup_tpl->set_var('apps_status_alt',lang('completed')); |
||||
| 482 | // check if we have apps to upgrade or essential apps not installed |
||||
| 483 | $to_upgrade = $to_install = array(); |
||||
| 484 | foreach($setup_info as $app => $data) |
||||
| 485 | { |
||||
| 486 | if ($data['currentver'] && $data['version'] && $data['version'] != $data['currentver']) |
||||
| 487 | { |
||||
| 488 | $to_upgrade[] = lang(!empty($data['title']) ? $data['title'] : $app); |
||||
| 489 | $setup_tpl->set_var('apps_status_img',$incomplete); |
||||
| 490 | } |
||||
| 491 | } |
||||
| 492 | // warn if essential apps are not installed |
||||
| 493 | foreach(array('api','admin','preferences') as $app) |
||||
| 494 | { |
||||
| 495 | if (!isset($setup_info[$app]) || empty($setup_info[$app]['currentver'])) |
||||
| 496 | { |
||||
| 497 | $to_install[] = lang($app); |
||||
| 498 | $setup_tpl->set_var('apps_status_img',$incomplete); |
||||
| 499 | } |
||||
| 500 | } |
||||
| 501 | $msg = ''; |
||||
| 502 | if ($to_upgrade || $to_install) |
||||
| 503 | { |
||||
| 504 | if ($to_upgrade) $msg = '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade); |
||||
| 505 | if ($to_install) $msg .= ($msg?'<br />':'').'<b>'.lang('The following applications are required, but NOT installed:').'</b> '.implode(', ',$to_install); |
||||
| 506 | } |
||||
| 507 | $btn_manage_apps = $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
||||
| 508 | $msg ? $msg : lang('This stage is completed<br />'), |
||||
| 509 | 'post','applications.php', |
||||
| 510 | 'submit',lang('Manage Applications'), |
||||
| 511 | ''); |
||||
| 512 | $setup_tpl->set_var('apps_table_data',$btn_manage_apps); |
||||
| 513 | break; |
||||
| 514 | default: |
||||
| 515 | $setup_tpl->set_var('apps_status_img',$incomplete); |
||||
| 516 | $setup_tpl->set_var('apps_status_alt',lang('not completed')); |
||||
| 517 | $setup_tpl->set_var('apps_table_data',lang('Not ready for this stage yet')); |
||||
| 518 | break; |
||||
| 519 | } |
||||
| 520 | // Backup and restore section |
||||
| 521 | $setup_tpl->set_var('backup_step_text',lang('Step %1 - DB backup and restore', ++$num)); |
||||
| 522 | if ($GLOBALS['egw_info']['setup']['stage']['db'] == 10 && !$no_backup_dir) |
||||
| 523 | { |
||||
| 524 | $setup_tpl->set_var('backup_status_img',$completed); |
||||
| 525 | $setup_tpl->set_var('backup_status_alt',lang('completed')); |
||||
| 526 | $setup_tpl->set_var('backup_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple( |
||||
| 527 | ''/*lang('This stage is completed<br />')*/, |
||||
| 528 | 'post','db_backup.php', |
||||
| 529 | 'submit',lang('backup and restore'), |
||||
| 530 | '')); |
||||
| 531 | } |
||||
| 532 | else |
||||
| 533 | { |
||||
| 534 | $setup_tpl->set_var('backup_status_img',$incomplete); |
||||
| 535 | $setup_tpl->set_var('backup_status_alt',lang('not completed')); |
||||
| 536 | $setup_tpl->set_var('backup_table_data',$no_backup_dir ? $no_backup_dir : lang('Not ready for this stage yet')); |
||||
| 537 | } |
||||
| 538 | |||||
| 539 | $setup_tpl->pparse('out','T_setup_main'); |
||||
| 540 | $GLOBALS['egw_setup']->html->show_footer(); |
||||
| 541 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.