Migration of 2.3 to 2.4.03
  Welcome
 



This wizard will perform the migration of version 2.3 to 2.4.03 .

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

  Step 1
Database migration.
 


Changes will be made to the tables 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"); unset($sas_config) ; //clear the config array first $query = "SELECT config_key,config_value FROM $table_configuration WHERE config_key NOT LIKE 'agenda_t%'"; //read all the configuration items except agenda options. $result = mysql_query($query) or die(mysql_error()); while ($config_list = mysql_fetch_array($result)) { $sas_config[$config_list[0]] = $config_list[1] ; //put them in the config array } //get the sas version $sas_version = $sas_config['sas_version'].$sas_config['sas_patch_version'] ; if(isset($sas_version)) { print "Current Site@School version: " .$sas_version."

" ; } switch ($sas_version) // start of switch { case "2.400": //level is ok , quit here mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); $step1 = 0 ; $step2 = 0 ; $step3 = 0 ; break; case "2.401": //level is ok , quit here mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); $step1 = 0 ; $step2 = 0 ; $step3 = 0 ; break; case "2.402": //level is ok , quit here mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); $step1 = 0 ; $step2 = 0 ; $step3 = 0 ; break; case "2.403": //level is ok , quit here print "Your Site@School version is already up to the right level!.
"; $step1 = 0 ; $step2 = 0 ; $step3 = 0 ; break; case "2.400f": //level is ok , quit here mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); $step1 = 0 ; $step2 = 0 ; $step3 = 0 ; break; case "2.400e": //level is ok , quit here mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); $step1 = 0 ; $step2 = 0 ; $step3 = 0 ; break; case "2.400d": //level is ok , just alter the patch version mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); $step1 = 0 ; $step2 = 0 ; $step3 = 0 ; break; case "2.400c": //only do step3 //set new patch version mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); $step1 = 0 ; $step2 = 0 ; $step3 = 1 ; break; case "2.400b": //only do download module (step2) $step1 = 0 ; $step2 = 1 ; $step3 = 1 ; //set new patch version mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); break; case "2.400a": //only do download module (step2) $step1 = 0 ; $step2 = 1 ; $step3 = 1 ; //set new patch version mysql_query("UPDATE $table_configuration SET config_value = '03' WHERE config_key = 'sas_patch_version'"); break; default: //sas version 2.3 I assume. $step1 = 1 ; $step2 = 1 ; $step3 = 1 ; mysql_query("INSERT INTO $table_configuration VALUES ('sas_version', '2.4', 'Sas main version')"); mysql_query("INSERT INTO $table_configuration VALUES ('sas_patch_version', '03', 'Sas patch version')"); break; } if($step1 == 1) { //configuration table, search module fix mysql_query("UPDATE $table_configuration SET config_value = 'studentid,title,content' WHERE config_key = 'search_module_returnfield3' "); //users table mysql_query("ALTER TABLE $table_users MODIFY class varchar(80)"); mysql_query("ALTER TABLE $table_users MODIFY project varchar(80)"); mysql_query("ALTER TABLE $table_users ADD initial tinyint(1) default 0") ; // pupilpages module mysql_query("ALTER TABLE $table_studentpages ADD sort tinyint(4) not null default 0"); mysql_query("ALTER TABLE $table_studentpages ADD invisible tinyint(1) not null default 0"); print "Pupilpages table has been altered.

"; //downloads $table_downloads = $dbprefix ."m_downloads"; mysql_query("ALTER TABLE $table_downloads ADD counter tinyint(11) default 0"); print "Downloads table has been altered.

"; //newsletter $table_newsletters = $dbprefix ."m_newsletter_cat"; mysql_query("ALTER TABLE $table_newsletters MODIFY title text"); mysql_query("ALTER TABLE $table_newsletters ADD template text default null"); print "Newsletter table has been altered.

"; //stats $table_stats = $dbprefix."stats" ; //check if the public field already exists $result = mysql_query("SHOW COLUMNS FROM $table_stats LIKE 'public'"); if (!$result) { echo 'Could not run query: ' . mysql_error(); } if (mysql_num_rows($result) == 0) { mysql_query("ALTER TABLE $table_stats ADD public tinyint(4)"); mysql_query("UPDATE TABLE $table_stats SET public=0 WHERE id > 0"); print "Table alterations for the stats has been done!

