massive cleanup and improvements so that it can handle upgrades

This commit is contained in:
seek3r 2000-09-28 08:17:06 +00:00
parent d354b87a24
commit 26fcc38cdd
2 changed files with 219 additions and 64 deletions

View File

@ -11,6 +11,8 @@
/* $Id$ */
function add_default_server_config(){
global $db;
$db->query("insert into config (config_name, config_value) values ('default_tplset', 'default')");
$db->query("insert into config (config_name, config_value) values ('temp_dir', '/path/to/tmp')");
$db->query("insert into config (config_name, config_value) values ('files_dir', '/path/to/dir/phpgroupware/files')");
@ -18,11 +20,6 @@
$db->query("insert into config (config_name, config_value) values ('site_title', 'phpGroupWare')");
$db->query("insert into config (config_name, config_value) values ('hostname', 'local.machine.name')");
$db->query("insert into config (config_name, config_value) values ('webserver_url', '/phpgroupware')");
$db->query("insert into config (config_name, config_value) values ('db_host', 'localhost')");
$db->query("insert into config (config_name, config_value) values ('db_name', 'phpGroupWare_dev')");
$db->query("insert into config (config_name, config_value) values ('db_user', 'phpgroupware')");
$db->query("insert into config (config_name, config_value) values ('db_pass', 'phpgr0upwar3')");
$db->query("insert into config (config_name, config_value) values ('db_type', 'mysql')");
$db->query("insert into config (config_name, config_value) values ('auth_type', 'sql')");
$db->query("insert into config (config_name, config_value) values ('ldap_host', 'localhost')");
$db->query("insert into config (config_name, config_value) values ('ldap_context', 'o=phpGroupWare')");
@ -47,7 +44,56 @@
$db->query("insert into config (config_name, config_value) values ('httpproxy_port', '')");
$db->query("insert into config (config_name, config_value) values ('showpoweredbyon', 'bottom')");
$db->query("insert into config (config_name, config_value) values ('checkfornewversion', 'False')");
}
if ($useglobalconfigsettings == "on"){
if (is_file($basedir)){
include ($phpgw_info["server"]["include_root"]."/globalconfig.inc.php");
$db->query("insert into config (config_name, config_value) values ('default_tplset', '".$phpgw_info["server"]["default_tplset"]."')");
$db->query("insert into config (config_name, config_value) values ('temp_dir', '".$phpgw_info["server"]["temp_dir"]."')");
$db->query("insert into config (config_name, config_value) values ('files_dir', '".$phpgw_info["server"]["files_dir"]."')");
$db->query("insert into config (config_name, config_value) values ('encryptkey', '".$phpgw_info["server"]["encryptkey"]."')");
$db->query("insert into config (config_name, config_value) values ('site_title', '".$phpgw_info["server"]["site_title"]."')");
$db->query("insert into config (config_name, config_value) values ('hostname', '".$phpgw_info["server"]["hostname"]."')");
$db->query("insert into config (config_name, config_value) values ('webserver_url', '".$phpgw_info["server"]["webserver_url"].")");
$db->query("insert into config (config_name, config_value) values ('auth_type', '".$phpgw_info["server"]["auth_type"]."')");
$db->query("insert into config (config_name, config_value) values ('ldap_host', '".$phpgw_info["server"]["ldap_host"]."')");
$db->query("insert into config (config_name, config_value) values ('ldap_context', '".$phpgw_info["server"]["ldap_context"]."')");
$db->query("insert into config (config_name, config_value) values ('usecookies', '".$phpgw_info["server"]["usecookies"]."')");
$db->query("insert into config (config_name, config_value) values ('mail_server', '".$phpgw_info["server"]["mail_server"]."')");
$db->query("insert into config (config_name, config_value) values ('mail_server_type', '".$phpgw_info["server"]["mail_server_type"]."')");
$db->query("insert into config (config_name, config_value) values ('imap_server_type', '".$phpgw_info["server"]["imap_server_type"]."')");
$db->query("insert into config (config_name, config_value) values ('mail_suffix', '".$phpgw_info["server"]["mail_suffix"]."')");
$db->query("insert into config (config_name, config_value) values ('mail_login_type', '".$phpgw_info["server"]["mail_login_type"]."')");
$db->query("insert into config (config_name, config_value) values ('smtp_server', '".$phpgw_info["server"]["smtp_server"]."')");
$db->query("insert into config (config_name, config_value) values ('smtp_port', '".$phpgw_info["server"]["smtp_port"]."')");
$db->query("insert into config (config_name, config_value) values ('nntp_server', '".$phpgw_info["server"]["nntp_server"]."')");
$db->query("insert into config (config_name, config_value) values ('nntp_port', '".$phpgw_info["server"]["nntp_port"]."')");
$db->query("insert into config (config_name, config_value) values ('nntp_sender', '".$phpgw_info["server"]["nntp_sender"]."')");
$db->query("insert into config (config_name, config_value) values ('nntp_organization', '".$phpgw_info["server"]["nntp_organization"]."')");
$db->query("insert into config (config_name, config_value) values ('nntp_admin', '".$phpgw_info["server"]["nntp_admin"]."')");
$db->query("insert into config (config_name, config_value) values ('nntp_login_username', '".$phpgw_info["server"]["nntp_login_username"]."')");
$db->query("insert into config (config_name, config_value) values ('nntp_login_password', '".$phpgw_info["server"]["nntp_login_password"]."')");
$db->query("insert into config (config_name, config_value) values ('charset', '".$phpgw_info["server"]["charset"]."')");
$db->query("insert into config (config_name, config_value) values ('default_ftp_server', '".$phpgw_info["server"]["default_ftp_server"]."')");
$db->query("insert into config (config_name, config_value) values ('httpproxy_server', '".$phpgw_info["server"]["httpproxy_server"]."')");
$db->query("insert into config (config_name, config_value) values ('httpproxy_port', '".$phpgw_info["server"]["httpproxy_port"]."')");
$db->query("insert into config (config_name, config_value) values ('showpoweredbyon', '".$phpgw_info["server"]["showpoweredbyon"]."')");
$db->query("insert into config (config_name, config_value) values ('checkfornewversion', '".$phpgw_info["server"]["checkfornewversion"]."')");
}else{
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Error</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Could not find your old globalconfig.inc.php.<br> You will be required to configure your installation manually.</td>\n";
echo " </tr>\n";
echo "</table>\n";
add_default_server_config();
}
}else{
add_default_server_config();
}
$db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('admin', 'Administration', 1, 1, NULL)");
$db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('tts', 'Trouble Ticket System', 0, 2, NULL)");
$db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('inv', 'Inventory', 0, 3, NULL)");

