| 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();     
 | 
|---|
| 17 |         var $external_define_path;
 | 
|---|
| 18 |         var $xp_config_file_path;
 | 
|---|
| 19 |         var $xoops_root_path;
 | 
|---|
| 20 |         var $xoops_url;
 | 
|---|
| 21 |         var $xoops_trust_path;
 | 
|---|
| 22 |         var $xoops_db_prefix;
 | 
|---|
| 23 |         var $xoops_db_name;
 | 
|---|
| 24 |         var $xoops_db_user;
 | 
|---|
| 25 |         var $xoops_db_pass;
 | 
|---|
| 26 |         var $xoops_db_host;
 | 
|---|
| 27 |         var $module_name;
 | 
|---|
| 28 |         var $module_path;
 | 
|---|
| 29 |         var $module_url;
 | 
|---|
| 30 |         var $module_db_prefix;
 | 
|---|
| 31 |         var $module_version;
 | 
|---|
| 32 |         var $module_codename;   
 | 
|---|
| 33 |         var $xoops_upload_path;
 | 
|---|
| 34 |         var $xoops_upload_url;
 | 
|---|
| 35 |         var $xoops_db_salt;
 | 
|---|
| 36 |         var $xoops_salt;
 | 
|---|
| 37 |         var $is_impress;
 | 
|---|
| 38 |         var $impress_db_config_file;
 | 
|---|
| 39 |         var $is_wpmu;
 | 
|---|
| 40 |         var $mu_domain_current_site;
 | 
|---|
| 41 |         var $mu_path_current_site;
 | 
|---|
| 42 |         var $wp_db_version;
 | 
|---|
| 43 |         var $wp_version;
 | 
|---|
| 44 |         var $is_wp_me;
 | 
|---|
| 45 |         var $xoops_language;
 | 
|---|
| 46 |         var $module_id;
 | 
|---|
| 47 |         var $module_config= array();
 | 
|---|
| 48 |         
 | 
|---|
| 49 |         function __constructor()        //for PHP5
 | 
|---|
| 50 |     {
 | 
|---|
| 51 |         $this->ConfigFromXoops();
 | 
|---|
| 52 |        
 | 
|---|
| 53 |     }
 | 
|---|
| 54 |     
 | 
|---|
| 55 |     function xpress_eval($str){
 | 
|---|
| 56 |         $eval_str = '$ret = ' . $str . ' ;';
 | 
|---|
| 57 |         eval($eval_str);
 | 
|---|
| 58 |         return $ret;
 | 
|---|
| 59 |     }
 | 
|---|
| 60 | 
 | 
|---|
| 61 |     function ConfigFromXoops()  //for PHP4 constructor
 | 
