Revision: 1038
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1038&view=rev
Author:   jberanek
Date:     2009-03-01 23:18:07 +0000 (Sun, 01 Mar 2009)

Log Message:
-----------
* Added support for automatic database upgrades. This includes the
 addition of a new database table, with the default name of mrbs_variables.

* Moved definition of table name variables out of config.inc.php, into
 dbsys.inc.

* Database version check/upgrade code is implemented in dbsys.inc
 and upgrade.inc. Database upgrade SQL code is stored in
 upgrade/<SCHEMA_VERSION>/<DB_TYPE>.sql. Added three new localisation
 tokens into lang.en.

* Added multiple inclusion protection to all functions.inc and
 mrbs_auth.inc inclusions.

* Added code to allow print_header() to be called more than once. The
 second time just does nothing.

* Added new DB abstraction function, sql_table_exists($table).

* Added new function, print_footer(), to print a basic page footer,
 and optionally exit.

* Fixed prototype of getAuthorised().

Modified Paths:
--------------
    mrbs/trunk/tables.my.sql
    mrbs/trunk/tables.pg.73and_above.sql
    mrbs/trunk/tables.pg.sql
    mrbs/trunk/web/add.php
    mrbs/trunk/web/admin.php
    mrbs/trunk/web/config.inc.php
    mrbs/trunk/web/day.php
    mrbs/trunk/web/dbsys.inc
    mrbs/trunk/web/del.php
    mrbs/trunk/web/del_entry.php
    mrbs/trunk/web/edit_area_room.php
    mrbs/trunk/web/edit_entry.php
    mrbs/trunk/web/edit_entry_handler.php
    mrbs/trunk/web/edit_users.php
    mrbs/trunk/web/functions.inc
    mrbs/trunk/web/help.php
    mrbs/trunk/web/lang.en
    mrbs/trunk/web/month.php
    mrbs/trunk/web/mrbs_auth.inc
    mrbs/trunk/web/mysql.inc
    mrbs/trunk/web/mysqli.inc
    mrbs/trunk/web/pgsql.inc
    mrbs/trunk/web/report.php
    mrbs/trunk/web/search.php
    mrbs/trunk/web/view_entry.php
    mrbs/trunk/web/week.php

Added Paths:
-----------
    mrbs/trunk/web/upgrade/
    mrbs/trunk/web/upgrade/1/
    mrbs/trunk/web/upgrade/1/mysql.sql
    mrbs/trunk/web/upgrade/1/pgsql.sql
    mrbs/trunk/web/upgrade.inc

Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql    2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/tables.my.sql    2009-03-01 23:18:07 UTC (rev 1038)
@@ -67,3 +67,15 @@
   
   PRIMARY KEY (id)
 );
+
+CREATE TABLE mrbs_variables
+(
+  id               int NOT NULL auto_increment,
+  variable_name    varchar(80),
+  variable_content text,
+      
+  PRIMARY KEY (id)
+);
+
+INSERT INTO mrbs_variables (variable_name, variable_content)
+  VALUES ( 'db_version', '1');

Modified: mrbs/trunk/tables.pg.73and_above.sql
===================================================================
--- mrbs/trunk/tables.pg.73and_above.sql        2009-02-27 23:22:59 UTC (rev 
1037)
+++ mrbs/trunk/tables.pg.73and_above.sql        2009-03-01 23:18:07 UTC (rev 
1038)
@@ -23,8 +23,6 @@
 -- line below.
 
 
-
-
 CREATE TABLE mrbs_area
 (
   id                serial primary key,
@@ -75,3 +73,12 @@
   description text,
   rep_num_weeks smallint DEFAULT 0 NULL
 );
+
+CREATE TABLE mrbs_variables
+(
+  id               serial primary key,
+  variable_name    varchar(80),
+  variable_content text
+);
+INSERT INTO mrbs_variables (variable_name, variable_content)
+  VALUES ('db_version', '1');

Modified: mrbs/trunk/tables.pg.sql
===================================================================
--- mrbs/trunk/tables.pg.sql    2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/tables.pg.sql    2009-03-01 23:18:07 UTC (rev 1038)
@@ -61,3 +61,12 @@
   description text,
   rep_num_weeks smallint DEFAULT NULL NULL
 );
