From f5d9544164b039001906db98b59c92f7250553fb Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 5 Apr 2011 11:28:45 +0000
Subject: [PATCH] Meerged revisions 2265-2278 from stable branch.

---
 interface/lib/classes/remoting_lib.inc.php    |  9 +++++---
 interface/web/client/client_edit.php          | 22 ++++++++++++++++---
 interface/web/client/reseller_edit.php        | 19 ++++++++++++++--
 interface/web/dashboard/dashboard.php         |  2 +-
 server/conf/bind_pri.domain.master            |  2 +-
 .../maildeliver_plugin.inc.php                |  1 +
 .../plugins-available/maildrop_plugin.inc.php |  1 +
 7 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/interface/lib/classes/remoting_lib.inc.php b/interface/lib/classes/remoting_lib.inc.php
index 57ff99807..ecd71bf35 100644
--- a/interface/lib/classes/remoting_lib.inc.php
+++ b/interface/lib/classes/remoting_lib.inc.php
@@ -701,7 +701,7 @@ class remoting_lib {
 		function ispconfig_sysuser_update($params,$client_id){
 			global $app;
 			$username = $app->db->quote($params["username"]);
-			$password = $app->db->quote($params["password"]);
+			$clear_password = $app->db->quote($params["password"]);
 			$client_id = intval($client_id);
 			$salt="$1$";
 			$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -709,8 +709,9 @@ class remoting_lib {
 				$salt.=$base64_alphabet[mt_rand(0,63)];
 			}
 			$salt.="$";
-			$password = crypt(stripslashes($password),$salt);
-			$sql = "UPDATE sys_user set username = '$username', passwort = '$password' WHERE client_id = $client_id";
+			$password = crypt(stripslashes($clear_password),$salt);
+			if ($clear_password) $pwstring = ", passwort = '$password'"; else $pwstring ="" ;
+			$sql = "UPDATE sys_user set username = '$username' $pwstring WHERE client_id = $client_id";
 			$app->db->query($sql);
 		}
 		
@@ -719,6 +720,8 @@ class remoting_lib {
 			$client_id = intval($client_id);
 			$sql = "DELETE FROM sys_user WHERE client_id = $client_id";
 			$app->db->query($sql);
+			$sql = "DELETE FROM sys_group WHERE client_id = $client_id";
+			$app->db->query($sql);
 		}
 
         function datalogSave($action,$primary_id, $record_old, $record_new) {
diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php
index 4514b5cc0..843e435b3 100644
--- a/interface/web/client/client_edit.php
+++ b/interface/web/client/client_edit.php
@@ -150,6 +150,15 @@ class page_action extends tform_actions {
 		$active = 1;
 		$language = $app->db->quote($this->dataRecord["language"]);
 		
+		$salt="$1$";
+		$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+		for ($n=0;$n<8;$n++) {
+			$salt.=$base64_alphabet[mt_rand(0,63)];
+		}
+		$salt.="$";
+		$password = crypt(stripslashes($password),$salt);
+		
+		// Create the controlpaneluser for the client
 		//Generate ssh-rsa-keys
 		exec('ssh-keygen -t rsa -C '.$username.'-rsa-key-'.time().' -f /tmp/id_rsa -N ""');
 		$app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".file_get_contents('/tmp/id_rsa')."', ssh_rsa = '".file_get_contents('/tmp/id_rsa.pub')."' WHERE client_id = ".$this->id;
@@ -157,7 +166,7 @@ class page_action extends tform_actions {
 		
 		// Create the controlpaneluser for the client
 		$sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id)
-		VALUES ('$username',md5('$password'),'$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,".$this->id.")";
+		VALUES ('$username','$password','$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,".$this->id.")";
 		$app->db->query($sql);
 		
 		//* If the user who inserted the client is a reseller (not admin), we will have to add this new client group 
@@ -198,8 +207,15 @@ class page_action extends tform_actions {
 		// password changed
 		if($conf['demo_mode'] != true && isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') {
 			$password = $app->db->quote($this->dataRecord["password"]);
+			$salt="$1$";
+			$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+			for ($n=0;$n<8;$n++) {
+				$salt.=$base64_alphabet[mt_rand(0,63)];
+			}
+			$salt.="$";
+			$password = crypt(stripslashes($password),$salt);
 			$client_id = $this->id;
-			$sql = "UPDATE sys_user SET passwort = md5('$password') WHERE client_id = $client_id";
+			$sql = "UPDATE sys_user SET passwort = '$password' WHERE client_id = $client_id";
 			$app->db->query($sql);
 		}
 		
@@ -232,4 +248,4 @@ class page_action extends tform_actions {
 $page = new page_action;
 $page->onLoad();
 
-?>
+?>
\ No newline at end of file
diff --git a/interface/web/client/reseller_edit.php b/interface/web/client/reseller_edit.php
index 1c9a2a1aa..9ab636920 100644
--- a/interface/web/client/reseller_edit.php
+++ b/interface/web/client/reseller_edit.php
@@ -150,9 +150,17 @@ class page_action extends tform_actions {
 		$active = 1;
 		$language = $app->db->quote($this->dataRecord["language"]);
 		
+		$salt="$1$";
+		$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+		for ($n=0;$n<8;$n++) {
+			$salt.=$base64_alphabet[mt_rand(0,63)];
+		}
+		$salt.="$";
+		$password = crypt(stripslashes($password),$salt);
+		
 		// Create the controlpaneluser for the reseller
 		$sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id)
-		VALUES ('$username',md5('$password'),'$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,".$this->id.")";
+		VALUES ('$username','$password','$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,".$this->id.")";
 		$app->db->query($sql);
 		
 		//* set the number of clients to 1
@@ -188,7 +196,14 @@ class page_action extends tform_actions {
 		if($conf['demo_mode'] != true && isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') {
 			$password = $app->db->quote($this->dataRecord["password"]);
 			$client_id = $this->id;
-			$sql = "UPDATE sys_user SET passwort = md5('$password') WHERE client_id = $client_id";
+			$salt="$1$";
+			$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+			for ($n=0;$n<8;$n++) {
+				$salt.=$base64_alphabet[mt_rand(0,63)];
+			}
+			$salt.="$";
+			$password = crypt(stripslashes($password),$salt);
+			$sql = "UPDATE sys_user SET passwort = '$password' WHERE client_id = $client_id";
 			$app->db->query($sql);
 		}
 		
diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php
index 377f563dd..a7ed82ec8 100644
--- a/interface/web/dashboard/dashboard.php
+++ b/interface/web/dashboard/dashboard.php
@@ -131,7 +131,7 @@ while ($file = @readdir ($handle)) {
 
 /* Which dashlets in which column */
 /******************************************************************************/
-$leftcol_dashlets = array('modules');
+$leftcol_dashlets = array('modules','invoices');
 $rightcol_dashlets = array('limits');
 /******************************************************************************/
 
diff --git a/server/conf/bind_pri.domain.master b/server/conf/bind_pri.domain.master
index 057daad21..0bd54b7fe 100644
--- a/server/conf/bind_pri.domain.master
+++ b/server/conf/bind_pri.domain.master
@@ -12,7 +12,7 @@ $TTL        {tmpl_var name='ttl'}
 {tmpl_var name='name'}      NS        {tmpl_var name='data'}
 </tmpl_if>
 <tmpl_if name="type" op='==' value='A'>
-{tmpl_var name='name'}      A        {tmpl_var name='data'}
+{tmpl_var name='name'} {tmpl_var name='ttl'} A        {tmpl_var name='data'}
 </tmpl_if>
 <tmpl_if name="type" op='==' value='AAAA'>
 {tmpl_var name='name'}      AAAA        {tmpl_var name='data'}
diff --git a/server/plugins-available/maildeliver_plugin.inc.php b/server/plugins-available/maildeliver_plugin.inc.php
index 33f00aee5..4d0b465a3 100644
--- a/server/plugins-available/maildeliver_plugin.inc.php
+++ b/server/plugins-available/maildeliver_plugin.inc.php
@@ -60,6 +60,7 @@ class maildeliver_plugin {
 		Register for the events
 		*/
 		
+		$app->plugins->registerEvent('mail_user_insert','maildeliver_plugin','update');
 		$app->plugins->registerEvent('mail_user_update','maildeliver_plugin','update');
 		$app->plugins->registerEvent('mail_user_delete','maildeliver_plugin','delete');
 		
diff --git a/server/plugins-available/maildrop_plugin.inc.php b/server/plugins-available/maildrop_plugin.inc.php
index 3b1360fce..a0ad50e87 100644
--- a/server/plugins-available/maildrop_plugin.inc.php
+++ b/server/plugins-available/maildrop_plugin.inc.php
@@ -60,6 +60,7 @@ class maildrop_plugin {
 		Register for the events
 		*/
 		
+		$app->plugins->registerEvent('mail_user_update','maildrop_plugin','insert');
 		$app->plugins->registerEvent('mail_user_update','maildrop_plugin','update');
 		$app->plugins->registerEvent('mail_user_delete','maildrop_plugin','delete');
 		
-- 
GitLab