[ PHPXref.com ] [ Generated: Sun Jul 20 20:26:56 2008 ] [ Streber pm 0.052 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/std/ -> check_version.inc (source)

   1  <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit;}
   2  /**

   3  * check the current version of php, mysql and streber

   4  *

   5  * this prevents from mysql-exceptions provides propper error-messages

   6  *

   7  */
   8  
   9  
  10  
  11  /**

  12  * do some checks before doing anything serious 

  13  * 

  14  * This file is assumed to be php4 valid.

  15  */
  16  function validateEnvironment() 
  17  {
  18      
  19      $flag_errors= false;
  20      if(($result= testPhpVersion()) !== true) {
  21          
  22          echo confGet('MESSAGE_OFFLINE');
  23          echo $result;
  24          exit;
  25      }
  26      
  27      
  28      if(($result= testDbConnection()) !== true) {
  29          echo confGet('MESSAGE_OFFLINE');
  30          echo $result;
  31          exit;
  32      }
  33  
  34      #if(($result= testInstallDirectoryExists()) != true) {

  35      #    echo $result;

  36      #    $flag_errors= true;

  37      #}

  38  
  39  
  40      
  41      if($flag_errors){
  42          return false;
  43      }
  44      return true;
  45  }
  46      
  47      
  48      
  49      
  50  /**

  51  * check propper php-version

  52  */
  53  function testPhpVersion() {
  54      $version=phpversion();
  55      if($version < confGet('PHP_VERSION_REQUIRED')) {
  56          $buffer=
  57          "<h1>Problem</h1>"
  58          ."streber requires php version ".confGet('PHP_VERSION_REQUIRED'). ' to work.<br>'
  59          ."current version is '$version' <br>"
  60          ."Read more about the minimal requirements of streber:"
  61          .'<ul>'
  62          .'<li><a href="http://streber.sourceforge.net">streber</a>'
  63          .'<li><a href="http://wiki.pixtur.de/index.php/Installation">wiki / installation guide"</a>'
  64          .'</ul>';
  65          return $buffer;        
  66      }
  67      return true;
  68  }
  69      
  70  
  71  /**

  72  * is db online?

  73  */
  74  function testDbConnection() {
  75      require_once(dirname(__FILE__)."/../db/db.inc");
  76      $db= new DB_Mysql();
  77      if($db=$db->getVersion()) {
  78          if($db['version'] < confGet('DB_VERSION_REQUIRED')) {
  79              return "the version of current database (". $db['version'] .")does not match the current version of streber (". confGet('STREBER_VERSION'). ")<br><a href='install/install.php'>try upgrading</a>";
  80          }
  81          if($db['version_streber_required'] > confGet('STREBER_VERSION')) {
  82              return "the version of current database (". $db['version'] .") requires at least version ". $db['version_streber_required'] ." of streber to be installed. This is version (". confGet('STREBER_VERSION'). ")";
  83          }
  84      }
  85      else {
  86          return "could not connect to database.";
  87      }
  88      return true;
  89  }
  90  
  91  
  92  /**

  93  * check if install-directory exists...

  94  */
  95  function testInstallDirectoryExists() {
  96      
  97      if(file_exists('install')) {
  98          echo "<h2>Install-directory still present.</h2> This is a massive security issue (<a href='".confGet('STREBER_WIKI_URL')."installation'>read more</a>).";
  99          echo '<ul><li><a href="install/remove_install_dir.php">remove install directory now.</a></ul>';
 100          return false;
 101      }
 102      return true;
 103  }
 104  
 105  


[ Powered by PHPXref - Served by Debian GNU/Linux ]