XPressME Integration Kit

Trac

Changeset 763


Ignore:
Timestamp:
May 23, 2011, 5:03:32 PM (13 years ago)
Author:
toemon
Message:

XOOPS DB接続情報取得方法の変更

Location:
branches/Ver2.4/xpressme_integration_kit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Ver2.4/xpressme_integration_kit/class/config_from_xoops.class.php

    r727 r763  
    7878        // end of /admin/index.php page detect 
    7979         
    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                                 } 
    95  
    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                 } 
     80                $this->xoops_root_path = XOOPS_ROOT_PATH; 
     81                $this->xoops_url = XOOPS_URL; 
     82                $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 
     83                if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = ''; 
     84                $this->xoops_db_prefix = XOOPS_DB_PREFIX; 
     85                $this->xoops_db_name = XOOPS_DB_NAME; 
     86                $this->xoops_db_user = XOOPS_DB_USER; 
     87                $this->xoops_db_pass = XOOPS_DB_PASS; 
     88                $this->xoops_db_host = XOOPS_DB_HOST; 
     89                if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = ''; 
     90                if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = ''; 
    10691 
    10792                //  define from /settings/definition.inc.php (XCL)  or /include/common.php(2016a-JP) 
     
    118103    } 
    119104 
    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         } 
    268          
    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         } 
    326105         
    327106        // call after the $this->xoops_trust_path is set 
  • branches/Ver2.4/xpressme_integration_kit/include/add_xpress_config.php

    r551 r763  
    11<?php 
     2$request_method =  (isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : ''; 
     3//$_SERVER['REQUEST_METHOD'] = 'POST' is 
     4//When notifying by a private message, Notification_reserve_send(); 
     5//it is evaded that the data base becomes read-only as a result of the check on the referrer and the method.  
     6$_SERVER['REQUEST_METHOD'] = 'POST'; 
     7 
     8if ( defined('WP_ADMIN') )      { 
     9        $nocommon_scripts = array( 
     10                'wp-admin/async-upload.php', 
     11        ); 
     12        foreach($nocommon_scripts as $nocommon_script){ 
     13                if (strstr($_SERVER['SCRIPT_NAME'],$nocommon_script) !== false) { 
     14                        $xoopsOption['nocommon'] = 1; 
     15                        break; 
     16                } 
     17        } 
     18} 
     19 
     20require_once dirname(dirname(dirname(dirname( __FILE__ )))).'/mainfile.php' ; 
     21 
     22$_SERVER['REQUEST_METHOD'] = $request_method; //It returns it to former data.  
     23 
    224require_once dirname( __FILE__ ).'/xpress_debug_log.php' ; 
    325require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ; 
  • branches/Ver2.4/xpressme_integration_kit/include/add_xpress_process.php

    r696 r763  
    118118 
    119119if (is_xpress_index_page_call()){ 
    120         //$_SERVER['REQUEST_METHOD'] = 'POST' is 
    121         //When notifying by a private message, Notification_reserve_send(); 
    122         //it is evaded that the data base becomes read-only as a result of the check on the referrer and the method.  
    123         $request_method =  (isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : ''; 
    124         $_SERVER['REQUEST_METHOD'] = 'POST'; 
    125         require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php.  
    126         $_SERVER['REQUEST_METHOD'] = $request_method; 
    127120        xpress_set_memory_limmit(); // Set memory limmit.(Limmit Value from XPressMe modele config.) 
    128121        unset($offset);         //This Trap is provides the case where $offset is defined on the XOOPS side. 
Note: See TracChangeset for help on using the changeset viewer.