Project

General

Profile

Feature #4206 ยป index.php

Yoselyn Castillo, 25/05/2012 02:57

 
1
<?php
2
/* For licensing terms, see /license.txt */
3

    
4
/**
5
 * Chamilo installation
6
 *
7
 * As seen from the user, the installation proceeds in 6 steps.
8
 * The user is presented with several webpages where he/she has to make choices
9
 * and/or fill in data.
10
 *
11
 * The aim is, as always, to have good default settings and suggestions.
12
 *
13
 * @todo reduce high level of duplication in this code
14
 * @todo (busy) organise code into functions
15
 * @package chamilo.install
16
 */
17

    
18
/*		CONSTANTS */
19

    
20
define('SYSTEM_INSTALLATION',                   1);
21
define('INSTALL_TYPE_UPDATE',                   'update');
22
define('FORM_FIELD_DISPLAY_LENGTH',             40);
23
define('DATABASE_FORM_FIELD_DISPLAY_LENGTH',    25);
24
define('MAX_FORM_FIELD_LENGTH',                 80);
25

    
26
/*		PHP VERSION CHECK */
27

    
28
// PHP version requirement.
29
define('REQUIRED_PHP_VERSION', '5');
30

    
31
if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
32
	$global_error_code = 1;
33
	// Incorrect PHP version.
34
	require '../inc/global_error_message.inc.php';
35
	die();