View File

@ -37,33 +37,142 @@
// $db->Halt_On_Error = "report";
$db->Halt_On_Error = "no";
switch($msg){
case "1":
return "You have been successfully logged out";
break;
case "2":
return "Your old tables were deleted";
break;
}
/* Database setup */
switch($action){
case "askforupgrade":
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running a pre-beta version of phpGroupWare<br>\n";
echo " We are not providing an upgrade path at this time, please backup your tables and drop them, so that this script can recreate them.</td>\n";
echo " </tr>\n";
echo "</table>\n";
?>
<form method="POST" action=<?php $PHP_SELF?>>
<table border="0" align="center">
<tr bgcolor="486591">
<td colspan="2"><font color="fefefe">&nbsp;<b>Upgrade information</b></font></td>
</tr>
<tr bgcolor="e6e6e6">
<td>Select your old version:</td>
<td>
<select name="oldversion">
<option value="7122000">7122000</option>
<option value="8032000">8032000</option>
<option value="8072000">8072000</option>
<option value="8212000">8212000</option>
<option value="9052000">9052000</option>
<option value="9072000">9072000</option>
<option value="9262000">9262000</option>
</select>
</td>
</tr>
<tr bgcolor="e6e6e6">
<td>Port old globalconfig settings.</td>
<td><input type="checkbox" name="useglobalconfigsettings"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="action" value="Upgrade"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="action" value="Dump my old tables"></td>
</tr>
</table>
</form>
<?php
break;
case "Dump my old tables":
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Information</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>At your request, this script is going to take the evil action of dropping your existing tables and re-creating them in the new format.</td>\n";
echo " </tr>\n";
include ("droptables_".$phpgw_info["server"]["db_type"].".inc.php");
include ("createtables_".$phpgw_info["server"]["db_type"].".inc.php");
include ("default_records.inc.php");
include ("lang_records.inc.php");
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any errors, your tables have been created.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.</td>\n";
echo " </tr>\n";
echo "</table>\n";
break;
case "Upgrade":
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Information</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>At your request, this script is going to attempt to upgrade your tables to the new format.</td>\n";
echo " </tr>\n";
echo "</table>\n";
include ("createtables_".$phpgw_info["server"]["db_type"].".inc.php");
include ("default_records.inc.php");
include ("lang_records.inc.php");
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any errors, your tables have been updated.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.</td>\n";
echo " </tr>\n";
echo "</table>\n";
break;
default:
$db->query("select * from config");
if ($db->num_rows() == 0){
$db->query("select * from accounts");
if ($db->num_rows() == 0){
echo "You appear to be running a new install of phpGroupWare, so the tables will be created for you.<br>\n";
include ("droptables_".$phpgw_info["server"]["db_type"].".inc.php");
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running a new install of phpGroupWare, so the tables will be created for you.</td>\n";
echo " </tr>\n";
include ("createtables_".$phpgw_info["server"]["db_type"].".inc.php");
include ("default_records.inc.php");
include ("lang_records.inc.php");
echo "If you did not recieve any errors, your tables have been created.<br>\n";
echo "<a href=\"config.php\">Click here</a> to configure the environment.<br>\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any errors, your tables have been created.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.</td>\n";
echo " </tr>\n";
echo "</table>\n";
}else{
echo "You appear to be running a pre-beta version of phpGroupWare<br>\n";
//echo "We are not providing an upgrade path at this time, please backup your tables and drop them, so that this script can recreate them.<br>\n";
/* This is a temporary evil section */
echo "This script is going to take the evil action of dropping your existing table and re-creating them in the new format.<br>\n";
include ("droptables_".$phpgw_info["server"]["db_type"].".inc.php");
include ("createtables_".$phpgw_info["server"]["db_type"].".inc.php");
include ("default_records.inc.php");
include ("lang_records.inc.php");
echo "If you did not recieve any errors, your tables have been created.<br>\n";
echo "<a href=\"config.php\">Click here</a> to configure the environment.<br>\n";
Header("Location: $PHP_SELF?action=askforupgrade");
}
}else{
echo "Your database seems to be current.<br>\n";
echo "<a href=\"config.php\">Click here</a> to configure the environment.<br>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Your database seems to be current.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.</td>\n";
echo " </tr>\n";
echo "</table>\n";
}
}
//db->disconnect();
?>