- Timestamp:
- Jul 8, 2009, 3:46:33 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Ver2.0/xpressme_integration_kit/class/config_from_xoops.class.php
r232 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; … … 57 58 $this->module_path=dirname(dirname(__FILE__)); 58 59 $this->module_name=basename($this->module_path); 59 if(file_exists($this->xoops_mainfile_path)){ 60 $array_file = file($this->xoops_mainfile_path); 61 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;'; 62 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)'; 63 for ($i = 0 ; $i <count($array_file) ; $i++){ 64 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 65 $keys = $matchs[1]; 66 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 67 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 68 $key_value = $matchs[2]; 69 70 switch ($keys){ 71 case 'XOOPS_ROOT_PATH': 72 $this->xoops_root_path = $this->xpress_eval($key_value); 73 $this->xoops_url . '/modules/' . $this->module_name; 74 break; 75 case 'XOOPS_URL': 76 $this->xoops_url = $this->xpress_eval($key_value); 77 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 78 break; 79 case 'XOOPS_TRUST_PATH': 80 $this->xoops_trust_path = $this->xpress_eval($key_value); 81 break; 82 case 'XOOPS_DB_PREFIX': 83 $this->xoops_db_prefix = $this->xpress_eval($key_value); 84 break; 85 case 'XOOPS_DB_NAME': 86 $this->xoops_db_name = $this->xpress_eval($key_value); 87 break; 88 case 'XOOPS_DB_USER': 89 $this->xoops_db_user = $this->xpress_eval($key_value); 90 break; 91 case 'XOOPS_DB_PASS': 92 $this->xoops_db_pass = $this->xpress_eval($key_value); 93 break; 94 case 'XOOPS_DB_HOST': 95 $this->xoops_db_host = $this->xpress_eval($key_value); 96 break; 97 case 'XOOPS_DB_SALT': 98 $this->xoops_db_salt = $this->xpress_eval($key_value); 99 break; 100 case 'XOOPS_SALT': 101 $this->xoops_salt = $this->xpress_eval($key_value); 102 break; 103 default : 104 105 } // end of switch 106 } // end of if preg_match 107 108 // Check ImpressCMS 109 if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){ 110 $this->is_impress = true; 111 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2]; 112 } 113 } // end of for loop 114 } // end of if file_exists 115 116 // DB Config from Impress CMS impress_db_config file 117 if ($this->is_impress){ 118 if(file_exists($this->impress_db_config_file)){ 119 $array_file = file($this->impress_db_config_file); 120 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;'; 60 if (defined('XOOPS_MAINFILE_INCLUDED')){ 61 $this->xoops_root_path = XOOPS_ROOT_PATH; 62 $this->xoops_url = XOOPS_URL; 63 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 64 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 65 $this->xoops_db_prefix = XOOPS_DB_PREFIX; 66 $this->xoops_db_name = XOOPS_DB_NAME; 67 $this->xoops_db_user = XOOPS_DB_USER; 68 $this->xoops_db_pass = XOOPS_DB_PASS; 69 $this->xoops_db_host = XOOPS_DB_HOST; 70 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 71 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 72 } else { 73 if(file_exists($this->xoops_mainfile_path)){ 74 $array_file = file($this->xoops_mainfile_path); 75 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;'; 76 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)'; 77 $external_define_file_pattern = '^\s*(include_once|include|require_once|require_once)\s*\((.*mainfile\.php.*)\)'; 121 78 for ($i = 0 ; $i <count($array_file) ; $i++){ 122 79 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ … … 127 84 128 85 switch ($keys){ 129 case 'SDATA_DB_SALT': 86 case 'XOOPS_ROOT_PATH': 87 $this->xoops_root_path = $this->xpress_eval($key_value); 88 break; 89 case 'XOOPS_URL': 90 $this->xoops_url = $this->xpress_eval($key_value); 91 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 92 break; 93 case 'XOOPS_TRUST_PATH': 94 $this->xoops_trust_path = $this->xpress_eval($key_value); 95 break; 96 case 'XOOPS_DB_PREFIX': 97 $this->xoops_db_prefix = $this->xpress_eval($key_value); 98 break; 99 case 'XOOPS_DB_NAME': 100 $this->xoops_db_name = $this->xpress_eval($key_value); 101 break; 102 case 'XOOPS_DB_USER': 103 $this->xoops_db_user = $this->xpress_eval($key_value); 104 break; 105 case 'XOOPS_DB_PASS': 106 $this->xoops_db_pass = $this->xpress_eval($key_value); 107 break; 108 case 'XOOPS_DB_HOST': 109 $this->xoops_db_host = $this->xpress_eval($key_value); 110 break; 111 case 'XOOPS_DB_SALT': 130 112 $this->xoops_db_salt = $this->xpress_eval($key_value); 131 113 break; 132 case 'SDATA_DB_PREFIX': 133 $this->xoops_db_prefix = $this->xpress_eval($key_value); 134 break; 135 case 'SDATA_DB_NAME': 136 $this->xoops_db_name = $this->xpress_eval($key_value); 137 break; 138 case 'SDATA_DB_USER': 139 $this->xoops_db_user = $this->xpress_eval($key_value); 140 break; 141 case 'SDATA_DB_PASS': 142 $this->xoops_db_pass = $this->xpress_eval($key_value); 143 break; 144 case 'SDATA_DB_HOST': 145 $this->xoops_db_host = $this->xpress_eval($key_value); 114 case 'XOOPS_SALT': 115 $this->xoops_salt = $this->xpress_eval($key_value); 146 116 break; 147 117 default : 148 118 149 119 } // end of switch 120 } // end of if preg_match 121 122 // Check External Define File 123 if (preg_match('/' . $external_define_file_pattern . '/' ,$array_file[$i],$trust_main_matchs)){ 124 $include_path = $this->xpress_eval($trust_main_matchs[2]); 125 if (file_exists($include_path)) 126 $this->external_define_path = $include_path; 150 127 } 151 } // end of for 128 129 // Check ImpressCMS 130 if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){ 131 $this->is_impress = true; 132 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2]; 133 } 134 } // end of for loop 135 } // end of if file_exists 136 137 // DB Config from Impress CMS impress_db_config file 138 if ($this->is_impress){ 139 if(file_exists($this->impress_db_config_file)){ 140 $array_file = file($this->impress_db_config_file); 141 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;'; 142 for ($i = 0 ; $i <count($array_file) ; $i++){ 143 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 144 $keys = $matchs[1]; 145 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 146 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 147 $key_value = $matchs[2]; 148 149 switch ($keys){ 150 case 'SDATA_DB_SALT': 151 $this->xoops_db_salt = $this->xpress_eval($key_value); 152 break; 153 case 'SDATA_DB_PREFIX': 154 $this->xoops_db_prefix = $this->xpress_eval($key_value); 155 break; 156 case 'SDATA_DB_NAME': 157 $this->xoops_db_name = $this->xpress_eval($key_value); 158 break; 159 case 'SDATA_DB_USER': 160 $this->xoops_db_user = $this->xpress_eval($key_value); 161 break; 162 case 'SDATA_DB_PASS': 163 $this->xoops_db_pass = $this->xpress_eval($key_value); 164 break; 165 case 'SDATA_DB_HOST': 166 $this->xoops_db_host = $this->xpress_eval($key_value); 167 break; 168 default : 169 170 } // end of switch 171 } 172 } // end of for 173 } // end of if file_exists 174 } // end ofImpress CMS 175 176 // DB Config from external define file 177 if(!empty($this->external_define_path)){ 178 if(file_exists($this->external_define_path)){ 179 require_once($this->external_define_path); 180 181 $this->xoops_root_path = XOOPS_ROOT_PATH; 182 $this->xoops_url = XOOPS_URL; 183 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 184 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 185 $this->xoops_db_prefix = XOOPS_DB_PREFIX; 186 $this->xoops_db_name = XOOPS_DB_NAME; 187 $this->xoops_db_user = XOOPS_DB_USER; 188 $this->xoops_db_pass = XOOPS_DB_PASS; 189 $this->xoops_db_host = XOOPS_DB_HOST; 190 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 191 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 192 } // end of if file_exists 152 193 } 153 194 }
Note: See TracChangeset
for help on using the changeset viewer.