[ 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: PmvConfig.class.php 162 2006-11-11 16:16:47Z cmil $ 11 12 require_once INCLUDE_PATH."/core/include/commonDB.php"; 13 14 class PmvConfig 15 { 16 17 var $url; // config file 18 var $content; // config file content array 19 var $varname = "config"; // var namein file 20 21 function PmvConfig($p_fileName = "config.php", $setDefineAsConstant = true) 22 { 23 $this->url = INCLUDE_PATH . "/config/".$p_fileName; 24 $this->content = array(); 25 $this->varname = substr($p_fileName, 0, strpos($p_fileName, ".")); 26 27 if(!@is_file($this->url)) 28 { 29 //trigger_error("Unable to load base config file, can't continue...", E_USER_WARNING); 30 } 31 else 32 { 33 include $this->url; 34 35 if (!is_array(${$this->varname})) 36 { 37 trigger_error('Unattended config file format, please verify or delete your configuration file', E_USER_WARNING); 38 } 39 else 40 { 41 $this->content = ${$this->varname}; //$config; 42 if ($setDefineAsConstant) { 43 $this->defineAsConstant( $this->content ); 44 } 45 } 46 } 47 if ($p_fileName == "config.php") { 48 //$this->defineTables(); 49 $db =& Db::getInstance(); 50 $db->defineTables(); 51 } 52 elseif ($p_fileName == "plugin.php") { 53 //$this->defineTables(); 54 foreach($this->content as $key => $val) { 55 $db =& Db::getInstance($key); 56 $db->defineTables(); 57 } 58 } 59 } 60 61 /** 62 * Singleton 63 */ 64 function &getInstance($p_fileName = "config.php", $setDefineAsConstant = true) 65 { 66 // static $instance; 67 // if (!isset($instance)){ 68 // $c = __CLASS__; 69 // $instance = new $c($p_fileName, $setDefineAsConstant); 70 // } 71 static $PmvConfigTabInstance; 72 if (!isset($PmvConfigTabInstance)){ 73 $PmvConfigTabInstance = array(); 74 } 75 if (!isset($PmvConfigTabInstance[$p_fileName])) { 76 $c = __CLASS__; 77 $instance = new $c($p_fileName, $setDefineAsConstant); 78 $PmvConfigTabInstance[$p_fileName] =& $instance; 79 } 80 else { 81 $instance =& $PmvConfigTabInstance[$p_fileName]; 82 } 83 return $instance; 84 } 85 86 // function defineTables() 87 // { 88 // if(defined('DB_TABLES_PREFIX')) 89 // { 90 // $db =& Db::getInstance(); 91 // $tables = $db->getAllTablesList(); 92 // foreach($tables as $name) 93 // { 94 // define('T_' . strtoupper($name), DB_TABLES_PREFIX . $name); 95 // } 96 // } 97 // } 98 99 function defineAsConstant( $a_vars ) 100 { 101 foreach ($a_vars as $constName => $constValue) 102 { 103 define(strtoupper($constName), $constValue); 104 } 105 } 106 107 function update( $a_varValue ) 108 { 109 $this->content = array_merge( $this->content, $a_varValue ); 110 } 111 112 function write() 113 { 114 saveConfigFile( $this->url, $this->content, $this->varname); 115 } 116 } 117 ?>
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 |
![]() |