Index: /trunk/xpressme_integration_kit/admin/index.php
===================================================================
--- /trunk/xpressme_integration_kit/admin/index.php	(revision 550)
+++ /trunk/xpressme_integration_kit/admin/index.php	(revision 551)
@@ -166,5 +166,5 @@
 	global $xoopsModule;
 	include(dirname(__FILE__) . '/../wp-includes/version.php');
-	require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
+	require_once dirname(dirname( __FILE__ )).'/include/memory_limit.php' ;
 
 	if ($is_report) {
@@ -196,6 +196,5 @@
 		echo  ini_get( 'memory_limit' );
 		echo "<br />\n";
-		$xoops_config = new ConfigFromXoops;
-		$xoops_config->xpress_set_memory_limmit();
+		xpress_set_memory_limmit();
 		echo "change memory_limit:   " ;
 		echo  ini_get( 'memory_limit' );
@@ -270,6 +269,5 @@
 		echo  ini_get( 'memory_limit' );
 		echo "</text><br />";
-		$xoops_config = new ConfigFromXoops;
-		$xoops_config->xpress_set_memory_limmit();
+		xpress_set_memory_limmit();
 		echo "<label>change memory_limit:</label><text>";
 		echo  ini_get( 'memory_limit' );
Index: /trunk/xpressme_integration_kit/class/config_from_xoops.class.php
===================================================================
--- /trunk/xpressme_integration_kit/class/config_from_xoops.class.php	(revision 550)
+++ /trunk/xpressme_integration_kit/class/config_from_xoops.class.php	(revision 551)
@@ -101,7 +101,4 @@
 		$this->set_module_version();
 		$this->set_wp_version();
-		$this->xpress_get_module_id();
-		$this->xoops_language = $this->xpress_get_xoops_config('language');
-		$this->xpress_get_module_config();
     }
 
@@ -300,74 +297,4 @@
     }
     
-	function xpress_get_xoops_config($config_name = '',$mid = 0){
-		$ret = '';
-		$cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass);
-		if (!$cn) return $ret;
-		
-		$db_selected = mysql_select_db($this->xoops_db_name, $cn);
-		if ($db_selected){
-			$table_name = $this->xoops_db_prefix . '_config';
-			$sql = "SELECT conf_value AS value FROM $table_name WHERE `conf_modid` = $mid AND `conf_name` = '$config_name'";
-			if($result = mysql_query($sql)){
-				$row = mysql_fetch_assoc($result);
-				$ret = $row['value'];
-			} else {
-				$ret = $sql;
-			}
-		}
-		if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn);
-		return $ret;
-	}
-
-	function xpress_get_module_config(){
-		$this->module_config= array();
-		$cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass);
-		if (!$cn) return $ret;
-		
-		$db_selected = mysql_select_db($this->xoops_db_name, $cn);
-		if ($db_selected){
-			$table_name = $this->xoops_db_prefix . '_config';
-			$sql = "SELECT conf_name AS name, conf_value AS value FROM $table_name WHERE `conf_modid` = $this->module_id";
-			if($result = mysql_query($sql)){
-				while ($row = mysql_fetch_assoc($result)) {
-	    			$this->module_config[$row['name']] = $row['value'];
-				}
-			}
-		}
-		if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn);
-		return $this->module_config;
-	}
-
-	function xpress_get_module_id(){
-		$this->module_id = '';
-		$cn = mysql_connect($this->xoops_db_host, $this->xoops_db_user, $this->xoops_db_pass);
-		if ($cn){
-			$db_selected = mysql_select_db($this->xoops_db_name, $cn);
-			if ($db_selected){
-				$table_name = $this->xoops_db_prefix . '_modules';
-				$sql = "SELECT mid FROM $table_name WHERE `dirname` = '$this->module_name'";
-				if($result = mysql_query($sql)){
-					$row = mysql_fetch_assoc($result);
-					$this->module_id = $row['mid'];
-				}
-			}
-			if( ! defined( 'XOOPS_ROOT_PATH' ) ) mysql_close($cn);
-		}
-		return $this->module_id;
-	}
-	
-	
-	// Set XPressME memory limit
-	function xpress_set_memory_limmit(){
-		$memory = $this->module_config['memory_limit'];
-		if (empty($memory)) return;
- 		if ( !defined('WP_MEMORY_LIMIT') )
-			define('WP_MEMORY_LIMIT', $memory . 'M');
-		if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
-			@ini_set('memory_limit', WP_MEMORY_LIMIT);
-	}
-
-
-
 }
 ?>
