0) {
echo "Start migration ....." ;
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 "
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 "
pupil pages migration finished.";
print "
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 "
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 "
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 "
Forms module migration finished."; }
else {
print "
Warning: Forms module not installed!, please run install_forms.php if you need this module.";
}
print "
Start search module migration.";
mysql_query("INSERT INTO $table_configuration VALUES ('search_module_welcome',
'
Search our site
Give a search argument:', 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 "
Search module options inserted.";
print "
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 "
Allbum module migration finished.";
} else {
print "
Warning: Allbum module not installed!, please run install_allbum.php if you need this module.";
}
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 "
Migration is finished for version 2.3
You can now continue normal operation on your site.
Please don't forget to delete the starnet/install directory when you are finished!" ;
?>
The S@S team.