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 |
|
---|
11 | /*
|
---|
12 | * The function to acquire only a set value without calling the XOOPS system is here.
|
---|
13 | */
|
---|
14 | class ConfigFromXoops{
|
---|
15 | var $xoops_mainfile_path;
|
---|
16 | var $define_arry = array();
|
---|
17 | var $xoops_root_path;
|
---|
18 | var $xoops_url;
|
---|
19 | var $xoops_trust_path;
|
---|
20 | var $xoops_db_prefix;
|
---|
21 | var $xoops_db_name;
|
---|
22 | var $xoops_db_user;
|
---|
23 | var $xoops_db_pass;
|
---|
24 | var $xoops_db_host;
|
---|
25 | var $module_name;
|
---|
26 | var $module_path;
|
---|
27 | var $module_url;
|
---|
28 |
|
---|
29 | function __constructor() //for PHP5
|
---|
30 | {
|
---|
31 | $this->ConfigFromXoops();
|
---|
32 | }
|
---|
33 |
|
---|
34 | function ConfigFromXoops() //for PHP4 constructor
|
---|
35 | {
|
---|
36 | $this->xoops_mainfile_path = $this->get_xoops_mainfile_path();
|
---|
37 | $this->module_path=dirname(dirname(__FILE__));
|
---|
38 | $this->module_name=basename($this->module_path);
|
---|
39 | if(file_exists($this->xoops_mainfile_path)){
|
---|
40 | $array_file = file($this->xoops_mainfile_path);
|
---|
41 | for ($i = 0 ; $i <count($array_file) ; $i++){
|
---|
42 | $array_file[$i] = trim($array_file[$i]);
|
---|
43 | $array_file[$i] = str_replace(' ','',$array_file[$i]);
|
---|
44 |
|
---|
45 | $array_file[$i] = preg_replace('/\s\s+/', '', $array_file[$i]);
|
---|
46 | $array_file[$i] = preg_replace('/^include.*/','',$array_file[$i]);
|
---|
47 | $array_file[$i] = preg_replace('/^\/\/.*/','',$array_file[$i]);
|
---|
48 | $array_file[$i] = preg_replace('/^if.*/','',$array_file[$i]);
|
---|
49 | if (strstr($array_file[$i],'define')!== false){
|
---|
50 | $array_file[$i] = preg_replace('/\"/', '', $array_file[$i]);
|
---|
51 | $array_file[$i] = preg_replace('/\(/', '', $array_file[$i]);
|
---|
52 | $array_file[$i] = preg_replace('/\)/', '', $array_file[$i]);
|
---|
53 | $array_file[$i] = preg_replace('/\;/', '', $array_file[$i]);
|
---|
54 | $array_file[$i] = preg_replace('/\'/', '', $array_file[$i]);
|
---|
55 | $array_file[$i] = preg_replace('/define/', '', $array_file[$i]);
|
---|
56 | $define = explode(',',$array_file[$i] );
|
---|
57 | $define[0] = trim($define[0]);
|
---|
58 | $define[1] = trim($define[1]);
|
---|
59 | switch ($define[0]){
|
---|
60 | case 'XOOPS_ROOT_PATH':
|
---|
61 | $this->xoops_root_path = $define[1];
|
---|
62 | $this->xoops_url . '/modules/' . $this->module_name;
|
---|
63 | break;
|
---|
64 | case 'XOOPS_URL':
|
---|
65 | $this->xoops_url = $define[1];
|
---|
66 | $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
|
---|
67 | break;
|
---|
68 | case 'XOOPS_TRUST_PATH':
|
---|
69 | $this->xoops_trust_path = $define[1];
|
---|
70 | break;
|
---|
71 | case 'XOOPS_DB_PREFIX':
|
---|
72 | $this->xoops_db_prefix = $define[1];
|
---|
73 | break;
|
---|
74 | case 'XOOPS_DB_NAME':
|
---|
75 | $this->xoops_db_name = $define[1];
|
---|
76 | break;
|
---|
77 | case 'XOOPS_DB_USER':
|
---|
78 | $this->xoops_db_user = $define[1];
|
---|
79 | break;
|
---|
80 | case 'XOOPS_DB_PASS':
|
---|
81 | $this->xoops_db_pass = $define[1];
|
---|
82 | break;
|
---|
83 | case 'XOOPS_DB_HOST':
|
---|
84 | $this->xoops_db_host = $define[1];
|
---|
85 | break;
|
---|
86 | default :
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | function get_xoops_mainfile_path(){
|
---|
94 | return dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
|
---|
95 | }
|
---|
96 |
|
---|
97 | }
|
---|
98 | ?>
|
---|