Index: /branches/XPressMU/xpressme_integration_kit/admin/index.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/admin/index.php	(revision 413)
+++ /branches/XPressMU/xpressme_integration_kit/admin/index.php	(revision 414)
@@ -497,4 +497,5 @@
 	global $xoopsModule;
 	include(dirname(__FILE__) . '/../wp-includes/version.php');
+	include(dirname(__FILE__) . '/../include/general_functions.php');
 
 	$xoopsDB =& Database::getInstance();
@@ -506,38 +507,64 @@
 
 	$prefix = $xoopsDB->prefix($xp_prefix . '_');
-	$sql = "SELECT COUNT(DISTINCT post_author) AS count_author, COUNT(*) AS count_article FROM ".$prefix . "posts WHERE post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')";
-	$result = $xoopsDB->query($sql);
-	if($myrow = $xoopsDB->fetchArray($result)){
-		$count_article = $myrow["count_article"];
-		$count_author = $myrow["count_author"];
-	}
-
-	if ($wp_db_version < 6124){
-		$sql = "SELECT COUNT(*) AS count_category FROM ".$xoopsDB->prefix($xp_prefix . "_categories");
-	} else {
-		$sql = "SELECT COUNT(*) AS count_category FROM ".$xoopsDB->prefix($xp_prefix . "_term_taxonomy") . " WHERE taxonomy = 'category'";
-	}
-	$result = $xoopsDB->query($sql);
-	if($myrow = $xoopsDB->fetchArray($result)){
-		$count_category = $myrow["count_category"];
-	}
-
-	if ($is_report){
-		echo "******** " . _AM_XP2_STATS . "********" . "<br />\n";
-		echo _AM_XP2_CATEGORIES .":  ".@$count_category. "<br />\n";
-		echo _AM_XP2_ARTICLES .":  ". $count_article. "<br />\n";
-		echo _AM_XP2_AUTHORS .":  ". $count_author. "<br />\n";
+	
+	$posts_tables = get_table_list($prefix,'posts');
+	$blogname = array();
+	$count_article = array();
+	$count_author = array();
+	$count_category = array();
+	$array_index = 0;
+	foreach( $posts_tables as $posts_table){
+		$sql = "SELECT COUNT(DISTINCT post_author) AS count_author, COUNT(*) AS count_article FROM ". $posts_table . " WHERE post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')";
+		$result = $xoopsDB->query($sql);
+		if($myrow = $xoopsDB->fetchArray($result)){
+			$count_article[$array_index] = $myrow["count_article"];
+			$count_author[$array_index] = $myrow["count_author"];
+		} else {
+			$count_article[$array_index] = 0;
+			$count_author[$array_index] = 0;
+		}
+		$mid_prefix = get_multi_mid_prefix($prefix,'posts' , $posts_table);
 		
-	} else {
-		echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_STATS . "</legend>";
-		echo "<div style='padding: 8px;'>";
-		echo "<label>" . _AM_XP2_CATEGORIES .":</label><text>".@$count_category;
-		echo "</text><br />";
-		echo "<label>" . _AM_XP2_ARTICLES .":</label><text>". $count_article;
-		echo "</text><br />";
-		echo "<label>" . _AM_XP2_AUTHORS .":</label><text>". $count_author;
-		echo "</text>";
-		echo "</div>";
-		echo "</fieldset>";
+		$sql = "SELECT option_value AS blogname FROM ".$prefix. $mid_prefix . "options" . " WHERE option_name = 'blogname'";
+		$result = $xoopsDB->query($sql);
+		if($myrow = $xoopsDB->fetchArray($result)){
+			$blogname[$array_index] = $myrow["blogname"];
+		} else {
+			$blogname[$array_index] = 'none name';
+		}
+		
+		if ($wp_db_version < 6124){
+			
+			$sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "categories";
+		} else {
+			$sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "term_taxonomy" . " WHERE taxonomy = 'category'";
+		}
+		$result = $xoopsDB->query($sql);
+		if($myrow = $xoopsDB->fetchArray($result)){
+			$count_category[$array_index] = $myrow["count_category"];
+		} else {
+			$count_category[$array_index] = 0;
+		}
+		$array_index++;
+	}
+	for ($i = 0 ; $i < $array_index ; $i++){
+		if ($is_report){
+			echo "******** " . $blogname[$i] . _AM_XP2_STATS . "********" . "<br />\n";
+			echo _AM_XP2_CATEGORIES .":  ".@$count_category[$i]. "<br />\n";
+			echo _AM_XP2_ARTICLES .":  ". $count_article[$i]. "<br />\n";
+			echo _AM_XP2_AUTHORS .":  ". $count_author[$i]. "<br />\n";
+			
+		} else {
+			echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . $blogname[$i] . _AM_XP2_STATS . "</legend>";
+			echo "<div style='padding: 8px;'>";
+			echo "<label>" . _AM_XP2_CATEGORIES .":</label><text>".@$count_category[$i];
+			echo "</text><br />";
+			echo "<label>" . _AM_XP2_ARTICLES .":</label><text>". $count_article[$i];
+			echo "</text><br />";
+			echo "<label>" . _AM_XP2_AUTHORS .":</label><text>". $count_author[$i];
+			echo "</text>";
+			echo "</div>";
+			echo "</fieldset>";
+		}
 	}
 }