|---|
| 62 |     {  
 | 
|---|
| 63 |         $this->xoops_mainfile_path = $this->get_xoops_mainfile_path();
 | 
|---|
| 64 |         $this->module_path=dirname(dirname(__FILE__));
 | 
|---|
| 65 |         $this->module_name=basename($this->module_path);
 | 
|---|
| 66 |         $this->xp_config_file_path = $this->module_path . '/xp-config.php';
 | 
|---|
| 67 |         
 | 
|---|
| 68 |         // start /admin/index.php page detect
 | 
|---|
| 69 |         $php_script_name = $_SERVER['SCRIPT_NAME'];
 | 
|---|
| 70 |                 $php_query_string = $_SERVER['QUERY_STRING'];
 | 
|---|
| 71 |                 $admin_page =   basename(dirname(dirname(__FILE__))) . '/admin/index.php';
 | 
|---|
| 72 |                 $is_xoops_module_admin = false;
 | 
|---|
| 73 |                 if (strstr($php_script_name,$admin_page) !== false) $is_xoops_module_admin = true;
 | 
|---|
| 74 |                 if (strstr($php_query_string,$admin_page) !== false) $is_xoops_module_admin = true;
 | 
|---|
| 75 |         // end of /admin/index.php page detect
 | 
|---|
| 76 |         
 | 
|---|
| 77 |         if (file_exists($this->xp_config_file_path)){   // file exists xp-config.php
 | 
|---|
| 78 |                 $this->_get_value_by_xp_config_file();
 | 
|---|
| 79 |         }else if (defined('XOOPS_MAINFILE_INCLUDED') && !$is_xoops_module_admin){ // loaded XOOPS mainfile.php
 | 
|---|
| 80 |                 $this->_get_value_by_xoops_define();
 | 
|---|
| 81 |         } else {  // A set value is acquired from mainfile.php by the pattern match.
 | 
|---|
| 82 |                         if(file_exists($this->xoops_mainfile_path)){
 | 
|---|
| 83 |                         $this->_get_value_by_xoops_mainfile();
 | 
|---|
| 84 |                         // Value 'is_impress' and value 'external_define_path' used in the under
 | 
|---|
| 85 |                         // are set in _get_value_by_xoops_mainfile(). 
 | 
|---|
| 86 |                                 if ($this->is_impress){         // DB Config from Impress CMS impress_db_config file
 | 
|---|
| 87 |                                         $this->_get_value_by_impress_db_config_file();
 | 
|---|
| 88 |                                 } else if(!empty($this->external_define_path)){ // file exists mainfile.php in the trust pass.
 | 
|---|
| 89 |                                         $this->_get_value_by_trust_mainfile();
 | 
|---|
| 90 |                                 }
 | 
|---|
| 91 |                         } // end of if file_exists
 | 
|---|
| 92 |                         
 | 
|---|
| 93 |                 }
 | 
|---|
| 94 | 
 | 
|---|
| 95 |                 //  define from /settings/definition.inc.php (XCL)  or /include/common.php(2016a-JP)
 | 
|---|
| 96 |                 $this->xoops_upload_path = $this->xoops_root_path .'/uploads';
 | 
|---|
| 97 |                 $this->xoops_upload_url = $this->xoops_url . '/uploads';
 | 
|---|
| 98 |                 
 | 
|---|
| 99 |                 if ($this->module_name == 'wordpress')
 | 
|---|
| 100 |                         $this->module_db_prefix =  $this->xoops_db_prefix  . '_wp_';
 | 
|---|
| 101 |                 else
 | 
|---|
| 102 |                         $this->module_db_prefix =  $this->xoops_db_prefix  . '_' . $this->module_name . '_';
 | 
|---|
| 103 |                 
 | 
|---|
| 104 |                 $this->set_module_version();
 | 
|---|
| 105 |                 $this->set_wp_version();
 | 
|---|
| 106 |                 $this->set_mu_current_site();
 | 
|---|
| 107 |                 $this->xpress_get_module_id();
 | 
|---|
| 108 |                 $this->xoops_language = $this->xpress_get_xoops_config('language');
 | 
|---|
| 109 |                 $this->xpress_get_module_config();
 | 
|---|
| 110 |     }
 | 
|---|
| 111 | 
 | 
|---|
| 112 |         // A set value is acquired from XOOPS mainfile.php by the pattern match.
 | 
|---|
| 113 |         function _get_value_by_xoops_mainfile(){
 | 
|---|
| 114 |                 $array_file = file($this->xoops_mainfile_path);
 | 
|---|
| 115 |                 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*([^\s]+.*)\s*\)\s*;';
 | 
|---|
| 116 |                 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)';
 | 
|---|
| 117 |                 $external_define_file_pattern = '^\s*(include_once|include|require_once|require_once)\s*\((.*mainfile\.php.*)\)';
 | 
|---|
| 118 |                 for ($i = 0 ; $i <count($array_file) ; $i++){
 | 
|---|
| 119 |                         if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){
 | 
|---|
| 120 |                                 $keys = $matchs[1];
 | 
|---|
| 121 |                                 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys);
 | 
|---|
| 122 |                                 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys);
 | 
