<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<meta http-equiv="Content-Language" content="nl">
<TITLE>Site@School migration tool</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<STYLE>A:link {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #638ab9; TEXT-DECORATION: none
}
A:active {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #638ab9; TEXT-DECORATION: none
}
A:visited {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #638ab9; TEXT-DECORATION: none
}
A:hover {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #ff0000; TEXT-DECORATION: none
}
TEXTAREA {
	COLOR: #000000; FONT-FAMILY: verdana, arial; BACKGROUND-COLOR: #ccdaec
}
Input.BUTTON {
	border:1px outset #ccdaec; BACKGROUND-COLOR: #ccdaec
}
SELECT {
	BORDER-RIGHT: #ccdaec 1px inset; BORDER-TOP: #ccdaec 1px inset; BORDER-LEFT: #ccdaec 1px inset; COLOR: #000000; BORDER-BOTTOM: #ccdaec 1px inset; FONT-FAMILY: verdana, arial; BACKGROUND-COLOR: #ccdaec
}
.text {
	FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial
}
.link {
	FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #638ab9; FONT-FAMILY: Verdana, Arial
}
.heading {
	FONT-WEIGHT: bold; FONT-SIZE: 13pt; COLOR: #638ab9; FONT-FAMILY: Verdana, Arial
}
.error { color : red ;}

INPUT.textfield {
	BORDER-RIGHT: #ccdaec 1px inset; BORDER-TOP: #ccdaec 1px inset; BORDER-LEFT: #ccdaec 1px inset; BORDER-BOTTOM: #ccdaec 1px inset; BACKGROUND-COLOR: #ccdaec
}
</STYLE>


</HEAD>
<BODY style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial, Helvetica" bottomMargin=0 vLink=#000000 aLink=#466c9b link=#000000 bgColor=#ffffff leftMargin=0 topMargin=0 rightMargin=0>


<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 height=45
cellSpacing=0 cellPadding=0 width="100%"
background=../graphics/banner-bg.gif border=0>
  <TBODY>
  <TR>
    <TD align=left width="5%"><IMG height=45
      src="../graphics/banner-left.gif" width=4 border=0></TD>
    <TD align=right width="70%">
    <b><font size="6" color="#FFFFFF">Migration of 2.1 to 2.2</font></b></TD>
    <TD align=right width="3%"><IMG height=45
      src="../graphics/banner-right.gif" width=3
border=0></TD></TR></TBODY></TABLE>
<TABLE id=AutoNumber3 style="BORDER-COLLAPSE: collapse" borderColor=#111111
cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD vAlign=top>
      <TABLE cellPadding=5 width="100%" border=0>
        <TBODY>
        <TR>
          <TD>