Index: /branches/XPressMU/xpressme_integration_kit/include/general_functions.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 413)
+++ /branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 414)
@@ -119,3 +119,36 @@
 }
 
+// Get Multi Blog table list for WordPressMU 
+if (!function_exists('get_multi_table_list')){
+	function get_table_list($wp_prefix = '',$table_name = ''){
+		global $xoopsDB,$xoops_db;
+
+		$table_list = array();
+		$ret = array();
+		if (!empty($wp_prefix) && !empty($table_name)){
+			$sql = "SHOW TABLES LIKE '" . $wp_prefix  . '%' . $table_name . "'";
+
+			if (empty($xoops_db)) { // not load XPressME			
+				if($result = $xoopsDB->queryF($sql)){
+					while($row = $xoopsDB->fetchRow($result)){
+						$table_list[] = $row[0];
+					}
+				}
+			} else { // load XPressME or not Load XOOPS
+				$table_list = $xoops_db->get_results($sql);
+			}			
+		}
+		return $table_list;
+	}
+}
+
+// Get Middle Prefix from Table name for WordPressMU 
+if (!function_exists('get_multi_mid_prefix')){
+	function get_multi_mid_prefix($wp_prefix = '',$table_name = '' , $full_table_name){
+		$pattern = '/' . $wp_prefix . '(.*)' . $table_name . '/';
+		preg_match($pattern,$full_table_name,$match);
+		return $match[1];
+	}
+}
+
 ?>
Index: /trunk/xpressme_integration_kit/admin/index.php
===================================================================
--- /trunk/xpressme_integration_kit/admin/index.php	(revision 413)
+++ /trunk/xpressme_integration_kit/admin/index.php	(revision 414)
@@ -497,4 +497,5 @@
 	global $xoopsModule;
 	include(dirname(__FILE__) . '/../wp-includes/version.php');
+	include(dirname(__FILE__) . '/../include/general_functions.php');
 
 	$xoopsDB =& Database::getInstance();
@@ -506,38 +507,64 @@
 
 	$prefix = $xoopsDB->prefix($xp_prefix . '_');
