Changeset 438

Show
Ignore:
Timestamp:
05/11/07 15:42:07 (2 years ago)
Author:
laurentj
Message:

worked on the install checker

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/checker.php

    r411 r438  
    3838        echo '<div class="results">'; 
    3939        if($checker->nbError){ 
    40             echo $checker->nbError, ' errors'
     40            echo ' ',$checker->nbError, $checker->messages->get('number.errors')
    4141        } 
    4242        if($checker->nbWarning){ 
    43             echo $checker->nbWarning, ' warnings'; 
     43            echo ' ',$checker->nbWarning, $checker->messages->get('number.warnings'); 
     44        } 
     45        if($checker->nbNotice){ 
     46            echo ' ',$checker->nbNotice, $checker->messages->get('number.notices'); 
     47        } 
     48 
     49        if($checker->nbError){ 
     50           echo '<p>',$checker->messages->get('conclusion.errors'),'</p>'; 
     51        }else  if($checker->nbWarning){ 
     52            echo '<p>',$checker->messages->get('conclusion.warnings'),'</p>'; 
     53        }else  if($checker->nbNotice){ 
     54            echo '<p>',$checker->messages->get('conclusion.notices'),'</p>'; 
     55        }else{ 
     56            echo '<p>',$checker->messages->get('conclusion.ok'),'</p>'; 
    4457        } 
    4558    } 
     
    5265 
    5366<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    54 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_EN" lang="en_EN"> 
     67<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $check->messages->getLang(); ?>" lang="<?php echo $check->messages->getLang(); ?>"> 
    5568<head> 
    5669    <meta content="text/html; charset=UTF-8" http-equiv="content-type"/> 
    57     <title>Installation checker for jelix</title> 
     70    <title><?php echo htmlspecialchars($check->messages->get('checker.title')); ?></title> 
    5871 
    5972    <style type="text/css"> 
     
    7790 
    7891</head><body > 
    79     <h1>Installation checker for jelix</h1> 
     92    <h1><?php echo htmlspecialchars($check->messages->get('checker.title')); ?></h1> 
    8093 
    8194<?php $check->run(); ?> 
  • trunk/lib/jelix/core/jInstallChecker.class.php

    r411 r438  
    2727} 
    2828 
     29/** 
     30 * message provider for jInstallCheck 
     31 * @since 1.0b2 
     32 * @experimental 
     33 */ 
     34class jInstallMessageProvider { 
     35    protected $currentLang; 
     36 
     37    protected $messages = array( 
     38        'fr'=>array( 
     39            'checker.title'=>'Vérification de l\'installation de Jelix', 
     40            'number.errors'=>' erreurs.', 
     41            'number.warnings'=>' avertissements.', 
     42            'number.notices'=>' remarques.', 
     43            'conclusion.errors'=>'Vous devez corriger les erreurs pour faire fonctionner correctement votre application.', 
     44            'conclusion.warnings'=>'Votre application peut à priori fonctionner, mais il est préférable de corriger les avertissements pour être sûr.', 
     45            'conclusion.notices'=>'L\'installation est correcte malgré les remarques.', 
     46            'conclusion.ok'=>'L\'installation est correcte', 
     47            'cannot.continue'=>'Les vérifications ne peuvent continuer : ', 
     48            'extension.dom'=>'L\'extension DOM n\'est pas installée', 
     49            'extension.spl'=>'L\'extension spl  n\'est pas installée', 
     50            'extension.simplexml'=>'L\'extension simplexml n\'est pas installée', 
     51            'extension.pcre'=>'L\'extension pcre n\'est pas installée', 
     52            'extension.session'=>'L\'extension session n\'est pas installée', 
     53            'extension.tokenizer'=>'L\'extension tokenizer n\'est pas installée', 
     54            'extension.iconv'=>'L\'extension iconv n\'est pas installée', 
     55            'extensions.required.ok'=>'Toutes les extensions obligatoires sont installées', 
     56            'path.core'=>'Le fichier init.php  de jelix ou le fichier application.ini.php de votre application n\'est pas chargé', 
     57            'path.temp'=>'Le repertoire temporaire n\'est pas accessible en écriture ou alors JELIX_APP_TEMP_PATH n\'est pas configurée comme il faut', 
     58            'path.log'=>'Le repertoire log n\'est pas accessible en écriture ou alors JELIX_APP_LOG_PATH n\'est pas configurée comme il faut', 
     59            'path.var'=>'JELIX_APP_VAR_PATH n\'est pas configuré correctement : ce répertoire n\'existe pas', 
     60            'path.config'=>'JELIX_APP_CONFIG_PATH n\'est pas configuré correctement : ce répertoire n\'existe pas', 
     61            'path.www'=>'JELIX_APP_WWW_PATH n\'est pas configuré correctement : ce répertoire n\'existe pas', 
     62            'too.critical.error'=>'Trop d\'erreurs critiques sont apparues. Corrigez les.', 
     63            'config.file'=>'La variable $config_file n\'existe pas ou le fichier qu\'elle indique n\'existe pas', 
     64            'paths.ok'=>'Les répertoires temp, log, var, config et www sont ok', 
     65            'ini.magic_quotes_gpc'=>'php.ini : l\'activation des magicquotes n\'est pas recommandée pour jelix. Vous devez les désactiver ou activer le plugin magicquotes si ce n\'est pas fait', 
     66            'ini.magic_quotes_runtime'=>'php.ini : magic_quotes_runtime doit être à off', 
     67            'ini.session.auto_start'=>'php.ini : session.auto_start doit être à off', 
     68            'ini.safe_mode'=>'php.ini : le safe_mode n\'est pas recommandé pour jelix.', 
     69            'ini.register_globals'=>'php.ini : il faut désactiver register_globals, pour des raisons de sécurité et parce que l\'application n\'en a pas besoin.', 
     70            'ini.asp_tags'=>'php.ini :  il est conseillé de désactiver asp_tags. L\'application n\'en a pas besoin.', 
     71            'ini.short_open_tag'=>'php.ini :  il est conseillé de désactiver short_open_tag. L\'application n\'en a pas besoin.', 
     72            'ini.ok'=>'Les paramètres de php sont ok', 
     73        ), 
     74 
     75        'en'=>array( 
     76            'checker.title'=>'Jelix Installation checking', 
     77            'number.errors'=>' errors.', 
     78            'number.warnings'=>' warnings.', 
     79            'number.notices'=>' notices.', 
     80            'conclusion.errors'=>'You must fix errors in order to run your application correctly.', 
     81            'conclusion.warnings'=>'Your application may run without problems, but it is recommanded to fix warning.', 
     82            'conclusion.notices'=>'The install is ok, although there are notices.', 
     83            'conclusion.ok'=>'The install is ok', 
     84            'cannot.continue'=>'Cannot continue the checking: ', 
     85            'extension.dom'=>'DOM extension is not installed', 
     86            'extension.spl'=>'SPL extension is not installed', 
     87            'extension.simplexml'=>'simplexml extension is not installed', 
     88            'extension.pcre'=>'pcre extension is not installed', 
     89            'extension.session'=>'session extension is not installed', 
     90            'extension.tokenizer'=>'tokenizer extension is not installed', 
     91            'extension.iconv'=>'iconv extension is not installed', 
     92            'extensions.required.ok'=>'All needed PHP extensions are installed', 
     93            'path.core'=>'jelix init.php file or application.ini.php file is not loaded', 
     94            'path.temp'=>'Temp directory is not writable or JELIX_APP_TEMP_PATH is not correctly set !', 
     95            'path.log'=>'log directory is not writable or JELIX_APP_LOG_PATH is not correctly set!', 
     96            'path.var'=>'JELIX_APP_VAR_PATH is not correctly set: var directory  doesn\'t exist!', 
     97            'path.config'=>'JELIX_APP_CONFIG_PATH is not correctly set: config directory  doesn\'t exist!', 
     98            'path.www'=>'JELIX_APP_WWW_PATH is not correctly set: www directory  doesn\'t exist!', 
     99            'too.critical.error'=>'Too much critical errors. Fix them.', 
     100            'config.file'=>'$config_file variable does not exist or doesn\'t contain a correct application config file name', 
     101            'paths.ok'=>'temp, log, var, config and www directory are ok', 
     102            'ini.magic_quotes_gpc'=>'php.ini : magicquotes are not recommended for Jelix. You should deactivate it or activate the magicquote jelix plugin', 
     103            'ini.magic_quotes_runtime'=>'php.ini : magic_quotes_runtime must be off', 
     104            'ini.session.auto_start'=>'php.ini : session.auto_start must be off', 
     105            'ini.safe_mode'=>'php.ini : safe_mode is not recommended.', 
     106            'ini.register_globals'=>'php.ini : you must deactivate register_globals, for security reasons, and because the application doesn\'t need it.', 
     107            'ini.asp_tags'=>'php.ini :  you should deactivate  asp_tags. The application doesn\'t need it.', 
     108            'ini.short_open_tag'=>'php.ini :  you should deactivate short_open_tag. The application doesn\'t need it.', 
     109            'ini.ok'=>'php settings are ok', 
     110           /* ''=>'',*/ 
     111        ), 
     112    ); 
     113 
     114    function __construct($lang=''){ 
     115        if($lang == ''){ 
     116 
     117            $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); 
     118            foreach($languages as $bl){ 
     119                // pour les user-agents qui livrent un code internationnal 
     120                if(preg_match("/^([a-zA-Z]{2})(?:[-_]([a-zA-Z]{2}))?(;q=[0-9]\\.[0-9])?$/",$bl,$match)){ 
     121                    $lang = strtolower($match[1]); 
     122                    break; 
     123                } 
     124            } 
     125        } 
     126        if(!isset($this->messages[$lang])){ 
     127            $lang = 'en'; 
     128        } 
     129        $this->currentLang = $lang; 
     130    } 
     131 
     132    function get($key){ 
     133        if(isset($this->messages[$this->currentLang][$key])){ 
     134            return $this->messages[$this->currentLang][$key]; 
     135        }else{ 
     136            throw new Exception ("Error : don't find error message '$key'"); 
     137        } 
     138    } 
     139 
     140    function getLang(){ 
     141        return $this->currentLang; 
     142    } 
     143} 
     144 
    29145 
    30146/** 
     
    40156     */ 
    41157    protected $reporter; 
    42      
     158 
     159    /** 
     160     * @var JInstallMessageProvider 
     161     */ 
     162    public $messages; 
     163 
    43164    public $nbError = 0; 
    44165    public $nbOk = 0; 
    45166    public $nbWarning = 0; 
     167    public $nbNotice = 0; 
    46168 
    47169    function __construct ($reporter){ 
    48170        $this->reporter = $reporter; 
     171        $this->messages = new jInstallMessageProvider(); 
    49172    } 
    50173 
     
    53176        $this->nbOk = 0; 
    54177        $this->nbWarning = 0; 
     178        $this->nbNotice = 0; 
    55179        $this->reporter->start(); 
    56180        try { 
    57181            $this->checkPhpExtensions(); 
    58182            $this->checkAppPaths(); 
     183            $this->checkPhpSettings(); 
    59184        }catch(Exception $e){ 
    60             $this->error('Cannot continue the checking : '.$e->getMessage()); 
     185            $this->error($this->messages.get('cannot.continue').$e->getMessage()); 
    61186        } 
    62187        $this->reporter->end($this); 
     
    65190    protected function error($msg){ 
    66191        if($this->reporter) 
    67             $this->reporter->showError($msg); 
     192            $this->reporter->showError($this->messages->get($msg)); 
    68193        $this->nbError ++; 
    69194    } 
    70195    protected function ok($msg){ 
    71196        if($this->reporter) 
    72             $this->reporter->showOk($msg); 
     197            $this->reporter->showOk($this->messages->get($msg)); 
    73198        $this->nbOk ++; 
    74199    } 
    75200    protected function warning($msg){ 
    76201        if($this->reporter) 
    77             $this->reporter->showWarning($msg); 
     202            $this->reporter->showWarning($this->messages->get($msg)); 
    78203        $this->nbWarning ++; 
    79204    } 
    80205    protected function notice($msg){ 
    81206        if($this->reporter) 
    82             $this->reporter->showNotice($msg); 
    83     } 
     207            $this->reporter->showNotice($this->messages->get($msg)); 
     208        $this->nbNotice ++; 
     209    } 
     210 
     211 
    84212 
    85213    function checkPhpExtensions(){ 
     
    87215 
    88216        if(!class_exists('DOMDocument',false)){ 
    89             $this->error('DOM extension is not installed'); 
     217            $this->error('extension.dom'); 
    90218            $ok=false; 
    91219        } 
    92220        if(!class_exists('DirectoryIterator',false)){ 
    93             $this->error('SPL extension is not installed'); 
     221            $this->error('extension.spl'); 
    94222            $ok=false; 
    95223        } 
     
    104232        foreach($funcs as $f=>$name){ 
    105233            if(!function_exists($f)){ 
    106                 $this->error($name.' extension is not installed'); 
     234                $this->error('extension.'.$name); 
    107235                $ok=false; 
    108236            } 
     
    110238 
    111239        if($ok) 
    112             $this->ok('All needed PHP extensions are installed'); 
     240            $this->ok('extensions.required.ok'); 
    113241 
    114242        return $ok; 
     
    119247        $ok = true; 
    120248        if(!defined('JELIX_LIB_PATH') || !defined('JELIX_APP_PATH')){ 
    121             throw new Exception('jelix init.php file or application.ini.php file is not loaded'); 
     249            throw new Exception($this->messages->get('path.core')); 
    122250        } 
    123251 
    124252        if(!file_exists(JELIX_APP_TEMP_PATH) || !is_writable(JELIX_APP_TEMP_PATH)){ 
    125             $this->error('Temp directory is not writable or JELIX_APP_TEMP_PATH is not correctly set !'); 
     253            $this->error('path.temp'); 
    126254            $ok=false; 
    127255        } 
    128256        if(!file_exists(JELIX_APP_LOG_PATH) || !is_writable(JELIX_APP_LOG_PATH)){ 
    129             $this->error('log directory is not writable or JELIX_APP_LOG_PATH is not correctly set!'); 
     257            $this->error('path.log'); 
    130258            $ok=false; 
    131259        } 
    132260        if(!file_exists(JELIX_APP_VAR_PATH)){ 
    133             $this->error('JELIX_APP_VAR_PATH is not correctly set: var directory  doesn\'t exist!'); 
     261            $this->error('path.var'); 
    134262            $ok=false; 
    135263        } 
    136264        if(!file_exists(JELIX_APP_CONFIG_PATH)){ 
    137             $this->error('JELIX_APP_CONFIG_PATH is not correctly set: config directory  doesn\'t exist!'); 
     265            $this->error('path.config'); 
    138266            $ok=false; 
    139267        } 
    140268        if(!file_exists(JELIX_APP_WWW_PATH)){ 
    141             $this->error('JELIX_APP_WWW_PATH is not correctly set: www directory  doesn\'t exist!'); 
    142             $ok=false; 
    143         } 
    144         if(!$ok) 
    145             throw new Exception('jelix init.php file or application.ini.php file is not loaded'); 
     269            $this->error('path.www'); 
     270            $ok=false; 
     271        } 
    146272 
    147273        if($ok) 
    148             $this->ok('temp, log, var, config and www directory are ok'); 
     274            $this->ok('paths.ok'); 
     275        else 
     276            throw new Exception($this->messages->get('too.critical.error')); 
    149277 
    150278        if(!isset($GLOBALS['config_file']) || empty($GLOBALS['config_file']) || !file_exists(JELIX_APP_CONFIG_PATH.$GLOBALS['config_file'])){ 
    151             throw new Exception('$config_file does not exist or doesn\'t contain a correct application config file name'); 
     279            throw new Exception($this->messages->get('config.file')); 
    152280        } 
    153281 
     
    158286 
    159287    function checkPhpSettings(){ 
    160  
    161  
    162  
     288        $ok = true; 
     289        if(ini_get('magic_quotes_gpc') == 1){ 
     290            $this->warning('ini.magic_quotes_gpc'); 
     291            $ok=false; 
     292        } 
     293        if(ini_get('magic_quotes_runtime') == 1){ 
     294            $this->error('ini.magic_quotes_runtime'); 
     295            $ok=false; 
     296        } 
     297 
     298        if(ini_get('session.auto_start') == 1){ 
     299            $this->error('ini.session.auto_start'); 
     300            $ok=false; 
     301        } 
     302        if(ini_get('safe_mode') == 1){ 
     303            $this->warning('safe_mode'); 
     304            $ok=false; 
     305        } 
     306 
     307        if(ini_get('register_globals') == 1){ 
     308            $this->warning('ini.register_globals'); 
     309            $ok=false; 
     310        } 
     311 
     312        if(ini_get('asp_tags') == 1){ 
     313            $this->notice('ini.asp_tags'); 
     314        } 
     315        if(ini_get('short_open_tag') == 1){ 
     316            $this->notice('ini.short_open_tag'); 
     317        } 
     318        if($ok){ 
     319            $this->ok('ini.ok'); 
     320        } 
     321        return $ok; 
    163322    } 
    164323 
    165324 
    166325/* 
    167 existence des modules optionnels 
    168     filter 
    169     json 
    170     xmlrpc 
    171     jelix 
    172  
    173 Verification des settings de php.ini : 
    174  
    175 magic_quotes_gpc et magic_quotes_runtime doivent être à off. verifier que le plugin magicquotes soit activé ou pas selon la valeur 
    176 session.auto_start doit être à 0 
    177 safe_mode doit être à off 
    178 register_globals = off 
    179 asp_tags = off 
    180 short_open_tag = off 
    181  
    182  
    183 JELIX_LIB_PATH, JELIX_APP_PATH : si absent, erreur fatale. 
    184326 
    185327Verifier que l'install est en adéquation avec les paramètres du fichier build : 
     
    190332ENABLE_PHP_JELIX 
    191333 
    192 verifier la presence du module jelix 
    193  
    194 JELIX_APP_TEMP_PATH existe et est ok en écriture 
    195 JELIX_APP_LOG_PATH existe et est ok en écriture 
     334->existence des modules optionnels 
     335    filter 
     336    json 
     337    xmlrpc 
     338    jelix 
    196339 
    197340existence des fichiers de configuration dans JELIX_APP_CONFIG_PATH 
     341    dbprofils.php 
    198342 
    199343test connection à une base pour tout les profils 
    200  
    201344 
    202345Dans la conf : 
    203346    verification de tous les chemins de modules 
    204347    verification de tous les chemins de plugins et plugins tpl 
     348    verifier que le plugin magicquotes est activé ou pas selon la valeur de magic_quotes 
     349 
     350Verification de l'existence de l'url /jelix/ (alias de jelix-www) 
    205351 
    206352*/ 
Download in other formats: Unified Diff Zip Archive