36
}
37

    
38
/*		INITIALIZATION SECTION */
39

    
40
ob_implicit_flush(true);
41
session_start();
42

    
43
// Including necessary libraries.
44
require_once '../inc/lib/main_api.lib.php';
45
require_once api_get_path(LIBRARY_PATH).'database.lib.php';
46
require_once api_get_path(LIBRARY_PATH).'log.class.php';
47
require_once 'install.lib.php';
48
require_once 'install.class.php';
49
require_once 'i_database.class.php';
50

    
51
// The function api_get_setting() might be called within the installation scripts.
52
// We need to provide some limited support for it through initialization of the
53
// global array-type variable $_setting.
54
$_setting = array(
55
	'platform_charset' => 'UTF-8',
56
	'server_type' => 'production', // 'production' | 'test'
57
	'permissions_for_new_directories' => '0770',
58
	'permissions_for_new_files' => '0660',
59
	'stylesheets' => 'chamilo'
60
);
61

    
62
// Determination of the language during the installation procedure.
63
if (!empty($_POST['language_list'])) {
64
	$search = array('../', '\\0');
65
	$install_language = str_replace($search, '', urldecode($_POST['language_list']));
66
	api_session_register('install_language');
67
} elseif (isset($_SESSION['install_language']) && $_SESSION['install_language']) {
68
	$install_language = $_SESSION['install_language'];
69
} else {
70
	// Trying to switch to the browser's language, it is covenient for most of the cases.
71
	$install_language = detect_browser_language();
72
}
73

    
74
// Language validation.
75
if (!array_key_exists($install_language, get_language_folder_list())) {
76
	$install_language = 'english';
77
}
78

    
79
// Loading language files.
80
require api_get_path(SYS_LANG_PATH).'english/trad4all.inc.php';
81
require api_get_path(SYS_LANG_PATH).'english/admin.inc.php';
82
require api_get_path(SYS_LANG_PATH).'english/install.inc.php';
83
if ($install_language != 'english') {
84
	include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
85
	include_once api_get_path(SYS_LANG_PATH).$install_language.'/install.inc.php';
86
    include_once api_get_path(SYS_LANG_PATH).$install_language.'/admin.inc.php';
87
}
88

    
89
// These global variables must be set for proper working of the function get_lang(...) during the installation.
90
$language_interface = $install_language;
91
$language_interface_initial_value = $install_language;
92

    
93
// Character set during the installation, it is always to be 'UTF-8'.
94
$charset = 'UTF-8';
95

    
96
// Initialization of the internationalization library.
97
api_initialize_internationalization();
98
// Initialization of the default encoding that will be used by the multibyte string routines in the internationalization library.
99
api_set_internationalization_default_encoding($charset);
100

    
101
// Page encoding initialization.
102
header('Content-Type: text/html; charset='. api_get_system_encoding());
103

    
104
// Setting the error reporting levels.
105
error_reporting(E_ALL);
106

    
107
// Overriding the timelimit (for large campusses that have to be migrated).
108
@set_time_limit(0);
109

    
110
// Upgrading from any subversion of 1.6 is just like upgrading from 1.6.5
111
$update_from_version_6 = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5');
112
// Upgrading from any subversion of 1.8 avoids the additional step of upgrading from 1.6
113
$update_from_version_8 = array('1.8', '1.8.2', '1.8.3', '1.8.4', '1.8.5', '1.8.6', '1.8.6.1', '1.8.6.2','1.8.7','1.8.7.1','1.8.8','1.8.8.2', '1.8.8.4');
114

    
115
$my_old_version = '';
116
$tmp_version = get_config_param('dokeos_version');
117
if (empty($tmp_version)) {
118
	$tmp_version = get_config_param('system_version');
119
}
120
if (!empty($_POST['old_version'])) {
121
	$my_old_version = $_POST['old_version'];
122
} elseif (!empty($tmp_version)) {
123
    $my_old_version = $tmp_version;
124
} elseif (!empty($dokeos_version)) { //variable coming from installedVersion, normally
125
	$my_old_version = $dokeos_version;
126
}
127

    
128
$new_version 		= '1.9.0';
129
$new_version_stable = false;
130
$new_version_major 	= true;
131
$software_name 		= 'Chamilo';
132
$software_url 		= 'http://www.chamilo.org/';
133

    
134
// A protection measure for already installed systems.
135

    
136
if (is_already_installed_system()) {
137
	// The system has already been installed, so block re-installation.
138
	$global_error_code = 6;
139
	require '../inc/global_error_message.inc.php';
140
	die();
141
}
142

    
143
/*		STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
144

    
145
// Is valid request
146
$is_valid_request = isset($_REQUEST['is_executable']) ? $_REQUEST['is_executable'] : null;
147
foreach ($_POST as $request_index => $request_value) {
148
	if (substr($request_index, 0, 4) == 'step') {
149
		if ($request_index != $is_valid_request) {
150
			unset($_POST[$request_index]);
151
		}
152
	}
153
}
154

    
155
$badUpdatePath = false;
156
$emptyUpdatePath = true;
157
$proposedUpdatePath = '';
158
if (!empty($_POST['updatePath'])) {
159
	$proposedUpdatePath = $_POST['updatePath'];
160
}
161

    
162
if (@$_POST['step2_install'] || @$_POST['step2_update_8'] || @$_POST['step2_update_6']) {
163
	if (@$_POST['step2_install']) {
164
		$installType = 'new';
165
		$_POST['step2'] = 1;
166
	} else {
167
		$installType = 'update';
168
		if (@$_POST['step2_update_8']) {
169
			$emptyUpdatePath = false;
170
			$proposedUpdatePath = api_add_trailing_slash(empty($_POST['updatePath']) ? api_get_path(SYS_PATH) : $_POST['updatePath']);
171
			if (file_exists($proposedUpdatePath)) {
172
				if (in_array($my_old_version, $update_from_version_8)) {
173
					$_POST['step2'] = 1;
174
				} else {
175
					$badUpdatePath = true;
176
				}
177
			} else {
178
				$badUpdatePath = true;
179
			}
180
		} else { //step2_update_6, presumably
181
			if (empty($_POST['updatePath'])) {
182
				$_POST['step1'] = 1;
183
			} else {
184
				$emptyUpdatePath = false;
185
				$_POST['updatePath'] = api_add_trailing_slash($_POST['updatePath']);
186
				if (file_exists($_POST['updatePath'])) {
187
					//1.6.x
188
					$my_old_version = get_config_param('clarolineVersion', $_POST['updatePath']);
189
					if (in_array($my_old_version, $update_from_version_6)) {
190
						$_POST['step2'] = 1;
191
						$proposedUpdatePath = $_POST['updatePath'];
192
					} else {
193
						$badUpdatePath = true;
194
					}
195
				} else {
196
					$badUpdatePath = true;
197
				}
198
			}
199
		}
200
	}
201
} elseif (@$_POST['step1']) {
202
	$_POST['updatePath'] = '';
203
	$installType = '';
204
	$updateFromConfigFile = '';
205
	unset($_GET['running']);
206
} else {
207
	$installType = isset($_GET['installType']) ? $_GET['installType'] : null;
208
	$updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false;
209
}
210

    
211
if ($installType == 'update' && in_array($my_old_version, $update_from_version_8)) {
212
	// This is the main configuration file of the system before the upgrade.
213
	include api_get_path(CONFIGURATION_PATH).'configuration.php'; // Don't change to include_once
214
}
215

    
216
if (!isset($_GET['running'])) {
217

    
218
	$dbHostForm		= 'localhost';
219
	$dbUsernameForm = 'root';
220
	$dbPassForm		= '';
221
 	$dbPrefixForm   = '';
222
	$dbNameForm		= 'chamilo';
223
	
224
	$dbStatsForm    = 'chamilo';
225
	$dbScormForm    = 'chamilo';
226
	$dbUserForm		= 'chamilo';
227

    
228
	// Extract the path to append to the url if Chamilo is not installed on the web root directory.
229
	$urlAppendPath  = api_remove_trailing_slash(api_get_path(REL_PATH));
230
  	$urlForm 		= api_get_path(WEB_PATH);
231
	$pathForm 		= api_get_path(SYS_PATH);
232

    
233
	$emailForm = $_SERVER['SERVER_ADMIN'];
234
	$email_parts = explode('@', $emailForm);
235
	if ($email_parts[1] == 'localhost') {
236
		$emailForm .= '.localdomain';
237
	}
238
	$adminLastName	= 'Doe';
239
	$adminFirstName	= 'John';
240
	$loginForm		= 'admin';
241
	$passForm		= api_generate_password();
242

    
243
	$campusForm		= 'My campus';
244
	$educationForm	= 'Albert Einstein';
245
	$adminPhoneForm	= '(000) 001 02 03';
246
	$institutionForm    = 'My Organisation';
247
	$institutionUrlForm = 'http://www.chamilo.org';
248
	// TODO: A better choice to be tested:
249
	//$languageForm	    = 'english';
250
	$languageForm	    = api_get_interface_language();
251

    
252
	$checkEmailByHashSent	= 0;
253
	$ShowEmailnotcheckedToStudent = 1;
254
	$userMailCanBeEmpty		= 1;
255
	$allowSelfReg			= 1;
256
	$allowSelfRegProf		= 1;
257
	$enableTrackingForm		= 1;
258
	$singleDbForm			= 0;
259
	$encryptPassForm		= 'sha1';
260
	$session_lifetime		= 360000;
261
} else {
262
	foreach ($_POST as $key => $val) {
263
		$magic_quotes_gpc = ini_get('magic_quotes_gpc');
264
		if (is_string($val)) {
265
			if ($magic_quotes_gpc) {
266
				$val = stripslashes($val);
267
			}
268
			$val = trim($val);
269
			$_POST[$key] = $val;
270
		} elseif (is_array($val)) {
271
			foreach ($val as $key2 => $val2) {
272
				if ($magic_quotes_gpc) {
273
					$val2 = stripslashes($val2);
274
				}
275
				$val2 = trim($val2);
276
				$_POST[$key][$key2] = $val2;
277
			}
278
		}
279
		$GLOBALS[$key] = $_POST[$key];
280
	}
281
}
282

    
283
/*		NEXT STEPS IMPLEMENTATION */
284

    
285
$total_steps = 7;
286
if (!$_POST) {
287
	$current_step = 1;
288
} elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) or ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])))  && ($emptyUpdatePath or $badUpdatePath))) {
289
	$current_step = 2;
290
} elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])) )) {
291
	$current_step = 3;
292
} elseif (!empty($_POST['step3'])) {
293
	$current_step = 4;
294
} elseif (!empty($_POST['step4'])) {
295
	$current_step = 5;
296
} elseif (!empty($_POST['step5'])) {
297
	$current_step = 6;
298
}
299

    
300
// Managing the $encryptPassForm
301
if ($encryptPassForm == '1') {
302
	$encryptPassForm = 'sha1';
303
} elseif ($encryptPassForm == '0') {
304
	$encryptPassForm = 'none';
305
}
306
?>
307
<!DOCTYPE html>
308
<head>
309
	<title>&mdash; <?php echo get_lang('ChamiloInstallation').' &mdash; '.get_lang('Version_').' '.$new_version; ?></title>