-	$sql = "SELECT COUNT(DISTINCT post_author) AS count_author, COUNT(*) AS count_article FROM ".$prefix . "posts WHERE post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')";
-	$result = $xoopsDB->query($sql);
-	if($myrow = $xoopsDB->fetchArray($result)){
-		$count_article = $myrow["count_article"];
-		$count_author = $myrow["count_author"];
-	}
-
-	if ($wp_db_version < 6124){
-		$sql = "SELECT COUNT(*) AS count_category FROM ".$xoopsDB->prefix($xp_prefix . "_categories");
-	} else {
-		$sql = "SELECT COUNT(*) AS count_category FROM ".$xoopsDB->prefix($xp_prefix . "_term_taxonomy") . " WHERE taxonomy = 'category'";
-	}
-	$result = $xoopsDB->query($sql);
-	if($myrow = $xoopsDB->fetchArray($result)){
-		$count_category = $myrow["count_category"];
-	}
-
-	if ($is_report){
-		echo "******** " . _AM_XP2_STATS . "********" . "<br />\n";
-		echo _AM_XP2_CATEGORIES .":  ".@$count_category. "<br />\n";
-		echo _AM_XP2_ARTICLES .":  ". $count_article. "<br />\n";
-		echo _AM_XP2_AUTHORS .":  ". $count_author. "<br />\n";
+	
+	$posts_tables = get_table_list($prefix,'posts');
+	$blogname = array();
+	$count_article = array();
+	$count_author = array();
+	$count_category = array();
+	$array_index = 0;
+	foreach( $posts_tables as $posts_table){
+		$sql = "SELECT COUNT(DISTINCT post_author) AS count_author, COUNT(*) AS count_article FROM ". $posts_table . " WHERE post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')";
+		$result = $xoopsDB->query($sql);
+		if($myrow = $xoopsDB->fetchArray($result)){
+			$count_article[$array_index] = $myrow["count_article"];
+			$count_author[$array_index] = $myrow["count_author"];
+		} else {
+			$count_article[$array_index] = 0;
+			$count_author[$array_index] = 0;
+		}
+		$mid_prefix = get_multi_mid_prefix($prefix,'posts' , $posts_table);
 		
-	} else {
-		echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_STATS . "</legend>";
-		echo "<div style='padding: 8px;'>";
-		echo "<label>" . _AM_XP2_CATEGORIES .":</label><text>".@$count_category;
-		echo "</text><br />";
-		echo "<label>" . _AM_XP2_ARTICLES .":</label><text>". $count_article;
-		echo "</text><br />";
-		echo "<label>" . _AM_XP2_AUTHORS .":</label><text>". $count_author;
-		echo "</text>";
-		echo "</div>";
-		echo "</fieldset>";
+		$sql = "SELECT option_value AS blogname FROM ".$prefix. $mid_prefix . "options" . " WHERE option_name = 'blogname'";
+		$result = $xoopsDB->query($sql);
+		if($myrow = $xoopsDB->fetchArray($result)){
+			$blogname[$array_index] = $myrow["blogname"];
+		} else {
+			$blogname[$array_index] = 'none name';
+		}
+		
+		if ($wp_db_version < 6124){
+			
+			$sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "categories";
+		} else {
+			$sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "term_taxonomy" . " WHERE taxonomy = 'category'";
+		}
+		$result = $xoopsDB->query($sql);
+		if($myrow = $xoopsDB->fetchArray($result)){
+			$count_category[$array_index] = $myrow["count_category"];
+		} else {
+			$count_category[$array_index] = 0;
+		}
+		$array_index++;
+	}
+	for ($i = 0 ; $i < $array_index ; $i++){
+		if ($is_report){
+			echo "******** " . $blogname[$i] . _AM_XP2_STATS . "********" . "<br />\n";
+			echo _AM_XP2_CATEGORIES .":  ".@$count_category[$i]. "<br />\n";
+			echo _AM_XP2_ARTICLES .":  ". $count_article[$i]. "<br />\n";
+			echo _AM_XP2_AUTHORS .":  ". $count_author[$i]. "<br />\n";
+			
+		} else {
+			echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . $blogname[$i] . _AM_XP2_STATS . "</legend>";
+			echo "<div style='padding: 8px;'>";
+			echo "<label>" . _AM_XP2_CATEGORIES .":</label><text>".@$count_category[$i];
+			echo "</text><br />";
+			echo "<label>" . _AM_XP2_ARTICLES .":</label><text>". $count_article[$i];
+			echo "</text><br />";
+			echo "<label>" . _AM_XP2_AUTHORS .":</label><text>". $count_author[$i];
+			echo "</text>";
+			echo "</div>";
+			echo "</fieldset>";
+		}
 	}
 }
Index: /trunk/xpressme_integration_kit/include/general_functions.php
===================================================================
--- /trunk/xpressme_integration_kit/include/general_functions.php	(revision 413)
+++ /trunk/xpressme_integration_kit/include/general_functions.php	(revision 414)
@@ -119,3 +119,36 @@
 }
 
+// Get Multi Blog table list for WordPressMU 
+if (!function_exists('get_multi_table_list')){
+	function get_table_list($wp_prefix = '',$table_name = ''){
+		global $xoopsDB,$xoops_db;
+
+		$table_list = array();
+		$ret = array();
+		if (!empty($wp_prefix) && !empty($table_name)){
+			$sql = "SHOW TABLES LIKE '" . $wp_prefix  . '%' . $table_name . "'";
+
+			if (empty($xoops_db)) { // not load XPressME			
+				if($result = $xoopsDB->queryF($sql)){
+					while($row = $xoopsDB->fetchRow($result)){
+						$table_list[] = $row[0];
+					}
+				}
+			} else { // load XPressME or not Load XOOPS
+				$table_list = $xoops_db->get_results($sql);
+			}			
+		}
+		return $table_list;
+	}
+}
+
+// Get Middle Prefix from Table name for WordPressMU 
+if (!function_exists('get_multi_mid_prefix')){
+	function get_multi_mid_prefix($wp_prefix = '',$table_name = '' , $full_table_name){
+		$pattern = '/' . $wp_prefix . '(.*)' . $table_name . '/';
+		preg_match($pattern,$full_table_name,$match);
+		return $match[1];
+	}
+}
+
 ?>
