Index: /trunk/xpressme_integration_kit/include/oninstall.php
===================================================================
--- /trunk/xpressme_integration_kit/include/oninstall.php	(revision 383)
+++ /trunk/xpressme_integration_kit/include/oninstall.php	(revision 384)
@@ -29,4 +29,5 @@
 		$root =& XCube_Root::getSingleton();
 		$root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success' , 'xpress_message_append_oninstall' ) ;
+		$root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Fail' , 'xpress_message_append_oninstall_err' ) ;
 		$ret = array() ;
 	} else {
@@ -36,4 +37,10 @@
 	$db =& Database::getInstance() ;
 	$mid = $module->getVar('mid') ;
+
+	if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
+		$ret[] = "********************************* Install Log ********************************<br />";
+	} else {
+		$ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Install Log</h4>';
+    }
 
 //xpress
@@ -47,4 +54,15 @@
 	$site_name = ucfirst($mydirname) . ' ' . _MI_XP2_NAME;
 	
+// permission and wordpress files check
+	require_once ($path . 'include/pre_check.php');
+	if(! xp_permission_check($mydirname, $mydirpath)){
+		if( ! defined( 'XOOPS_CUBE_LEGACY' ) ) {
+			$ret = $GLOBALS["err_log"];
+			$ret[] = "<br /><span style=\"color:#ff0000;\">The uninstallation of the module is executed now. </span><br />";
+			$ret[] = xoops_module_uninstall($mydirname);
+		}
+		return false;
+	}
+	
 // install WordPress
 	if (file_exists($path . 'wp-load.php')) {
@@ -56,5 +74,5 @@
 	wp_cache_flush();
 	make_db_current_silent();
-	$ret[] = "The data base of wordpress was made by prefix $table_prefix.";
+	$ret[] = "The data base of wordpress was made by prefix $table_prefix.<br />";
 	
 	$option_desc = __('WordPress web address');
@@ -84,8 +102,6 @@
   		KEY post_id (post_id)
 		)$charset_collate;";
-
 	dbDelta($views_queries);
-	$ret[] = "$views_table table of XPressME was made.";
-
+	$ret[] = "$views_table table of XPressME was made.<br />";
 	
 	$d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ;
@@ -97,5 +113,5 @@
 		)$charset_collate;";
 	dbDelta($views_queries);
-	$ret[] = "$d3forum_link table of XPressME was made.";
+	$ret[] = "$d3forum_link table of XPressME was made.<br />";
 	
 	$group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ;
@@ -110,5 +126,5 @@
 		)$charset_collate;";
 	dbDelta($views_queries);
-	$ret[] = "$group_role table of XPressME was made.";
+	$ret[] = "$group_role table of XPressME was made.<br />";
 	
 	$notify_reserve = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_notify_reserve' ;
@@ -126,5 +142,5 @@
 		)TYPE=MyISAM";
 	dbDelta($queries);
-	$ret[] = "$notify_reserve table of XPressME was made.";
+	$ret[] = "$notify_reserve table of XPressME was made.<br />";
 
 	$sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')";
@@ -163,5 +179,5 @@
 	$sql = "UPDATE $wpdb->users SET user_pass ='$pass_md5' WHERE ID = $user_id";
 	$wpdb->query($sql);
-	$ret[] = 'The password of XOOPS was copied.';
+	$ret[] = 'The password of XOOPS was copied.<br />';
 	
 	
@@ -175,5 +191,5 @@
 		}
 		
-		$ret[] = 'The first sample post & comment was written.';
+		$ret[] = 'The first sample post & comment was written.<br />';
 		
 		// Rewrite Option for Xpress
@@ -195,9 +211,9 @@
 			update_option("what_to_show", "posts");
 			update_option('default_pingback_flag', 0);
-			$ret[] = 'The initial data was written in the data base of wordpress.';
+			$ret[] = 'The initial data was written in the data base of wordpress.<br />';
 			
 			update_option("template", "xpress_default");
 			update_option("stylesheet", "xpress_default");
-			$ret[] = 'The default theme of wordpress was set to xpress_default.';
+			$ret[] = 'The default theme of wordpress was set to xpress_default.<br />';
 		//	update_option('uploads_use_yearmonth_folders', 1);
 			update_option('upload_path', 'wp-content/uploads');
@@ -220,5 +236,8 @@
 	require_once dirname( __FILE__ ).'/xpress_active_plugin.php';
 	if (xpress_pulugin_activation('xpressme/xpressme.php')){
-		$ret[] = 'The xpressme plug-in was activated.';
+		$ret[] = 'The xpressme plug-in was activated.<br />';
+	} else {
+		$GLOBALS["err_log"][] =  '<span style="color:#ff0000;">failed in the activation of xpressme plug-in.</span><br />';
+		return false;
 	}
 
@@ -241,4 +260,18 @@
 }
 endif;
