| [92] | 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();     
 | 
|---|
| [326] | 17 |         var $external_define_path;
 | 
|---|
| [331] | 18 |         var $xp_config_file_path;
 | 
|---|
| [92] | 19 |         var $xoops_root_path;
 | 
|---|
 | 20 |         var $xoops_url;
 | 
|---|
 | 21 |         var $xoops_trust_path;
 | 
|---|
| [657] | 22 |         var $xoops_cache_path;
 | 
|---|
| [92] | 23 |         var $xoops_db_prefix;
 | 
|---|
 | 24 |         var $xoops_db_name;
 | 
|---|
 | 25 |         var $xoops_db_user;
 | 
|---|
 | 26 |         var $xoops_db_pass;
 | 
|---|
 | 27 |         var $xoops_db_host;
 | 
|---|
 | 28 |         var $module_name;
 | 
|---|
 | 29 |         var $module_path;
 | 
|---|
 | 30 |         var $module_url;
 | 
|---|
| [95] | 31 |         var $module_db_prefix;
 | 
|---|
| [113] | 32 |         var $module_version;
 | 
|---|
 | 33 |         var $module_codename;   
 | 
|---|
| [95] | 34 |         var $xoops_upload_path;
 | 
|---|
 | 35 |         var $xoops_upload_url;
 | 
|---|
| [129] | 36 |         var $xoops_db_salt;
 | 
|---|
| [159] | 37 |         var $xoops_salt;
 | 
|---|
| [129] | 38 |         var $is_impress;
 | 
|---|
 | 39 |         var $impress_db_config_file;
 | 
|---|
| [252] | 40 |         var $wp_db_version;
 | 
|---|
| [360] | 41 |         var $wp_version;
 | 
|---|
 | 42 |         var $is_wp_me;
 | 
|---|
| [491] | 43 |         var $xoops_language;
 | 
|---|
 | 44 |         var $module_id;
 | 
|---|
 | 45 |         var $module_config= array();
 | 
|---|
| [614] | 46 |         var $xoops_time_zone;
 | 
|---|
| [669] | 47 |         var $xoops_var_path;
 | 
|---|
 | 48 |         var $xoops_db_charset;
 | 
|---|
 | 49 |         var $xoops_db_pconnect;
 | 
|---|
| [697] | 50 |         var $xoops_path;
 | 
|---|
| [92] | 51 |         
 | 
|---|
 | 52 |         function __constructor()        //for PHP5
 | 
|---|
 | 53 |     {
 | 
|---|
 | 54 |         $this->ConfigFromXoops();
 | 
|---|
| [95] | 55 |        
 | 
|---|
| [92] | 56 |     }
 | 
|---|
| [159] | 57 |     
 | 
|---|
 | 58 |     function xpress_eval($str){
 | 
|---|
 | 59 |         $eval_str = '$ret = ' . $str . ' ;';
 | 
|---|
 | 60 |         eval($eval_str);
 | 
|---|
 | 61 |         return $ret;
 | 
|---|
 | 62 |     }
 | 
|---|
| [92] | 63 | 
 | 
|---|
 | 64 |     function ConfigFromXoops()  //for PHP4 constructor
 | 
|---|
 | 65 |     {  
 | 
|---|
 | 66 |         $this->xoops_mainfile_path = $this->get_xoops_mainfile_path();
 | 
|---|
| [326] | 67 |         $this->module_path=dirname(dirname(__FILE__));
 | 
|---|
| [92] | 68 |         $this->module_name=basename($this->module_path);
 | 
|---|
| [331] | 69 |         $this->xp_config_file_path = $this->module_path . '/xp-config.php';
 | 
|---|
 | 70 |         
 | 
|---|
| [357] | 71 |         // start /admin/index.php page detect
 | 
|---|
 | 72 |         $php_script_name = $_SERVER['SCRIPT_NAME'];
 | 
|---|
 | 73 |                 $php_query_string = $_SERVER['QUERY_STRING'];
 | 
|---|
 | 74 |                 $admin_page =   basename(dirname(dirname(__FILE__))) . '/admin/index.php';
 | 
|---|
 | 75 |                 $is_xoops_module_admin = false;
 | 
|---|
 | 76 |                 if (strstr($php_script_name,$admin_page) !== false) $is_xoops_module_admin = true;
 | 
|---|
 | 77 |                 if (strstr($php_query_string,$admin_page) !== false) $is_xoops_module_admin = true;
 | 
|---|
 | 78 |         // end of /admin/index.php page detect
 | 
|---|
 | 79 |         
 | 
|---|
| [769] | 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 |                                 }
 | 
|---|
| [669] | 95 | 
 | 
|---|
| [769] | 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 | 
 | 
|---|
| [95] | 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';
 | 
|---|
| [583] | 110 |                 $this->module_db_prefix = $this->xoops_db_prefix  . '_' . preg_replace('/wordpress/','wp',$this->module_name) . '_';
 | 
|---|
| [95] | 111 |                 
 | 
|---|
| [113] | 112 |                 $this->set_module_version();
 | 
|---|
| [252] | 113 |                 $this->set_wp_version();
 | 
|---|
| [614] | 114 |                 if (function_exists('date_default_timezone_get')){
 | 
|---|
 | 115 |                         $this->xoops_time_zone = date_default_timezone_get();
 | 
|---|
 | 116 |                 }
 | 