|---|
| 123 |                                 $key_value = $matchs[2];
 | 
|---|
| 124 | 
 | 
|---|
| 125 |                                 switch ($keys){
 | 
|---|
| 126 |                                         case  'XOOPS_ROOT_PATH':
 | 
|---|
| 127 |                                                 $this->xoops_root_path = $this->xpress_eval($key_value);
 | 
|---|
| 128 |                                                 break;
 | 
|---|
| 129 |                                         case  'XOOPS_URL':
 | 
|---|
| 130 |                                                 $this->xoops_url = $this->xpress_eval($key_value);
 | 
|---|
| 131 |                                                 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
 | 
|---|
| 132 |                                                 break;
 | 
|---|
| 133 |                                         case  'XOOPS_TRUST_PATH':
 | 
|---|
| 134 |                                                 $this->xoops_trust_path = $this->xpress_eval($key_value);
 | 
|---|
| 135 |                                                 break;
 | 
|---|
| 136 |                                         case  'XOOPS_DB_PREFIX':
 | 
|---|
| 137 |                                                 $this->xoops_db_prefix = $this->xpress_eval($key_value);
 | 
|---|
| 138 |                                                 break;
 | 
|---|
| 139 |                                         case  'XOOPS_DB_NAME':
 | 
|---|
| 140 |                                                 $this->xoops_db_name = $this->xpress_eval($key_value);
 | 
|---|
| 141 |                                                 break;
 | 
|---|
| 142 |                                         case  'XOOPS_DB_USER':
 | 
|---|
| 143 |                                                 $this->xoops_db_user = $this->xpress_eval($key_value);
 | 
|---|
| 144 |                                                 break;
 | 
|---|
| 145 |                                         case  'XOOPS_DB_PASS':
 | 
|---|
| 146 |                                                 $this->xoops_db_pass = $this->xpress_eval($key_value);
 | 
|---|
| 147 |                                                 break;
 | 
|---|
| 148 |                                         case  'XOOPS_DB_HOST':
 | 
|---|
| 149 |                                                 $this->xoops_db_host = $this->xpress_eval($key_value);
 | 
|---|
| 150 |                                                 break;
 | 
|---|
| 151 |                                         case  'XOOPS_DB_SALT':
 | 
|---|
| 152 |                                                 $this->xoops_db_salt = $this->xpress_eval($key_value);
 | 
|---|
| 153 |                                                 break;
 | 
|---|
| 154 |                                         case  'XOOPS_SALT':
 | 
|---|
| 155 |                                                 $this->xoops_salt = $this->xpress_eval($key_value);
 | 
|---|
| 156 |                                                 break;
 | 
|---|
| 157 |                                         default :
 | 
|---|
| 158 |                                                 
 | 
|---|
| 159 |                                 }       // end of switch
 | 
|---|
| 160 |                         }        // end of if preg_match
 | 
|---|
| 161 |                         
 | 
|---|
| 162 |                         // Check External Define File
 | 
|---|
| 163 |                         if (preg_match('/' . $external_define_file_pattern . '/' ,$array_file[$i],$trust_main_matchs)){
 | 
|---|
| 164 |                                 $include_path = $this->xpress_eval($trust_main_matchs[2]);
 | 
|---|
| 165 |                                 if (file_exists($include_path))
 | 
|---|
| 166 |                                         $this->external_define_path = $include_path;
 | 
|---|
| 167 |                         }
 | 
|---|
| 168 |                         
 | 
|---|
| 169 |                         // Check ImpressCMS
 | 
|---|
| 170 |                         if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){
 | 
|---|
| 171 |                                 $this->is_impress = true;
 | 
|---|
| 172 |                                 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2];
 | 
|---|
| 173 |                         }
 | 
|---|
| 174 |                 } // end of for loop            
 | 
|---|
| 175 |         }
 | 
|---|
| 176 |         // A set value is acquired from XOOPS define value .
 | 
