Changeset 331
- Timestamp:
- Jul 9, 2009, 6:18:51 PM (15 years ago)
- Location:
- trunk/xpressme_integration_kit
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/class/config_from_xoops.class.php
r326 r331 16 16 var $define_arry = array(); 17 17 var $external_define_path; 18 var $xp_config_file_path; 18 19 var $xoops_root_path; 19 20 var $xoops_url; … … 59 60 $this->module_path=dirname(dirname(__FILE__)); 60 61 $this->module_name=basename($this->module_path); 61 if (defined('XOOPS_MAINFILE_INCLUDED')){ 62 $this->xoops_root_path = XOOPS_ROOT_PATH; 63 $this->xoops_url = XOOPS_URL; 64 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 65 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 66 $this->xoops_db_prefix = XOOPS_DB_PREFIX; 67 $this->xoops_db_name = XOOPS_DB_NAME; 68 $this->xoops_db_user = XOOPS_DB_USER; 69 $this->xoops_db_pass = XOOPS_DB_PASS; 70 $this->xoops_db_host = XOOPS_DB_HOST; 71 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 72 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 73 } else { 62 $this->xp_config_file_path = $this->module_path . '/xp-config.php'; 63 64 if (file_exists($this->xp_config_file_path)){ // file exists xp-config.php 65 $this->_get_value_by_xp_config_file(); 66 } else if (defined('XOOPS_MAINFILE_INCLUDED')){ // loaded XOOPS mainfile.php 67 $this->_get_value_by_xoops_define(); 68 } else { // A set value is acquired from mainfile.php by the pattern match. 74 69 if(file_exists($this->xoops_mainfile_path)){ 75 $array_file = file($this->xoops_mainfile_path); 76 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;'; 77 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)'; 78 $external_define_file_pattern = '^\s*(include_once|include|require_once|require_once)\s*\((.*mainfile\.php.*)\)'; 79 for ($i = 0 ; $i <count($array_file) ; $i++){ 80 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 81 $keys = $matchs[1]; 82 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 83 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 84 $key_value = $matchs[2]; 85 86 switch ($keys){ 87 case 'XOOPS_ROOT_PATH': 88 $this->xoops_root_path = $this->xpress_eval($key_value); 89 break; 90 case 'XOOPS_URL': 91 $this->xoops_url = $this->xpress_eval($key_value); 92 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 93 break; 94 case 'XOOPS_TRUST_PATH': 95 $this->xoops_trust_path = $this->xpress_eval($key_value); 96 break; 97 case 'XOOPS_DB_PREFIX': 98 $this->xoops_db_prefix = $this->xpress_eval($key_value); 99 break; 100 case 'XOOPS_DB_NAME': 101 $this->xoops_db_name = $this->xpress_eval($key_value); 102 break; 103 case 'XOOPS_DB_USER': 104 $this->xoops_db_user = $this->xpress_eval($key_value); 105 break; 106 case 'XOOPS_DB_PASS': 107 $this->xoops_db_pass = $this->xpress_eval($key_value); 108 break; 109 case 'XOOPS_DB_HOST': 110 $this->xoops_db_host = $this->xpress_eval($key_value); 111 break; 112 case 'XOOPS_DB_SALT': 113 $this->xoops_db_salt = $this->xpress_eval($key_value); 114 break; 115 case 'XOOPS_SALT': 116 $this->xoops_salt = $this->xpress_eval($key_value); 117 break; 118 default : 119 120 } // end of switch 121 } // end of if preg_match 122 123 // Check External Define File 124 if (preg_match('/' . $external_define_file_pattern . '/' ,$array_file[$i],$trust_main_matchs)){ 125 $include_path = $this->xpress_eval($trust_main_matchs[2]); 126 if (file_exists($include_path)) 127 $this->external_define_path = $include_path; 128 } 129 130 // Check ImpressCMS 131 if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){ 132 $this->is_impress = true; 133 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2]; 134 } 135 } // end of for loop 70 $this->_get_value_by_xoops_mainfile(); 71 // Value 'is_impress' and value 'external_define_path' used in the under 72 // are set in _get_value_by_xoops_mainfile(). 73 if ($this->is_impress){ // DB Config from Impress CMS impress_db_config file 74 $this->_get_value_by_impress_db_config_file(); 75 } else if(!empty($this->external_define_path)){ // file exists mainfile.php in the trust pass. 76 $this->_get_value_by_trust_mainfile(); 77 } 136 78 } // end of if file_exists 137 79 138 // DB Config from Impress CMS impress_db_config file139 if ($this->is_impress){140 if(file_exists($this->impress_db_config_file)){141 $array_file = file($this->impress_db_config_file);142 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;';143 for ($i = 0 ; $i <count($array_file) ; $i++){144 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){145 $keys = $matchs[1];146 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys);147 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys);148 $key_value = $matchs[2];149 150 switch ($keys){151 case 'SDATA_DB_SALT':152 $this->xoops_db_salt = $this->xpress_eval($key_value);153 break;154 case 'SDATA_DB_PREFIX':155 $this->xoops_db_prefix = $this->xpress_eval($key_value);156 break;157 case 'SDATA_DB_NAME':158 $this->xoops_db_name = $this->xpress_eval($key_value);159 break;160 case 'SDATA_DB_USER':161 $this->xoops_db_user = $this->xpress_eval($key_value);162 break;163 case 'SDATA_DB_PASS':164 $this->xoops_db_pass = $this->xpress_eval($key_value);165 break;166 case 'SDATA_DB_HOST':167 $this->xoops_db_host = $this->xpress_eval($key_value);168 break;169 default :170 171 } // end of switch172 }173 } // end of for174 } // end of if file_exists175 } // end ofImpress CMS176 177 // DB Config from external define file178 if(!empty($this->external_define_path)){179 if(file_exists($this->external_define_path)){180 require_once($this->external_define_path);181 182 $this->xoops_root_path = XOOPS_ROOT_PATH;183 $this->xoops_url = XOOPS_URL;184 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;185 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = '';186 $this->xoops_db_prefix = XOOPS_DB_PREFIX;187 $this->xoops_db_name = XOOPS_DB_NAME;188 $this->xoops_db_user = XOOPS_DB_USER;189 $this->xoops_db_pass = XOOPS_DB_PASS;190 $this->xoops_db_host = XOOPS_DB_HOST;191 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = '';192 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = '';193 } // end of if file_exists194 }195 80 } 196 81 197 198 82 // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP) 199 83 $this->xoops_upload_path = $this->xoops_root_path .'/uploads'; … … 209 93 $this->set_mu_current_site(); 210 94 } 95 96 // A set value is acquired from XOOPS mainfile.php by the pattern match. 97 function _get_value_by_xoops_mainfile(){ 98 $array_file = file($this->xoops_mainfile_path); 99 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;'; 100 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)'; 101 $external_define_file_pattern = '^\s*(include_once|include|require_once|require_once)\s*\((.*mainfile\.php.*)\)'; 102 for ($i = 0 ; $i <count($array_file) ; $i++){ 103 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 104 $keys = $matchs[1]; 105 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 106 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 107 $key_value = $matchs[2]; 108 109 switch ($keys){ 110 case 'XOOPS_ROOT_PATH': 111 $this->xoops_root_path = $this->xpress_eval($key_value); 112 break; 113 case 'XOOPS_URL': 114 $this->xoops_url = $this->xpress_eval($key_value); 115 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 116 break; 117 case 'XOOPS_TRUST_PATH': 118 $this->xoops_trust_path = $this->xpress_eval($key_value); 119 break; 120 case 'XOOPS_DB_PREFIX': 121 $this->xoops_db_prefix = $this->xpress_eval($key_value); 122 break; 123 case 'XOOPS_DB_NAME': 124 $this->xoops_db_name = $this->xpress_eval($key_value); 125 break; 126 case 'XOOPS_DB_USER': 127 $this->xoops_db_user = $this->xpress_eval($key_value); 128 break; 129 case 'XOOPS_DB_PASS': 130 $this->xoops_db_pass = $this->xpress_eval($key_value); 131 break; 132 case 'XOOPS_DB_HOST': 133 $this->xoops_db_host = $this->xpress_eval($key_value); 134 break; 135 case 'XOOPS_DB_SALT': 136 $this->xoops_db_salt = $this->xpress_eval($key_value); 137 break; 138 case 'XOOPS_SALT': 139 $this->xoops_salt = $this->xpress_eval($key_value); 140 break; 141 default : 142 143 } // end of switch 144 } // end of if preg_match 145 146 // Check External Define File 147 if (preg_match('/' . $external_define_file_pattern . '/' ,$array_file[$i],$trust_main_matchs)){ 148 $include_path = $this->xpress_eval($trust_main_matchs[2]); 149 if (file_exists($include_path)) 150 $this->external_define_path = $include_path; 151 } 152 153 // Check ImpressCMS 154 if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){ 155 $this->is_impress = true; 156 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2]; 157 } 158 } // end of for loop 159 } 160 // A set value is acquired from XOOPS define value . 161 function _get_value_by_xoops_define(){ 162 $this->xoops_root_path = XOOPS_ROOT_PATH; 163 $this->xoops_url = XOOPS_URL; 164 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 165 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 166 $this->xoops_db_prefix = XOOPS_DB_PREFIX; 167 $this->xoops_db_name = XOOPS_DB_NAME; 168 $this->xoops_db_user = XOOPS_DB_USER; 169 $this->xoops_db_pass = XOOPS_DB_PASS; 170 $this->xoops_db_host = XOOPS_DB_HOST; 171 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 172 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 173 } 174 // A set value is acquired from xp-config.php . 175 function _get_value_by_xp_config_file(){ 176 require_once($this->xp_config_file_path); 177 $this->xoops_root_path =XP_XOOPS_ROOT_PATH; 178 $this->xoops_url = XP_XOOPS_URL; 179 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 180 if(defined('XP_XOOPS_TRUST_PATH')) $this->xoops_trust_path = XP_XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 181 $this->xoops_db_prefix = XP_XOOPS_DB_PREFIX; 182 $this->xoops_db_name = XP_XOOPS_DB_NAME; 183 $this->xoops_db_user = XP_XOOPS_DB_USER; 184 $this->xoops_db_pass = XP_XOOPS_DB_PASS; 185 $this->xoops_db_host = XP_XOOPS_DB_HOST; 186 if(defined('XP_XOOPS_DB_SALT')) $this->xoops_db_salt = XP_XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 187 if(defined('XOOPS_SALT')) $this->xoops_salt = XP_XOOPS_SALT; else $this->xoops_salt = ''; 188 } 189 190 // A set value is acquired from config file in the trust pass by the pattern match. 191 function _get_value_by_impress_db_config_file(){ 192 if(file_exists($this->impress_db_config_file)){ 193 $array_file = file($this->impress_db_config_file); 194 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;'; 195 for ($i = 0 ; $i <count($array_file) ; $i++){ 196 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 197 $keys = $matchs[1]; 198 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 199 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 200 $key_value = $matchs[2]; 201 202 switch ($keys){ 203 case 'SDATA_DB_SALT': 204 $this->xoops_db_salt = $this->xpress_eval($key_value); 205 break; 206 case 'SDATA_DB_PREFIX': 207 $this->xoops_db_prefix = $this->xpress_eval($key_value); 208 break; 209 case 'SDATA_DB_NAME': 210 $this->xoops_db_name = $this->xpress_eval($key_value); 211 break; 212 case 'SDATA_DB_USER': 213 $this->xoops_db_user = $this->xpress_eval($key_value); 214 break; 215 case 'SDATA_DB_PASS': 216 $this->xoops_db_pass = $this->xpress_eval($key_value); 217 break; 218 case 'SDATA_DB_HOST': 219 $this->xoops_db_host = $this->xpress_eval($key_value); 220 break; 221 default : 222 223 } // end of switch 224 } 225 } // end of for 226 } // end of if file_exists 227 } 228 229 function _get_value_by_trust_mainfile(){ 230 // When the definition is written in mainfile.php in the trust passing 231 if(file_exists($this->external_define_path)){ 232 require_once($this->external_define_path); 233 234 $this->xoops_root_path = XOOPS_ROOT_PATH; 235 $this->xoops_url = XOOPS_URL; 236 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 237 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 238 $this->xoops_db_prefix = XOOPS_DB_PREFIX; 239 $this->xoops_db_name = XOOPS_DB_NAME; 240 $this->xoops_db_user = XOOPS_DB_USER; 241 $this->xoops_db_pass = XOOPS_DB_PASS; 242 $this->xoops_db_host = XOOPS_DB_HOST; 243 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 244 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 245 } // end of if file_exists 246 } 211 247 212 248 function get_xoops_mainfile_path(){
Note: See TracChangeset
for help on using the changeset viewer.