<?php
if($_GET[step] == "")
{
?>
          <form method="POST" action="migrate2.1_2.2.php?step=1">
            <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111
            cellSpacing=0 cellPadding=4 width="100%" border=0>
              <TBODY>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=left width="65%">
                <SPAN class=heading>Welcome<BR></SPAN></TD>
                <TD vAlign=top align=middle width="10%">&nbsp;</TD>
              </TR>
              <TR>
                <TD align=center width="25%">
                <img border="0" src="../graphics/install_banner.jpg"></TD>
                <TD vAlign=top align=middle width="65%">
                <table border="1" height="300" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#E5E5E5" width="100%" id="AutoNumber4" bgcolor="#F7F7F7">
                  <tr>
                    <td width="100%" valign="top"><span class=text>
                    <br><br><br>This wizard will perform the migration of version 2.1 to 2.2 .<br><br>
                     Before you continue , please make sure you have made a <b>backup</b> of you MYSQL database.<br>
                     This can be done with <a href="http://phpmyadmin.sourceforge.net/">PHPMYADMIN</a> or via backup tool from S@S.
                    </span></td>
                  </tr>
                </table>
                </TD>
                <TD vAlign=top align=middle width="10%"></TD></TR>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=right width="65%">

                 <p>
                  <input type="submit" value="Continue" name="B1" class="BUTTON">
                  </p>
                </form>
<?php
}
if($_GET[step] == "1")
{
$installdir = $_SERVER["DOCUMENT_ROOT"]."/starnet";
$installdir = str_replace("//","/",$installdir);
?>


          <form method="POST" action="migrate2.1_2.2.php?step=2">

            <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111
            cellSpacing=0 cellPadding=4 width="100%" border=0>
              <TBODY>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=left width="65%">
                <SPAN class=heading>Step 1<BR></SPAN><span class="text">S@S Database migration.</span></TD>
                <TD vAlign=top align=middle width="10%">&nbsp;</TD>
              </TR>
              <TR>
                <TD align=center width="25%">
                <img border="0" src="../graphics/install_banner.jpg"></TD>
                <TD vAlign=top align=middle width="65%">
                <table border="1" height="300" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#E5E5E5" width="100%" id="AutoNumber4" bgcolor="#F7F7F7">
                  <tr>
                    <td width="100%" valign="top"><span class=text>
                   <br><br>This migration consists of 2 steps:<p>
                   1. Provide an email address for the newsletter module<br>
                   2. Newletter module tables will be created and some S@S tables will be altered<p> 
                   Click on continue.</td>
                  </tr>
                </table>
                </TD>
                <TD vAlign=top align=middle width="10%"></TD></TR>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=right width="65%">


                 <p>
                  <input type="submit" value="Continue" name="B1" class="BUTTON">
                </form>
<?php
}
if($_GET[step] == "2" OR $step == "2")
{
?>


          <form method="POST" action="migrate2.1_2.2.php?step=3">

            <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 cellPadding=4 width="100%" border=0>
              <TBODY>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=left width="65%">
                <SPAN class=heading>Step 2<BR></SPAN><span class="text">&nbsp</span></TD>
                <TD vAlign=top align=middle width="10%">&nbsp;</TD>
              </TR>
              <TR>
                <TD align=center width="25%">
                <img border="0" src="../graphics/install_banner.jpg"></TD>
                <TD vAlign=top align=middle width="65%">
                <table border="0" height="300" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#E5E5E5" width="100%" id="AutoNumber4" bgcolor="#F7F7F7">
                  <tr>
	                <td valign=top><span class=text><b>Please give the E-mail address of the administrator for the new newsletter module</b></span>
                	<p><input type=text name="email" value="" size=35><br>
                	<p><span class="text">Explanation: The newsletter module (which is a new module) needs 
                  a valid email address of a S@S user, this user will become the owner of the newsletter module.
                  <p>You might have to go into S@S admin and change/add a user of your choice
                  and give him a valid email address and use this email address here.</span></td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom"><span class=text>
                    In the next step the Newsletter module tables will be created
                    and other S@S tables will be altered..</td>
                  </tr>
                </table>
                </TD>
                <TD vAlign=top align=middle width="10%"></TD></TR>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=right width="65%">
                 <p>
                  <input type="submit" value="Continue" name="B1" class="BUTTON">
                </form>
<?php
}
if($_GET[step] == "3")
{

?>
            <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111
            cellSpacing=0 cellPadding=4 width="100%" border=0>
              <TBODY>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=left width="65%">
                <SPAN class=heading>Step 3<BR></SPAN></TD>
                <TD vAlign=top align=middle width="10%">&nbsp;</TD>
              </TR>
              <TR>
                <TD align=center width="25%">
                <img border="0" src="../graphics/install_banner.jpg"></TD>
                <TD vAlign=top align=middle width="65%">
                <table border="1" height="300" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#E5E5E5" width="100%" id="AutoNumber4" bgcolor="#F7F7F7">
                  <tr>
                  <td width="100%" valign="top"><span class=text>

<?php
$email =  $_POST[email];

include("../configuration/database.inc.php");       
mysql_connect("$db_server", "$db_username", "$db_password");
mysql_select_db("$db_name");
$query = "SELECT id FROM $table_users WHERE email='$email'";
$result = mysql_query($query) or die_script(mysql_error());

$RecordCount = mysql_num_rows($result);

  if($RecordCount > 0) {
echo "Start migration .....<p>"   ;
print "Create newsletter tables.";
$table_newsletter_content = $dbprefix ."m_newsletters";
$table_newsletters = $dbprefix ."m_newsletter_cat";
$table_email_adresses = $dbprefix ."m_newsletter_emails";

mysql_query("INSERT INTO $table_configuration VALUES ('newsletter_admin_email', '$email', 'Email address of administrator')");
mysql_query("CREATE TABLE $table_email_adresses (id int(11) NOT NULL auto_increment,name varchar(100) not null, email varchar(80),remarks varchar(100),newsletter_id varchar(30), date date,
enable tinyint(4), surename varchar(35) not null, code varchar(12), PRIMARY KEY (id))");
mysql_query("CREATE TABLE $table_newsletter_content (id int(11) NOT NULL auto_increment, title text, archive tinyint(4) default 0, content text, newsletter_id tinyint(4), date date, published tinyint(4) not null default 0, sent tinyint(4) not null default 0, header text, footer text, PRIMARY KEY (id))");
mysql_query("CREATE TABLE $table_newsletters (id int(11) NOT NULL auto_increment, name varchar(50) , title text,link tinyint(4),email varchar(80) not null, confirm tinyint(4) not null, register_text text
,decline_text text , contribute_text text, contribute tinyint(4), extra_info varchar(40),contribute_thanks text , PRIMARY KEY (id))") ;
mysql_query("INSERT INTO $table_modules VALUES (NULL, 'Newsletter', 'sn_newsletter', 'newsletter.php, Add Newsletter', 'admin.php', '$table_newsletter_content,$table_newsletters,$table_email_adresses')");

print "<p>Start pupil pages migration.";
mysql_query("UPDATE $table_modules SET options='user_login.php,Teacher/Pupils\'s login,viewpage.php,View pupil pages,viewpage2.php,View pupil pages per class' WHERE location = 'sn_studentpages'");
if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }
mysql_query("UPDATE $table_pages SET module = 'sn_studentpages/user_login.php' WHERE module = 'sn_studentpages/student.php'");
if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }
mysql_query("UPDATE $table_pages SET module = 'sn_studentpages/user_login.php' WHERE module = 'sn_studentpages/teacher.php'");
if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }
print "<p>pupil pages migration finished.";