Index: /trunk/xpressme_integration_kit/include/add_xpress_config.php
===================================================================
--- /trunk/xpressme_integration_kit/include/add_xpress_config.php	(revision 550)
+++ /trunk/xpressme_integration_kit/include/add_xpress_config.php	(revision 551)
@@ -3,5 +3,4 @@
 require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
 $xoops_config = new ConfigFromXoops;
-$xoops_config->xpress_set_memory_limmit();
 require_once dirname( __FILE__ ).'/set_cash_cookie_path.php' ;
 ?>
Index: /trunk/xpressme_integration_kit/include/add_xpress_process.php
===================================================================
--- /trunk/xpressme_integration_kit/include/add_xpress_process.php	(revision 550)
+++ /trunk/xpressme_integration_kit/include/add_xpress_process.php	(revision 551)
@@ -107,4 +107,5 @@
 
 require_once( dirname( __FILE__ ).'/request_url.php');
+require_once( dirname( __FILE__ ).'/memory_limit.php');
 if (is_xpress_index_page_call()){
 	//$_SERVER['REQUEST_METHOD'] = 'POST' is
@@ -115,5 +116,5 @@
 	require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php. 
 	$_SERVER['REQUEST_METHOD'] = $request_method;
-	
+	xpress_set_memory_limmit(); // Set memory limmit.(Limmit Value from XPressMe modele config.)
 	unset($offset);		//This Trap is provides the case where $offset is defined on the XOOPS side.
 	require_once(ABSPATH.'wp-settings.php');
@@ -181,3 +182,4 @@
 if (is_admin_post_call()) require_once $xoops_config->xoops_mainfile_path;		// for Notification_triggerEvent
 if (is_xpress_comments_post_call()) require_once $xoops_config->xoops_mainfile_path;	// for Notification_triggerEvent
+xpress_set_memory_limmit(); // Set memory limmit.(Limmit Value from XPressMe modele config.)
 ?>
Index: /trunk/xpressme_integration_kit/include/memory_limit.php
===================================================================
--- /trunk/xpressme_integration_kit/include/memory_limit.php	(revision 551)
+++ /trunk/xpressme_integration_kit/include/memory_limit.php	(revision 551)
@@ -0,0 +1,67 @@
+<?php
+	// Set XPressME memory limit
+	function xpress_set_memory_limmit(){
+		global $xoops_config;
+		global $xoopsDB;
+		
+		$module_id = '';
+		$memory = '';
+		
+		if (!is_object($xoops_config)){
+			require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
+			$xoops_config = new ConfigFromXoops;
+		}
+		
+		$has_xoops_db = (!empty($xoopsDB));
+		if (!$has_xoops_db) {
+			$cn = mysql_connect($xoops_config->xoops_db_host, $xoops_config->xoops_db_user, $xoops_config->xoops_db_pass);
+			if ($cn){
+				$db_selected = mysql_select_db($xoops_config->xoops_db_name, $cn);
+			}
+		}
+
+		// get module ID
+		$module_table = $xoops_config->xoops_db_prefix . '_modules';
+		$module_sql = "SELECT mid FROM $module_table WHERE `dirname` = '$xoops_config->module_name'";
+		if ($has_xoops_db) {
+			if ($result = $xoopsDB->query($module_sql, 0, 0)){
+				$row = $xoopsDB->fetchArray($result);
+				$module_id = $row['mid'];
+			}	
+		} else {
+			if ($db_selected){
+				if($result = mysql_query($module_sql)){
+					$row = mysql_fetch_assoc($result);
+					$module_id = $row['mid'];
+				}
+			}
+		}
+		if (!empty($module_id)){
+			// get memory_limit
+			$config_table = $xoops_config->xoops_db_prefix . '_config';
+			$config_sql = "SELECT conf_value FROM $config_table WHERE `conf_modid` = $module_id AND `conf_name` = 'memory_limit'";
+			if ($has_xoops_db) {
+				if ($result = $xoopsDB->query($config_sql, 0, 0)){
+					$row = $xoopsDB->fetchArray($result);
+					$memory = $row['conf_value'];
+				}
+			} else {
+				if ($db_selected){
+					if($result = mysql_query($config_sql)){
+						$row = mysql_fetch_assoc($result);
+						$memory = $row['conf_value'];
+					}
+				}
+			}
+		}
+		if (!$has_xoops_db) {
+			mysql_close($cn);
+		}
+		
+		if (empty($memory)) return;
+ 		if ( !defined('WP_MEMORY_LIMIT') )
+			define('WP_MEMORY_LIMIT', $memory . 'M');
+		if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
+			@ini_set('memory_limit', WP_MEMORY_LIMIT);
+	}
+?>
