Changeset 769 for branches/Ver2.4/xpressme_integration_kit/class
- Timestamp:
- May 24, 2011, 9:03:23 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Ver2.4/xpressme_integration_kit/class/config_from_xoops.class.php
r763 r769 78 78 // end of /admin/index.php page detect 79 79 80 if (file_exists($this->xp_config_file_path)){ // file exists xp-config.php 81 $this->_get_value_by_xp_config_file(); 82 }else if (defined('XOOPS_MAINFILE_INCLUDED') && !$is_xoops_module_admin){ // loaded XOOPS mainfile.php 83 $this->_get_value_by_xoops_define(); 84 } else { // A set value is acquired from mainfile.php by the pattern match. 85 if(file_exists($this->xoops_mainfile_path)){ 86 $this->_get_value_by_xoops_mainfile(); 87 88 // Xoops2.5 secure.php 89 if (!empty($this->xoops_var_path)){ 90 $secure_path = $this->xoops_var_path . "/data/secure.php"; 91 if (file_exists($secure_path)){ 92 $this->_get_value_by_xoops_secure($secure_path); 93 } 94 } 95 96 // Value 'is_impress' and value 'external_define_path' used in the under 97 // are set in _get_value_by_xoops_mainfile(). 98 if ($this->is_impress){ // DB Config from Impress CMS impress_db_config file 99 $this->_get_value_by_impress_db_config_file(); 100 } else if(!empty($this->external_define_path)){ // file exists mainfile.php in the trust pass. 101 $this->_get_value_by_trust_mainfile(); 102 } 103 } // end of if file_exists 104 105 } 106 107 // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP) 108 $this->xoops_upload_path = $this->xoops_root_path .'/uploads'; 109 $this->xoops_upload_url = $this->xoops_url . '/uploads'; 110 $this->module_db_prefix = $this->xoops_db_prefix . '_' . preg_replace('/wordpress/','wp',$this->module_name) . '_'; 111 112 $this->set_module_version(); 113 $this->set_wp_version(); 114 if (function_exists('date_default_timezone_get')){ 115 $this->xoops_time_zone = date_default_timezone_get(); 116 } 117 $this->_get_cache_path(); 118 } 119 120 // A set value is acquired from XOOPS mainfile.php by the pattern match. 121 function _get_value_by_xoops_mainfile(){ 122 $array_file = file($this->xoops_mainfile_path); 123 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;'; 124 $impress_include_pattern = '^\s*(include_once|include)\s*[\(\s]\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*[\)\s]\s*;'; 125 $external_define_file_pattern = '^\s*(include_once|include|require_once|require_once)\s*\((.*mainfile\.php.*)\)'; 126 for ($i = 0 ; $i <count($array_file) ; $i++){ 127 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 128 $keys = $matchs[1]; 129 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 130 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 131 $key_value = $matchs[2]; 132 133 switch ($keys){ 134 case 'XOOPS_ROOT_PATH': 135 $this->xoops_root_path = $this->xpress_eval($key_value); 136 break; 137 case 'XOOPS_URL': 138 $this->xoops_url = $this->xpress_eval($key_value); 139 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 140 break; 141 case 'XOOPS_PATH': 142 $this->xoops_path = $this->xpress_eval($key_value); 143 case 'XOOPS_TRUST_PATH': 144 $this->xoops_trust_path = $this->xpress_eval($key_value); 145 if ($this->xoops_trust_path == 'XOOPS_PATH') 146 $this->xoops_trust_path = $this->xoops_path; 147 break; 148 case 'XOOPS_DB_PREFIX': 149 $this->xoops_db_prefix = $this->xpress_eval($key_value); 150 break; 151 case 'XOOPS_DB_NAME': 152 $this->xoops_db_name = $this->xpress_eval($key_value); 153 break; 154 case 'XOOPS_DB_USER': 155 $this->xoops_db_user = $this->xpress_eval($key_value); 156 break; 157 case 'XOOPS_DB_PASS': 158 $this->xoops_db_pass = $this->xpress_eval($key_value); 159 break; 160 case 'XOOPS_DB_HOST': 161 $this->xoops_db_host = $this->xpress_eval($key_value); 162 break; 163 case 'XOOPS_DB_SALT': 164 $this->xoops_db_salt = $this->xpress_eval($key_value); 165 break; 166 case 'XOOPS_SALT': 167 $this->xoops_salt = $this->xpress_eval($key_value); 168 break; 169 case 'XOOPS_VAR_PATH': 170 $this->xoops_var_path = $this->xpress_eval($key_value); 171 break; 172 default : 173 174 } // end of switch 175 } // end of if preg_match 176 177 // Check External Define File 178 if (preg_match('/' . $external_define_file_pattern . '/' ,$array_file[$i],$trust_main_matchs)){ 179 $include_path = $this->xpress_eval($trust_main_matchs[2]); 180 if (file_exists($include_path)) 181 $this->external_define_path = $include_path; 182 } 183 184 // Check ImpressCMS 185 if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){ 186 $this->is_impress = true; 187 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2]; 188 } 189 } // end of for loop 190 } 191 // A set value is acquired from XOOPS mainfile.php by the pattern match. 192 function _get_value_by_xoops_secure($secure_path){ 193 $array_file = file($secure_path); 194 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;'; 195 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)'; 196 $external_define_file_pattern = '^\s*(include_once|include|require_once|require_once)\s*\((.*mainfile\.php.*)\)'; 197 for ($i = 0 ; $i <count($array_file) ; $i++){ 198 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 199 $keys = $matchs[1]; 200 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 201 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 202 $key_value = $matchs[2]; 203 204 switch ($keys){ 205 case 'XOOPS_DB_PREFIX': 206 $this->xoops_db_prefix = $this->xpress_eval($key_value); 207 break; 208 case 'XOOPS_DB_NAME': 209 $this->xoops_db_name = $this->xpress_eval($key_value); 210 break; 211 case 'XOOPS_DB_USER': 212 $this->xoops_db_user = $this->xpress_eval($key_value); 213 break; 214 case 'XOOPS_DB_PASS': 215 $this->xoops_db_pass = $this->xpress_eval($key_value); 216 break; 217 case 'XOOPS_DB_HOST': 218 $this->xoops_db_host = $this->xpress_eval($key_value); 219 break; 220 case 'XOOPS_DB_SALT': 221 $this->xoops_db_salt = $this->xpress_eval($key_value); 222 break; 223 case 'XOOPS_SALT': 224 $this->xoops_salt = $this->xpress_eval($key_value); 225 break; 226 case 'XOOPS_DB_CHARSET': 227 $this->xoops_db_charset = $this->xpress_eval($key_value); 228 break; 229 case 'XOOPS_DB_PCONNECT': 230 $this->xoops_db_pconnect = $this->xpress_eval($key_value); 231 break; 232 default : 233 234 } // end of switch 235 } // end of if preg_match 236 237 } // end of for loop 238 } 239 // A set value is acquired from XOOPS define value . 240 function _get_value_by_xoops_define(){ 80 241 $this->xoops_root_path = XOOPS_ROOT_PATH; 81 242 $this->xoops_url = XOOPS_URL; … … 89 250 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 90 251 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 91 92 // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP) 93 $this->xoops_upload_path = $this->xoops_root_path .'/uploads'; 94 $this->xoops_upload_url = $this->xoops_url . '/uploads'; 95 $this->module_db_prefix = $this->xoops_db_prefix . '_' . preg_replace('/wordpress/','wp',$this->module_name) . '_'; 96 97 $this->set_module_version(); 98 $this->set_wp_version(); 99 if (function_exists('date_default_timezone_get')){ 100 $this->xoops_time_zone = date_default_timezone_get(); 101 } 102 $this->_get_cache_path(); 103 } 104 252 } 253 // A set value is acquired from xp-config.php . 254 function _get_value_by_xp_config_file(){ 255 require_once($this->xp_config_file_path); 256 $this->xoops_root_path =XP_XOOPS_ROOT_PATH; 257 $this->xoops_url = XP_XOOPS_URL; 258 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 259 if(defined('XP_XOOPS_TRUST_PATH')) $this->xoops_trust_path = XP_XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 260 $this->xoops_db_prefix = XP_XOOPS_DB_PREFIX; 261 $this->xoops_db_name = XP_XOOPS_DB_NAME; 262 $this->xoops_db_user = XP_XOOPS_DB_USER; 263 $this->xoops_db_pass = XP_XOOPS_DB_PASS; 264 $this->xoops_db_host = XP_XOOPS_DB_HOST; 265 if(defined('XP_XOOPS_DB_SALT')) $this->xoops_db_salt = XP_XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 266 if(defined('XOOPS_SALT')) $this->xoops_salt = XP_XOOPS_SALT; else $this->xoops_salt = ''; 267 } 268 269 // A set value is acquired from config file in the trust pass by the pattern match. 270 function _get_value_by_impress_db_config_file(){ 271 if(file_exists($this->impress_db_config_file)){ 272 $array_file = file($this->impress_db_config_file); 273 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;'; 274 for ($i = 0 ; $i <count($array_file) ; $i++){ 275 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 276 $keys = $matchs[1]; 277 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 278 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 279 $key_value = $matchs[2]; 280 281 switch ($keys){ 282 case 'SDATA_DB_SALT': 283 $this->xoops_db_salt = $this->xpress_eval($key_value); 284 break; 285 case 'SDATA_DB_PREFIX': 286 $this->xoops_db_prefix = $this->xpress_eval($key_value); 287 break; 288 case 'SDATA_DB_NAME': 289 $this->xoops_db_name = $this->xpress_eval($key_value); 290 break; 291 case 'SDATA_DB_USER': 292 $this->xoops_db_user = $this->xpress_eval($key_value); 293 break; 294 case 'SDATA_DB_PASS': 295 $this->xoops_db_pass = $this->xpress_eval($key_value); 296 break; 297 case 'SDATA_DB_HOST': 298 $this->xoops_db_host = $this->xpress_eval($key_value); 299 break; 300 default : 301 302 } // end of switch 303 } 304 } // end of for 305 } // end of if file_exists 306 } 307 308 function _get_value_by_trust_mainfile(){ 309 // When the definition is written in mainfile.php in the trust passing 310 if(file_exists($this->external_define_path)){ 311 require_once($this->external_define_path); 312 313 $this->xoops_root_path = XOOPS_ROOT_PATH; 314 $this->xoops_url = XOOPS_URL; 315 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 316 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 317 $this->xoops_db_prefix = XOOPS_DB_PREFIX; 318 $this->xoops_db_name = XOOPS_DB_NAME; 319 $this->xoops_db_user = XOOPS_DB_USER; 320 $this->xoops_db_pass = XOOPS_DB_PASS; 321 $this->xoops_db_host = XOOPS_DB_HOST; 322 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 323 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 324 } // end of if file_exists 325 } 105 326 106 327 // call after the $this->xoops_trust_path is set
Note: See TracChangeset
for help on using the changeset viewer.