2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* http://atutor.ca */
\r
8 /* This program is free software. You can redistribute it and/or */
\r
9 /* modify it under the terms of the GNU General Public License */
\r
10 /* as published by the Free Software Foundation. */
\r
11 /************************************************************************/
\r
14 ignore_user_abort(true);
\r
15 @set_time_limit(0);
\r
17 if (!defined('AT_INCLUDE_PATH')) { exit; }
\r
18 require('classes/TableConversion.class.php');
\r
19 $_POST['db_login'] = urldecode($_POST['db_login']);
\r
20 $_POST['db_password'] = urldecode($_POST['db_password']);
\r
23 //check DB & table connection
\r
24 $db = @mysql_connect($_POST['db_host'] . ':' . $_POST['db_port'], $_POST['db_login'], urldecode($_POST['db_password']));
\r
27 $error_no = mysql_errno();
\r
28 if ($error_no == 2005) {
\r
29 $errors[] = 'Unable to connect to database server. Database with hostname '.$_POST['db_host'].' not found.';
\r
31 $errors[] = 'Unable to connect to database server. Wrong username/password combination.';
\r
34 if (!mysql_select_db($_POST['db_name'], $db)) {
\r
35 $errors[] = 'Unable to connect to database <b>'.$_POST['db_name'].'</b>.';
\r
38 $sql = "SELECT VERSION() AS version";
\r
39 $result = mysql_query($sql, $db);
\r
40 $row = mysql_fetch_assoc($result);
\r
41 if (version_compare($row['version'], '4.0.2', '>=') === FALSE) {
\r
42 $errors[] = 'MySQL version '.$row['version'].' was detected. ATutor requires version 4.0.2 or later.';
\r
46 print_progress($step);
\r
49 * Check if version is > 1.6, if so, this entire step can be skipped
\r
50 * OR if db table are already all in utf8.
\r
52 if (version_compare($_POST['step1']['old_version'], '1.6.1', '>') === TRUE ||
\r
53 check_db_default_charset($db) === TRUE) {
\r
54 $progress[] = 'Version <kbd><b>'.$_POST['step1']['old_version'].'</b></kbd> found.';
\r
55 $progress[] = 'UTF-8 Conversion is not needed, skipping.';
\r
56 print_feedback($progress);
\r
57 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
58 <input type="hidden" name="step" value="4" />';
\r
60 echo '<p align="center"><input type="submit" class="button" value=" Next »" name="submit" /></p></form>';
\r
64 unset($_POST['submit']);
\r
65 if (isset($progress)) {
\r
66 print_feedback($progress);
\r
69 $progress[] = 'Connected to database <b>'.$_POST['db_name'].'</b> successfully.';
\r
72 //If this is a Retry on step3 failure, load step2 post values back to jump right back to where it left off.
\r
73 if (isset($_POST['step2'])){
\r
75 $_POST = $_POST['step2'];
\r
76 $_POST['step1'] = $temp['step1'];
\r
79 //Conversion type set
\r
80 if ($_POST['con_step']=='2'){
\r
81 //Get list of unqiue encoding; skip utf8
\r
82 $char_encodings = array();
\r
83 foreach($_SESSION['course_info'] AS $course_id=>$temp){
\r
84 if (strtolower($temp['char_set'])!='utf-8' && strtolower($temp['char_set'])!='utf8'
\r
85 && !in_array($temp['char_set'], $char_encodings)){
\r
86 $char_encodings[] = $temp['char_set'];
\r
89 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
90 <input type="hidden" name="step" value="3" />';
\r
94 * If we are converting the entire database, then all we need is just 1 language encoding;
\r
95 * if we are converting each class individually, then we need to output all the classes and allow language
\r
96 * options to choose from
\r
98 $convert_type = $_POST['convert_type'];
\r
99 $recommanded_conversion = $_POST['recommanded_conversion'];
\r
100 $confirm_con_step = $_POST['confirm_con_step'];
\r
101 //check if the user-selected convert_type is the same as the recommanded conversion type, if not, give a warning msg
\r
102 if ($convert_type!=$recommanded_conversion && $confirm_con_step==""){
\r
103 //The html fragment that sets the suggested conversion type on bold
\r
104 $suggestion = array('class="suggested"', 'checked="checked"');
\r
105 $suggestion_skip="";
\r
106 $suggestion_all="";
\r
107 $suggestion_courses="";
\r
108 echo '<div><p>You have selected a different conversion option from the recommanded one. Please verify your option and click "Yes, please continue." to continue.</p><p>Please be aware that invalid conversion may lose your data.</p></div>';
\r
109 generateCourseLangTable($_POST['tb_prefix'], $_SESSION['course_info']);
\r
110 //Print the selected options from the previous user option.
\r
111 switch($convert_type){
\r
113 $suggestion_all[1] =& $suggestion[1] ;
\r
116 $suggestion_skip[1] =& $suggestion[1];
\r
119 $suggestion_courses[1] =& $suggestion[1];
\r
122 switch($recommanded_conversion){
\r
124 $suggestion_all[0] =& $suggestion[0] ;
\r
127 $suggestion_skip[0] =& $suggestion[0];
\r
130 $suggestion_courses[0] =& $suggestion[0];
\r
135 echo '<div '.$suggestion_all[0].'><input type="radio" id="convert_all" name="convert_type" value="all" '.$suggestion_all[1].'/>';
\r
136 echo '<label for="convert_all">Convert all content</label></div>';
\r
138 echo '<div '.$suggestion_courses[0].'><input type="radio" id="convert_courses" name="convert_type" value="courses" '.$suggestion_courses[1].'/>';
\r
139 echo '<label for="convert_courses">Convert content by courses</label></div>';
\r
141 echo '<div '.$suggestion_skip[0].'><input type="radio" id="convert_skip" name="convert_type" value="skip" '.$suggestion_skip[1].'/>';
\r
142 echo '<label for="convert_skip">Skip conversion</label></div>';
\r
144 print_post_for_step9($_POST);
\r
145 echo '<input type="hidden" name="step" value="3" />';
\r
146 echo '<input type="hidden" name="con_step" value="2" />';
\r
147 echo '<input type="hidden" name="confirm_con_step" value="true" />';
\r
148 echo '<p align="center"><input type="submit" class="button" value=" Yes, please continue. " name="submit" /></p></form>';
\r
152 if ($convert_type=='all'){
\r
153 echo "<div><p>You have chosen the <strong>Convert all content</strong> option. All ATutor's content will be converted to UTF-8 from the encoding listed below.</p></div>";
\r
154 echo "<div><p>Note: This might take up to several minutes, please be patient while you wait.</p></div><br/>";
\r
155 echo "<div><label>Convert From: </label><select name='encoding_code'>";
\r
157 foreach ($char_encodings as $index=>$encoding){
\r
159 if ($encoding==$_POST['conv_all_char_set']){
\r
160 $selected = 'selected="selected" ';
\r
162 echo "<option value='$encoding' $selected>$encoding</option>";
\r
164 echo "</select></div>";
\r
165 } elseif ($convert_type=='courses'){
\r
166 echo "<div><p>You have chosen the conversion by course. Each of the following courses' content will be converted to UTF-8 with respect to its Course Primary Language. </p></div>";
\r
167 echo '<div><p>Notes:</p><ul>';
\r
168 echo '<li class="important">Please backup your ATutor database before clicking next.</li>';
\r
169 echo '<li>This conversion will convert only course related tables, other tables will be converted from the ATutor default (ISO-8859-1) to UTF-8.</li>';
\r
170 echo '<li>If the "Course Primary Language" listed below is not the language that you wish to convert from, please change the "Course Primary Language" under "Course Properties" to the language you want to convert from.</li>';
\r
171 echo '</ul></div>';
\r
172 generateCourseLangTable($_POST['tb_prefix'], $_SESSION['course_info']);
\r
173 } elseif ($convert_type=='skip'){
\r
174 //When 'skip' has been chosen, check if version# < 1.6, if so, convert database structure(not content); o/w skip to next step.
\r
175 if (version_compare($_POST['step1']['old_version'], '1.6', '<') === TRUE) {
\r
177 $progress[] = "Will not be converting database content.";
\r
178 $progress[] = "Will be converting database table column structure (charset, collation) to UTF-8.";
\r
179 print_feedback($progress);
\r
180 print_post_for_step9($_POST);
\r
181 echo '<input type="hidden" name="step" value="3" />';
\r
182 echo '<input type="hidden" name="con_step" value="3" />';
\r
183 echo '<p align="center"><input type="submit" class="button" value=" Next »" name="submit" /></p></form>';
\r
185 } elseif (version_compare($_POST['step1']['old_version'], '1.6.1', '<') === TRUE) {
\r
186 //Check if version#=1.6 if so, then this 1.6 database must already been upgraded before.
\r
187 //change all table to utf-8.
\r
188 $conversionDriver = new ConversionDriver($_POST['tb_prefix']);
\r
189 $conversionDriver->alter_all_charset();
\r
191 $progress[] = "All tables' charset are now in UTF-8.";
\r
192 print_feedback($progress);
\r
193 print_post_for_step9($_POST);
\r
194 echo '<input type="hidden" name="step" value="3" />';
\r
195 echo '<input type="hidden" name="con_step" value="4" />';
\r
196 echo '<p align="center"><input type="submit" class="button" value=" Next »" name="submit" /></p></form>';
\r
199 echo "<div><p>Skipping UTF-8 Conversion.</p><p>No content will be converted.</p></div>";
\r
200 echo '<input type="hidden" name="step" value="4" />'; //skip to next step
\r
201 echo '<p align="center"><input type="submit" class="button" value=" Next »" name="submit" /></p></form>';
\r
204 $errors[] = "No conversion type selected.";
\r
205 print_errors($errors);
\r
206 print_post_for_step9($_POST);
\r
207 echo '<input type="hidden" name="step" value="3" />';
\r
208 echo '<p align="center"><input type="submit" class="button" value=" Retry »" name="submit" /></p></form>';
\r
211 print_post_for_step9($_POST);
\r
212 echo '<input type="hidden" name="convert_type" value="'.$convert_type.'"/>';
\r
213 echo '<input type="hidden" name="con_step" value="3" />';
\r
214 echo '<p align="center"><input type="submit" class="button" value=" Next »" name="submit" /></p></form>';
\r
216 } elseif ($_POST['con_step'] == '3'){
\r
217 //Check if this is a refresh request, if so, don't convert the db.
\r
218 if (isset($_SESSION['conversion_completed']) && $_SESSION['conversion_completed']==true){
\r
219 $progress[] ='Database has already been converted, click next to continue.';
\r
220 print_feedback($progress);
\r
221 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
222 <input type="hidden" name="step" value="3" />
\r
223 <input type="hidden" name="con_step" value="4" />
\r
224 <input type="hidden" name="upgrade_action" value="true" />';
\r
226 print_post_for_step9($_POST);
\r
227 echo '<p align="center"><input type="submit" class="button" value=" Next » " name="submit" /></p></form>';
\r
232 // Get course code to map encoding/charset
\r
233 if ($_POST['convert_type'] == 'all' || $_POST['convert_type'] == 'courses' ){
\r
234 $query = "SELECT course_id, title FROM ".$_POST['tb_prefix']."courses";
\r
235 $result = mysql_query($query);
\r
236 if (mysql_num_rows($result) <= 0){
\r
240 //'Skip' was selected, convert table structure only
\r
241 queryFromFile('db/atutor_convert_db_to_utf8.sql');
\r
242 $progress[] = 'Database table structure has been converted to UTF-8.';
\r
243 print_feedback($progress);
\r
244 if (isset($errors)){
\r
245 print_errors($errors);
\r
246 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
247 <input type="hidden" name="step" value="3" />';
\r
249 print_post_for_step9($_POST);
\r
250 echo '<p align="center"><input type="submit" class="button" value=" Retry " name="submit" /></p></form>';
\r
253 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
254 <input type="hidden" name="step" value="3" />';
\r
255 echo '<input type="hidden" name="con_step" value="4" />';
\r
257 print_post_for_step9($_POST);
\r
258 echo '<p align="center"><input type="submit" class="button" value=" Next » " name="submit" /></p></form>';
\r
263 * redo_conversion SESSION variable keep tracks of the table that failed conversion.
\r
264 * If it is set, then run only those tables inside the redo_conversion SESSION variable.
\r
266 if (isset($_SESSION['redo_conversion'])){
\r
268 foreach($_SESSION['redo_conversion'] as $course_title=>$class_obj){
\r
269 foreach($class_obj as $class_name=>$class_param){
\r
270 $temp_table = new $class_name ($class_param[0], $class_param[1], $class_param[2], $class_param[3]);
\r
271 if (!$temp_table->convert()){
\r
272 $errors[]= $course_title.': '.$class_param[0].$class_param[1].' was not converted.';
\r
274 unset($_SESSION['redo_conversion'][$class_name]);
\r
275 $progress[] = "$class_param[1] has now been converted.";
\r
281 * Convert course independent materials such as user information, categories
\r
282 * Decide which language to use
\r
284 $conversionDriver = new ConversionDriver($_POST['tb_prefix']);
\r
285 if (version_compare($_POST['step1']['old_version'], '1.6', '<') === TRUE) {
\r
286 $conversionDriver->convertTableBySysDefault();
\r
288 $conversionDriver->convertTableBySysDefault_161();
\r
291 * Loop through all the courses, and convert all the course's content
\r
292 * Flush out the process in the mean time.
\r
294 echo '<div style="padding-left:1em; margin-top: 0.5em; margin-left:1em; overflow:auto; height:100px; border:1px solid #30b626;;">';
\r
295 while ($row = mysql_fetch_assoc($result)){
\r
296 $course_id = $row['course_id'];
\r
298 if (isset($_POST['encoding_code'])&& $_POST['encoding_code']!=""){
\r
299 $char_set = $_POST['encoding_code'];
\r
301 $char_set = $_SESSION['course_info'][$course_id]['char_set'];
\r
303 $row['title'] = mb_convert_encoding($row['title'], "UTF-8", $char_set);
\r
305 //If this is already in UTF-8, skip conversion
\r
306 if (strtolower($char_set)=="utf-8" || strtolower($char_set)=="utf8"){
\r
307 $progress[] = 'Course ('.$row['title'].') <strong>has been skipped</strong>, course\'s content are already in UTF-8.';
\r
310 $progress[] = 'Course ('.$row['title'].') <strong>has been converted</strong> from '.$char_set;
\r
312 //Run through all ATutor table and convert only those rows with the above courses.
\r
313 //todo: implement a driver class inside the TableConversion class.
\r
315 echo "Converting $row[title]...<br/>";
\r
319 if (version_compare($_POST['step1']['old_version'], '1.6', '<') === TRUE) {
\r
320 $conversionDriver->convertTableByClass($row['title'], $char_set, $course_id);
\r
322 $conversionDriver->convertTableByClass_161($row['title'], $char_set, $course_id);
\r
326 //Check if there are any errors, if not, jump to next step
\r
328 unset($_POST['submit']);
\r
330 //Will not allow refresh on this screen, because it will re-convert the database.
\r
331 $_SESSION['conversion_completed'] = true;
\r
333 print_feedback($progress);
\r
335 if (isset($errors)){
\r
336 print_errors($errors);
\r
337 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
338 <input type="hidden" name="step" value="3" />
\r
339 <input type="hidden" name="con_step" value="4" />';
\r
341 print_post_for_step9($_POST);
\r
342 echo '<p align="center"><input type="submit" class="button" value=" Retry " name="submit" /></p></form>';
\r
346 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
347 <input type="hidden" name="step" value="3" />
\r
348 <input type="hidden" name="con_step" value="4" />
\r
349 <input type="hidden" name="upgrade_action" value="true" />';
\r
351 print_post_for_step9($_POST);
\r
352 echo '<p align="center"><input type="submit" class="button" value=" Next » " name="submit" /></p></form>';
\r
355 } elseif ($_POST['con_step'] == '4'){
\r
356 //Convert the database charset to UTF8.
\r
357 if (!check_db_default_charset($db)){
\r
358 $sql = 'ALTER DATABASE `'.$_POST['db_name'].'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci';
\r
359 if (mysql_query($sql)===false){
\r
360 //Alter failed, probably the user doesn't have permission.
\r
361 $errors[] = 'Failed to change the database default character set to UTF-8. Please set the database character set to UTF8 before continuing by using the following query: ALTER DATABASE `'.$_POST['db_name'].'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci. To use ALTER DATABASE, you need the ALTER privilege on the database.';
\r
364 $progress[] ='Database default charset is now in UTF-8, click next to continue.';
\r
365 print_feedback($progress);
\r
366 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
367 <input type="hidden" name="step" value="4" />';
\r
369 print_post_for_step9($_POST);
\r
370 echo '<p align="center"><input type="submit" class="button" value=" Next » " name="submit" /></p></form>';
\r
373 /* If the installation has been stopped right after the conversion step. The session variable
\r
374 * that prevents refreshes will still be set, have to unset it to carry on the installation.
\r
376 if (isset($_SESSION['conversion_completed'])){
\r
377 unset($_SESSION['conversion_completed']);
\r
380 $html = '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
381 <input type="hidden" name="step" value="3" />';
\r
384 $html .= '<div><p>ATutor 2.0 upgrade requires you to convert ATutor content to UTF-8 if you are upgrading from a version earlier than ATutor 1.6. The courses are listed below with their associated primary language. </p><p>Please choose one of the conversion options listed below, the recommanded option(in blue) is already selected for you.</p><p>For a more detailed description for each of these conversions, please visit our <a href="http://wiki.atutor.ca/display/atutorwiki/UTF-8+Conversion" target="blank">ATutor Wiki page</a></p></div>';
\r
386 //The html fragment that sets the suggested conversion type on bold
\r
387 $suggestion = array('class="suggested"', 'checked="checked"');
\r
388 $suggestion_skip="";
\r
389 $suggestion_all="";
\r
390 $suggestion_courses="";
\r
391 $recommanded_conversion = "";
\r
393 $html .= '<table class="data">';
\r
394 $html .= '<tr><th>Course Title</th><th>Course Primary Language</th></tr>';
\r
396 //Get all courses and their associated language from $_POST
\r
397 $prev_language = ""; //Keep tracks of the course primary language in each loop.
\r
398 $is_same_language = true;
\r
399 if (isset($_SESSION['course_info'])){
\r
400 foreach ($_SESSION['course_info'] as $course_id=>$row){
\r
401 if ($prev_language==""){
\r
402 $prev_language = $row['char_set'];
\r
403 } elseif ($is_same_language==true) {
\r
404 if($prev_language != $row['char_set']){
\r
405 $is_same_language &= false;
\r
409 $query = 'SELECT title, primary_language FROM '.$_POST['tb_prefix'].'courses WHERE course_id='.$course_id;
\r
410 $result = mysql_query($query);
\r
411 if ($result && mysql_numrows($result) > 0){
\r
412 $rs_row = mysql_fetch_assoc($result);
\r
413 //if the char_set of the course is not defined, the array will be emptied.
\r
414 $html .= '<tr><td>';
\r
415 $html .= @mb_convert_encoding($rs_row['title'], "UTF-8", $row['char_set']);
\r
416 $html .= '</td><td>'.$row['char_set'];
\r
417 if ($row['char_set']==''){
\r
418 $errors[] = "<strong>$rs_row[title]</strong> has a primary language that does not appear to be installed on the system. Before continuing, either set the primary language to one that is installed, or install the missing language pack.";
\r
419 $html .= ' <strong style="color:red;">Missing "'.$rs_row['primary_language'].'"</strong>';
\r
421 $html .= '</td></tr>';
\r
425 if ($is_same_language == true){
\r
426 if (strtolower($prev_language)=="utf8" || strtolower($prev_language)=="utf-8" ){
\r
427 $suggestion_skip =& $suggestion;
\r
428 $recommanded_conversion = "skip";
\r
430 $suggestion_all =& $suggestion;
\r
431 $recommanded_conversion = "all";
\r
432 $html .= '<input type="hidden" name="conv_all_char_set" value="'.$prev_language.'" />';
\r
435 $suggestion_courses =& $suggestion;
\r
436 $recommanded_conversion = "courses";
\r
438 $html .= '</table><br/>';
\r
440 $html .= '<div><p><strong>Convert all content:</strong> Use this option if you are using just <i><u>one</u></i> non-UTF-8 language pack in your ATutor.</p>';
\r
441 $html .= '<p><strong>Convert content by courses:</strong> Use this option when you are using <i><u>more than one</u></i> UTF-8 or non-UTF-8 language pack in your ATutor.</p>';
\r
442 $html .= '<p><strong>Skip conversion:</strong> Use this option when you have <i><u>only UTF-8</u></i> language packs in your ATutor.</p>';
\r
445 $html .= '<div '.$suggestion_all[0].'><input type="radio" id="convert_all" name="convert_type" value="all" '.$suggestion_all[1].'/>';
\r
446 $html .= '<label for="convert_all">Convert all content</label></div>';
\r
448 $html .= '<div '.$suggestion_courses[0].'><input type="radio" id="convert_courses" name="convert_type" value="courses" '.$suggestion_courses[1].'/>';
\r
449 $html .= '<label for="convert_courses">Convert content by courses</label></div>';
\r
451 $html .= '<div '.$suggestion_skip[0].'><input type="radio" id="convert_skip" name="convert_type" value="skip" '.$suggestion_skip[1].'/>';
\r
452 $html .= '<label for="convert_skip">Skip conversion</label></div>';
\r
454 //States flags for ustep9
\r
455 $html .= '<input type="hidden" name="con_step" value="2" />';
\r
456 $html .= '<input type="hidden" name="recommanded_conversion" value="'.$recommanded_conversion.'" />';
\r
457 if (isset($errors)){
\r
458 print_errors($errors);
\r
459 $html .= '<p align="center"><input type="submit" class="button" value=" Retry " name="submit" /></p>';
\r
461 $html .= '<p align="center"><input type="submit" class="button" value=" Next »" name="submit" /></p>';
\r
465 print_post_for_step9($_POST);
\r
473 if (isset($errors)) {
\r
474 print_errors($errors);
\r
477 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
\r
478 <input type="hidden" name="step" value="3" />';
\r
481 print_post_for_step9($_POST);
\r
482 echo '<p align="center"><input type="submit" class="button" value=" Retry " name="submit" /></p></form>';
\r
486 /** ---------------------------------------------------------------------------
\r
487 * Functions declaraion
\r
488 * ---------------------------------------------------------------------------
\r
491 * Runs through the database and get all the courses' titles and languages out
\r
492 * @param table_prefix is the database table prefix
\r
493 * @course_info is the array that stores the course_id->[charset, encoding] mapping.
\r
495 function generateCourseLangTable($table_prefix, $course_info){
\r
496 echo '<table class="data">';
\r
497 echo '<tr><th>Course Title</th><th>Course Primary Language</th></tr>';
\r
498 //Get all courses and their associated languages out
\r
499 foreach ($course_info AS $course_id=>$row){
\r
500 $query = 'SELECT title FROM '.$table_prefix.'courses WHERE course_id='.$course_id;
\r
501 $result = mysql_query($query);
\r
502 if ($result && mysql_numrows($result) > 0){
\r
503 $rs_row = mysql_fetch_assoc($result);
\r
508 if ($row['char_set']==''){
\r
509 echo $rs_row['title'];
\r
510 echo '</td><td>Undefined</td></tr>';
\r
512 echo mb_convert_encoding($rs_row['title'], "UTF-8", $row['char_set']);
\r
513 echo '</td><td>'.$row['char_set'].'</td></tr>';
\r
520 * This function prints out the post values that need to be carried over along
\r
521 * the entire step 9.
\r
522 * @param $_post the post parameter
\r
524 function print_post_for_step9($_POST){
\r
525 echo '<input type="hidden" name="db_login" value="'.urlencode($_POST['db_login']).'" />';
\r
526 echo '<input type="hidden" name="db_password" value="'.urlencode($_POST['db_password']).'" />';
\r
527 echo '<input type="hidden" name="db_host" value="'.$_POST['db_host'].'" />';
\r
528 echo '<input type="hidden" name="db_name" value="'.$_POST['db_name'].'" />';
\r
529 echo '<input type="hidden" name="db_port" value="'.$_POST['db_port'].'" />';
\r
530 echo '<input type="hidden" name="tb_prefix" value="'.$_POST['tb_prefix'].'" />';
\r
531 echo '<input type="hidden" name="old_version" value="'.$_POST['old_version'].'" />';
\r
532 echo '<input type="hidden" name="new_version" value="'.$_POST['new_version'].'" />';
\r
537 * This function checks if the database's and tbale's default charset are UTF-8.
\r
538 * @return true if db default charset is UTF-8, false otherwise.
\r
540 function check_db_default_charset($db){
\r
541 //Check database's default charset
\r
542 $sql = "SHOW CREATE DATABASE `$_POST[db_name]`";
\r
543 $result = mysql_query($sql, $db);
\r
544 $row = mysql_fetch_assoc($result);
\r
546 if (!preg_match('/CHARACTER SET utf8/i', $row['Create Database'])){
\r
551 $sql = "SHOW TABLES";
\r
552 $result = mysql_query($sql, $db);
\r
553 while ($row = mysql_fetch_row($result)){
\r
555 $sql2 = "SHOW CREATE TABLE `$row[0]`";
\r
556 $result2 = mysql_query($sql2, $db);
\r
557 $row2 = mysql_fetch_row($result);
\r
559 if (!preg_match('/DEFAULT CHARSET\=utf8/i', $row[1])){
\r