Changeset 1712

Show
Ignore:
Timestamp:
03/24/2008 06:47:23 PM (8 months ago)
Author:
driehle
Message:

Code Cleanup

Files:

Legend:

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

    r1711 r1712  
    1111  /** 
    1212   * If there is no version information available we think of the installation 
    13    * as of Jlog 1.0.2, which means that it will be impossible to update from any 
    14    * version earlier as 1.0.2 to this version - you MUST upgrade to 1.0.2 before 
     13   * as of Jlog 1.0.2, which means that it will be impossible to upgrade from any 
     14   * version earlier as 1.0.2 - you MUST upgrade to 1.0.2 before 
    1515   * you can install this version of Jlog. 
    1616   */ 
     
    1818    define('JLOG_INSTALLED_VERSION', '1.0.2'); 
    1919  } 
    20   // Seitenaufbau 
     20  // Rendering 
    2121  $c['meta']['title'] = "Update"; 
    2222  $c['main'] = sprintf("<h2>Update von <var>%s</var> auf <var>%s</var></h2>", JLOG_INSTALLED_VERSION, JLOG_SOFTWARE_VERSION); 
     
    3030  } else { 
    3131 
    32         // VerfÃŒgbare Sprachen auslesen 
     32        // get list of available languages 
    3333        $dir = opendir(JLOG_BASEPATH.'lang'); 
    3434        $languages = array(); 
     
    3838          $languages[] = $matches[1]; 
    3939        } 
    40         // bisherige Sprache herausfinden 
     40        // detect current language 
    4141        include(JLOG_BASEPATH."lang".DIRECTORY_SEPARATOR."lang.inc.php"); 
    4242        list($old_language) = explode("-", $l["language"]); 
     
    5656          $c['main'] .= "</select> 
    5757             </p> 
    58                  <p>Die Datei <code>personal/template.tpl</code> muss nach UTF-8 konvertiert werden. Wenn diese Datei 
    59                     beschreibbar ist (z.B.: chmod 777), wird dies vom Updatescript fÃŒr sie automatisch erledigt. 
    60                     Ansonsten mÃŒssen Sie es im nachhinein manuell erledigen.</p> 
     58                 <p>Die Zeichenkodierung ihrer Template-Datei <code>personal/template.tpl</code> muss nach UTF-8 umgewandelt werden. Wenn diese Datei 
     59                    beschreibbar ist (z.B.: chmod 777), wird dies vom Updatescript automatisch fÃŒr sie erledigt. 
     60                    Andernfalls mÃŒssen Sie die Konvertierung nachtrÀglich manuell vornehmen.</p> 
    6161             <p><input type='submit' name='update' value='Update starten' /></p> 
    6262             </form>"; 
     
    6464        else { 
    6565          /** 
    66            * Das alte Passwort ist anders kodiert (vorher ISO, jetzt UTF-8), deshalb 
    67            * testen wir verschiedene Varianten des Passwortes 
     66           * The hash of the administrator password is the hash of an ISO-encoded 
     67           * password, which is different from the hash of the same password encoded 
     68           * in UTF-8. Therefore, we have to convert the received password to ISO first, 
     69           * before we can run md5(). 
    6870           */ 
    69           $pass1 = md5($_POST['password']);              # Idealfall 
    70           $pass2 = md5(utf8_decode($_POST['password'])); # wahrscheinlichster Fall, wenn Jlog 1.0.2 vorher installiert war 
    71           $pass3 = md5(utf8_encode($_POST['password'])); # sollte in der RealitÀt eigentlich nie in der Form vorkommen 
    72  
     71          $pass1 = md5($_POST['password']);              # This is how it should look in  
     72                                                         # Jlog 1.1.0 
     73          $pass2 = md5(utf8_decode($_POST['password'])); # This is what we need to do for  
     74                                                         # Jlog 1.0.2 password 
     75          $pass3 = md5(utf8_encode($_POST['password'])); # actually this should not happen, 
     76                                                         # but better try this as well, as we 
     77                                                         # don't know how the end-user's  
     78                                                         # system looks like 
     79           
    7380          /** 
    74            * Formulareingaben validieren 
     81           * validate form data 
    7582           */ 
    7683          if(JLOG_ADMIN_PASSWORD != $pass1 AND JLOG_ADMIN_PASSWORD != $pass2 AND JLOG_ADMIN_PASSWORD != $pass3) { 
     
    8188            require(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."settings.class.php"); 
    8289    
    83             // aktuelle Einstellungen aus Environment und User-Input auslesen 
     90            // read current settings from environment and POSTed data 
    8491            $update = new Settings($l); 
    8592            $update->get_data(); 
    8693            $update->get_userdata(); 
    8794    
    88             // alle Werte nach UTF-8 umkodieren 
     95            // convert all settings to utf8 
    8996            foreach($update->d as $key => $value) { 
    9097              $update->d[$key] = utf8_encode($value); 
    9198            } 
    9299    
    93             // Passwort-Hash neu setzen, falls wegen neuer Kodierung nicht mehr korrekt 
     100            // reset hash of the administrator password (reasons, see above) 
    94101            $update->d['jlog_admin_password'] = $pass1; 
    95102    
    96             // Sprache speichern 
     103            // store chosen language 
    97104            $update->d['jlog_language'] = $_POST['jlog_language']; 
    98105    
    99             // settings.inc.php neu schreiben 
     106            // rewrite settings.inc.php 
    100107            $update_errors = $update->do_settings(); 
    101108          
    102109            /** 
    103              * Das Template von Jlog sollte als ISO abgespeichert sein bei Jlog 1.0.2, 
    104              * fÃŒr Jlog 1.1.0 muss es allerdings als UTF-8 abgespeichert werden, dies 
    105              * geschieht hier. 
     110             * On a correct Jlog 1.0.2 installation, the template is saved with an ISO 
     111             * encoding, so we're going to try to convert this to UTF-8 
    106112             */ 
    107113            $template = JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."template.tpl"; 
     
    110116            } 
    111117 
    112             // Fertig :-) 
     118            // Ready :-) 
    113119            require(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."update.php"); 
    114120    
  • trunk/index.php

    r1707 r1712  
    22 
    33/** 
     4 * Jlog 
     5 *  
     6 * This program is free software; you can redistribute it and/or modify 
     7 * it under the terms of the GNU General Public License as published by 
     8 * the Free Software Foundation; either version 2 of the License, or 
     9 * (at your option) any later version. 
     10 *  
     11 * This program is distributed in the hope that it will be useful, 
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     14 * GNU General Public License for more details. 
     15 *  
     16 * You should have received a copy of the GNU General Public License 
     17 * along with this program; if not, write to the Free Software 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     19 *  
    420 * $HeadURL$ 
    521 * $Rev$ 
  • trunk/scripts/prepend.inc.php

    • Property svn:keywords set to HeadURL Rev Author Date
    r1711 r1712  
    11<?php 
     2 
     3/** 
     4 * Jlog 
     5 *  
     6 * This program is free software; you can redistribute it and/or modify 
     7 * it under the terms of the GNU General Public License as published by 
     8 * the Free Software Foundation; either version 2 of the License, or 
     9 * (at your option) any later version. 
     10 *  
     11 * This program is distributed in the hope that it will be useful, 
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     14 * GNU General Public License for more details. 
     15 *  
     16 * You should have received a copy of the GNU General Public License 
     17 * along with this program; if not, write to the Free Software 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     19 *  
     20 * $HeadURL$ 
     21 * $Rev$ 
     22 * $Author$ 
     23 * $Date$ 
     24 */ 
    225 
    326// load settings and version information 
     
    730  
    831// redirect to update-script if new jlog version was installed 
    9 if((!defined('JLOG_INSTALLED_VERSION') OR version_compare(JLOG_INSTALLED_VERSION, JLOG_SOFTWARE_VERSION, '<')) 
    10         AND "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"] != JLOG_PATH."/admin/update.php") { 
    11  
    12         header("Location: ".JLOG_PATH."/admin/update.php"); 
     32if((!defined('JLOG_INSTALLED_VERSION') 
     33  OR version_compare(JLOG_INSTALLED_VERSION, JLOG_SOFTWARE_VERSION, '<')) 
     34        AND substr($_SERVER['SCRIPT_FILENAME'], -17) !== '/admin/update.php') 
     35
     36        header('Location: ' . JLOG_PATH . '/admin/update.php'); 
    1337        exit; 
    1438} 
     
    5983    
    6084// eof 
    61 ?> 
  • trunk/scripts/settings.class.php

    • Property svn:keywords set to HeadURL Rev Author Date
    r1706 r1712  
    11<?php 
    2 /* settings Class for the Jlog setup.php and change settings in /admin/settings.php 
    3    It needs the $l(anguage) array  
    4 */ 
    5  
     2 
     3/** 
     4 * Jlog 
     5 *  
     6 * This program is free software; you can redistribute it and/or modify 
     7 * it under the terms of the GNU General Public License as published by 
     8 * the Free Software Foundation; either version 2 of the License, or 
     9 * (at your option) any later version. 
     10 *  
     11 * This program is distributed in the hope that it will be useful, 
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     14 * GNU General Public License for more details. 
     15 *  
     16 * You should have received a copy of the GNU General Public License 
     17 * along with this program; if not, write to the Free Software 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     19 *  
     20 * $HeadURL$ 
     21 * $Rev$ 
     22 * $Author$ 
     23 * $Date$ 
     24 */ 
     25 
     26/** 
     27 * Settings class 
     28 *  
     29 * This class represents the current settings for Jlog and 
     30 * offers the possibility to modify these settings based on 
     31 * user's input. The configuration can be saved to disk, 
     32 * if wanted. 
     33 *  
     34 * @category  Jlog 
     35 * @package   Jlog_Settings 
     36 * @license   GNU General Public License 
     37 * 
     38 */ 
    639class Settings { 
    7      
    8     var $d = array(); 
    9      
    10     function Settings($l) { 
    11      # no return 
    12      
    13      // get the language array $l and put it into the class 
    14      $this->l = $l; 
    15     } 
    16  
    17     function put_data($what = false) { 
    18         if($what === false) return $this->d; 
    19         else return $this->d[$what]; 
    20     } 
    21  
    22     function get_data() { 
    23      # no return 
    24      // this is a blacklist of constats which are not to be written in settings.inc.php 
    25      $search = array(   'JLOG_ADMIN', 
    26                         'JLOG_DB_CONTENT', 
    27                         'JLOG_DB_COMMENTS', 
    28                         'JLOG_DB_CATASSIGN', 
    29                         'JLOG_DB_CATEGORIES', 
    30                         'JLOG_DB_ATTRIBUTES', 
    31                         'JLOG_UPDATE', 
    32                         'JLOG_VERSION', 
    33                         'JLOG_LOGIN', 
    34                         'JLOG_SOFTWARE_VERSION', 
    35                         'JLOG_SOFTWARE_URL', 
    36                         'JLOG_SOFTWARE_PHPV', 
    37                         'JLOG_SOFTWARE_MYSQLV', 
    38                         'JLOG_ADMIN_PASSWORD_AGAIN' 
    39                      ); 
    40      
    41      // get all needed constants and put it into the class 
    42      $constants = get_defined_constants(); 
    43      foreach($constants as $key => $value) { 
     40 
     41  /** 
     42   * Assoziative array holding configuration options 
     43   * 
     44   * @access private 
     45   * @var array 
     46   */ 
     47  var $d = array(); 
     48 
     49  /** 
     50   * Assoziative array holding translations according 
     51   * to the current language. 
     52   * 
     53   * @access private 
     54   * @var array 
     55   */ 
     56  var $l = array(); 
     57 
     58  /** 
     59   * Settings() - class constructor 
     60   * 
     61   * @access public 
     62   * @param array $l 
     63   * @return void 
     64   */ 
     65  function Settings($l) { 
     66    // get the language array $l and put it into the class 
     67    $this->l = $l; 
     68  } 
     69 
     70  /** 
     71   * put_data() - reads configuration data 
     72   *  
     73   * This procedure returns the value for then configuration option 
     74   * specified by $key or an array of all options if $key is not 
     75   * specified or false 
     76   * 
     77   * @access public 
     78   * @param string|boolean $key 
     79   * @return mixed 
     80   */ 
     81  function put_data($key = false) { 
     82    if($key === false) return $this->d; 
     83    else return $this->d[$key]; 
     84  } 
     85 
     86  /** 
     87   * Enter description here... 
     88   * 
     89   * @access public 
     90   * @return void 
     91   */ 
     92  function get_data() { 
     93    # no return 
     94    // this is a blacklist of constats which are not to be written in settings.inc.php 
     95    $search = array( 
     96      'JLOG_ADMIN', 
     97      'JLOG_DB_CONTENT', 
     98      'JLOG_DB_COMMENTS', 
     99      'JLOG_DB_CATASSIGN', 
     100      'JLOG_DB_CATEGORIES', 
     101      'JLOG_DB_ATTRIBUTES', 
     102      'JLOG_UPDATE', 
     103      'JLOG_VERSION', 
     104      'JLOG_LOGIN', 
     105      'JLOG_SOFTWARE_VERSION', 
     106      'JLOG_SOFTWARE_URL', 
     107      'JLOG_SOFTWARE_PHPV', 
     108      'JLOG_SOFTWARE_MYSQLV', 
     109      'JLOG_ADMIN_PASSWORD_AGAIN' 
     110    ); 
     111 
     112    // get all needed constants and put it into the class 
     113    $constants = get_defined_constants(); 
     114    foreach($constants as $key => $value) { 
    44115      if(!in_array($key, $search) AND strpos($key, "JLOG_") !== false) { 
    45        $key = strtolower($key); 
    46        $this->d[$key] = stripslashes($value); 
     116        $key = strtolower($key); 
     117        $this->d[$key] = stripslashes($value); 
    47118      } 
    48      } 
    49     } 
    50      
    51     function get_userdata($d = false, $exclusiv = false) { 
    52     # no return 
    53      
    54      // get the data from users $d array and put it into the class 
    55       if($d !== false) { 
    56         if($exclusiv) $this->d = $d; 
    57         else $this->d = array_merge($this->d, $d); 
    58       } 
    59        
    60       if(JLOG_ADMIN === true) { 
    61         $this->d['jlog_db'] = JLOG_DB; 
    62         $this->d['jlog_db_url'] = JLOG_DB_URL; 
    63         $this->d['jlog_db_user'] = JLOG_DB_USER; 
    64         $this->d['jlog_db_pwd'] = JLOG_DB_PWD; 
    65         $this->d['jlog_db_prefix'] = JLOG_DB_PREFIX; 
    66         $this->d['jlog_start_year'] = JLOG_START_YEAR; 
    67         $this->d['jlog_path'] = JLOG_PATH; 
    68         $this->d['jlog_basepath'] = JLOG_BASEPATH; 
    69         if($this->d['jlog_admin_password'] == '') $this->jlog_admin_password = JLOG_ADMIN_PASSWORD; 
    70         else { 
    71           $this->d['jlog_admin_password'] = md5($this->d['jlog_admin_password']); 
    72           $this->d['jlog_admin_password_again'] = md5($this->d['jlog_admin_password_again']); 
    73         } 
    74         $this->d['jlog_installed_version'] = JLOG_INSTALLED_VERSION; 
    75         $this->d['jlog_installed_url'] = JLOG_INSTALLED_URL; 
    76         $this->d['jlog_installed_phpv'] = JLOG_INSTALLED_PHPV; 
    77         $this->d['jlog_installed_mysqlv'] = JLOG_INSTALLED_MYSQLV; 
     119    } 
     120  } 
     121 
     122  /** 
     123   * get_userdata() - sets configuration data 
     124   *  
     125   * Sets configuration data according to $d. If working in 
     126   * non-exclusive mode (the default), $d is merged into the current  
     127   * configuration, otherwise the current configuration is discared 
     128   * and $d is set as the new configuration. 
     129   * 
     130   * @access public 
     131   * @param array $d 
     132   * @param boolean $exclusiv 
     133   * @return void 
     134   */ 
     135  function get_userdata($d = false, $exclusiv = false) { 
     136 
     137    // get the data from users $d array and put it into the class 
     138    if($d !== false) { 
     139      if($exclusiv) $this->d = $d; 
     140      else $this->d = array_merge($this->d, $d); 
     141    } 
     142 
     143    if(JLOG_ADMIN === true) { 
     144      $this->d['jlog_db'] = JLOG_DB; 
     145      $this->d['jlog_db_url'] = JLOG_DB_URL; 
     146      $this->d['jlog_db_user'] = JLOG_DB_USER; 
     147      $this->d['jlog_db_pwd'] = JLOG_DB_PWD; 
     148      $this->d['jlog_db_prefix'] = JLOG_DB_PREFIX; 
     149      $this->d['jlog_start_year'] = JLOG_START_YEAR; 
     150      $this->d['jlog_path'] = JLOG_PATH; 
     151      $this->d['jlog_basepath'] = JLOG_BASEPATH; 
     152      if($this->d['jlog_admin_password'] == '') { 
     153        $this->jlog_admin_password = JLOG_ADMIN_PASSWORD; 
    78154      } 
    79155      else { 
     
    81157        $this->d['jlog_admin_password_again'] = md5($this->d['jlog_admin_password_again']); 
    82158      } 
    83        
    84       if((defined('JLOG_SETUP') AND JLOG_SETUP === true) OR (defined('JLOG_UPDATE') AND JLOG_UPDATE === true)) { 
    85         $this->d['jlog_installed_version'] = JLOG_SOFTWARE_VERSION; 
    86         $this->d['jlog_installed_url'] = JLOG_SOFTWARE_URL; 
    87         $this->d['jlog_installed_phpv'] = JLOG_SOFTWARE_PHPV; 
    88         $this->d['jlog_installed_mysqlv'] = JLOG_SOFTWARE_MYSQLV; 
    89       } 
    90     } 
    91      
    92     function get_sugestiondata() { 
    93      # no return 
    94      
    95      // suggest some data for setup 
    96      $this->d['jlog_path'] = dirname("http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]); 
    97      $this->d['jlog_basepath'] = dirname(dirname( __FILE__ )).DIRECTORY_SEPARATOR; 
    98      $date = getdate(); 
    99      $this->d['jlog_start_year'] = $date['year']; 
    100      $this->d['jlog_max_blog_orginal'] = 1; 
    101      $this->d['jlog_max_blog_big'] = 4; 
    102      $this->d['jlog_max_blog_small'] = 15; 
    103      $this->d['jlog_sub_current'] = 6; 
    104      $this->d['jlog_date'] = $this->l['date_format']; 
    105      $this->d['jlog_date_comment'] = $this->l['date_format_comment']; 
    106      $this->d['jlog_date_subcurrent'] = $this->l['date_format_subcurrent']; 
    107      $this->d['jlog_info_by_comment'] = '1'; 
    108      $this->d['jlog_db_url'] = "localhost"; 
    109      $this->d['jlog_db_prefix'] = "jlog_"; 
    110      $this->d['jlog_blogservices'] = "http://rpc.pingomatic.com/"; 
    111      $this->d['jlog_language'] = JLOG_LANGUAGE; 
    112     } 
    113      
    114     function get_value($array, $key, $default = "") { 
    115     # Return value of entry $key in $array if exists 
    116     # or return $default otherwise 
    117       if(isset($array[$key])) { 
    118         return $array[$key]; 
    119       } 
    120       else { 
    121         return $default; 
    122       } 
    123     } 
    124      
    125     function form_output() { 
     159      $this->d['jlog_installed_version'] = JLOG_INSTALLED_VERSION; 
     160      $this->d['jlog_installed_url'] = JLOG_INSTALLED_URL; 
     161      $this->d['jlog_installed_phpv'] = JLOG_INSTALLED_PHPV; 
     162      $this->d['jlog_installed_mysqlv'] = JLOG_INSTALLED_MYSQLV; 
     163    } 
     164    else { 
     165      $this->d['jlog_admin_password'] = md5($this->d['jlog_admin_password']); 
     166      $this->d['jlog_admin_password_again'] = md5($this->d['jlog_admin_password_again']); 
     167    } 
     168 
     169    if((defined('JLOG_SETUP') AND JLOG_SETUP === true)  
     170    OR (defined('JLOG_UPDATE') AND JLOG_UPDATE === true))  
     171    { 
     172      $this->d['jlog_installed_version'] = JLOG_SOFTWARE_VERSION; 
     173      $this->d['jlog_installed_url'] = JLOG_SOFTWARE_URL; 
     174      $this->d['jlog_installed_phpv'] = JLOG_SOFTWARE_PHPV; 
     175      $this->d['jlog_installed_mysqlv'] = JLOG_SOFTWARE_MYSQLV; 
     176    } 
     177  } 
     178 
     179  /** 
     180   * get_suggestiondata() - preallocates configuration data 
     181   *  
     182   * Initialises the configuration with useful settings during 
     183   * the installation process. 
     184   *  
     185   * @access public 
     186   * @return void 
     187   */ 
     188  function get_sugestiondata() { 
     189 
     190    // suggest some data for setup 
     191    $this->d['jlog_path'] = $this->get_suggest_path(); 
     192    $this->d['jlog_basepath'] = dirname(dirname( __FILE__ )).DIRECTORY_SEPARATOR; 
     193    $date = getdate(); 
     194    $this->d['jlog_start_year'] = $date['year']; 
     195    $this->d['jlog_max_blog_orginal'] = 1; 
     196    $this->d['jlog_max_blog_big'] = 4; 
     197    $this->d['jlog_max_blog_small'] = 15; 
     198    $this->d['jlog_sub_current'] = 6; 
     199    $this->d['jlog_date'] = $this->l['date_format']; 
     200    $this->d['jlog_date_comment'] = $this->l['date_format_comment']; 
     201    $this->d['jlog_date_subcurrent'] = $this->l['date_format_subcurrent']; 
     202    $this->d['jlog_info_by_comment'] = '1'; 
     203    $this->d['jlog_db_url'] = 'localhost'; 
     204    $this->d['jlog_db_prefix'] = 'jlog_'; 
     205    $this->d['jlog_blogservices'] = 'http://rpc.pingomatic.com/'; 
     206    $this->d['jlog_language'] = JLOG_LANGUAGE; 
     207  } 
     208 
     209 
     210  /** 
     211   * get_suggest_path() - generate a suggestion for JLOG_PATH 
     212   * 
     213   * @access private 
     214   * @return string 
     215   */ 
     216  function get_suggest_path() { 
     217    $host  = empty($_SERVER['HTTP_HOST']) 
     218              ? (empty($_SERVER['SERVER_NAME']) 
     219                  ? $_SERVER['SERVER_ADDR'] 
     220                  : $_SERVER['SERVER_NAME']) 
     221              : $_SERVER['HTTP_HOST']; 
     222    $proto = (empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] == 'off') 
     223              ? 'http' 
     224              : 'https'; 
     225    $port  = $_SERVER['SERVER_PORT']; 
     226 
     227    $uri   = $proto . '://' . $host; 
     228    if ((('http' == $proto) and (80 != $port)) 
     229    or (('https' == $proto) and (443 != $port)))  
     230    { 
     231      $uri .= ':' . $port; 
     232    } 
     233    $uri  .= dirname(dirname($_SERVER['PHP_SELF'])); 
     234 
     235    return $uri; 
     236  } 
     237 
     238  /** 
     239   * get_value() - gets a value of an array 
     240   *  
     241   * Look for index $key in the array $array and return 
     242   * the corresponding value if it exists or the default 
     243   * value $default if it doesn't. 
     244   * 
     245   * @access public 
     246   * @param array $array 
     247   * @param mixed $key 
     248   * @param mixed $default 
     249   * @return mixed 
     250   */ 
     251  function get_value($array, $key, $default = '') { 
     252 
     253    if(isset($array[$key])) { 
     254      return $array[$key]; 
     255    } 
     256    else { 
     257      return $default; 
     258    } 
     259  } 
     260 
     261  /** 
     262   * form_output() - generates HTML output for formular 
     263   * 
     264   * @access public 
     265   * @return string 
     266   */ 
     267  function form_output() { 
    126268    # returns the filled form 
    127       
    128     $data = array_htmlspecialchars($this->d); 
    129  
    130     if(isset($data['jlog_clean_url']) AND ($data['jlog_clean_url'] === 'true' OR $data['jlog_clean_url'] === '1'))  
    131         $d['clean_url_yes'] = " checked='checked'"; 
    132     else $d['clean_url_no'] = " checked='checked'"; 
    133  
    134     if(isset($data['jlog_info_by_comment'])) $d['info_by_comment'] = " checked='checked'"; 
    135     else $d['info_by_comment'] = ""; 
    136  
    137     if(isset($data['jlog_bs_weblogs_com']) AND ($data['jlog_bs_weblogs_com'] === 'true' OR $data['jlog_bs_weblogs_com'] === '1')) 
    138         $d['bs_weblogs_com'] = " checked='checked' "; 
    139  
    140     if(defined("JLOG_ADMIN") AND JLOG_ADMIN === true) $admincenter_password = " ".$this->l['admin']['m_admin_password_admin']; 
    141     else $admincenter_password = ''; 
    142    
    143     // get available languages 
    144     $dir = opendir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'); 
    145     $languages = array(); 
    146     while(($file = readdir($dir)) !== false) { 
     269 
     270    $data = array_htmlspecialchars($this->d); 
     271 
     272    if(isset($data['jlog_clean_url']) AND ($data['jlog_clean_url'] === 'true' OR $data['jlog_clean_url'] === '1')) 
     273    $d['clean_url_yes'] = " checked='checked'"; 
     274    else $d['clean_url_no'] = " checked='checked'"; 
     275 
     276    if(isset($data['jlog_info_by_comment'])) $d['info_by_comment'] = " checked='checked'"; 
     277    else $d['info_by_comment'] = ""; 
     278 
     279    if(isset($data['jlog_bs_weblogs_com']) AND ($data['jlog_bs_weblogs_com'] === 'true' OR $data['jlog_bs_weblogs_com'] === '1')) 
     280    $d['bs_weblogs_com'] = " checked='checked' "; 
     281 
     282    if(defined("JLOG_ADMIN") AND JLOG_ADMIN === true) $admincenter_password = " ".$this->l['admin']['m_admin_password_admin']; 
     283    else $admincenter_password = ''; 
     284 
     285    // get available languages 
     286    $dir = opendir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'); 
     287    $languages = array(); 
     288    while(($file = readdir($dir)) !== false) { 
    147289      if($file == '.' OR $file == '..') continue; 
    148290      if(!preg_match('/lang\.([a-zA-z0-9]+)\.inc\.php/', $file, $matches)) continue; 
    149291      $languages[] = $matches[1]; 
    150    
    151       
    152     // do the form  
    153     $form = " 
     292   
     293 
     294    // do the form 
     295    $form = " 
    154296     <form action='".$_SERVER['PHP_SELF']."' method='post'> 
    155297      <fieldset><legend>".$this->l['admin']['m_metadata']."</legend> 
    156298       <p><label for='language'>".$this->l['admin']['m_language']."</label><br /> 
    157299          <select class='userdata' id='language' name='jlog_language'>"; 
    158     foreach($languages as $lang) { 
     300    foreach($languages as $lang) { 
    159301      $form .= "<option"; 
    160302      if((isset($_POST['jlog_language']) AND $lang = $_POST['jlog_language']) OR $lang == JLOG_LANGUAGE) 
    161         $form .= " selected='selected'"; 
     303      $form .= " selected='selected'"; 
    162304      $form .= ">$lang</option>"; 
    163    
    164            
    165     $form .= "</select> 
     305   
     306 
     307    $form .= "</select> 
    166308       </p> 
    167309        
     
    202344     "; 
    203345 
    204     if(defined('JLOG_SETUP') AND JLOG_SETUP === true) { 
    205      $form .= 
    206      
     346    if(defined('JLOG_SETUP') AND JLOG_SETUP === true) { 
     347      $form .= 
     348     
    207349      <fieldset><legend>".$this->l['admin']['m_database']."</legend> 
    208350       <p><label for='db'>".$this->l['admin']['m_db']."</label><br /> 
     
    221363      </fieldset> 
    222364     "; 
    223    
    224      
    225     $form .= " 
     365   
     366 
     367    $form .= " 
    226368      <p><input type='submit' class='button' value='".$this->l['admin']['submit']."' /></p> 
    227369     </form> 
    228370     "; 
    229371 
    230      return $form; 
    231     } 
    232      
    233     function validate() { 
    234      # if everything validate then return true 
    235      # otherwise return the $errors array 
    236  
    237      $errors = array(); 
    238       
    239        // paths 
    240        if(empty($this->d['jlog_path']) OR (check_url($this->d['jlog_path'], array ('http')) === false)) $errors[] = $this->l['admin']['e_path']; 
    241        if(empty($this->d['jlog_basepath']) OR !is_dir($this->d['jlog_basepath'])) $errors[] = $this->l['admin']['e_basepath']; 
    242        if($this->d['jlog_clean_url'] != 'true') $this->d['jlog_clean_url'] = 'false'; 
    243        // metadata 
    244        if(empty($this->d['jlog_website'])) $errors[] = $this->l['admin']['e_website']; 
    245        if(empty($this->d['jlog_publisher'])) $errors[] = $this->l['admin']['e_publisher']; 
    246        if(defined('JLOG_SETUP') AND JLOG_SETUP) { 
    247          if($this->d['jlog_admin_password'] == md5(""))  
    248            $errors[] = $this->l['admin']['e_admin_password']; 
    249          elseif($this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again'])  
    250            $errors[] = $this->l['admin']['e_admin_password_again']; 
    251        } 
    252        elseif(!empty($this->d['jlog_admin_password']) AND $this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) { 
    253          $errors[] = $this->l['admin']['e_admin_password_again']; 
    254        } 
    255        // Fix of bug #148 
    256        if(isset($this->d['jlog_admin_password_again']))  
    257          unset($this->d['jlog_admin_password_again']); 
    258         
    259        if(empty($this->d['jlog_email']) OR !strpos($this->d['jlog_email'], '@')) $errors[] = $this->l['admin']['e_email']; 
    260        if(empty($this->d['jlog_description'])) $errors[] = $this->l['admin']['e_description']; 
    261        // behavour 
    262        if(!is_numeric($this->d['jlog_max_blog_orginal']) OR intval($this->d['jlog_max_blog_orginal']) < 0) $errors[] = $this->l['admin']['e_max_blog_orginal']; 
    263        if(!is_numeric($this->d['jlog_max_blog_big']) OR intval($this->d['jlog_max_blog_big']) < 0) $errors[] = $this->l['admin']['e_max_blog_big']; 
    264        if(!is_numeric($this->d['jlog_max_blog_small']) OR intval($this->d['jlog_max_blog_small']) < 0) $errors[] = $this->l['admin']['e_max_blog_small']; 
    265        if(!is_numeric($this->d['jlog_sub_current']) OR intval($this->d['jlog_sub_current']) < 0) $errors[] = $this->l['admin']['e_sub_current']; 
    266        if(!is_numeric($this->d['jlog_start_year'])) $errors[] = $this->l['admin']['e_start_year']; 
    267        if($this->d['jlog_info_by_comment'] != 'true') $this->d['jlog_info_by_comment'] = 'false'; 
    268        // database 
    269        if(empty($this->d['jlog_db'])) $errors[] = $this->l['admin']['e_db']; 
    270        if(empty($this->d['jlog_db_url'])) $errors[] = $this->l['admin']['e_db_url']; 
    271  
    272       return $errors; 
    273     } 
    274      
    275     function do_settings() { 
    276     # if it's all done return true  
     372    return $form; 
     373  } 
     374 
     375  /** 
     376   * validate() - validates the current configuration 
     377   *  
     378   * If the current configuration is valid, an empty array is returned. 
     379   * Otherwise the returned array containes all errors, described in the 
     380   * current language. 
     381   * 
     382   * @access public 
     383   * @return array 
     384   */ 
     385  function validate() { 
     386    # if everything validate then return true 
    277387    # otherwise return the $errors array 
    278388 
    279      $errors = array(); 
    280  
    281      // if there is no new password set the old 
    282      if(JLOG_ADMIN AND empty($this->d['jlog_admin_password'])) $this->d['jlog_admin_password'] = $this->jlog_admin_password; 
    283      
    284      // erase last slashes 
     389    $errors = array(); 
     390 
     391    // paths 
     392    if(empty($this->d['jlog_path']) OR (check_url($this->d['jlog_path'], array ('http')) === false)) $errors[] = $this->l['admin']['e_path']; 
     393    if(empty($this->d['jlog_basepath']) OR !is_dir($this->d['jlog_basepath'])) $errors[] = $this->l['admin']['e_basepath']; 
     394    if($this->d['jlog_clean_url'] != 'true') $this->d['jlog_clean_url'] = 'false'; 
     395    // metadata 
     396    if(empty($this->d['jlog_website'])) $errors[] = $this->l['admin']['e_website']; 
     397    if(empty($this->d['jlog_publisher'])) $errors[] = $this->l['admin']['e_publisher']; 
     398    if(defined('JLOG_SETUP') AND JLOG_SETUP) { 
     399      if($this->d['jlog_admin_password'] == md5("")) 
     400      $errors[] = $this->l['admin']['e_admin_password']; 
     401      elseif($this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) 
     402      $errors[] = $this->l['admin']['e_admin_password_again']; 
     403    } 
     404    elseif(!empty($this->d['jlog_admin_password']) AND $this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) { 
     405      $errors[] = $this->l['admin']['e_admin_password_again']; 
     406    } 
     407    // Fix of bug #148 
     408    if(isset($this->d['jlog_admin_password_again'])) 
     409    unset($this->d['jlog_admin_password_again']); 
     410 
     411    if(empty($this->d['jlog_email']) OR !strpos($this->d['jlog_email'], '@')) $errors[] = $this->l['admin']['e_email']; 
     412    if(empty($this->d['jlog_description'])) $errors[] = $this->l['admin']['e_description']; 
     413    // behavour 
     414    if(!is_numeric($this->d['jlog_max_blog_orginal']) OR intval($this->d['jlog_max_blog_orginal']) < 0) $errors[] = $this->l['admin']['e_max_blog_orginal']; 
     415    if(!is_numeric($this->d['jlog_max_blog_big']) OR intval($this->d['jlog_max_blog_big']) < 0) $errors[] = $this->l['admin']['e_max_blog_big']; 
     416    if(!is_numeric($this->d['jlog_max_blog_small']) OR intval($this->d['jlog_max_blog_small']) < 0) $errors[] = $this->l['admin']['e_max_blog_small']; 
     417    if(!is_numeric($this->d['jlog_sub_current']) OR intval($this->d['jlog_sub_current']) < 0) $errors[] = $this->l['admin']['e_sub_current']; 
     418    if(!is_numeric($this->d['jlog_start_year'])) $errors[] = $this->l['admin']['e_start_year']; 
     419    if($this->d['jlog_info_by_comment'] != 'true') $this->d['jlog_info_by_comment'] = 'false'; 
     420    // database 
     421    if(empty($this->d['jlog_db'])) $errors[] = $this->l['admin']['e_db']; 
     422    if(empty($this->d['jlog_db_url'])) $errors[] = $this->l['admin']['e_db_url']; 
     423 
     424    return $errors; 
     425  } 
     426 
     427  /** 
     428   * do_settings() - save configuration 
     429   *  
     430   * Saves the current configuration to the settings.inc.php file  
     431   * in the personal folder. Return an empty array if configuration 
     432   * was saved successfully, or an array containing descriptions of 
     433   * the errors that occured otherwise. 
     434   * 
     435   * @access public 
     436   * @return array 
     437   */ 
     438  function do_settings() { 
     439    # if it's all done return true 
     440    # otherwise return the $errors array 
     441 
     442    $errors = array(); 
     443 
     444    // if there is no new password set the old 
     445    if(JLOG_ADMIN AND empty($this->d['jlog_admin_password'])) $this->d['jlog_admin_password'] = $this->jlog_admin_password; 
     446 
     447    // erase last slashes 
    285448    if(strrpos($this->d['jlog_path'], "/") == strlen($this->d['jlog_path'])-1) $this->d['jlog_path'] = substr($this->d['jlog_path'], 0, strrpos($this->d['jlog_path'], "/")); 
    286449    if(strrpos($this->d['jlog_basepath'], DIRECTORY_SEPARATOR) != strlen($this->d['jlog_basepath'])-1) $this->d['jlog_basepath'] = $this->d['jlog_basepath'].DIRECTORY_SEPARATOR; 
    287450 
    288      // no quotes for bolean and numbers 
    289      $no_quotes = array ( "jlog_clean_url", 
    290                           "jlog_max_blog_orginal", 
    291                           "jlog_max_blog_big", 
    292                           "jlog_max_blog_small", 
    293                           "jlog_sub_current", 
    294                           "jlog_start_year", 
    295                           "jlog_info_by_comment" ); 
    296  
    297      // serialize data to file format 
    298      $file_content = "<?php\n//generated at " . date('Y-m-d, h:i:s') . "\n"; 
    299      
    300      foreach($this->d as $key => $value) { 
    301      unset($q, $s, $s2); 
    302             if(!in_array($key, $no_quotes)) $q = "'"; 
    303         $key = strtoupper($key); 
    304  
    305         // bolean 
    306         if($key == 'JLOG_CLEAN_URL' OR $key == 'JLOG_INFO_BY_COMMENT') { 
    307             if($value == 'true' OR $value === true) $value = "true"; 
    308             else $value = "false"; 
    309         } 
    310         $file_content .= " define('".$key."', ".$q.addslashes($value).$q.");\n"; 
    311     } 
    312   
     451    // no quotes for bolean and numbers 
     452    $no_quotes = array ( 
     453      'jlog_clean_url', 
     454      'jlog_max_blog_orginal', 
     455      'jlog_max_blog_big', 
     456      'jlog_max_blog_small', 
     457      'jlog_sub_current', 
     458      'jlog_start_year', 
     459      'jlog_info_by_comment' 
     460    ); 
     461 
     462    // serialize data to file format 
     463    $file_content = "<?php\n//generated at " . date('Y-m-d, h:i:s') . "\n"; 
     464 
     465    foreach($this->d as $key => $value) { 
     466      unset($q, $s, $s2); 
     467      if(!in_array($key, $no_quotes)) $q = "'"; 
     468      $key = strtoupper($key); 
     469 
     470      // bolean 
     471      if($key == 'JLOG_CLEAN_URL' OR $key == 'JLOG_INFO_BY_COMMENT') { 
     472        if($value == 'true' OR $value === true) $value = "true"; 
     473        else $value = 'false'; 
     474      } 
     475      $file_content .= " define('".$key."', ".$q.addslashes($value).$q.");\n"; 
     476    } 
     477 
    313478    $file_content .= "\n// eof"; 
    314479 
    315480    // write to settings.inc.php 
    316     if(!$handle = fopen(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."settings.inc.php", "w")) $errors[] = $this->l['admin']['can_not_open']." /personal/settings.inc.php"; 
    317     if(!fwrite($handle, $file_content)) $errors[] = $this->l['admin']['can_not_write']." /personal/settings.inc.php"; 
    318     fclose($handle); 
    319     
    320     return $errors; 
    321    
     481    if(!$handle = fopen(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."settings.inc.php", "w")) $errors[] = $this->l['admin']['can_not_open']." /personal/settings.inc.php"; 
     482    if(!fwrite($handle, $file_content)) $errors[] = $this->l['admin']['can_not_write']." /personal/settings.inc.php"; 
     483    fclose($handle); 
     484 
     485    return $errors; 
     486 
    322487} 
    323 ?> 
     488 
     489// eof 
  • trunk/scripts/version.inc.php

    • Property svn:keywords set to HeadURL Rev Author Date
    r1711 r1712  
    11<?php 
    22 
    3 /* 
    4  * Version information on the current version of Jlog 
    5  */  
     3/** 
     4 * Jlog 
     5 *  
     6 * This program is free software; you can redistribute it and/or modify 
     7 * it under the terms of the GNU General Public License as published by 
     8 * the Free Software Foundation; either version 2 of the License, or 
     9 * (at your option) any later version. 
     10 *  
     11 * This program is distributed in the hope that it will be useful, 
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     14 * GNU General Public License for more details. 
     15 *  
     16 * You should have received a copy of the GNU General Public License 
     17 * along with this program; if not, write to the Free Software 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     19 *  
     20 * $HeadURL$ 
     21 * $Rev$ 
     22 * $Author$ 
     23 * $Date$ 
     24 */ 
    625 
    726define('JLOG_SOFTWARE_VERSION', '1.1.0'); 
     
    1029define('JLOG_SOFTWARE_MYSQLV', '4.1.0'); 
    1130 
    12 // EOF 
    13 ?> 
     31// eof