+
+CREATE TABLE mrbs_variables
+(
+  id               serial primary key,
+  variable_name    varchar(80),
+  variable_content text
+);
+INSERT INTO mrbs_variables (variable_name, variable_content)
+  VALUES ('db_version', '1');

Modified: mrbs/trunk/web/add.php
===================================================================
--- mrbs/trunk/web/add.php      2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/add.php      2009-03-01 23:18:07 UTC (rev 1038)
@@ -4,9 +4,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 // Get form variables
 $day = get_form_var('day', 'int');

Modified: mrbs/trunk/web/admin.php
===================================================================
--- mrbs/trunk/web/admin.php    2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/admin.php    2009-03-01 23:18:07 UTC (rev 1038)
@@ -4,9 +4,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 // Get form variables
 $day = get_form_var('day', 'int');

Modified: mrbs/trunk/web/config.inc.php
===================================================================
--- mrbs/trunk/web/config.inc.php       2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/config.inc.php       2009-03-01 23:18:07 UTC (rev 1038)
@@ -586,13 +586,4 @@
 // Make sure notice errors are not reported, they can break mrbs code:
 error_reporting (E_ALL ^ E_NOTICE);
 
-// These variables specify the names of the tables in the database
-// These should not need to be changed.  Please change $db_tbl_prefix
-// in the database section above.
-$tbl_area   = $db_tbl_prefix . "area";
-$tbl_entry  = $db_tbl_prefix . "entry";
-$tbl_repeat = $db_tbl_prefix . "repeat";
-$tbl_room   = $db_tbl_prefix . "room";
-$tbl_users  = $db_tbl_prefix . "users";
-
 ?>

Modified: mrbs/trunk/web/day.php
===================================================================
--- mrbs/trunk/web/day.php      2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/day.php      2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 include "mincals.inc";
 
 // Get form variables

Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc    2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/dbsys.inc    2009-03-01 23:18:07 UTC (rev 1038)
@@ -4,6 +4,20 @@
 
 global $dbsys;
 
+// These variables specify the names of the tables in the database
+global $db_tbl_prefix;
+
+$tbl_area      = $db_tbl_prefix . "area";
+$tbl_entry     = $db_tbl_prefix . "entry";
+$tbl_repeat    = $db_tbl_prefix . "repeat";
+$tbl_room      = $db_tbl_prefix . "room";
+$tbl_users     = $db_tbl_prefix . "users";
+$tbl_variables = $db_tbl_prefix . "variables";
+
+
+$db_schema_version = 1;
+
+
 // Include the abstraction configured to be used for the default MRBS
 // database
 require_once("${dbsys}.inc");
@@ -511,6 +525,28 @@
 }
 
 
+// Check if a table exists - returns TRUE if it exists, FALSE if it doesn't
+function sql_table_exists($table)
+{
+  if (func_num_args() > 1)
+  {
+    $handle = func_get_arg(1);
+    $db_sys = $handle['system'];
+    $db_conn = $handle['connection'];
+  }
+  else
+  {
+    global $dbsys;
+
+    $db_sys = $dbsys;
+    $db_conn = null;
+  }
+
+  $f = "sql_${db_sys}_table_exists";
+  return $f($table, $db_conn);
+}
+
+
 // Connect to a database host and select the supplied database
 function sql_connect($system, $host, $username, $password, $db_name,
                      $persist = 0)
@@ -532,3 +568,43 @@
 
 $f = "sql_${dbsys}_default_connect";
 $f();