|---|
| [657] | 117 |                 $this->_get_cache_path();
 | 
|---|
| [92] | 118 |     }
 | 
|---|
| [331] | 119 | 
 | 
|---|
| [769] | 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(){
 | 
|---|
 | 241 |                 $this->xoops_root_path = XOOPS_ROOT_PATH;
 | 
|---|
 | 242 |                 $this->xoops_url = XOOPS_URL;
 | 
|---|
 | 243 |                 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
 | 
|---|
 | 244 |                 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = '';
 | 
|---|
 | 245 |                 $this->xoops_db_prefix = XOOPS_DB_PREFIX;
 | 
|---|
 | 246 |                 $this->xoops_db_name = XOOPS_DB_NAME;
 | 
|---|
 | 247 |                 $this->xoops_db_user = XOOPS_DB_USER;
 | 
|---|
 | 248 |                 $this->xoops_db_pass = XOOPS_DB_PASS;
 | 
|---|
 | 249 |                 $this->xoops_db_host = XOOPS_DB_HOST;
 | 
|---|
 | 250 |                 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = '';
 | 
|---|
 | 251 |                 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = '';
 | 
|---|
 | 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 |         }
 | 
|---|
| [331] | 268 |         
 | 
|---|
| [769] | 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 |         }
 | 
|---|
 | 326 |         
 | 
|---|
| [657] | 327 |         // call after the $this->xoops_trust_path is set
 | 
|---|
 | 328 |         function _get_cache_path(){
 | 
|---|
 | 329 |                 $cache_path = $this->xoops_trust_path . '/cache';
 | 
|---|
 | 330 |                 if (file_exists($cache_path) && is_writable($cache_path)){
 | 
|---|
 | 331 |                         $this->xoops_cache_path = $cache_path;
 | 
|---|
 | 332 |                         return;
 | 
|---|
 | 333 |                 }
 | 
|---|
 | 334 |                 $this->xoops_cache_path = $this->xoops_root_path . '/cache';
 | 
|---|
 | 335 |         }
 | 
|---|
| [331] | 336 |     
 | 
|---|
| [92] | 337 |     function get_xoops_mainfile_path(){
 | 
|---|
 | 338 |         return dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
 | 
|---|
 | 339 |     }
 | 
|---|
| [113] | 340 |     
 | 
|---|
 | 341 |     // set XPressME module virsion and codename from xoops_versions.php
 | 
|---|
 | 342 |     function set_module_version(){
 | 
|---|
 | 343 |         $xoops_version_file = dirname(dirname(__FILE__)) . '/xoops_version.php';
 | 
|---|
 | 344 |                 if(file_exists($xoops_version_file)){
 | 
|---|
 | 345 |                         $version_file = file($xoops_version_file);
 | 
|---|
| [129] | 346 |                         $version_pattern = '^\s*(\$modversion\[\s*\'version\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
 | 
|---|
 | 347 |                         $codename_pattern = '^\s*(\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
 | 
|---|
| [113] | 348 |                         $version_found = false;
 | 
|---|
 | 349 |                         $codename_found = false;
 | 
|---|
 | 350 |                         for ($i = 0 ; $i <count($version_file) ; $i++){
 | 
|---|
 | 351 |                                 if (preg_match( "/$version_pattern/", $version_file[$i] ,$v_matches )){
 | 
|---|
 | 352 |                                         $this->module_version = $v_matches[2];
 | 
|---|
 | 353 |                                         $version_found = true;
 | 
|---|
 | 354 |                                 }
 | 
|---|
 | 355 |                                 if (preg_match( "/$codename_pattern/", $version_file[$i] ,$c_matches )){
 | 
|---|
 | 356 |                                         $this->module_codename = $c_matches[2];
 | 
|---|
 | 357 |                                         $codename_found = true;
 | 
|---|
 | 358 |                                 }
 | 
|---|
 | 359 |                                 if ( $version_found && $codename_found ) break;
 | 
|---|
 | 360 |                         }
 | 
|---|
 | 361 |                 }
 | 
|---|
 | 362 |     }
 | 
|---|
 | 363 |     
 | 
|---|
| [252] | 364 |     function set_wp_version(){
 | 
|---|
| [209] | 365 |         include dirname(dirname(__FILE__)) . '/wp-includes/version.php';
 | 
|---|
 | 366 |         
 | 
|---|
| [252] | 367 |         $this->wp_db_version = $wp_db_version;
 | 
|---|
 | 368 |                 
 | 
|---|
| [360] | 369 |                 $this->wp_version = str_replace("ME", "", $wp_version);
 | 
|---|
 | 370 |                 
 | 
|---|
 | 371 |                 $pattern = 'ME.*';
 | 
|---|
 | 372 |         if (preg_match('/' . $pattern . '/' ,$wp_version)){
 | 
|---|
 | 373 |                         $this->is_wp_me = true;
 | 
|---|
 | 374 |                 } else {
 | 
|---|
 | 375 |                         $this->is_wp_me = true;
 | 
|---|
 | 376 |                 }
 | 
|---|
| [209] | 377 |     }
 | 
|---|
 | 378 |     
 | 
|---|
| [92] | 379 | }
 | 
|---|
| [551] | 380 | ?> | 
|---|