From ea9e7bd9934c5264511ebf176d3faf9effe54f85 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 11 Jan 2009 07:48:57 -0500
Subject: [PATCH] - Updated german language files - Added onKeypress handler for the username field in the login form.

---
 server/plugins-available/mysql_clientdb_plugin.inc.php |   61 +++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/server/plugins-available/mysql_clientdb_plugin.inc.php b/server/plugins-available/mysql_clientdb_plugin.inc.php
index 24e4ba2..8e0f15b 100644
--- a/server/plugins-available/mysql_clientdb_plugin.inc.php
+++ b/server/plugins-available/mysql_clientdb_plugin.inc.php
@@ -1,7 +1,7 @@
 <?php
 
 /*
-Copyright (c) 2008, Till Brehm, projektfarm Gmbh
+Copyright (c) 2007, Till Brehm, projektfarm Gmbh
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification,
@@ -32,6 +32,19 @@
 	
 	var $plugin_name = 'mysql_clientdb_plugin';
 	var $class_name  = 'mysql_clientdb_plugin';
+	
+	//* This function is called during ispconfig installation to determine
+	//  if a symlink shall be created for this plugin.
+	function onInstall() {
+		global $conf;
+		
+		if($conf['services']['db'] == true) {
+			return true;
+		} else {
+			return false;
+		}
+		
+	}
 	
 		
 	/*
@@ -84,15 +97,18 @@
 				$app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR);
 			}
 			
-			// Create the database user
-			if($data["new"]["remote_access"] == 'y') {
-			 	$db_host = '%';
-			} else {
-				$db_host = 'localhost';
+			// Create the database user if database is active
+			if($data["new"]["active"] == 'y') {
+				
+				if($data["new"]["remote_access"] == 'y') {
+			 		$db_host = '%';
+				} else {
+					$db_host = 'localhost';
+				}
+				
+				mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';",$link);
+				//echo "GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';";
 			}
-			
-			mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';",$link);
-			//echo "GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';";
 			
 			mysql_query("FLUSH PRIVILEGES;",$link);
 			mysql_close($link);
@@ -107,7 +123,7 @@
 				$app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR);
 				return;
 			}
-		
+			
 			//* Connect to the database
 			$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
 			if (!$link) {
@@ -115,6 +131,31 @@
 				return;
 			}
 			
+			// Create the database user if database was disabled before
+			if($data["new"]["active"] == 'y' && $data["old"]["active"] == 'n') {
+				
+				if($data["new"]["remote_access"] == 'y') {
+			 		$db_host = '%';
+				} else {
+					$db_host = 'localhost';
+				}
+				
+				mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';",$link);
+				//echo "GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';";
+			}
+			
+			// Remove database user, if inactive
+			if($data["new"]["active"] == 'n' && $data["old"]["active"] == 'y') {
+				
+				if($data["old"]["remote_access"] == 'y') {
+			 		$db_host = '%';
+				} else {
+					$db_host = 'localhost';
+				}
+				
+				mysql_query("REVOKE ALL PRIVILEGES ON ".mysql_real_escape_string($data["new"]["database_name"]).".* FROM '".mysql_real_escape_string($data["new"]["database_user"])."';",$link);
+			}
+			
 			//* Rename User
 			if($data["new"]["database_user"] != $data["old"]["database_user"]) {
 				mysql_query("RENAME USER '".mysql_real_escape_string($data["old"]["database_user"])."' TO '".mysql_real_escape_string($data["new"]["database_user"])."'",$link);

--
Gitblit v1.9.1