310
	<style type="text/css" media="screen, projection">
311
		/*<![CDATA[*/        
312
		@import "../css/base.css";
313
		@import "../css/<?php echo api_get_visual_theme(); ?>/default.css";        
314
		/*]]>*/
315
	</style>
316
	<script type="text/javascript" src="../inc/lib/javascript/jquery.min.js"></script>	
317
	<script type="text/javascript" >
318
		$(document).ready( function() {
319
		   $("#button_please_wait").hide();
320
			 //checked
321
			if ($('#singleDb1').attr('checked')==false) {
322
					//$('#dbStatsForm').removeAttr('disabled');
323
					//$('#dbUserForm').removeAttr('disabled');
324
					$('#dbStatsForm').attr('value','chamilo_main');
325
				    $('#dbUserForm').attr('value','chamilo_main');
326
			} else if($('#singleDb1').attr('checked')==true){
327
			        //$('#dbStatsForm').attr('disabled','disabled');
328
					//$('#dbUserForm').attr('disabled','disabled');
329
					$('#dbStatsForm').attr('value','chamilo_main');
330
					$('#dbUserForm').attr('value','chamilo_main');
331
			}
332
            
333
			$("button").addClass('btn');
334
            
335
    		//Allow Chamilo install in IE
336
    		$("button").click(function() {
337
    			$("#is_executable").attr("value",$(this).attr("name"));
338
    		});
339

    
340
			//Blocking step6 button
341
    			$("#button_step6").click(function() { 
342
    		    	$("#button_step6").hide();
343
        			$("#button_please_wait").html('<?php echo addslashes(get_lang('PleaseWait'));?>');
344
                    $("#button_please_wait").show();
345
                    $("#button_please_wait").attr('disabled', true);
346
        			$("#is_executable").attr("value",'step6');
347
               
348
          	});    
349
             	
350
	 	});
351
        
352
        /*
353
        function check_db() {
354
            var status = ($('#db_status').attr('class'));
355
            if (status == 'confirmation-message') {
356
                return true;    
357
            }
358
            return false;
359
        }*/
360

    
361
		function show_hide_tracking_and_user_db (my_option) {
362
			if (my_option=='singleDb1') {
363
				$('#optional_param2').hide();
364
				$('#optional_param4').hide();				
365
				
366
				$('#dbStatsForm').attr('value','chamilo_main');
367
				$('#dbUserForm').attr('value','chamilo_main');
368
			} else if (my_option=='singleDb0') {
369
				$('#optional_param2').show();
370
				$('#optional_param4').show();
371
				
372
				$('#dbStatsForm').attr('value','chamilo_main');
373
				$('#dbUserForm').attr('value','chamilo_main');
374
			}
375
		}
