[757] | 1 | <?php
|
---|
| 2 | /*
|
---|
| 3 | * XPressME - WordPress for XOOPS
|
---|
| 4 | *
|
---|
| 5 | * @copyright XPressME Project http://www.toemon.com
|
---|
| 6 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license
|
---|
| 7 | * @author toemon
|
---|
| 8 | * @package module::xpress
|
---|
| 9 | */
|
---|
| 10 |
|
---|
[783] | 11 | if (defined( 'XOOPS_MAINFILE_INCLUDED')|| defined( 'XOOPS_BOOTSTRAP')) :
|
---|
[757] | 12 | require_once dirname( __FILE__ ).'/langInfo_class.php' ;
|
---|
| 13 |
|
---|
| 14 | class wpConfigInfoClass {
|
---|
| 15 | var $xoops_db_prefix;
|
---|
| 16 | var $db_prefix;
|
---|
| 17 | var $db_name;
|
---|
| 18 | var $db_user;
|
---|
| 19 | var $db_pass;
|
---|
| 20 | var $db_host;
|
---|
| 21 | var $db_salt;
|
---|
| 22 | var $langInfo;
|
---|
| 23 |
|
---|
| 24 | function __constructor() //for PHP5
|
---|
| 25 | {
|
---|
| 26 | $this->wpConfigInfoClass();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | function wpConfigInfoClass() //for PHP4 constructor
|
---|
| 30 | {
|
---|
| 31 | global $xoopsModule;
|
---|
| 32 | $this->xoops_db_prefix = XOOPS_DB_PREFIX .'_';
|
---|
| 33 | $this->db_prefix = $this->_get_wp_db_prefix();
|
---|
| 34 | $this->db_name = XOOPS_DB_NAME;
|
---|
| 35 | $this->db_user = XOOPS_DB_USER;
|
---|
| 36 | $this->db_pass = XOOPS_DB_PASS;
|
---|
| 37 | $this->db_host = XOOPS_DB_HOST;
|
---|
| 38 | if(!defined('XOOPS_DB_NAME') ) $this->_get_resource_db_ini();
|
---|
| 39 | $this->db_salt = (defined('XOOPS_DB_SALT')) ? XOOPS_DB_SALT : '';
|
---|
| 40 | require_once dirname( __FILE__ ).'/langInfo_class.php' ;
|
---|
| 41 | $this->langInfo = new langInfoClass;
|
---|
| 42 | }
|
---|
| 43 | function _get_wp_db_prefix(){
|
---|
| 44 | $module_name = basename(dirname(dirname(__FILE__)));
|
---|
| 45 | $module_db_prefix = XOOPS_DB_PREFIX . '_' . preg_replace('/wordpress/','wp',$module_name) . '_';
|
---|
| 46 | return $module_db_prefix;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | // XOOPS3 doesn't define the DB connection information in the constant.
|
---|
| 50 | function _get_resource_db_ini(){
|
---|
| 51 | if(!defined('XOOPS_VAR_PATH') ) return;
|
---|
| 52 | $def_file = XOOPS_VAR_PATH . '/etc/resource.db.ini.php';
|
---|
| 53 | if(! file_exists($def_file)) return;
|
---|
| 54 | $array_file = file($def_file);
|
---|
| 55 | foreach ($array_file as $line){
|
---|
| 56 | if (preg_match('/^\s*dbname\s*=\s*[\'"](.*)[\'"]/' ,$line,$matchs))
|
---|
| 57 | $this->db_name = $matchs[1];
|
---|
| 58 | if (preg_match('/^\s*host\s*=\s*[\'"](.*)[\'"]/' ,$line,$matchs))
|
---|
| 59 | $this->db_host = $matchs[1];
|
---|
| 60 | if (preg_match('/^\s*username\s*=\s*[\'"](.*)[\'"]/' ,$line,$matchs))
|
---|
| 61 | $this->db_user = $matchs[1];
|
---|
| 62 | if (preg_match('/^\s*password\s*=\s*[\'"](.*)[\'"]/' ,$line,$matchs))
|
---|
| 63 | $this->db_pass = $matchs[1];
|
---|
| 64 | if (preg_match('/^\s*prefix\s*=\s*[\'"](.*)[\'"]/' ,$line,$matchs))
|
---|
| 65 | $this->db_prefix = $matchs[1];
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | function get_xoops_db_prefix(){
|
---|
| 70 | return $this->xoops_db_prefix;
|
---|
| 71 | }
|
---|
| 72 | function get_db_prefix(){
|
---|
| 73 | return $this->db_prefix;
|
---|
| 74 | }
|
---|
| 75 | function get_wp_db_prefix(){
|
---|
| 76 | return $this->db_prefix;
|
---|
| 77 | }
|
---|
| 78 | function get_db_name(){
|
---|
| 79 | return $this->db_name;
|
---|
| 80 | }
|
---|
| 81 | function get_db_user(){
|
---|
| 82 | return $this->db_user;
|
---|
| 83 | }
|
---|
| 84 | function get_db_pass(){
|
---|
| 85 | return $this->db_pass;
|
---|
| 86 | }
|
---|
| 87 | function get_db_host(){
|
---|
| 88 | return $this->db_host;
|
---|
| 89 | }
|
---|
| 90 | function get_db_salt(){
|
---|
| 91 | return $this->db_salt;
|
---|
| 92 | }
|
---|
| 93 | function get_wpLang($xoops_lang=''){
|
---|
| 94 | return $this->langInfo->get_wpLang($xoops_lang);
|
---|
| 95 | }
|
---|
| 96 | }
|
---|
| 97 | endif;
|
---|
| 98 | ?> |
---|