[geeklog-cvs] Geeklog-1.x/public_html/admin/install index.php, 1.28, 1.29

Dirk Haun dhaun at qs1489.pair.com
Mon Dec 31 10:24:18 EST 2007


Update of /cvsroot/geeklog/Geeklog-1.x/public_html/admin/install
In directory qs1489.pair.com:/tmp/cvs-serv43158

Modified Files:
	index.php 
Log Message:
Catch attempts to upgrade an empty database; fixed language selection (may be overridden by the presence of a language cookie); moved a hard-coded English text to the language files.


Index: index.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/admin/install/index.php,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** index.php	30 Dec 2007 21:11:32 -0000	1.28
--- index.php	31 Dec 2007 15:24:15 -0000	1.29
***************
*** 372,375 ****
--- 372,378 ----
                                  $display .= '<h2>' . $LANG_INSTALL[74] . '</h2>' . LB
                                            . '<p>' . $LANG_INSTALL[75] . '</p>';
+                             } elseif ($curv == 'empty') {
+                                 $display .= '<h2>' . $LANG_INSTALL[90] . '</h2>' . LB
+                                           . '<p>' . $LANG_INSTALL[91] . '</p>';
                              } else {
  
***************
*** 384,388 ****
                                          <input type="hidden" name="step" value="3"' . XHTML . '>
                                          <input type="hidden" name="dbconfig_path" value="' . $dbconfig_path . '"' . XHTML . '>
!                                         <p><label>Current Version:</label> <select name="version">';
                                      $tmp_counter = 0;
                                      $ver_selected = '';
--- 387,391 ----
                                          <input type="hidden" name="step" value="3"' . XHTML . '>
                                          <input type="hidden" name="dbconfig_path" value="' . $dbconfig_path . '"' . XHTML . '>
!                                         <p><label>' . $LANG_INSTALL[89] . '</label> <select name="version">';
                                      $tmp_counter = 0;
                                      $ver_selected = '';
***************
*** 701,705 ****
      global $_TABLES, $_DB, $_DB_dbms, $dbconfig_path, $siteconfig_path;
  
!     $_DB->setDisplayError (true);
  
      // simple tests for the version of the database:
--- 704,708 ----
      global $_TABLES, $_DB, $_DB_dbms, $dbconfig_path, $siteconfig_path;
  
!     $_DB->setDisplayError(true);
  
      // simple tests for the version of the database:
***************
*** 715,760 ****
      switch ($_DB_dbms) {
  
!         case 'mysql':
!             $test = array(
!                 '1.5.0'  => array("DESCRIBE {$_TABLES['storysubmission']} bodytext",''),
!                 '1.4.1'  => array("SELECT ft_name FROM {$_TABLES['features']} WHERE ft_name = 'syndication.edit'", 'syndication.edit'),
!                 '1.4.0'  => array("DESCRIBE {$_TABLES['users']} remoteusername",''),
!                 '1.3.11' => array("DESCRIBE {$_TABLES['comments']} sid", 'sid,varchar(40)'),
!                 '1.3.10' => array("DESCRIBE {$_TABLES['comments']} lft",''),
!                 '1.3.9'  => array("DESCRIBE {$_TABLES['syndication']} fid",''),
!                 '1.3.8'  => array("DESCRIBE {$_TABLES['userprefs']} showonline",'')
!                 // It's hard to (reliably) test for 1.3.7 - let's just hope nobody uses
!                 // such an old version any more ...
              );
  
!             break;
! 
!         case 'mssql':
  
  	    $test = array(
!                 '1.5.0'  => array("DESCRIBE {$_TABLES['storysubmission']} bodytext",''),
!                 '1.4.1'  => array("SELECT ft_name FROM {$_TABLES['features']} WHERE ft_name = 'syndication.edit'", 'syndication.edit'),
              );
  
!             break;
  
      }
  
      $version = '';
      foreach ($test as $v => $qarray) {
!         $result = DB_query ($qarray[0], 1);
          if ($result === false) {
  
              // error - continue with next test
!         } else if (DB_numRows ($result) > 0) {
!             $A = DB_fetchArray ($result);
!             if (empty ($qarray[1])) {
                  // test only for existence of field - succeeded
                  $version = $v;
                  break;
              } else {
!                 if (substr ($qarray[0], 0, 6) == 'SELECT') {
                      // text for a certain value
!                     if($A[0] == $qarray[1]) {
                          $version = $v;
                          break;
--- 718,773 ----
      switch ($_DB_dbms) {
  
!     case 'mysql':
!         $test = array(
!             '1.5.0'  => array("DESCRIBE {$_TABLES['storysubmission']} bodytext",''),
!             '1.4.1'  => array("SELECT ft_name FROM {$_TABLES['features']} WHERE ft_name = 'syndication.edit'", 'syndication.edit'),
!             '1.4.0'  => array("DESCRIBE {$_TABLES['users']} remoteusername",''),
!             '1.3.11' => array("DESCRIBE {$_TABLES['comments']} sid", 'sid,varchar(40)'),
!             '1.3.10' => array("DESCRIBE {$_TABLES['comments']} lft",''),
!             '1.3.9'  => array("DESCRIBE {$_TABLES['syndication']} fid",''),
!             '1.3.8'  => array("DESCRIBE {$_TABLES['userprefs']} showonline",'')
!             // It's hard to (reliably) test for 1.3.7 - let's just hope
!             // nobody uses such an old version any more ...
              );
  
!         break;
  
+     case 'mssql':
  	    $test = array(
!             '1.5.0'  => array("DESCRIBE {$_TABLES['storysubmission']} bodytext",''),
!             '1.4.1'  => array("SELECT ft_name FROM {$_TABLES['features']} WHERE ft_name = 'syndication.edit'", 'syndication.edit')
!             // 1.4.1 was the first version with MS SQL support
              );
  
!         break;
  
      }
  
      $version = '';
+ 
+     $result = DB_query("DESCRIBE {$_TABLES['access']} acc_ft_id", 1);
+     if ($result === false) {
+         // A check for the first field in the first table failed?
+         // Sounds suspiciously like an empty table ...
+ 
+         return 'empty';
+     }
+ 
      foreach ($test as $v => $qarray) {
!         $result = DB_query($qarray[0], 1);
          if ($result === false) {
  
              // error - continue with next test
! 
!         } else if (DB_numRows($result) > 0) {
!             $A = DB_fetchArray($result);
!             if (empty($qarray[1])) {
                  // test only for existence of field - succeeded
                  $version = $v;
                  break;
              } else {
!                 if (substr($qarray[0], 0, 6) == 'SELECT') {
                      // text for a certain value
!                     if ($A[0] == $qarray[1]) {
                          $version = $v;
                          break;
***************
*** 762,766 ****
                  } else {
                      // test for certain type of field
!                     $tst = explode (',', $qarray[1]);
                      if (($A['Field'] == $tst[0]) && ($A['Type'] == $tst[1])) {
                          $version = $v;
--- 775,779 ----
                  } else {
                      // test for certain type of field
!                     $tst = explode(',', $qarray[1]);
                      if (($A['Field'] == $tst[0]) && ($A['Type'] == $tst[1])) {
                          $version = $v;
***************
*** 771,774 ****
--- 784,788 ----
          }
      }
+ 
      return $version;
  }
***************
*** 1395,1400 ****
  
  $language = 'english';
! if (isset($_REQUEST['language'])) {
!     $lng = $_REQUEST['language'];
  } else if (isset($_COOKIE['language'])) {
      // Okay, so the name of the language cookie is configurable, so it may not
--- 1409,1416 ----
  
  $language = 'english';
! if (isset($_POST['language'])) {
!     $lng = $_POST['language'];
! } elseif (isset($_GET['language'])) {
!     $lng = $_GET['language'];
  } else if (isset($_COOKIE['language'])) {
      // Okay, so the name of the language cookie is configurable, so it may not
***************
*** 1413,1417 ****
  
  // $display holds all the outputted HTML and content
! if ( defined( 'XHTML' ) ) {
  	$display = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
--- 1429,1433 ----
  
  // $display holds all the outputted HTML and content
! if (defined('XHTML')) {
  	$display = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';




More information about the geeklog-cvs mailing list