+
+if( ! function_exists( 'xpress_message_append_oninstall_err' ) ) :
+function xpress_message_append_oninstall_err( &$module_obj , &$log )
+{
+	if( is_array( @$GLOBALS["err_log"] ) ) {
+		foreach( $GLOBALS["err_log"] as $message ) {
+			$log->add( strip_tags($message)) ;
+		}
+	}
+
+	// use mLog->addWarning() or mLog->addError() if necessary
+}
+endif;
+
 
 if( ! function_exists( 'wp_install_old_defaults' ) ) :
@@ -274,4 +307,3 @@
 }
 endif;
-
 ?>
Index: /trunk/xpressme_integration_kit/include/onupdate.php
===================================================================
--- /trunk/xpressme_integration_kit/include/onupdate.php	(revision 383)
+++ /trunk/xpressme_integration_kit/include/onupdate.php	(revision 384)
@@ -15,4 +15,5 @@
 		$root =& XCube_Root::getSingleton();
 		$root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Success', 'xpress_message_append_onupdate' ) ;
+		$root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Fail', 'xpress_message_append_onupdate' ) ;
 		$msgs = array() ;
 	} else {
@@ -22,4 +23,6 @@
 	$db =& Database::getInstance() ;
 	$mid = $module->getVar('mid') ;
+	
+
 
 //XPressME Update
@@ -28,5 +31,12 @@
 	$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
 	$path = $mydirpath . '/';
-	
+
+// permission and wordpress files check
+	require_once ($path . 'include/pre_check.php');
+	if(! xp_permission_check($mydirname, $mydirpath)){
+		$msgs = $GLOBALS["err_log"];
+		return false;
+	}
+
 //Site_url and home of an optional table are repaired. 
 	$site_url= XOOPS_URL."/modules/".$mydirname;
Index: /trunk/xpressme_integration_kit/include/pre_check.php
===================================================================
--- /trunk/xpressme_integration_kit/include/pre_check.php	(revision 384)
+++ /trunk/xpressme_integration_kit/include/pre_check.php	(revision 384)
@@ -0,0 +1,50 @@
+<?php
+function xp_permission_check($mydirname , $mydirpath) {
+	global $ret ; // TODO :-D
+	// permission check
+
+    $error = false;
+	if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
+		$GLOBALS["err_log"][] = "********************************* Error Log ********************************<br />";
+	} else {
+		$GLOBALS["err_log"][] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Error Log</h4>';
+    }
+    
+    if (!file_exists($mydirpath . '/wp-settings.php')){
+		$GLOBALS["err_log"][] =  '<span style="color:#ff0000;">WordPress is not built in.</span><br />';
+		$error = true;
+	}
+    $check_files = array('/templates/', '/wp-content/');
+    foreach ($check_files as $check) {
+    	$check_file = $mydirpath . $check;
+        if (!is_dir($check_file)) {
+           if ( file_exists($check_file) ) {
+                @chmod($check_file, 0666);
+                if (! is_writeable($check_file)) {
+                    $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file is not writeable</span><br />";
+                    $error = true;
+				}
+            }
+        } else {
+            @chmod($check_file, 0777);
+            if (! is_writeable($check_file)) {
+                $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file directory is not writeable</span><br />";
+                $error = true;
+            } else {
+            	// Windows parmission check
+            	$src_file = __FILE__ ;
+				$newfile = $check_file . 'write_check.txt';
+				if (!copy($src_file, $newfile)) {
+                	$GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file directory is not writeable</span><br />";
+                	$error = true;
+				} else {
+					unlink($newfile);
+				}
+			}
+        }
+    }
+    if($error) return false;
+    
+    return true;
+}
+?>
Index: /trunk/xpressme_integration_kit/include/xpress_templates_make.php
===================================================================
--- /trunk/xpressme_integration_kit/include/xpress_templates_make.php	(revision 383)
+++ /trunk/xpressme_integration_kit/include/xpress_templates_make.php	(revision 384)
@@ -22,7 +22,7 @@
 				$rcd = copy($file_path, $target_file_path);
 				if ($rcd){
-					$msgs[] = 'Template <b>'.htmlspecialchars($target_file_path).'</b> copy from ' . htmlspecialchars($file);
+					$msgs[] = 'Template <b>'.htmlspecialchars($target_file_path).'</b> copy from ' . htmlspecialchars($file) . '<br />';
 				} else {
-					$msgs[] = '<span style="color:#ff0000;">ERROR: Could not copy template <b>'.htmlspecialchars($target_file_name).'</b> from ' . htmlspecialchars($file). '(check templates directory permision (777))</span>';
+					$msgs[] = '<span style="color:#ff0000;">ERROR: Could not copy template <b>'.htmlspecialchars($target_file_name).'</b> from ' . htmlspecialchars($file). '(check templates directory permision (777))</span><br />';
 				}					
 				$tplfile =& $tplfile_handler->create() ;
