[ Index ]
 

Code source de dotProject 2.1 RC1

Accédez au Source d'autres logiciels libres | Soutenez Angelica Josefina !

title

Body

[fermer]

/install/ -> check_upgrade.php (source)

   1  <?php
   2  /*
   3  All files in this work, except the modules/ticketsmith directory, are now
   4  covered by the following copyright notice.  The ticketsmith module is
   5  under the Voxel Public License.  See modules/ticketsmith/LICENSE
   6  for details.  Please note that included libraries in the lib directory
   7  may have their own license.
   8  
   9  Copyright (c) 2003-2005 The dotProject Development Team <core-developers@dotproject.net>
  10  
  11      This file is part of dotProject.
  12  
  13      dotProject is free software; you can redistribute it and/or modify
  14      it under the terms of the GNU General Public License as published by
  15      the Free Software Foundation; either version 2 of the License, or
  16      (at your option) any later version.
  17  
  18      dotProject is distributed in the hope that it will be useful,
  19      but WITHOUT ANY WARRANTY; without even the implied warranty of
  20      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21      GNU General Public License for more details.
  22  
  23      You should have received a copy of the GNU General Public License
  24      along with dotProject; if not, write to the Free Software
  25      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  26  
  27  The full text of the GPL is in the COPYING file.
  28  */
  29  
  30  // Check for upgrade or install.  This is a little tricky as there can be a few
  31  // variations on the theme.  In an ideal situation if there is no config.php then
  32  // it is an install, otherwise it is an upgrade, however nothing is ever that
  33  // simple.  The possibilities are:
  34  // 1. A simple install as describe above, no config.php, no database
  35  // 2. Someone has read that it needs a writable config.php so creates an empty one
  36  // 3. Someone has uploaded the dotproject.sql file and then run the installer
  37  // 4. Combination of 2 and 3
  38  // 5. It is an upgrade - there must be a config.php and a database.
  39  
  40  require_once  'install.inc.php';
  41  $baseDir = dirname(dirname(__FILE__));
  42  define('DP_BASE_DIR', $baseDir);
  43  require_once "$baseDir/lib/adodb/adodb.inc.php";
  44  
  45  function dPcheckExistingDB($conf) {
  46      global $AppUI, $ADODB_FETCH_MODE;
  47      $AppUI = new InstallerUI;
  48      
  49      $ado = @NewADOConnection($conf['dbtype'] ? $conf['dbtype'] : 'mysql');
  50      if (empty($ado))
  51          return false;
  52      $db = @$ado->Connect($conf['dbhost'], $conf['dbuser'], $conf['dbpass']);
  53      if (! $db)
  54          return false;
  55      $exists = @$ado->SelectDB($conf['dbname']);
  56      if (! $exists)
  57          return false;
  58  
  59      // Now we make a check to see if the dotproject.sql has been loaded
  60      // prior to the installer being run.  This needs to rely on the
  61      // fact that the GACL tables will exist but will be unpopulated.
  62      // The install procedure populates them - If this situation changes
  63      // then this code must be modified to suit.
  64  
  65      $q1 = 'SELECT count(*) from gacl_phpgacl'; // Should be 2
  66      $q2 = 'SELECT count(*) from gacl_axo'; // Should be greater than the count of modules
  67  
  68      $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
  69  
  70      // Note the sense of this test.  If the tables don't exist, it is by default an
  71      // upgrade (mainly because these only exist in the 2.x and later series). 
  72      // If one exists and is populated (the version information is seeded by the sql file)
  73      // but the other either doesn't exist or is unpopulated, then it is an install as
  74      // the SQL file has been loaded manually.
  75      if (($qid = @$ado->Execute($q1) ) && ($q1Data = @$qid->fetchRow() ) && ! empty($q1Data[0]) ) {
  76          @$qid->Close();
  77          if ( ! ($qid2 = @$ado->Execute($q2) ) || ! ($q2Data = @$qid2->fetchRow() ) || empty($q2Data[0]) ) {
  78              return false;
  79          }
  80          @$qid2->Close();
  81      }
  82  
  83      return true;
  84  }
  85  
  86  function dPcheckUpgrade() {
  87      $mode = 'install';
  88      if (is_file('../includes/config.php')) {
  89          include_once  '../includes/config.php';
  90          if (isset($dPconfig['dbhost'])) {
  91              if (dPcheckExistingDB($dPconfig)) {
  92                  $mode = 'upgrade';
  93              }
  94          }
  95      }
  96      return $mode;
  97  }
  98  ?>


Généré le : Sun Feb 18 19:46:52 2007 par Balluche grâce à PHPXref 0.7