376

    
377
		init_visibility=0;
378
		function show_hide_option() {			
379
			if (init_visibility == 0) {
380
				$('#optional_param1').show();
381
						
382
				if ($('#singleDb1').attr("checked") == true) {										
383
					//$('#optional_param2').hide();
384
					//$('#optional_param4').hide();
385
					$('#optional_param5').hide();
386
				} else {					
387
					//$('#optional_param2').show();
388
					//$('#optional_param4').show();
389
					$('#optional_param5').show();  					
390
                }	
391
                
392
				//document.getElementById('optional_param2').style.display = '';
393
				if (document.getElementById('optional_param3')) {
394
					document.getElementById('optional_param3').style.display = '';
395
				}
396
				
397
				//document.getElementById('optional_param5').style.display = '';
398
				//document.getElementById('optional_param6').style.display = '';
399
				init_visibility = 1;
400
				document.getElementById('optionalparameters').innerHTML='<img style="vertical-align:middle;" src="../img/div_hide.gif" alt="" /> <?php echo get_lang('OptionalParameters', ''); ?>';
401
			} else {
402
				document.getElementById('optional_param1').style.display = 'none';
403
				/*document.getElementById('optional_param2').style.display = 'none';
404
				if (document.getElementById('optional_param3')) {
405
					document.getElementById('optional_param3').style.display = 'none';
406
				}
407
				document.getElementById('optional_param4').style.display = 'none';
408
				*/
409
				document.getElementById('optional_param5').style.display = 'none';
410
				//document.getElementById('optional_param6').style.display = 'none';
411
				document.getElementById('optionalparameters').innerHTML='<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> <?php echo get_lang('OptionalParameters', ''); ?>';
412
				init_visibility = 0;
413
			}
414
			return false;
415
		}	
416

    
417
        $(document).ready( function() {
418
            $(".advanced_parameters").click(function() {
419
                if ($("#id_contact_form").css("display") == "none") {
420
                        $("#id_contact_form").css("display","block");
421
                        $("#img_plus_and_minus").html('&nbsp;<img src="<?php echo api_get_path(WEB_IMG_PATH) ?>div_hide.gif" alt="<?php echo get_lang('Hide') ?>" title="<?php echo get_lang('Hide')?>" style ="vertical-align:middle" >&nbsp;<?php echo get_lang('ContactInformation') ?>');
422
                } else {
423
                        $("#id_contact_form").css("display","none");
424
                        $("#img_plus_and_minus").html('&nbsp;<img src="<?php echo api_get_path(WEB_IMG_PATH) ?>div_show.gif" alt="<?php echo get_lang('Show') ?>" title="<?php echo get_lang('Show') ?>" style ="vertical-align:middle" >&nbsp;<?php echo get_lang('ContactInformation') ?>');
425
                }
426
            });
427
        });
428

    
429
        function send_contact_information() {
430
            var data_post = "";
431
            data_post += "person_name="+$("#person_name").val()+"&";
432
            data_post += "company_name="+$("#company_name").val()+"&";
433
            data_post += "company_activity="+$("#company_activity option:selected").val()+"&";
434
            data_post += "person_role="+$("#person_role option:selected").val()+"&";
435
            data_post += "company_country="+$("#country option:selected").val()+"&";
436
            data_post += "company_city="+$("#company_city").val()+"&";
437
            data_post += "language="+$("#language option:selected").val()+"&";
438
            data_post += "financial_decision="+$("input[@name='financial_decision']:checked").val();
439

    
440
            $.ajax({
441
                    contentType: "application/x-www-form-urlencoded",
442
                    beforeSend: function(objeto) {},
443
                    type: "POST",
444
                    url: "<?php echo api_get_path(WEB_AJAX_PATH) ?>install.ajax.php?a=send_contact_information",
445
                    data: data_post,
446
                    success: function(datos) {
447
                        if (datos == 'required_field_error') {
448
                            message = "<?php echo get_lang('FormHasErrorsPleaseComplete') ?>";
449
                        } else if (datos == '1') {
450
                            message = "<?php echo get_lang('ContactInformationHasBeenSent') ?>";
451
                        } else {
452
                            message = "<?php echo get_lang('Error').': '.get_lang('ContactInformationHasNotBeenSent') ?>";
453
                        }
454
                        alert(message);
455
                    }
456
            });
457
        }
458
    </script>        
459
	<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
460
</head>
461
<body dir="<?php echo api_get_text_direction(); ?>">
462

    
463
<div id="wrapper">
464
	<div id="header">
465
		<div id="header1" style="margin-bottom:10px;">	
466
			<div id="logo">	   
467
	        	<img src="../css/chamilo/images/header-logo.png" hspace="10" vspace="10" alt="Chamilo" />        
468
			</div>	
469
        </div>
470
	</div>
471
<div id="main">
472
    <div class="row-fluid">
473
        <div class="span3">
474
            <div class="well">		
475
                <ol>
476
                    <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
477
                    <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
478
                    <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
479
                    <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
480
                    <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
481
                    <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
482
                    <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
483
                </ol>
484
            </div>
485
        </div>
486
        <div class="span9">