"; } //gbook $modtable_guestbook = "$dbprefix" . "m_gbook"; mysql_query("ALTER TABLE $modtable_guestbook add initial tinyint(1) default 1"); mysql_query("INSERT INTO $table_configuration VALUES('gbook_check_before_post' , '0' , '')") ; //ads $modtable_ads = "$dbprefix" . "adtext"; mysql_query("ALTER TABLE $modtable_ads add initial tinyint(1) default 1"); mysql_query("INSERT INTO $table_configuration VALUES('ads_check_before_post' , '0' , '')") ; //downloads mysql_query("INSERT INTO $table_configuration VALUES('download_welcome_text_prot' , 'Welcome text protected area' , '')") ; //message $message_table = $dbprefix . "m_message"; mysql_query("CREATE TABLE $message_table ( id int(11) NOT NULL auto_increment, message text NOT NULL, date datetime default NULL, name varchar(45) default NULL, days int(11) default 0, todate date, PRIMARY KEY (id))"); $result = mysql_query("SELECT id FROM $table_modules WHERE location = 'sn_message'"); $RecordCount = mysql_num_rows($result); if($RecordCount == 0) { mysql_query("INSERT INTO $table_modules VALUES (NULL, 'Messages', 'sn_message', 'message.php,Add messages,view_message.php,View messages', 'admin.php', '')"); mysql_query("INSERT INTO $table_configuration VALUES ('message_add_text', 'Add a Message


', '')"); mysql_query("INSERT INTO $table_configuration VALUES ('message_view_text', 'View messages
', '')"); } //links $links_table = $dbprefix . "m_links"; $links_cat_table = $dbprefix . "m_links_cat"; mysql_query("CREATE TABLE $links_table ( id int(11) NOT NULL auto_increment, title varchar(50) NOT NULL default '', url varchar(100) NOT NULL default '', description text NOT NULL, pagename int(11) NOT NULL default '0', initial tinyint(1) NOT NULL default '1', sort tinyint(4) NOT NULL default '0', category varchar(30) NOT NULL default '', PRIMARY KEY (id))"); mysql_query("CREATE TABLE $links_cat_table ( id int(11) NOT NULL auto_increment, pagename varchar(50) NOT NULL default '', owner_email varchar(80) NOT NULL default '', row_count tinyint(4) NOT NULL default '0', welcome text NOT NULL, icon varchar(50) NOT NULL default '', propose tinyint(1) NOT NULL default '0', propose_welcome text, showlink tinyint(1) NOT NULL default '0', PRIMARY KEY (id))"); $result = mysql_query("SELECT id FROM $table_modules WHERE location = 'sn_links'"); $RecordCount = mysql_num_rows($result); if($RecordCount == 0) { mysql_query("INSERT INTO $table_modules VALUES (NULL, 'Links', 'sn_links', 'view_links.php,Show Links on page', 'admin.php', '')"); mysql_query("INSERT INTO $table_configuration VALUES ('links_module_row_count', '1', '')"); mysql_query("INSERT INTO $table_configuration VALUES ('links_module_icon', '/starnet/modules/sn_links/link.gif', '')"); } //encryption and file permissions mysql_query("INSERT INTO $table_configuration VALUES ('use_encryption', '0', 'Use encryption?')"); mysql_query("INSERT INTO $table_configuration VALUES ('file_permissions', '0777', 'File permissions for upload')"); //template editor $table_template = $dbprefix . "m_template"; mysql_query("UPDATE TABLE $table_template SET type8 = 's', name8 = 'Border size in px' WHERE script = 'content1.php'"); //FCK editor $result = mysql_query("SELECT id FROM $table_editors WHERE location = 'fckeditor/editor.php'"); $RecordCount = mysql_num_rows($result); if($RecordCount == 0) { mysql_query("INSERT INTO $table_editors VALUES (NULL, 'FCK editor', 'fckeditor/editor.php', '')"); } } if($step2 == 1 ) { //downloads module coversion $downloads_categorytable = $dbprefix."m_downloads_cat"; $downloads_table = $dbprefix."m_downloads"; $query = "SELECT * FROM $downloads_table LIMIT 1"; $result = mysql_query($query) ; if(mysql_field_name($result, 6) == "bin_data") //we have bin_data field , do the conversion { mysql_query("ALTER TABLE $downloads_table ADD stored_file VARCHAR(40)"); mysql_query("UPDATE $downloads_table SET stored_file = md5(filename) WHERE id > 0"); $query = "SELECT id, title, public FROM $downloads_categorytable"; $result = mysql_query($query) ; if (!$result) { die('Invalid query: ' . mysql_error()); } if(mysql_num_rows($result) > 0) { while ($cat_list = mysql_fetch_array($result)) //loop through the categories { $cat_dir = "$sas_config[serverpath]$sas_config[user_path]/$sas_config[media_dir]/downloads/".$cat_list[0] ; if (!file_exists($cat_dir)) { mkdir($cat_dir,0755); $handle = fopen($cat_dir."/index.html", 'w') ; //write an empty index.html in the directory fwrite($handle, "") ; } $query1 = "SELECT id, filename, stored_file, bin_data FROM $downloads_table WHERE category = '$cat_list[0]'"; $result1 = mysql_query($query1); if (!$result1) { die('Invalid query: ' . mysql_error()); } while ($doc_list = mysql_fetch_array($result1)) //loop through the documents { $write_path_from = "$sas_config[serverpath]$sas_config[user_path]/$sas_config[media_dir]/downloads/" . $doc_list[1]; $write_path_to = "$sas_config[serverpath]$sas_config[user_path]/$sas_config[media_dir]/downloads/$cat_list[0]/" . $doc_list[2]; if($cat_list[2] == 0) //category is public { if (!copy($write_path_from,$write_path_to)) { echo "failed to copy $file...\n"; } else { unlink($write_path_from) ; } } else { if (!$handle = fopen($write_path_to, 'w')) { echo "Cannot open file ($write_path_to)"; } //Write content from blobfield to our opened file. Blob is $doc_list[3], not $doclist[2]! 2006-05-31/PF if (fwrite($handle, $doc_list[3]) === FALSE) { echo "Cannot write to file ($write_path_to)"; } } } } } $query1 = "SELECT id, filename, stored_file, category FROM $downloads_table ORDER BY filename"; $result1 = mysql_query($query1); if (!$result1) { die('Invalid query: ' . mysql_error()); } $error = FALSE ; while ($doc_list = mysql_fetch_array($result1)) //loop through the documents { $filename = "$sas_config[serverpath]$sas_config[user_path]/$sas_config[media_dir]/downloads/$doc_list[3]/" . $doc_list[2]; if (!file_exists($filename)) { $error = TRUE ; print "File: ".$doc_list[1]." does not exists, stored filename is ".$doc_list[3]."/" . $doc_list[2]."
" ; } } if($error == FALSE) { mysql_query("ALTER TABLE $downloads_table DROP bin_data"); print "Download migration finished.
"; } else { print "
There has been problems migrating the downloads table, see previous messages.
" ; } } } if($step3 == 1) { $downloads_table = $dbprefix."m_downloads"; mysql_query("INSERT INTO $table_configuration VALUES('edex_file_name' , '' , '')") ; mysql_query("INSERT INTO $table_configuration VALUES('allbum_reverse_order' , '0' , '')") ; mysql_query("ALTER TABLE $downloads_table ADD last_download date"); mysql_query("ALTER TABLE $downloads_table MODIFY date datetime"); $table_scripts = $dbprefix . "m_scripts"; mysql_query("ALTER TABLE $table_scripts MODIFY value1 text"); mysql_query("ALTER TABLE $table_scripts MODIFY value2 text"); mysql_query("ALTER TABLE $table_scripts MODIFY value3 text"); } mysql_query("UPDATE $table_modules SET options = 'view_agenda.php,View agenda' WHERE location = 'sn_agenda'"); //tv module $result = mysql_query("SELECT id FROM $table_modules WHERE location = 'sn_tvmodule'"); $RecordCount = mysql_num_rows($result); if($RecordCount == 0) { mysql_query("INSERT INTO $table_modules VALUES (NULL, 'TV Module', 'sn_tvmodule', '', 'admin.php', '')"); $table_scripts = $dbprefix . "m_scripts"; mysql_query("CREATE TABLE $table_scripts (id int(11) NOT NULL auto_increment, name varchar(50) NOT NULL default '', script varchar(30) NOT NULL default '', active tinyint(4) default NULL, varname1 varchar(15) default NULL, value1 text default NULL, varname2 varchar(15) default NULL, value2 text default NULL, varname3 varchar(15) default NULL, value3 text default NULL, welcome text, loc_id tinyint(11), PRIMARY KEY (id))"); mysql_query("INSERT INTO $table_scripts VALUES (1, 'Scrollscript', 'scroll_page.php', 1, 'Page number', '1', 'Speed', '2', NULL, '', '', '1')"); mysql_query("INSERT INTO $table_scripts VALUES (2, 'Slideshow', 'slideshow_full.php', 0, 'Album name', 'slideshow', 'Speed', '5', 'Width', '300', '', '1')"); mysql_query("INSERT INTO $table_scripts VALUES (3, 'Showpage', 'show_page.php', 0, 'Page number', '1', NULL, '', NULL, '', '', '1')"); mysql_query("INSERT INTO $table_scripts VALUES (4, 'Page slideshow', 'page_slideshow.php', 0, 'Pages', '1', NULL, '', NULL, '', '', '1')"); print "TV module has been installed.

"; } print "

Migration is finished, current Site@School version is: 2.4.03
You can now continue normal operation on your site.

"; print "
Please don't forget to delete the content of the starnet/install directory when you are finished!" ; ?>

The S@S team.