Changeset 1706

Show
Ignore:
Timestamp:
03/20/2008 12:17:53 AM (8 months ago)
Author:
driehle
Message:

Detection of boolean values in settings.inc.php did not work properly.
This Bug caused e.g. mod-rewrite URLs to be deactivated after update to JLog 1.1-dev, even if it was activated till then.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/admin/update.php

    r1700 r1706  
    77   
    88  /** 
    9    * Wir brauchen alle Konstanten aus settings.inc.php, können diese 
    10    * Datei aber nicht inkluden, weil dann ebenfalls prepenc.inc.php 
    11    * eingebunden wÃŒrde - dies darf aber im Update-Script nicht passieren 
    12    *  
    13    * Deshalb lesen wir die Konstanten auf etwas umstÀndlichere Weise 
    14    * von Hand aus der Datei aus 
    15    */ 
    16   $lines = file("..".DIRECTORY_SEPARATOR."personal".DIRECTORY_SEPARATOR."settings.inc.php"); 
    17   $password_hash = ''; 
    18   foreach($lines as $line) { 
    19     if(preg_match("/define\('(JLOG_[A-Z_]+)', ('[^']*'|true|false|\d+)\);/", $line, $result)) { 
    20       switch($result[2]) { 
     9   * In earlier Jlog versions, there used to be an require_once(prepend.inc.php) in 
     10   * the settings.inc.php. Therefore, we need to check against this inclusion, as 
     11   * we MUST NOT include prepend.inc.php. 
     12   */ 
     13  $config = file_get_contents('..'.DIRECTORY_SEPARATOR.'personal'.DIRECTORY_SEPARATOR.'settings.inc.php'); 
     14  if(strpos($config, 'require_once') !== false) { 
     15    // there is require_once in settings.inc.php, so we need to parse that file manually 
     16    preg_match_all("/define\('(JLOG_[A-Z_]+)', ('[^']*'|true|false|\d+)\);/", $config, $result, PREG_SET_ORDER); 
     17    // only finds constants that start with JLOG_ and have a boolean, numeric or single-quoted value 
     18    foreach($result as $constant) { 
     19      switch($constant[2]) { 
    2120        case 'true': 
     21          $value = true; 
     22          break; 
    2223        case 'false': 
    23           $value = $result[2]
     24          $value = false
    2425          break; 
    2526        default: 
    26           if(is_numeric($result[2])) { 
    27             $value = (int) $result[2]; 
     27          if(is_numeric($constant[2])) { 
     28            $value = (int) $constant[2]; 
    2829          } 
    2930          else { 
    30             $value = stripslashes(substr($result[2], 1, -1)); 
     31            $value = stripslashes(substr($constant[2], 1, -1)); 
    3132          } 
    3233          break; 
    3334      } 
    34       define($result[1], $value); 
    35     } 
    36   } 
    37   define("JLOG_VERSION", '1.1.0'); 
     35      define($constant[1], $value); 
     36    } 
     37  } 
     38  else { 
     39    // there is no require_once in settings.inc.php, so we can simply include it 
     40    require_once('..'.DIRECTORY_SEPARATOR.'personal'.DIRECTORY_SEPARATOR.'settings.inc.php'); 
     41  } 
     42   
     43  // define table names 
    3844  define("JLOG_DB_CONTENT", JLOG_DB_PREFIX."content"); 
    3945  define("JLOG_DB_COMMENTS", JLOG_DB_PREFIX."comments"); 
     
    4248  define("JLOG_DB_ATTRIBUTES", JLOG_DB_PREFIX."attributes"); 
    4349   
    44   /** 
    45    * Die Konstante JLOG_LANGUAGE wurde mit Jlog 1.1.0 neu eingefÃŒhrt, 
    46    * folglich wurde das Update-Script auf 1.1.0 bereits ausgefÃŒhrt, wenn 
    47    * diese Konstante existiert. 
    48    */ 
    49   if(defined('JLOG_LANGUAGE')) { 
    50     die('Das Update-Script kann nur einmal ausgefÃŒhrt werden.'); 
     50  // get version information 
     51  require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'version.inc.php'); 
     52   
     53  /** 
     54   * If there is no version information available we think of the installation 
     55   * as of Jlog 1.0.2, which means that it will be impossible to update from any 
     56   * version earlier as 1.0.2 to this version - you MUST upgrade to 1.0.2 before 
     57   * you can install this version of Jlog. 
     58   */ 
     59  if(!defined('JLOG_INSTALLED_VERSION')) { 
     60    define('JLOG_INSTALLED_VERSION', '1.0.2'); 
     61  } 
     62  /** 
     63   * If we are already at the version we want to upgrade to this means that the 
     64   * upgrade script did already do its job. 
     65   */ 
     66  if(version_compare(JLOG_SOFTWARE_VERSION, JLOG_INSTALLED_VERSION, '==')) { 
     67    header('Content-Type: text/plain'); 
     68    echo 'The update script must only be runend once.' . "\n"; 
     69    echo 'Das Update-Skript darf nur einmal ausgefÃŒhrt werden.'; 
     70    exit; 
    5171  } 
    5272   
     
    5676   * nicht funktioniert. 
    5777   */ 
    58   require(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'version.inc.php'); 
    5978  require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang.inc.php'); 
    6079  require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang-admin.inc.php'); 
     
    87106  // Seitenaufbau 
    88107  $c['meta']['title'] = "Update"; 
    89   $c['main'] = "<h2>Update von <var>1.0.2</var> auf <var>1.1.0</var></h2>"
     108  $c['main'] = sprintf("<h2>Update von <var>%s</var> auf <var>%s</var></h2>", JLOG_INSTALLED_VERSION, JLOG_SOFTWARE_VERSION)
    90109  
    91110  if(!isset($_POST['update'])) { 
  • trunk/scripts/settings.class.php

    r1701 r1706  
    305305        // bolean 
    306306        if($key == 'JLOG_CLEAN_URL' OR $key == 'JLOG_INFO_BY_COMMENT') { 
    307             if($value == 'true') $value = "true"; 
     307            if($value == 'true' OR $value === true) $value = "true"; 
    308308            else $value = "false"; 
    309309        }