XPressME Integration Kit

Trac


Ignore:
Timestamp:
Mar 17, 2010, 11:38:11 AM (14 years ago)
Author:
toemon
Message:

mySQL接続上限警告 対策 Fixes#315

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/class/config_from_xoops.class.php

    r531 r551  
    101101                $this->set_module_version(); 
    102102                $this->set_wp_version(); 
    103                 $this->xpress_get_module_id(); 
    104                 $this->xoops_language = $this->xpress_get_xoops_config('language'); 
    105                 $this->xpress_get_module_config(); 
    106103    } 
    107104 
     
    300297    } 
    301298     
    302         function xpress_get_xoops_config($config_name = '',$mid = 0){ 
    303                 $ret = ''; 
    304                 $cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass); 
    305                 if (!$cn) return $ret; 
    306                  
    307                 $db_selected = mysql_select_db($this->xoops_db_name, $cn); 
    308                 if ($db_selected){ 
    309                         $table_name = $this->xoops_db_prefix . '_config'; 
    310                         $sql = "SELECT conf_value AS value FROM $table_name WHERE `conf_modid` = $mid AND `conf_name` = '$config_name'"; 
    311                         if($result = mysql_query($sql)){ 
    312                                 $row = mysql_fetch_assoc($result); 
    313                                 $ret = $row['value']; 
    314                         } else { 
    315                                 $ret = $sql; 
    316                         } 
    317                 } 
    318                 if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn); 
    319                 return $ret; 
    320         } 
    321  
    322         function xpress_get_module_config(){ 
    323                 $this->module_config= array(); 
    324                 $cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass); 
    325                 if (!$cn) return $ret; 
    326                  
    327                 $db_selected = mysql_select_db($this->xoops_db_name, $cn); 
    328                 if ($db_selected){ 
    329                         $table_name = $this->xoops_db_prefix . '_config'; 
    330                         $sql = "SELECT conf_name AS name, conf_value AS value FROM $table_name WHERE `conf_modid` = $this->module_id"; 
    331                         if($result = mysql_query($sql)){ 
    332                                 while ($row = mysql_fetch_assoc($result)) { 
    333                                 $this->module_config[$row['name']] = $row['value']; 
    334                                 } 
    335                         } 
    336                 } 
    337                 if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn); 
    338                 return $this->module_config; 
    339         } 
    340  
    341         function xpress_get_module_id(){ 
    342                 $this->module_id = ''; 
    343                 $cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass); 
    344                 if ($cn){ 
    345                         $db_selected = mysql_select_db($this->xoops_db_name, $cn); 
    346                         if ($db_selected){ 
    347                                 $table_name = $this->xoops_db_prefix . '_modules'; 
    348                                 $sql = "SELECT mid FROM $table_name WHERE `dirname` = '$this->module_name'"; 
    349                                 if($result = mysql_query($sql)){ 
    350                                         $row = mysql_fetch_assoc($result); 
    351                                         $this->module_id = $row['mid']; 
    352                                 } 
    353                         } 
    354                         if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn); 
    355                 } 
    356                 return $this->module_id; 
    357         } 
    358          
    359          
    360         // Set XPressME memory limit 
    361         function xpress_set_memory_limmit(){ 
    362                 $memory = $this->module_config['memory_limit']; 
    363                 if (empty($memory)) return; 
    364                 if ( !defined('WP_MEMORY_LIMIT') ) 
    365                         define('WP_MEMORY_LIMIT', $memory . 'M'); 
    366                 if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) ) 
    367                         @ini_set('memory_limit', WP_MEMORY_LIMIT); 
    368         } 
    369  
    370  
    371  
    372299} 
    373300?> 
Note: See TracChangeset for help on using the changeset viewer.