|---|
| 177 |         function _get_value_by_xoops_define(){
 | 
|---|
| 178 |                 $this->xoops_root_path = XOOPS_ROOT_PATH;
 | 
|---|
| 179 |                 $this->xoops_url = XOOPS_URL;
 | 
|---|
| 180 |                 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
 | 
|---|
| 181 |                 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = '';
 | 
|---|
| 182 |                 $this->xoops_db_prefix = XOOPS_DB_PREFIX;
 | 
|---|
| 183 |                 $this->xoops_db_name = XOOPS_DB_NAME;
 | 
|---|
| 184 |                 $this->xoops_db_user = XOOPS_DB_USER;
 | 
|---|
| 185 |                 $this->xoops_db_pass = XOOPS_DB_PASS;
 | 
|---|
| 186 |                 $this->xoops_db_host = XOOPS_DB_HOST;
 | 
|---|
| 187 |                 if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = '';
 | 
|---|
| 188 |                 if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = '';
 | 
|---|
| 189 |         }
 | 
|---|
| 190 |         // A set value is acquired from xp-config.php .
 | 
|---|
| 191 |         function _get_value_by_xp_config_file(){
 | 
|---|
| 192 |             require_once($this->xp_config_file_path);
 | 
|---|
| 193 |                 $this->xoops_root_path =XP_XOOPS_ROOT_PATH;
 | 
|---|
| 194 |                 $this->xoops_url = XP_XOOPS_URL;
 | 
|---|
| 195 |                 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
 | 
|---|
| 196 |                 if(defined('XP_XOOPS_TRUST_PATH')) $this->xoops_trust_path = XP_XOOPS_TRUST_PATH; else $this->xoops_trust_path = '';
 | 
|---|
| 197 |                 $this->xoops_db_prefix = XP_XOOPS_DB_PREFIX;
 | 
|---|
| 198 |                 $this->xoops_db_name = XP_XOOPS_DB_NAME;
 | 
|---|
| 199 |                 $this->xoops_db_user = XP_XOOPS_DB_USER;
 | 
|---|
| 200 |                 $this->xoops_db_pass = XP_XOOPS_DB_PASS;
 | 
|---|
| 201 |                 $this->xoops_db_host = XP_XOOPS_DB_HOST;
 | 
|---|
| 202 |                 if(defined('XP_XOOPS_DB_SALT')) $this->xoops_db_salt = XP_XOOPS_DB_SALT; else $this->xoops_db_salt = '';
 | 
|---|
| 203 |                 if(defined('XOOPS_SALT')) $this->xoops_salt = XP_XOOPS_SALT; else $this->xoops_salt = '';
 | 
|---|
| 204 |         }
 | 
|---|
| 205 |         
 | 
|---|
| 206 |         // A set value is acquired from config file in the trust pass by the pattern match.
 | 
