Changeset 438
- Timestamp:
- 05/11/07 15:42:07 (2 years ago)
- Files:
-
- trunk/lib/jelix/checker.php (modified) (3 diffs)
- trunk/lib/jelix/core/jInstallChecker.class.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/checker.php
r411 r438 38 38 echo '<div class="results">'; 39 39 if($checker->nbError){ 40 echo $checker->nbError, ' errors';40 echo ' ',$checker->nbError, $checker->messages->get('number.errors'); 41 41 } 42 42 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>'; 44 57 } 45 58 } … … 52 65 53 66 <!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(); ?>"> 55 68 <head> 56 69 <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> 58 71 59 72 <style type="text/css"> … … 77 90 78 91 </head><body > 79 <h1> Installation checker for jelix</h1>92 <h1><?php echo htmlspecialchars($check->messages->get('checker.title')); ?></h1> 80 93 81 94 <?php $check->run(); ?> trunk/lib/jelix/core/jInstallChecker.class.php
r411 r438 27 27 } 28 28 29 /** 30 * message provider for jInstallCheck 31 * @since 1.0b2 32 * @experimental 33 */ 34 class 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 29 145 30 146 /** … … 40 156 */ 41 157 protected $reporter; 42 158 159 /** 160 * @var JInstallMessageProvider 161 */ 162 public $messages; 163 43 164 public $nbError = 0; 44 165 public $nbOk = 0; 45 166 public $nbWarning = 0; 167 public $nbNotice = 0; 46 168 47 169 function __construct ($reporter){ 48 170 $this->reporter = $reporter; 171 $this->messages = new jInstallMessageProvider(); 49 172 } 50 173 … … 53 176 $this->nbOk = 0; 54 177 $this->nbWarning = 0; 178 $this->nbNotice = 0; 55 179 $this->reporter->start(); 56 180 try { 57 181 $this->checkPhpExtensions(); 58 182 $this->checkAppPaths(); 183 $this->checkPhpSettings(); 59 184 }catch(Exception $e){ 60 $this->error( 'Cannot continue the checking : '.$e->getMessage());185 $this->error($this->messages.get('cannot.continue').$e->getMessage()); 61 186 } 62 187 $this->reporter->end($this); … … 65 190 protected function error($msg){ 66 191 if($this->reporter) 67 $this->reporter->showError($ msg);192 $this->reporter->showError($this->messages->get($msg)); 68 193 $this->nbError ++; 69 194 } 70 195 protected function ok($msg){ 71 196 if($this->reporter) 72 $this->reporter->showOk($ msg);197 $this->reporter->showOk($this->messages->get($msg)); 73 198 $this->nbOk ++; 74 199 } 75 200 protected function warning($msg){ 76 201 if($this->reporter) 77 $this->reporter->showWarning($ msg);202 $this->reporter->showWarning($this->messages->get($msg)); 78 203 $this->nbWarning ++; 79 204 } 80 205 protected function notice($msg){ 81 206 if($this->reporter) 82 $this->reporter->showNotice($msg); 83 } 207 $this->reporter->showNotice($this->messages->get($msg)); 208 $this->nbNotice ++; 209 } 210 211 84 212 85 213 function checkPhpExtensions(){ … … 87 215 88 216 if(!class_exists('DOMDocument',false)){ 89 $this->error(' DOM extension is not installed');217 $this->error('extension.dom'); 90 218 $ok=false; 91 219 } 92 220 if(!class_exists('DirectoryIterator',false)){ 93 $this->error(' SPL extension is not installed');221 $this->error('extension.spl'); 94 222 $ok=false; 95 223 } … … 104 232 foreach($funcs as $f=>$name){ 105 233 if(!function_exists($f)){ 106 $this->error( $name.' extension is not installed');234 $this->error('extension.'.$name); 107 235 $ok=false; 108 236 } … … 110 238 111 239 if($ok) 112 $this->ok(' All needed PHP extensions are installed');240 $this->ok('extensions.required.ok'); 113 241 114 242 return $ok; … … 119 247 $ok = true; 120 248 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')); 122 250 } 123 251 124 252 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'); 126 254 $ok=false; 127 255 } 128 256 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'); 130 258 $ok=false; 131 259 } 132 260 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'); 134 262 $ok=false; 135 263 } 136 264 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'); 138 266 $ok=false; 139 267 } 140 268 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 } 146 272 147 273 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')); 149 277 150 278 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')); 152 280 } 153 281 … … 158 286 159 287 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; 163 322 } 164 323 165 324 166 325 /* 167 existence des modules optionnels168 filter169 json170 xmlrpc171 jelix172 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 valeur176 session.auto_start doit être à 0177 safe_mode doit être à off178 register_globals = off179 asp_tags = off180 short_open_tag = off181 182 183 JELIX_LIB_PATH, JELIX_APP_PATH : si absent, erreur fatale.184 326 185 327 Verifier que l'install est en adéquation avec les paramètres du fichier build : … … 190 332 ENABLE_PHP_JELIX 191 333 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 196 339 197 340 existence des fichiers de configuration dans JELIX_APP_CONFIG_PATH 341 dbprofils.php 198 342 199 343 test connection à une base pour tout les profils 200 201 344 202 345 Dans la conf : 203 346 verification de tous les chemins de modules 204 347 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 350 Verification de l'existence de l'url /jelix/ (alias de jelix-www) 205 351 206 352 */