print "<p>Start statistics migration.";
$table_stats = $dbprefix."stats" ;
$table_stats_new = $dbprefix."stats_new" ;
$table_stats_old = $dbprefix."stats_old" ;

mysql_query("CREATE TABLE $table_stats_new (
  id int(11) NOT NULL auto_increment,
  ip varchar(15) NOT NULL default '',
  received date NOT NULL default '0000-00-00',
  pageid varchar(10) NOT NULL default '',
  sectionid varchar(10) NOT NULL default '',
  count int(11) NOT NULL default '0',
  PRIMARY KEY  (id)
)");

if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }

mysql_query("UPDATE $table_stats_new SET count=1 WHERE id>0");
if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }
mysql_query("INSERT INTO $table_stats_new SELECT id,ip,received,pageid,sectionid, count(ip) as count FROM $table_stats group by ip,pageid");
if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }
mysql_query("RENAME TABLE $table_stats TO $table_stats_old");
if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }
mysql_query("RENAME TABLE $table_stats_new TO $table_stats");
if (mysql_errno() != 0)
  {
    echo mysql_errno() . ": " . mysql_error(). "\n";
  }
print "<p>Stats migration finished.";

$query = "SELECT dbtables FROM " .$table_modules. " WHERE location='sn_form'";
$result = mysql_query($query) or die (mysql_error().$query);
if(mysql_num_rows($result) > 0) {
 print "<p>Start forms module migration.";
 $table_forms = $dbprefix."m_forms" ;
 mysql_query("ALTER TABLE $table_forms ADD required tinyint(4) NOT NULL default 0");
 if (mysql_errno() != 0)
   {
     echo mysql_errno() . ": " . mysql_error(). "\n";
   }
 mysql_query("UPDATE $table_forms SET required = 0 WHERE id > 0");
 if (mysql_errno() != 0)
   {
     echo mysql_errno() . ": " . mysql_error(). "\n";
   }
 print "<p>Forms module migration finished."; }
else {
print "<p><b>Warning: Forms module not installed!, please run install_forms.php if you need this module.</b>";
}

