From: Sebastien D. <sde...@us...> - 2005-01-10 18:10:04
|
Update of /cvsroot/tslogparser/tslogparser/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15763/admin Added Files: upgrade.php Log Message: New installation procedure; fixes; documentation updated --- NEW FILE: upgrade.php --- <?php /* * Copyright (c) 2005, Bull S.A.. All rights reserved. * Created by: Sebastien Decugis * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. */ /* This file will set up or upgrade the database schema. */ $root="../"; $_PAGE["title"]="TSLP Database Installation / Upgrade"; /* Output header page */ require($root."header.inc.php"); /* We'll need functions defined in other files */ require($root."database.inc.php"); /* The following files define several usefull functions */ require($root."db/remove_db_data.inc.php"); require($root."db/initial_db_schema.inc.php"); echo "<pre>\n"; /* Connect the database server */ echo "Checking database connexion...: "; $db_link = @mysql_connect($db_server,$db_user,$db_pw); if (!$db_link) { echo "<font color='red'>Fail</font>\n"; echo "<i>MySQL error</i>: <b>".mysql_error()."</b>"; echo "</pre>\n"; echo "<p>Please check your db_inc.php file parameters.</p>\n"; require($root."footer.inc.php"); die(); } else { echo "<font color='green'>Ok</font>\n"; } /* Select the database */ echo "Selecting database............: "; $tmp = @mysql_select_db($db); if (!$tmp) { echo "<font color='red'>Fail</font>\n"; echo "<i>MySQL error</i>: <b>".mysql_error()."</b>"; echo "</pre>\n"; echo "<p>Please check your db_inc.php file parameters.</p>\n"; die(); mysql_close($db_link); require($root."footer.inc.php"); die(); } else { echo "<font color='green'>Ok</font>\n"; } /* Check if the configuration table exists */ $config=array(); echo "Checking current version......: "; $tmp = @mysql_query("SELECT * FROM opts_config"); if ($tmp) { while ($row = mysql_fetch_assoc($tmp)) $config[$row["cfg_key"]]=$row["cfg_val"]; } if (!isset($config["version"])) { if (isset($_GET["reset"])) { echo "<font color='orange'>Building...</font>\n"; echo " Deleting old database content...\n"; echo " ".remove_db_data()."\n"; echo " Creating new content...\n"; echo " ".initial_db_schema()."\n"; $tmp = @mysql_query("SELECT * FROM opts_config"); while ($row = mysql_fetch_assoc($tmp)) $config[$row["cfg_key"]]=$row["cfg_val"]; } else { echo "<font color='red'>Not found</font>\n"; echo "</pre>\n"; echo "<p>You have either an old or an incomplete installation.\n"; echo "The system is unable to upgrade/repair the database.</p>\n"; echo "<p><b>Do you want to install a fresh database? \n"; echo "(ALL EXISTING DATA WILL BE ERASED!)</p>\n"; echo "<form method='GET'>\n"; echo " <p><input type='submit' name='reset' value='Install/Reset'></p>\n"; echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } } echo "<b>".$config["version"]."</b>\n"; require_once($root."db/update_db.inc.php"); echo "Checking required version.....: <b>".LATEST_VERSION."</b>\n"; if ( $config["version"] < LATEST_VERSION) { echo " Updating...\n"; update_db($config["version"]); echo " <font color='green'><b>Done!</b> You may start using the new version safely.</font>\n"; } else { echo "Your database is already up-to-date.\n"; } echo "</pre>\n"; db_fini(); require($root."footer.inc.php"); die(); |