| [ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /* 3 * phpMyVisites : website statistics and audience measurements 4 * Copyright (C) 2002 - 2006 5 * http://www.phpmyvisites.net/ 6 * phpMyVisites is free software (license GNU/GPL) 7 * Authors : phpMyVisites team 8 */ 9 10 // $Id: FormDbConfig.class.php 236 2007-11-04 15:04:08Z matthieu_ $ 11 12 13 require_once INCLUDE_PATH . "/core/forms/Form.class.php"; 14 15 class FormDbConfig extends Form 16 { 17 function FormDbConfig( &$template ) 18 { 19 parent::Form( $template ); 20 } 21 22 function process() 23 { 24 $cst = array( 25 'DB_LOGIN', 26 'DB_PASSWORD', 27 'DB_HOST', 28 'DB_NAME', 29 'DB_TABLES_PREFIX', 30 ); 31 32 foreach($cst as $name) 33 { 34 if(defined( $name )) 35 $values[$name] = constant($name); 36 elseif($name=='DB_TABLES_PREFIX') 37 $values[$name] = 'phpmv_'; 38 else 39 $values[$name] = ''; 40 } 41 42 $password = !empty($values['DB_PASSWORD'])?md5($values['DB_PASSWORD']):''; 43 $formElements = array( 44 array('text', 'form_dblogin', $GLOBALS['lang']['install_loginmysql'], 'value='.$values['DB_LOGIN']), 45 array('password', 'form_dbpassword', $GLOBALS['lang']['install_mdpmysql'], 'value='.$password), 46 array('text', 'form_dbhost', $GLOBALS['lang']['install_serveurmysql'], 'value='.$values['DB_HOST']), 47 array('text', 'form_dbname', $GLOBALS['lang']['install_basemysql'], 'value='.$values['DB_NAME']), 48 array('text', 'form_dbprefix', $GLOBALS['lang']['install_prefixetable'], 'value='.$values['DB_TABLES_PREFIX']), 49 ); 50 51 $this->addElements( $formElements , $GLOBALS['lang']['generique_general'] ); 52 53 54 $formRules = array( 55 array('form_dblogin', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['install_loginmysql']), 'required'), 56 array('form_dbhost', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['install_serveurmysql']), 'required'), 57 array('form_dbname', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['install_basemysql']), 'required'), 58 array('form_dbprefix', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['install_prefixetable']), 'required'), 59 ); 60 61 $this->addRules( $formRules ); 62 63 return parent::process('install_database_setup'); 64 } 65 66 function postProcess() 67 { 68 $configPhpFileContent = array( 69 'db_login' => $this->getElementValue('form_dblogin'), 70 'db_password' => $this->getElementValue('form_dbpassword'), 71 'db_host' => $this->getElementValue('form_dbhost'), 72 'db_name' => $this->getElementValue('form_dbname'), 73 'db_tables_prefix' => $this->getElementValue('form_dbprefix'), 74 ); 75 76 $db =& Db::getInstance(); 77 78 // Verify if there is change on password 79 if ( defined('DB_PASSWORD') 80 && $configPhpFileContent['db_password'] == md5(DB_PASSWORD)) { 81 $configPhpFileContent['db_password'] = DB_PASSWORD; 82 } 83 84 // try to connect with new values 85 $db->host = $configPhpFileContent['db_host']; 86 $db->login = $configPhpFileContent['db_login']; 87 $db->password = $configPhpFileContent['db_password']; 88 $db->name = $configPhpFileContent['db_name']; 89 $db->init(); 90 91 if($db->isReady()) 92 { 93 $c =& PmvConfig::getInstance(); 94 $c->update( $configPhpFileContent ); 95 96 $c->write(); 97 98 $GLOBALS['header_error_message_tpl'] = ''; 99 100 $this->tpl->assign('db_connect_ok', true); 101 } 102 else 103 { 104 $this->display(); 105 } 106 } 107 } 108 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
|