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 | var $module_db_prefix;
|
---|
29 | var $xoops_upload_path;
|
---|
30 | var $xoops_upload_url;
|
---|
31 |
|
---|
32 |
|
---|
33 | function __constructor() //for PHP5
|
---|
34 | {
|
---|
35 | $this->ConfigFromXoops();
|
---|
36 |
|
---|
37 | }
|
---|
38 |
|
---|
39 | function ConfigFromXoops() //for PHP4 constructor
|
---|
40 | {
|
---|
41 | $this->xoops_mainfile_path = $this->get_xoops_mainfile_path();
|
---|
42 | $this->module_path=dirname(dirname(__FILE__));
|
---|
43 | $this->module_name=basename($this->module_path);
|
---|
44 | if(file_exists($this->xoops_mainfile_path)){
|
---|
45 | $array_file = file($this->xoops_mainfile_path);
|
---|
46 | for ($i = 0 ; $i <count($array_file) ; $i++){
|
---|
47 | /* Ref. ImpressCMS
|
---|
48 |
|
---|
49 | mainfile.php
|
---|
50 | define( 'XOOPS_TRUST_PATH', 'C:/xampp/trust_pathf6fac' );
|
---|
51 |
|
---|
52 | include_once(XOOPS_TRUST_PATH . '/3aec9eefada2c57b3705952094b7b070.php');
|
---|
53 |
|
---|
54 | define( 'XOOPS_DB_PREFIX', SDATA_DB_PREFIX );
|
---|
55 | define( 'XOOPS_DB_HOST', SDATA_DB_HOST );
|
---|
56 | define( 'XOOPS_DB_USER', SDATA_DB_USER );
|
---|
57 | define( 'XOOPS_DB_PASS', SDATA_DB_PASS );
|
---|
58 | define( 'XOOPS_DB_NAME', SDATA_DB_NAME );
|
---|
59 | define( 'XOOPS_DB_SALT', SDATA_DB_SALT );
|
---|
60 |
|
---|
61 | XOOPS_TRUST_PATH . '/3aec9eefada2c57b3705952094b7b070.php'
|
---|
62 | define( 'SDATA_DB_HOST', 'localhost' );
|
---|
63 | define( 'SDATA_DB_USER', 'root' );
|
---|
64 | define( 'SDATA_DB_PASS', '' );
|
---|
65 | define( 'SDATA_DB_NAME', 'impress' );
|
---|
66 | define( 'SDATA_DB_PREFIX', 'id85d03cc' );
|
---|
67 | define( 'SDATA_DB_SALT', '3mhUHMrsTU3CTifQbenOtK1ULG5QN2Dwx8zCfwtynudub4TS9AnmZAhmdQr43Uvot' );
|
---|
68 |
|
---|
69 | ref. code C:\xampp\htdocs\impress\install\page_configsave.php
|
---|
70 | $sdata_rewrite = array();
|
---|
71 | $sdata_rewrite['DB_HOST'] = $vars['DB_HOST'];
|
---|
72 | $sdata_rewrite['DB_USER'] = $vars['DB_USER'];
|
---|
73 | $sdata_rewrite['DB_PASS'] = $vars['DB_PASS'];
|
---|
74 | $sdata_rewrite['DB_NAME'] = $vars['DB_NAME'];
|
---|
75 | $sdata_rewrite['DB_PREFIX'] = $vars['DB_PREFIX'];
|
---|
76 | $sdata_rewrite['DB_SALT'] = $vars['DB_SALT'];
|
---|
77 |
|
---|
78 |
|
---|
79 | foreach( $sdata_rewrite as $key => $val ) {
|
---|
80 | if( preg_match( "/(define\()([\"'])(SDATA_$key)\\2,\s*([\"'])(.*?)\\4\s*\)/", $content ) ) {
|
---|
81 | $val = addslashes( $val );
|
---|
82 | $content = preg_replace( "/(define\()([\"'])(SDATA_$key)\\2,\s*([\"'])(.*?)\\4\s*\)/",
|
---|
83 | "define( 'SDATA_$key', '$val' )", $content );
|
---|
84 | } else {
|
---|
85 | //$this->error = true;
|
---|
86 | //$this->report .= _NGIMG.sprintf( ERR_WRITING_CONSTANT, "<b>$val</b>")."<br />\n";
|
---|
87 | }
|
---|
88 | }
|
---|
89 | */
|
---|
90 |
|
---|
91 | $array_file[$i] = trim($array_file[$i]);
|
---|
92 | $array_file[$i] = str_replace(' ','',$array_file[$i]);
|
---|
93 |
|
---|
94 | $array_file[$i] = preg_replace('/\s\s+/', '', $array_file[$i]);
|
---|
95 | $array_file[$i] = preg_replace('/^include.*/','',$array_file[$i]);
|
---|
96 | $array_file[$i] = preg_replace('/^\/\/.*/','',$array_file[$i]);
|
---|
97 | $array_file[$i] = preg_replace('/^if.*/','',$array_file[$i]);
|
---|
98 | if (strstr($array_file[$i],'define')!== false){
|
---|
99 | $array_file[$i] = preg_replace('/\"/', '', $array_file[$i]);
|
---|
100 | $array_file[$i] = preg_replace('/\(/', '', $array_file[$i]);
|
---|
101 | $array_file[$i] = preg_replace('/\)/', '', $array_file[$i]);
|
---|
102 | $array_file[$i] = preg_replace('/\;/', '', $array_file[$i]);
|
---|
103 | $array_file[$i] = preg_replace('/\'/', '', $array_file[$i]);
|
---|
104 | $array_file[$i] = preg_replace('/define/', '', $array_file[$i]);
|
---|
105 | $define = explode(',',$array_file[$i] );
|
---|
106 | $define[0] = trim($define[0]);
|
---|
107 | $define[1] = trim($define[1]);
|
---|
108 | switch ($define[0]){
|
---|
109 | case 'XOOPS_ROOT_PATH':
|
---|
110 | $this->xoops_root_path = $define[1];
|
---|
111 | $this->xoops_url . '/modules/' . $this->module_name;
|
---|
112 | break;
|
---|
113 | case 'XOOPS_URL':
|
---|
114 | $this->xoops_url = $define[1];
|
---|
115 | $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
|
---|
116 | break;
|
---|
117 | case 'XOOPS_TRUST_PATH':
|
---|
118 | $this->xoops_trust_path = $define[1];
|
---|
119 | break;
|
---|
120 | case 'XOOPS_DB_PREFIX':
|
---|
121 | $this->xoops_db_prefix = $define[1];
|
---|
122 | break;
|
---|
123 | case 'XOOPS_DB_NAME':
|
---|
124 | $this->xoops_db_name = $define[1];
|
---|
125 | break;
|
---|
126 | case 'XOOPS_DB_USER':
|
---|
127 | $this->xoops_db_user = $define[1];
|
---|
128 | break;
|
---|
129 | case 'XOOPS_DB_PASS':
|
---|
130 | $this->xoops_db_pass = $define[1];
|
---|
131 | break;
|
---|
132 | case 'XOOPS_DB_HOST':
|
---|
133 | $this->xoops_db_host = $define[1];
|
---|
134 | break;
|
---|
135 | default :
|
---|
136 | }
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP)
|
---|
142 | $this->xoops_upload_path = $this->xoops_root_path .'/uploads';
|
---|
143 | $this->xoops_upload_url = $this->xoops_url . '/uploads';
|
---|
144 |
|
---|
145 | if ($this->module_name == 'wordpress')
|
---|
146 | $this->module_db_prefix = $this->xoops_db_prefix . '_wp_';
|
---|
147 | else
|
---|
148 | $this->module_db_prefix = $this->xoops_db_prefix . '_' . $this->module_name . '_';
|
---|
149 |
|
---|
150 | }
|
---|
151 |
|
---|
152 | function get_xoops_mainfile_path(){
|
---|
153 | return dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
|
---|
154 | }
|
---|
155 |
|
---|
156 | }
|
---|
157 | ?>
|
---|