Migration of 2.0 to 2.1
  Welcome
 



This wizard will perform the migration of version 2.0 to 2.1 .

Before you continue , please make sure you have made a backup of you MYSQL database.
This can be done with PHPMYADMIN or via backup tool from S@S.
 

  Step 1
Database migration.
 


Tables will be altered during the next step..
Click on continue.
 

  Step 2
 

" ; include("../configuration/database.inc.php"); mysql_connect("$db_server", "$db_username", "$db_password"); mysql_select_db("$db_name"); mysql_query("ALTER TABLE $table_pages add history varchar(20)"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } $table_prot_pages = $dbprefix."prot_pages" ; mysql_query("ALTER TABLE $table_prot_pages add history varchar(20)"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } //insert new configuration item $RecordCount = 0 ; $query = "SELECT config_value FROM $table_configuration where config_key='number_pupilpages'" ; $result = mysql_query($query) or die_script(mysql_error()); $RecordCount = mysql_num_rows($result); if($RecordCount == 1) { Print "number_pupilpages already exists in configuration,
" ; } else { mysql_query("INSERT INTO $table_configuration VALUES ('number_pupilpages', '3', '')"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } } $RecordCount = 0 ; $query = "SELECT config_value FROM $table_configuration where config_key='user_path'" ; $result = mysql_query($query) or die_script(mysql_error()); $RecordCount = mysql_num_rows($result); if($RecordCount == 1) { Print "user_path already exists in configuration,
" ; } else { mysql_query("INSERT INTO $table_configuration VALUES ('user_path', '', '')"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } } //migrate news tables $modtable_news_categories = "$dbprefix" . "m_news_cat"; mysql_query("ALTER TABLE $modtable_news_categories ADD ispage tinyint(4) NOT NULL;"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } mysql_query("ALTER TABLE $modtable_news_categories ADD header text NOT NULL;"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } mysql_query("UPDATE $modtable_news_categories SET ispage = 0 WHERE id > 0;"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } mysql_query("UPDATE $table_modules SET options = 'frontpage.php,News Page,frontpage_cat.php,Category per page,archive.php,Archive,archive_prot.php,Protected Archive' WHERE location = 'sn_news';"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } // migrate all users to one table mysql_query("alter table $table_users add type tinyint(4)"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } mysql_query("alter table $table_users add class int(11)"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } mysql_query("UPDATE $table_users set type = 20 WHERE type IS NULL or type = 0"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } $result = mysql_query("SELECT MAX(id) FROM $table_students "); $max_id = mysql_result($result,0) + 10 ; unset($query); unset($result); //print $max_id; $result = mysql_query("UPDATE $table_users SET ID=ID+$max_id"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } $result = mysql_query("SELECT id, username, fullname, password, email, class FROM $table_students "); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "
"; } print "
Migrating Pupils

" ; mysql_query("ALTER TABLE $table_studentpages ADD change_date DATE NOT NULL"); while ($student_list = mysql_fetch_array($result)) { $RecordCount = 0 ; $query2 = "SELECT username FROM $table_users WHERE username='$student_list[1]'" ; $result2 = mysql_query($query2) or die_script(mysql_error()); $RecordCount = mysql_num_rows($result2); if($RecordCount > 0) { Print "Pupil already exists with Userid: ".$student_list[1]. " Fulname: ".$student_list[2]. " Password: ".$student_list[3]. " Email: ".$student_list[4]. " Class: ".$student_list[5]. " .
" ; mysql_query("UPDATE $table_users set class = '$student_list[5]' WHERE username='$student_list[1]'"); //set the class mysql_query("UPDATE $table_users set type = '21' WHERE username='$student_list[1]'"); //set the type to 21 if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } } else { mysql_query("INSERT INTO $table_users (id, username, name , password, email, class, type, access, highvisibility) VALUES ('$student_list[0]', '$student_list[1]', '$student_list[2]', '$student_list[3]', '$student_list[4]', '$student_list[5]' , '1', '000000000000,000000000000', '0')"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } } } print "
Migrating Teachers

" ; $result = mysql_query("SELECT id, username, fullname, password, email, class FROM $table_teachers "); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } while ($teacher_list = mysql_fetch_array($result)) { $RecordCount = 0 ; $query2 = "SELECT username, type FROM $table_users WHERE username='$teacher_list[1]'" ; $result2 = mysql_query($query2) or die_script(mysql_error()); $RecordCount = mysql_num_rows($result2); if($RecordCount > 0) { Print "Teacher already exists with Userid: ".$teacher_list[1]. " Fullname: ".$teacher_list[2]. " Password: ".$teacher_list[3]. " Email: ".$teacher_list[4]. " Class: ".$teacher_list[5]. " .
" ; mysql_query("UPDATE $table_users set class = '$teacher_list[5]' WHERE username='$teacher_list[1]'"); //set the class mysql_query("UPDATE $table_users set type = '22' WHERE username='$teacher_list[1]'"); //set the type to 22 } else { mysql_query("INSERT INTO $table_users (id, username, name , password, email, class, type, access, highvisibility) VALUES (NULL , '$teacher_list[1]', '$teacher_list[2]', '$teacher_list[3]', '$teacher_list[4]', '$teacher_list[5]' , '2', '000000000000,000000000000', '0')"); if (mysql_errno() != 0) { echo mysql_errno() . ": " . mysql_error(). "\n"; } } } print "
If there are duplicate userids reported , best is to print this page for reference.

Migration is finished!
This means that teachers, pupils and users are now in one table (users) in mysql.
If you wish you can delete the teacher and students table in mysql.

Migration is finished for version 2.1
You can now continue normal operation on your site." ; ?>

The S@S team.