487
            <div id="note" style="float:right;">
488
				<a href="../../documentation/installation_guide.html" target="_blank"><?php echo get_lang('ReadTheInstallationGuide'); ?></a>
489
			</div>
490
            
491
<form class="form-horizontal" id="install_form" style="padding: 0px; margin: 0px;" method="post" action="<?php echo api_get_self(); ?>?running=1&amp;installType=<?php echo $installType; ?>&amp;updateFromConfigFile=<?php echo urlencode($updateFromConfigFile); ?>">
492
<?php
493
    echo '<div class="page-header"><h1>'.get_lang('ChamiloInstallation').' &ndash; '.get_lang('Version_').' '.$new_version.'</h1></div>';
494
    
495
    $instalation_type_label = '';
496
    if ($installType == 'new'){ 
497
        $instalation_type_label  = get_lang('NewInstallation'); 
498
    }elseif ($installType == 'update') {
499
        $update_from_version = isset($update_from_version) ? $update_from_version : null;
500
        $instalation_type_label = get_lang('UpdateFromDokeosVersion').(is_array($update_from_version) ? implode('|', $update_from_version) : '');
501
    }
502
    if (!empty($instalation_type_label)) {
503
    	echo "<h2>$instalation_type_label</h2><hr />";
504
    }        
505
    ?>
506
	<input type="hidden" name="updatePath"           value="<?php if (!$badUpdatePath) echo api_htmlentities($proposedUpdatePath, ENT_QUOTES); ?>" />
507
	<input type="hidden" name="urlAppendPath"        value="<?php echo api_htmlentities($urlAppendPath, ENT_QUOTES); ?>" />
508
	<input type="hidden" name="pathForm"             value="<?php echo api_htmlentities($pathForm, ENT_QUOTES); ?>" />
509
	<input type="hidden" name="urlForm"              value="<?php echo api_htmlentities($urlForm, ENT_QUOTES); ?>" />
510
	<input type="hidden" name="dbHostForm"           value="<?php echo api_htmlentities($dbHostForm, ENT_QUOTES); ?>" />
511
	<input type="hidden" name="dbUsernameForm"       value="<?php echo api_htmlentities($dbUsernameForm, ENT_QUOTES); ?>" />
512
	<input type="hidden" name="dbPassForm"           value="<?php echo api_htmlentities($dbPassForm, ENT_QUOTES); ?>" />
513
	<input type="hidden" name="singleDbForm"         value="<?php echo api_htmlentities($singleDbForm, ENT_QUOTES); ?>" />
514
	<input type="hidden" name="dbPrefixForm"         value="<?php echo api_htmlentities($dbPrefixForm, ENT_QUOTES); ?>" />
515
	<input type="hidden" name="dbNameForm"           value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>" />
516
<?php
517
	if ($installType == 'update' OR $singleDbForm == 0) {
518
?>
519
	<input type="hidden" name="dbStatsForm"          value="<?php echo api_htmlentities($dbStatsForm, ENT_QUOTES); ?>" />
520
	<input type="hidden" name="dbScormForm"          value="<?php echo api_htmlentities($dbScormForm, ENT_QUOTES); ?>" />
521
	<input type="hidden" name="dbUserForm"           value="<?php echo api_htmlentities($dbUserForm, ENT_QUOTES); ?>" />
522
<?php
523
	} else {
524
?>
525
	<input type="hidden" name="dbStatsForm"          value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>" />
526
	<input type="hidden" name="dbUserForm"           value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>" />
527
<?php
528
	}
529
?>
530
	<input type="hidden" name="enableTrackingForm"   value="<?php echo api_htmlentities($enableTrackingForm, ENT_QUOTES); ?>" />
531
	<input type="hidden" name="allowSelfReg"         value="<?php echo api_htmlentities($allowSelfReg, ENT_QUOTES); ?>" />
532
	<input type="hidden" name="allowSelfRegProf"     value="<?php echo api_htmlentities($allowSelfRegProf, ENT_QUOTES); ?>" />
533
	<input type="hidden" name="emailForm"            value="<?php echo api_htmlentities($emailForm, ENT_QUOTES); ?>" />
534
	<input type="hidden" name="adminLastName"        value="<?php echo api_htmlentities($adminLastName, ENT_QUOTES); ?>" />
535
	<input type="hidden" name="adminFirstName"       value="<?php echo api_htmlentities($adminFirstName, ENT_QUOTES); ?>" />
536
	<input type="hidden" name="adminPhoneForm"       value="<?php echo api_htmlentities($adminPhoneForm, ENT_QUOTES); ?>" />
537
	<input type="hidden" name="loginForm"            value="<?php echo api_htmlentities($loginForm, ENT_QUOTES); ?>" />
538
	<input type="hidden" name="passForm"             value="<?php echo api_htmlentities($passForm, ENT_QUOTES); ?>" />
539
	<input type="hidden" name="languageForm"         value="<?php echo api_htmlentities($languageForm, ENT_QUOTES); ?>" />
540
	<input type="hidden" name="campusForm"           value="<?php echo api_htmlentities($campusForm, ENT_QUOTES); ?>" />