|---|
| 207 |     function _get_value_by_impress_db_config_file(){
 | 
|---|
| 208 |                 if(file_exists($this->impress_db_config_file)){
 | 
|---|
| 209 |                         $array_file = file($this->impress_db_config_file);
 | 
|---|
| 210 |                         $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;';
 | 
|---|
| 211 |                         for ($i = 0 ; $i <count($array_file) ; $i++){
 | 
|---|
| 212 |                                 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){
 | 
|---|
| 213 |                                         $keys = $matchs[1];
 | 
|---|
| 214 |                                         if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys);
 | 
|---|
| 215 |                                         if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys);
 | 
|---|
| 216 |                                         $key_value = $matchs[2];
 | 
|---|
| 217 | 
 | 
|---|
| 218 |                                         switch ($keys){
 | 
|---|
| 219 |                                                 case  'SDATA_DB_SALT':
 | 
|---|
| 220 |                                                         $this->xoops_db_salt = $this->xpress_eval($key_value);
 | 
|---|
| 221 |                                                         break;
 | 
|---|
| 222 |                                                 case  'SDATA_DB_PREFIX':
 | 
|---|
| 223 |                                                         $this->xoops_db_prefix = $this->xpress_eval($key_value);
 | 
|---|
| 224 |                                                         break;
 | 
|---|
| 225 |                                                 case  'SDATA_DB_NAME':
 | 
|---|
| 226 |                                                         $this->xoops_db_name = $this->xpress_eval($key_value);
 | 
|---|
| 227 |                                                         break;
 | 
|---|
| 228 |                                                 case  'SDATA_DB_USER':
 | 
|---|
| 229 |                                                         $this->xoops_db_user = $this->xpress_eval($key_value);
 | 
|---|
| 230 |                                                         break;
 | 
|---|
| 231 |                                                 case  'SDATA_DB_PASS':
 | 
|---|
| 232 |                                                         $this->xoops_db_pass = $this->xpress_eval($key_value);
 | 
|---|
| 233 |                                                         break;
 | 
|---|
| 234 |                                                 case  'SDATA_DB_HOST':
 | 
|---|
| 235 |                                                         $this->xoops_db_host = $this->xpress_eval($key_value);
 | 
|---|
| 236 |                                                         break;
 | 
|---|
| 237 |                                                 default :
 | 
|---|
| 238 |                                                         
 | 
|---|
| 239 |                                         }       // end of switch
 | 
|---|
| 240 |                                 }
 | 
|---|
| 241 |                         } // end of for
 | 
|---|
| 242 |                 } // end of if file_exists
 | 
|---|
| 243 |     }
 | 
|---|
| 244 |     
 | 
|---|
| 245 |     function _get_value_by_trust_mainfile(){
 | 
|---|
| 246 |                 // When the definition is written in mainfile.php in the trust passing
 | 
|---|
| 247 |                 if(file_exists($this->external_define_path)){
 | 
|---|
| 248 |                         require_once($this->external_define_path);
 | 
|---|
| 249 |                         
 | 
|---|
| 250 |                         $this->xoops_root_path = XOOPS_ROOT_PATH;
 | 
|---|
| 251 |                 $this->xoops_url = XOOPS_URL;
 | 
|---|
| 252 |                 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
 | 
|---|
| 253 |                 if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = '';
 | 
|---|
| 254 |                 $this->xoops_db_prefix = XOOPS_DB_PREFIX;
 | 
|---|
| 255 |                 $this->xoops_db_name = XOOPS_DB_NAME;
 | 
|---|
| 256 |                 $this->xoops_db_user = XOOPS_DB_USER;
 | 
|---|
| 257 |                 $this->xoops_db_pass = XOOPS_DB_PASS;
 | 
|---|
| 258 |                 $this->xoops_db_host = XOOPS_DB_HOST;
 | 
|---|
| 259 |                         if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = '';
 | 
|---|
| 260 |                         if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = '';
 | 
|---|
| 261 |                 } // end of if file_exists
 | 
|---|
| 262 |         }       
 | 
|---|
| 263 |     
 | 
|---|
| 264 |     function get_xoops_mainfile_path(){
 | 
|---|
| 265 |         return dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
 | 
|---|
| 266 |     }
 | 
|---|
| 267 |     
 | 
|---|
| 268 |     // set XPressME module virsion and codename from xoops_versions.php
 | 