print "<p>Start search module migration."; 
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_welcome', 
'<h3>Search our site</h3><br>Give a search argument:<p>', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_results', '10', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_name1', 'sn_news,m_news_articles,0', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_name2', 'sn_newsletter,m_newsletters,0', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_searchfield1', 'title, content', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_searchfield2', 'title, content', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_returnfield1', 'id, title, content', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_returnfield2', 'id, title, content', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_url1', '&article=@0@', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_url2', '&option=view&newsletter_id=@0@', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_pageid1', '2,43', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_pageid2', '9,94', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_name3', 'sn_studentpages,m_studentpages,0', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_searchfield3', 'content,title', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_returnfield3', 'studentid,content,title', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_pageid3', '3,44', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_url3', '&student=@0@', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_name4', 'sn_allbum,m_allbum,0', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_searchfield4', 'title,description', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_returnfield4', 'id,title,description', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_pageid4', '9,77', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_url4', '&ID=@0@&gallerypage=1', NULL)");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_extra_select1', '', ' ')");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_extra_select2', 'AND published=1', 'Only search in published newsletters')");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_extra_select3', '', ' ')");
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_extra_select4', '', ' ')");
print "<p>Search module options inserted.";
print "<p>Start allbum module migration."; 
$query = "SELECT dbtables FROM " .$table_modules. " WHERE location='sn_allbum'";
$result = mysql_query($query) or die (mysql_error().$query);

if(mysql_num_rows($result) > 0) {
 $moduletables = mysql_result($result,0);
 $moduletables = explode(",", $moduletables);
 $allbum_table = $moduletables[0];

 mysql_query("ALTER TABLE $allbum_table drop object_file") ;
 mysql_query("ALTER TABLE $allbum_table drop original_file") ;
 mysql_query("ALTER TABLE $allbum_table drop used_space") ;
 mysql_query("ALTER TABLE $allbum_table change parents parent longtext") ;
 mysql_query("ALTER TABLE $allbum_table change thumb_file thumb longtext") ;
 mysql_query("ALTER TABLE $allbum_table add ispage tinyint(4) NOT NULL DEFAULT 0") ;
 mysql_query("UPDATE $allbum_table SET ispage = 0 WHERE id > 0");
 $query = "SELECT path,title,id FROM $allbum_table WHERE type = 'picture'";
 $result = mysql_query($query) or die (mysql_error().$query);
  while ($allbum_list = mysql_fetch_array($result))
  {     
  mysql_query("UPDATE $allbum_table SET thumb = '$allbum_list[1]' WHERE id = '$allbum_list[2]'") ;
  }
  mysql_query("UPDATE $table_modules SET admin = 'admin.php' WHERE location = 'sn_allbum'") ;
  mysql_query("UPDATE $table_modules SET options = 'sas_index.php,View ALbums,sas_index2.php,View Album per page' WHERE location = 'sn_allbum'") ;
print "<p>Allbum module migration finished."; 
} else {
print "<p><b>Warning: Allbum module not installed!, please run install_allbum.php if you need this module.</b>";
}

mysql_query("INSERT INTO $table_configuration VALUES ('media_dir', 'media', '')");
mysql_query("INSERT INTO $table_configuration VALUES ('studentpages_dir', 'studentpages', '')");
mysql_query("INSERT INTO $table_editors VALUES (NULL, 'Plain text Editor', 'sn_plain/editor.php', '')");
$agenda_table = $dbprefix . "m_agenda_names";
mysql_query("ALTER TABLE $agenda_table ADD username varchar(20)");
print "<p>Migration is finished for version 2.3<br>You can now continue normal operation on your site.<p>
Please don't forget to delete the <b>starnet/install</b> directory when you are finished!"   ;
?>
<br><br>
<b>The S@S team.</b><br>
</span></td>



                  </tr>
                </table>
                </TD>
                <TD vAlign=top align=middle width="10%"></TD></TR>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=right width="65%">
                  <p>
<?php                  
} else {
?>
                  <span class="error">The email address: <?php echo $email ?> is not found in the Site@school users table!</span>
                  <p><span class="text">Explanation: The newsletter module (which is a new module) needs an 
                  a valid email address of a S@S user, this user will become the owner of the newsletter module.
                  <br>Please click the <b>Return</b> button and provide a valid email address.
                  <p>You might have to go into S@S admin and change/add a user of your choice
                  and give him a valid email address and use this email address here.</span>
                  </td>
                  </tr>
                </table>
                </TD>
                <TD vAlign=top align=middle width="10%"></TD></TR>
              <TR>
                <TD align=center width="25%">&nbsp;
                </TD>
                <TD vAlign=top align=right width="65%">
                 <p>
                  <input type="button" value="Return" name="backbutton" onClick="javascript:history.go(-1)" class="BUTTON">
<?php  
    }
}
?>
               </TD>
                <TD vAlign=top align=middle width="10%">&nbsp;</TD></TR>
              </TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
    </TR></TBODY></TABLE></BODY></HTML>