541
	<input type="hidden" name="educationForm"        value="<?php echo api_htmlentities($educationForm, ENT_QUOTES); ?>" />
542
	<input type="hidden" name="institutionForm"      value="<?php echo api_htmlentities($institutionForm, ENT_QUOTES); ?>" />
543
	<input type="hidden" name="institutionUrlForm"   value="<?php echo api_stristr($institutionUrlForm, 'http://', false) ? api_htmlentities($institutionUrlForm, ENT_QUOTES) : api_stristr($institutionUrlForm, 'https://', false) ? api_htmlentities($institutionUrlForm, ENT_QUOTES) : 'http://'.api_htmlentities($institutionUrlForm, ENT_QUOTES); ?>" />
544
	<input type="hidden" name="checkEmailByHashSent" value="<?php echo api_htmlentities($checkEmailByHashSent, ENT_QUOTES); ?>" />
545
	<input type="hidden" name="ShowEmailnotcheckedToStudent" value="<?php echo api_htmlentities($ShowEmailnotcheckedToStudent, ENT_QUOTES); ?>" />
546
	<input type="hidden" name="userMailCanBeEmpty"   value="<?php echo api_htmlentities($userMailCanBeEmpty, ENT_QUOTES); ?>" />
547
	<input type="hidden" name="encryptPassForm"      value="<?php echo api_htmlentities($encryptPassForm, ENT_QUOTES); ?>" />
548
	<input type="hidden" name="session_lifetime"     value="<?php echo api_htmlentities($session_lifetime, ENT_QUOTES); ?>" />
549
	<input type="hidden" name="old_version"          value="<?php echo api_htmlentities($my_old_version, ENT_QUOTES); ?>" />
550
	<input type="hidden" name="new_version"          value="<?php echo api_htmlentities($new_version, ENT_QUOTES); ?>" />
551
<?php
552
if (@$_POST['step2']) {
553
	//STEP 3 : LICENSE
554
	display_license_agreement();
555
} elseif (@$_POST['step3']) {
556
	//STEP 4 : MYSQL DATABASE SETTINGS	
557
	display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm);
558
} elseif (@$_POST['step4']) {
559
	//STEP 5 : CONFIGURATION SETTINGS
560
	
561
	//if update, try getting settings from the database...
562
	if ($installType == 'update') {
563
		$db_name = $dbNameForm;
564

    
565
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'platformLanguage');
566
		if (!empty($tmp)) $languageForm = $tmp;
567

    
568
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'emailAdministrator');
569
		if (!empty($tmp)) $emailForm = $tmp;
570

    
571
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'administratorName');
572
		if (!empty($tmp)) $adminFirstName = $tmp;
573

    
574
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'administratorSurname');
575
		if (!empty($tmp)) $adminLastName = $tmp;
576

    
577
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'administratorTelephone');
578
		if (!empty($tmp)) $adminPhoneForm = $tmp;
579

    
580
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'siteName');
581
		if (!empty($tmp)) $campusForm = $tmp;
582

    
583
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'Institution');
584
		if (!empty($tmp)) $institutionForm = $tmp;
585

    
586
		$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'InstitutionUrl');
587
		if (!empty($tmp)) $institutionUrlForm = $tmp;
588

    
589
		if (in_array($my_old_version, $update_from_version_6)) {   //for version 1.6
590
			$urlForm = get_config_param('rootWeb');
591
			$encryptPassForm = get_config_param('userPasswordCrypted');
592
			if (empty($encryptPassForm)) {
593
				$encryptPassForm = get_config_param('password_encryption');
594
			}
595
			// Managing the $encryptPassForm
596
			if ($encryptPassForm == '1') {
597
				$encryptPassForm = 'sha1';
598
			} elseif ($encryptPassForm == '0') {
599
				$encryptPassForm = 'none';
600
			}
601

    
602
			$allowSelfReg = get_config_param('allowSelfReg');
603
			$allowSelfRegProf = get_config_param('allowSelfRegProf');
604

    
605
		} else {   //for version 1.8
606
			$urlForm = $_configuration['root_web'];
607
			$encryptPassForm = get_config_param('userPasswordCrypted');
608
			// Managing the $encryptPassForm
609
			if ($encryptPassForm == '1') {
610
				$encryptPassForm = 'sha1';
611
			} elseif ($encryptPassForm == '0') {
612
				$encryptPassForm = 'none';
613
			}
614

    
615
			$allowSelfReg = false;
616
			$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'allow_registration');
617
			if (!empty($tmp)) $allowSelfReg = $tmp;
618

    
619
			$allowSelfRegProf = false;
620
			$tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'allow_registration_as_teacher');
621
			if (!empty($tmp)) $allowSelfRegProf = $tmp;
622
		}
623
	}
624
	display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm);