|---|
| 269 |     function set_module_version(){
 | 
|---|
| 270 |         $xoops_version_file = dirname(dirname(__FILE__)) . '/xoops_version.php';
 | 
|---|
| 271 |                 if(file_exists($xoops_version_file)){
 | 
|---|
| 272 |                         $version_file = file($xoops_version_file);
 | 
|---|
| 273 |                         $version_pattern = '^\s*(\$modversion\[\s*\'version\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
 | 
|---|
| 274 |                         $codename_pattern = '^\s*(\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
 | 
|---|
| 275 |                         $version_found = false;
 | 
|---|
| 276 |                         $codename_found = false;
 | 
|---|
| 277 |                         for ($i = 0 ; $i <count($version_file) ; $i++){
 | 
|---|
| 278 |                                 if (preg_match( "/$version_pattern/", $version_file[$i] ,$v_matches )){
 | 
|---|
| 279 |                                         $this->module_version = $v_matches[2];
 | 
|---|
| 280 |                                         $version_found = true;
 | 
|---|
| 281 |                                 }
 | 
|---|
| 282 |                                 if (preg_match( "/$codename_pattern/", $version_file[$i] ,$c_matches )){
 | 
|---|
| 283 |                                         $this->module_codename = $c_matches[2];
 | 
|---|
| 284 |                                         $codename_found = true;
 | 
|---|
| 285 |                                 }
 | 
|---|
| 286 |                                 if ( $version_found && $codename_found ) break;
 | 
|---|
| 287 |                         }
 | 
|---|
| 288 |                 }
 | 
|---|
| 289 |     }
 | 
|---|
| 290 |     
 | 
|---|
| 291 |     function set_wp_version(){
 | 
|---|
| 292 |         include dirname(dirname(__FILE__)) . '/wp-includes/version.php';
 | 
|---|
| 293 |         
 | 
|---|
| 294 |         if (empty($wpmu_version))
 | 
|---|
| 295 |                 $this->is_wpmu  = false;
 | 
|---|
| 296 |         else
 | 
|---|
| 297 |                 $this->is_wpmu  = true;
 | 
|---|
| 298 |         
 | 
|---|
| 299 |         $this->wp_db_version = $wp_db_version;
 | 
|---|
| 300 |                 
 | 
|---|
| 301 |                 $this->wp_version = str_replace("ME", "", $wp_version);
 | 
|---|
| 302 |                 
 | 
|---|
| 303 |                 $pattern = 'ME.*';
 | 
|---|
| 304 |         if (preg_match('/' . $pattern . '/' ,$wp_version)){
 | 
|---|
| 305 |                         $this->is_wp_me = true;
 | 
|---|
| 306 |                 } else {
 | 
|---|
| 307 |                         $this->is_wp_me = true;
 | 
|---|
| 308 |                 }
 | 
|---|
| 309 |     }
 | 
|---|
| 310 |     
 | 
|---|
| 311 |     function set_mu_current_site(){
 | 
|---|
| 312 |         $pattern = 'http:\/\/([^\/]*).*';
 | 
|---|
| 313 |         if (preg_match('/' . $pattern . '/' ,$this->xoops_url,$matchs)){
 | 
|---|
| 314 |                                 $this->mu_domain_current_site = $matchs[1];
 | 
|---|
| 315 |                 }
 | 
|---|
| 316 |                 
 | 
|---|
| 317 |         $pattern = 'http:\/\/[^\/]*(\/.*)';
 | 
|---|
| 318 |         if (preg_match('/' . $pattern . '/' ,$this->module_url,$matchs)){
 | 
|---|
| 319 |                                 $this->mu_path_current_site = $matchs[1] . '/';
 | 
|---|
| 320 |                 }
 | 
|---|
| 321 |     }
 | 
|---|
| 322 | 
 | 
|---|
| 323 |         function xpress_get_xoops_config($config_name = '',$mid = 0){
 | 
|---|
| 324 |                 $ret = '';
 | 
|---|
| 325 |                 $cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass);
 | 
|---|
| 326 |                 if (!$cn) return $ret;
 | 
|---|
| 327 |                 
 | 
|---|
| 328 |                 $db_selected = mysql_select_db($this->xoops_db_name, $cn);
 | 
|---|
| 329 |                 if ($db_selected){
 | 
|---|
| 330 |                         $table_name = $this->xoops_db_prefix . '_config';
 | 
|---|
| 331 |                         $sql = "SELECT conf_value AS value FROM $table_name WHERE `conf_modid` = $mid AND `conf_name` = '$config_name'";
 | 
|---|
| 332 |                         if($result = mysql_query($sql)){
 | 
|---|
| 333 |                                 $row = mysql_fetch_assoc($result);
 | 
|---|
| 334 |                                 $ret = $row['value'];
 | 
|---|
| 335 |                         } else {
 | 
|---|
| 336 |                                 $ret = $sql;
 | 
|---|
| 337 |                         }
 | 
|---|
| 338 |                 }
 | 