+
+// Default version is 0, before we had schema versions
+$current_db_schema_version = 0;
+
+if (sql_table_exists($tbl_variables))
+{
+  $current_db_schema_version = sql_query1("SELECT variable_content ".
+                                          "FROM $tbl_variables ".
+                                          "WHERE variable_name = 
'db_version'");
+}
+
+if ($current_db_schema_version < $db_schema_version)
+{
+  // Upgrade needed
+
+  include_once "functions.inc";
+  include_once "mrbs_auth.inc";
+
+  print_header(0,0,0,0,"");
+
+  $user = getUserName();
+  if (isset($user) && authGetUserLevel($user))
+  {
+    include "upgrade.inc";
+    upgrade_database($current_db_schema_version, $db_schema_version);
+
+    print get_vocab("upgrade_completed").
+      ". <a href=\"./\">".
+      get_vocab("returncal")."</a>.";
+  }
+  else
+  {
+    print "<div class=\"error\">
+  ".get_vocab("login_for_upgrade").".
+</div>\n";
+    authGet();
+  }
+
+  print_footer(TRUE);
+}

Modified: mrbs/trunk/web/del.php
===================================================================
--- mrbs/trunk/web/del.php      2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/del.php      2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 // Get form variables
 $day = get_form_var('day', 'int');

Modified: mrbs/trunk/web/del_entry.php
===================================================================
--- mrbs/trunk/web/del_entry.php        2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/del_entry.php        2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 include "mrbs_sql.inc";
 
 // Get form variables

Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php   2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/edit_area_room.php   2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 // Get form variables
 $day = get_form_var('day', 'int');

Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php       2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/edit_entry.php       2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once('grab_globals.inc.php');
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 global $twentyfourhour_format;
 

Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php       2009-02-27 23:22:59 UTC (rev 
1037)
+++ mrbs/trunk/web/edit_entry_handler.php       2009-03-01 23:18:07 UTC (rev 
1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 include "mrbs_sql.inc";
 
 // Get form variables

Modified: mrbs/trunk/web/edit_users.php
===================================================================
--- mrbs/trunk/web/edit_users.php       2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/edit_users.php       2009-03-01 23:18:07 UTC (rev 1038)
@@ -40,9 +40,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 // Get form variables
 $day = get_form_var('day', 'int');

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/functions.inc        2009-03-01 23:18:07 UTC (rev 1038)
@@ -20,12 +20,20 @@
 }
 
 
+$done_header = FALSE;
+
+
 // Print the page header
 function print_header($day, $month, $year, $area, $room)
 {
-  global $mrbs_company, $mrbs_company_logo, $mrbs_company_url, 
$mrbs_company_more_info,
-    $search_str, $locale_warning, $unicode_encoding, $vocab;
+  global $mrbs_ecompany, $mrbs_company_logo, $mrbs_company_url, 
$mrbs_company_more_info,
+    $search_str, $locale_warning, $unicode_encoding, $vocab, $done_header;
 
+  if ($done_header)
+  {
+    return;
+  }
+
   // If we dont know the right date then make it up 
   if (!$day)
   {
@@ -302,8 +310,26 @@
 </div>
 <?php
 
+  $done_header = TRUE;
+
 } // end of print_header()
 
+
+// Print the standard footer, currently very simple.  Pass $and_exit as
+// TRUE to exit afterwards
+function print_footer($and_exit)
+{
+?>
+</body>
+</html>
+<?php
+  if ($and_exit)
+  {
+    exit(0);
+  }
+}
+
+
 function toTimeString(&$dur, &$units)
 {
   if ($dur >= 60)

Modified: mrbs/trunk/web/help.php
===================================================================
--- mrbs/trunk/web/help.php     2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/help.php     2009-03-01 23:18:07 UTC (rev 1038)
@@ -5,8 +5,8 @@
 require_once "grab_globals.inc.php";
 include "config.inc.php";
 include "dbsys.inc";
-include "mrbs_auth.inc";
-include "functions.inc";
+include_once "mrbs_auth.inc";
+include_once "functions.inc";
 include "version.inc";
 
 // Get form variables

Modified: mrbs/trunk/web/lang.en
===================================================================
--- mrbs/trunk/web/lang.en      2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/lang.en      2009-03-01 23:18:07 UTC (rev 1038)
@@ -129,6 +129,11 @@
 $vocab["login"]              = "Log in";
 $vocab["logoff"]             = "Log Off";
 
+// Database upgrade code
+$vocab["login_for_upgrade"]  = "Please login as an administrator to perform a 
required database upgrade";
+$vocab["upgrade_to_version"] = "Upgrading to database version";
+$vocab["upgrade_completed"]  = "Database upgrade completed";
+
 // User access levels
 $vocab["level_0"]            = "none";
 $vocab["level_1"]            = "user";

Modified: mrbs/trunk/web/month.php
===================================================================
--- mrbs/trunk/web/month.php    2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/month.php    2009-03-01 23:18:07 UTC (rev 1038)
@@ -5,9 +5,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 include "mincals.inc";
 
 // Get form variables

Modified: mrbs/trunk/web/mrbs_auth.inc
===================================================================
--- mrbs/trunk/web/mrbs_auth.inc        2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/mrbs_auth.inc        2009-03-01 23:18:07 UTC (rev 1038)
@@ -8,12 +8,10 @@
   include "session_$auth[session].inc";
 }
 
-/* getAuthorised($user, $pass, $level)
+/* getAuthorised($level)
  * 
- * Check to see if the user name/password is valid
+ * Check to see if the current user has a certain level of rights
  * 
- * $user  - The user name
- * $pass  - The users password
  * $level - The access level required
  * 
  * Returns:

Modified: mrbs/trunk/web/mysql.inc
===================================================================
--- mrbs/trunk/web/mysql.inc    2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/mysql.inc    2009-03-01 23:18:07 UTC (rev 1038)
@@ -313,6 +313,17 @@
 }
 
 
+// Check if a table exists
+function sql_mysql_table_exists($table, $db_conn = null)
+{
+  sql_mysql_ensure_handle($db_conn);
+
+  $res = sql_mysql_query1("SHOW TABLES LIKE '".addslashes($table)."'");
+
+  return ($res == -1) ? FALSE : TRUE;
+}
+
+
 // Connect to a database server and select a database, optionally using
 // persistent connections
 function sql_mysql_connect($host, $username, $password, $db_name, $persist = 0)

Modified: mrbs/trunk/web/mysqli.inc
===================================================================
--- mrbs/trunk/web/mysqli.inc   2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/mysqli.inc   2009-03-01 23:18:07 UTC (rev 1038)
@@ -342,6 +342,17 @@
 }
 
 
+// Check if a table exists
+function sql_mysqli_table_exists($table, $db_conn = null)
+{
+  sql_mysqli_ensure_handle($db_conn);
+
+  $res = sql_mysqli_query1("SHOW TABLES LIKE '".addslashes($table)."'");
+
+  return ($res == -1) ? FALSE : TRUE;
+}
+
+
 // Connect to a database server and select a database, optionally using
 // persistent connections
 function sql_mysqli_connect($host, $username, $password,

Modified: mrbs/trunk/web/pgsql.inc
===================================================================
--- mrbs/trunk/web/pgsql.inc    2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/pgsql.inc    2009-03-01 23:18:07 UTC (rev 1038)
@@ -348,6 +348,20 @@
 }
 
 
+// Check if a table exists
+function sql_pgsql_table_exists($table, $db_conn = null)
+{
+  sql_pgsql_ensure_handle($db_conn);
+
+  $res = sql_pgsql_query1("SELECT table_name FROM information_schema.tables ".
+                          "WHERE table_schema='public' AND ".
+                          "table_type='BASE TABLE' AND ".
+                          "table_name = '".addslashes($table)."'");
+
+  return ($res == -1) ? FALSE : TRUE;
+}
+
+
 // Connect to a database server and select a database, optionally using
 // persistent connections
 function sql_pgsql_connect($host, $username, $password, $db_name,

Modified: mrbs/trunk/web/report.php
===================================================================
--- mrbs/trunk/web/report.php   2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/report.php   2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 
 function date_time_string($t)

Modified: mrbs/trunk/web/search.php
===================================================================
--- mrbs/trunk/web/search.php   2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/search.php   2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 // Get form variables
 $day = get_form_var('day', 'int');

Added: mrbs/trunk/web/upgrade/1/mysql.sql
===================================================================
--- mrbs/trunk/web/upgrade/1/mysql.sql                          (rev 0)
+++ mrbs/trunk/web/upgrade/1/mysql.sql  2009-03-01 23:18:07 UTC (rev 1038)
@@ -0,0 +1,12 @@
+# $Id$
+
+CREATE TABLE %DB_TBL_PREFIX%variables
+(
+  id               int NOT NULL auto_increment,
+  variable_name    varchar(80),
+  variable_content text,
+      
+  PRIMARY KEY (id)
+);
+INSERT INTO %DB_TBL_PREFIX%variables (variable_name, variable_content)
+  VALUES ( 'db_version', '1');


Property changes on: mrbs/trunk/web/upgrade/1/mysql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: mrbs/trunk/web/upgrade/1/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/1/pgsql.sql                          (rev 0)
+++ mrbs/trunk/web/upgrade/1/pgsql.sql  2009-03-01 23:18:07 UTC (rev 1038)
@@ -0,0 +1,10 @@
+-- $Id$
+
+CREATE TABLE %DB_TBL_PREFIX%variables
+(
+  id               serial primary key,
+  variable_name    varchar(80),
+  variable_content text
+);
+INSERT INTO %DB_TBL_PREFIX%variables (variable_name, variable_content)
+  VALUES ('db_version', '1');


Property changes on: mrbs/trunk/web/upgrade/1/pgsql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: mrbs/trunk/web/upgrade.inc
===================================================================
--- mrbs/trunk/web/upgrade.inc                          (rev 0)
+++ mrbs/trunk/web/upgrade.inc  2009-03-01 23:18:07 UTC (rev 1038)
@@ -0,0 +1,70 @@
+<?php
+
+// $Id$
+
+
+//
+function upgrade_database($from, $to)
+{
+  global $dbsys;
+  global $db_tbl_prefix;
+  global $tbl_variables;
+
+  $sql_type = $dbsys;
+  if ($sql_type == 'mysqli')
+  {
+    $sql_type = 'mysql';
+  }
+    
+  for ($ver = ($from+1); $ver <= $to; $ver++)
+  {
+    print "<p>".get_vocab("upgrade_to_version").": $ver";
+
+    $filename = "upgrade/$ver/$sql_type.sql";
+    $handle = fopen($filename, "r");
+    if (!$handle)
+    {
+      // No need to localise, should never happen!
+      print "Fatal error: Failed to open '$filename' for reading.\n";
+      return;
+    }
+    $sql = fread($handle, filesize($filename));
+    fclose($handle);
+
+    $sql = str_replace('%DB_TBL_PREFIX%', $db_tbl_prefix, $sql);
+
+    foreach (explode(";", $sql) as $command)
+    {
+      // Skip any empty command (so that last semi-colon doesn't run
+      // an empty command)
+      if (preg_match("/\S/", $command))
+      {
+        $res = sql_command($command);
+        if ($res == -1)
+        {
+          // No need to localise, should hopefully never happen
+          print "Tried:<pre>
+".htmlspecialchars($command)."
+</pre> and got error:<pre>
+".sql_error()."
+</pre>\n";
+        }
+      }
+    }
+
+    print "<br>".get_vocab("ok");
+    if ($ver > 1)
+    {
+      $res = sql_command("UPDATE $tbl_variables SET variable_content = '$ver' 
".
+                         "WHERE variable_name = 'db_version'");
+      if ($res == -1)
+      {
+        // No need to localise, should never happen
+        print "<span class=\"error\">Failed to update database version 
variable.</span>";
+      }
+    }
+    print "</p>\n";
+  }
+}
+
+?>


Property changes on: mrbs/trunk/web/upgrade.inc
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: mrbs/trunk/web/view_entry.php
===================================================================
--- mrbs/trunk/web/view_entry.php       2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/view_entry.php       2009-03-01 23:18:07 UTC (rev 1038)
@@ -3,9 +3,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 
 // Get form variables
 $day = get_form_var('day', 'int');

Modified: mrbs/trunk/web/week.php
===================================================================
--- mrbs/trunk/web/week.php     2009-02-27 23:22:59 UTC (rev 1037)
+++ mrbs/trunk/web/week.php     2009-03-01 23:18:07 UTC (rev 1038)
@@ -5,9 +5,9 @@
 
 require_once "grab_globals.inc.php";
 include "config.inc.php";
-include "functions.inc";
+include_once "functions.inc";
 include "dbsys.inc";
-include "mrbs_auth.inc";
+include_once "mrbs_auth.inc";
 include "mincals.inc";
 
 // Get form variables


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to