- Timestamp:
- Jul 8, 2009, 3:46:33 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/class/config_from_xoops.class.php
r252 r326 15 15 var $xoops_mainfile_path; 16 16 var $define_arry = array(); 17 var $external_define_path; 17 18 var $xoops_root_path; 18 19 var $xoops_url; … … 56 57 { 57 58 $this->xoops_mainfile_path = $this->get_xoops_mainfile_path(); 58 $this->module_path=dirname(dirname(__FILE__)); 59 $this->module_path=dirname(dirname(__FILE__)); 59 60 $this->module_name=basename($this->module_path); 60 if(file_exists($this->xoops_mainfile_path)){ 61 $array_file = file($this->xoops_mainfile_path); 62 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;'; 63 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)'; 64 for ($i = 0 ; $i <count($array_file) ; $i++){ 65 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 66 $keys = $matchs[1]; 67 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 68 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 69 $key_value = $matchs[2]; 70 71 switch ($keys){ 72 case 'XOOPS_ROOT_PATH': 73 $this->xoops_root_path = $this->xpress_eval($key_value); 74 $this->xoops_url . '/modules/' . $this->module_name; 75 break; 76 case 'XOOPS_URL': 77 $this->xoops_url = $this->xpress_eval($key_value); 78 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 79 break; 80 case 'XOOPS_TRUST_PATH': 81 $this->xoops_trust_path = $this->xpress_eval($key_value); 82 break; 83 case 'XOOPS_DB_PREFIX': 84 $this->xoops_db_prefix = $this->xpress_eval($key_value); 85 break; 86 case 'XOOPS_DB_NAME': 87 $this->xoops_db_name = $this->xpress_eval($key_value); 88 break; 89 case 'XOOPS_DB_USER': 90 $this->xoops_db_user = $this->xpress_eval($key_value); 91 break; 92 case 'XOOPS_DB_PASS': 93 $this->xoops_db_pass = $this->xpress_eval($key_value); 94 break; 95 case 'XOOPS_DB_HOST': 96 $this->xoops_db_host = $this->xpress_eval($key_value); 97 break; 98 case 'XOOPS_DB_SALT': 99 $this->xoops_db_salt = $this->xpress_eval($key_value); 100 break; 101 case 'XOOPS_SALT': 102 $this->xoops_salt = $this->xpress_eval($key_value); 103 break; 104 default : 105 106 } // end of switch 107 } // end of if preg_match 108 109 // Check ImpressCMS 110 if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){ 111 $this->is_impress = true; 112 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2]; 113 } 114 } // end of for loop 115 } // end of if file_exists 116 117 // DB Config from Impress CMS impress_db_config file 118 if ($this->is_impress){ 119 if(file_exists($this->impress_db_config_file)){ 120 $array_file = file($this->impress_db_config_file); 121 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;'; 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 { 74 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.*)\)'; 122 79 for ($i = 0 ; $i <count($array_file) ; $i++){ 123 80 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ … … 128 85 129 86 switch ($keys){ 130 case 'SDATA_DB_SALT': 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': 131 113 $this->xoops_db_salt = $this->xpress_eval($key_value); 132 114 break; 133 case 'SDATA_DB_PREFIX': 134 $this->xoops_db_prefix = $this->xpress_eval($key_value); 135 break; 136 case 'SDATA_DB_NAME': 137 $this->xoops_db_name = $this->xpress_eval($key_value); 138 break; 139 case 'SDATA_DB_USER': 140 $this->xoops_db_user = $this->xpress_eval($key_value); 141 break; 142 case 'SDATA_DB_PASS': 143 $this->xoops_db_pass = $this->xpress_eval($key_value); 144 break; 145 case 'SDATA_DB_HOST': 146 $this->xoops_db_host = $this->xpress_eval($key_value); 115 case 'XOOPS_SALT': 116 $this->xoops_salt = $this->xpress_eval($key_value); 147 117 break; 148 118 default : 149 119 150 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; 151 128 } 152 } // end of for 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 136 } // end of if file_exists 137 138 // DB Config from Impress CMS impress_db_config file 139 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 switch 172 } 173 } // end of for 174 } // end of if file_exists 175 } // end ofImpress CMS 176 177 // DB Config from external define file 178 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_exists 153 194 } 154 195 } 196 155 197 156 198 // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP)
Note: See TracChangeset
for help on using the changeset viewer.