|---|
| 339 |                 if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn);
 | 
|---|
| 340 |                 return $ret;
 | 
|---|
| 341 |         }
 | 
|---|
| 342 | 
 | 
|---|
| 343 |         function xpress_get_module_config(){
 | 
|---|
| 344 |                 $this->module_config= array();
 | 
|---|
| 345 |                 $cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass);
 | 
|---|
| 346 |                 if (!$cn) return $ret;
 | 
|---|
| 347 |                 
 | 
|---|
| 348 |                 $db_selected = mysql_select_db($this->xoops_db_name, $cn);
 | 
|---|
| 349 |                 if ($db_selected){
 | 
|---|
| 350 |                         $table_name = $this->xoops_db_prefix . '_config';
 | 
|---|
| 351 |                         $sql = "SELECT conf_name AS name, conf_value AS value FROM $table_name WHERE `conf_modid` = $this->module_id";
 | 
|---|
| 352 |                         if($result = mysql_query($sql)){
 | 
|---|
| 353 |                                 while ($row = mysql_fetch_assoc($result)) {
 | 
|---|
| 354 |                                 $this->module_config[$row['name']] = $row['value'];
 | 
|---|
| 355 |                                 }
 | 
|---|
| 356 |                         }
 | 
|---|
| 357 |                 }
 | 
|---|
| 358 |                 if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn);
 | 
|---|
| 359 |                 return $this->module_config;
 | 
|---|
| 360 |         }
 | 
|---|
| 361 | 
 | 
|---|
| 362 |         function xpress_get_module_id(){
 | 
|---|
| 363 |                 $this->module_id = '';
 | 
|---|
| 364 |                 $cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass);
 | 
|---|
| 365 |                 if ($cn){
 | 
|---|
| 366 |                         $db_selected = mysql_select_db($this->xoops_db_name, $cn);
 | 
|---|
| 367 |                         if ($db_selected){
 | 
|---|
| 368 |                                 $table_name = $this->xoops_db_prefix . '_modules';
 | 
|---|
| 369 |                                 $sql = "SELECT mid FROM $table_name WHERE `dirname` = '$this->module_name'";
 | 
|---|
| 370 |                                 if($result = mysql_query($sql)){
 | 
|---|
| 371 |                                         $row = mysql_fetch_assoc($result);
 | 
|---|
| 372 |                                         $this->module_id = $row['mid'];
 | 
|---|
| 373 |                                 }
 | 
|---|
| 374 |                         }
 | 
|---|
| 375 |                         if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn);
 | 
|---|
| 376 |                 }
 | 
|---|
| 377 |                 return $this->module_id;
 | 
|---|
| 378 |         }
 | 
|---|
| 379 |         
 | 
|---|
| 380 |         
 | 
|---|
| 381 |         // Set XPressME memory limit
 | 
|---|
| 382 |         function xpress_set_memory_limmit(){
 | 
|---|
| 383 |                 $memory = $this->module_config['memory_limit'];
 | 
|---|
| 384 |                 if (empty($memory)) return;
 | 
|---|
| 385 |                 if ( !defined('WP_MEMORY_LIMIT') )
 | 
|---|
| 386 |                         define('WP_MEMORY_LIMIT', $memory . 'M');
 | 
|---|
| 387 |                 if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
 | 
|---|
| 388 |                         @ini_set('memory_limit', WP_MEMORY_LIMIT);
 | 
|---|
| 389 |         }
 | 
|---|
| 390 | 
 | 
|---|
| 391 | 
 | 
|---|
| 392 | 
 | 
|---|
| 393 | }
 | 
|---|
| 394 | ?>
 | 
|---|