625

    
626
} elseif (@$_POST['step5']) {
627
	//STEP 6 : LAST CHECK BEFORE INSTALL
628
?>
629
    <div class="RequirementHeading">
630
		<h2><?php echo display_step_sequence().get_lang('LastCheck'); ?></h2>
631
	</div>
632
    <div class="RequirementContent">
633
		<?php echo get_lang('HereAreTheValuesYouEntered'); ?>
634
	</div><br />	
635
    
636
	<blockquote>        
637
    <?php if ($installType == 'new'): ?>
638
	<?php echo get_lang('AdminLogin').' : <strong>'.$loginForm; ?></strong><br />
639
	<?php echo get_lang('AdminPass').' : <strong>'.$passForm; /* TODO: Maybe this password should be hidden too? */ ?></strong><br /><br />
640
	<?php else: ?>	
641
	<?php endif; 
642
    
643
	if (api_is_western_name_order()) {
644
		echo get_lang('AdminFirstName').' : '.$adminFirstName, '<br />', get_lang('AdminLastName').' : '.$adminLastName, '<br />';
645
	} else {
646
		echo get_lang('AdminLastName').' : '.$adminLastName, '<br />', get_lang('AdminFirstName').' : '.$adminFirstName, '<br />';
647
	}
648
	
649
    echo get_lang('AdminEmail').' : '.$emailForm; ?><br />    
650
	<?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br />
651
	<?php echo get_lang('MainLang').' : '.$languageForm; ?><br /><br />
652
	<?php echo get_lang('DBHost').' : '.$dbHostForm; ?><br />
653
	<?php echo get_lang('DBLogin').' : '.$dbUsernameForm; ?><br />
654
	<?php echo get_lang('DBPassword').' : '.str_repeat('*', api_strlen($dbPassForm)); ?><br />
655
	<?php //echo get_lang('DbPrefixForm').' : '.$dbPrefixForm.'<br />'; ?>
656
	<?php echo get_lang('MainDB').' : <strong>'.$dbNameForm; ?></strong>
657
	
658
	<?php
659
	if (!$singleDbForm) {
660
		//Showing this data only in case a user migrates from a 3 main databases (main, user, tracking)
661
		//@todo should be removed
662
		if ($installType == 'update') {
663
			echo '<br />';
664
			echo get_lang('StatDB').' : <strong>'.$dbStatsForm.'</strong>';
665
			if ($installType == 'new') {
666
				echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
667
			}
668
			echo '<br />';
669
			echo get_lang('UserDB').' : <strong>'.$dbUserForm.'</strong>';
670
			if ($installType == 'new') {
671
				echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
672
			}
673
			echo '<br />';
674
		}
675
	}
676
	
677
	//echo get_lang('EnableTracking').' : '.($enableTrackingForm ? get_lang('Yes') : get_lang('No')); ?>
678
	<?php //echo get_lang('SingleDb').' : '.($singleDbForm ? get_lang('One') : get_lang('Several')); ?><br /><br />
679
	<?php echo get_lang('AllowSelfReg').' : '.($allowSelfReg ? get_lang('Yes') : get_lang('No')); ?><br />
680
	<?php echo get_lang('EncryptMethodUserPass').' : ';
681
  	echo $encryptPassForm;
682
	?><br /><br />
683

    
684
	<?php echo get_lang('CampusName').' : '.$campusForm; ?><br />
685
	<?php echo get_lang('InstituteShortName').' : '.$institutionForm; ?><br />
686
	<?php echo get_lang('InstituteURL').' : '.$institutionUrlForm; ?><br />
687
	<?php echo get_lang('ChamiloURL').' : '.$urlForm; ?><br />
688

    
689
	</blockquote>
690

    
691
	<?php if ($installType == 'new'): ?>
692
	<div style="background-color:#FFFFFF">	
693
		<div class="warning-message">
694
		<center>
695
			<h3><?php echo get_lang('Warning'); ?> !</h3>
696
			<?php echo get_lang('TheInstallScriptWillEraseAllTables'); ?>
697
		</center>
698
		</div>	
699
	</div>
700
	<?php endif; ?>
701

    
702
	<table width="100%">
703
	<tr>
704
		<td><button type="submit" class="back" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
705
	  	<td align="right">
706
			<input type="hidden" name="is_executable" id="is_executable" value="-" style="border: none;"/>
707
			<input type="hidden" name="step6" value="1" style="border: none;"/>
708
			<button id="button_step6" class="save" type="submit" name="button_step6" value="<?php echo get_lang('InstallChamilo'); ?>"><?php echo get_lang('InstallChamilo'); ?></button>
709
            <button class="save" id="button_please_wait"></button>`
710
        </td>
711
	</tr>
712
	</table>
713

    
714
<?php
715
} elseif (@$_POST['step6']) {
716
	//STEP 6 : INSTALLATION PROCESS
717
	
718
	if ($installType == 'update') {
719

    
720
		require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
721
		remove_memory_and_time_limits();
722
		database_server_connect();
723
		// Initialization of the database connection encoding intentionaly is not done.
724
		// This is the old style for connecting to the database server, that is implemented here.
725

    
726
		// Inializing global variables that are to be used by the included scripts.
727
		$dblist = Database::get_databases();
728
		$perm = api_get_permissions_for_new_directories();
729
		$perm_file = api_get_permissions_for_new_files();
730

    
731
		if (empty($my_old_version)) { $my_old_version = '1.8.6.2'; } //we guess
732
        
733
		$_configuration['main_database'] = $dbNameForm;
734
		//$urlAppendPath = get_config_param('urlAppend');
735
        Log::notice('Starting migration process from '.$my_old_version.' ('.time().')');
736

    
737
    	if ($userPasswordCrypted == '1') {
738
			$userPasswordCrypted = 'md5';
739
		} elseif ($userPasswordCrypted == '0') {
740
			$userPasswordCrypted = 'none';
741
		}
742
		
743
		Database::query("SET storage_engine = MYISAM;");
744

    
745
		if (version_compare($my_old_version, '1.8.7', '>=')) {
746
			Database::query("SET SESSION character_set_server='utf8';");
747
			Database::query("SET SESSION collation_server='utf8_general_ci';");
748
			//Database::query("SET CHARACTER SET 'utf8';"); // See task #1802.
749
			Database::query("SET NAMES 'utf8';");
750
		}
751

    
752
		switch ($my_old_version) {
753
			case '1.6':
754
			case '1.6.0':
755
			case '1.6.1':
756
			case '1.6.2':
757
			case '1.6.3':
758
			case '1.6.4':
759
			case '1.6.5':
760
				include 'update-db-1.6.x-1.8.0.inc.php';
761
				include 'update-files-1.6.x-1.8.0.inc.php';
762
				//intentionally no break to continue processing
763
			case '1.8':
764
			case '1.8.0':
765
				include 'update-db-1.8.0-1.8.2.inc.php';
766
				//intentionally no break to continue processing
767
			case '1.8.2':
768
				include 'update-db-1.8.2-1.8.3.inc.php';
769
				//intentionally no break to continue processing
770
			case '1.8.3':
771
				include 'update-db-1.8.3-1.8.4.inc.php';
772
				include 'update-files-1.8.3-1.8.4.inc.php';
773
			case '1.8.4':
774
				include 'update-db-1.8.4-1.8.5.inc.php';
775
                include 'update-files-1.8.4-1.8.5.inc.php';
776
			case '1.8.5':
777
				include 'update-db-1.8.5-1.8.6.inc.php';
778
                include 'update-files-1.8.5-1.8.6.inc.php';
779
            case '1.8.6':
780
                include 'update-db-1.8.6-1.8.6.1.inc.php';
781
                include 'update-files-1.8.6-1.8.6.1.inc.php';
782
            case '1.8.6.1':
783
                include 'update-db-1.8.6.1-1.8.6.2.inc.php';
784
                include 'update-files-1.8.6.1-1.8.6.2.inc.php';
785
            case '1.8.6.2':
786
                include 'update-db-1.8.6.2-1.8.7.inc.php';
787
                include 'update-files-1.8.6.2-1.8.7.inc.php';
788
                // After database conversion to UTF-8, new encoding initialization is necessary
789
                // to be used for the next upgrade 1.8.7[.1] -> 1.8.8.
790
                Database::query("SET SESSION character_set_server='utf8';");
791
                Database::query("SET SESSION collation_server='utf8_general_ci';");
792
                //Database::query("SET CHARACTER SET 'utf8';"); // See task #1802.
793
                Database::query("SET NAMES 'utf8';");
794

    
795
            case '1.8.7':
796
            case '1.8.7.1': 
797
                include 'update-db-1.8.7-1.8.8.inc.php';
798
                include 'update-files-1.8.7-1.8.8.inc.php';                                            
799
            case '1.8.8':
800
            case '1.8.8.2':
801
                //Only updates the configuration.inc.php with the new version 
802
                include 'update-configuration.inc.php';
803
			case '1.8.8.4':				
804
				include 'update-db-1.8.8-1.9.0.inc.php';
805
				//include 'update-files-1.8.8-1.9.0.inc.php';
806
				//Only updates the configuration.inc.php with the new version
807
				include 'update-configuration.inc.php';
808
				
809
                break;
810
            default:
811
				break;
812
		}
813
	} else {        
814
		set_file_folder_permissions();
815
		database_server_connect();
816

    
817
		// Initialization of the database encoding to be used.
818
		Database::query("SET storage_engine = MYISAM;");
819
		Database::query("SET SESSION character_set_server='utf8';");
820
		Database::query("SET SESSION collation_server='utf8_general_ci';");
821
		//Database::query("SET CHARACTER SET 'utf8';"); // See task #1802.
822
		Database::query("SET NAMES 'utf8';");
823

    
824
		include 'install_db.inc.php';
825
		include 'install_files.inc.php';
826
	}
827
    $current_step = 7;
828
    display_after_install_message($installType);
829

    
830
} elseif (@$_POST['step1'] || $badUpdatePath) {
831
	//STEP 1 : REQUIREMENTS
832
    //make sure that proposed path is set, shouldn't be necessary but...
833
    if (empty($proposedUpdatePath)) { $proposedUpdatePath = $_POST['updatePath']; }
834
    display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8, $update_from_version_6);
835
} else {
836
	// This is the start screen.
837
    display_language_selection();
838
}
839
?>
840
</form>
841
</div>                  <!-- span-->
842
</div>  <!-- row -->
843

    
844
</div> <!-- main end-->
845
<div class="push"></div>
846
</div><!-- wrapper end-->
847

    
848
<footer></footer>
849
</body>
850
</html>
    (1-1/1)