From 33e2c95c69b405f36caf9013ff9a256e6edf9500 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 11 Feb 2013 08:15:44 -0500
Subject: [PATCH] - htpasswd_stats file was not readable for apache user.

---
 interface/lib/classes/tform.inc.php |   73 +++++++++++++++++++++++-------------
 1 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index b0b727c..8e36fb2 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -687,7 +687,7 @@
 										}
                                 break;
                                 case 'INTEGER':
-                                        $new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0;
+										$new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0;
                                         //if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default'];
                                         //if($key == 'refresh') die($record[$key]);
                                 break;
@@ -856,7 +856,7 @@
 									}
                                 break;
                                 case 'ISINT':
-									if(function_exists('filter_var')) {
+									if(function_exists('filter_var') && $field_value < 2147483647) {
 										if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT) === false) {
 											$errmsg = $validator['errmsg'];
 											if(isset($this->wordbook[$errmsg])) {
@@ -887,6 +887,7 @@
 										  }
                                         }
                                 break;
+				/*
 				case 'ISV6PREFIX':
 					$v6_prefix_ok = 0;
 					$explode_field_value = explode(':',$field_value);
@@ -917,7 +918,8 @@
 					if($v6_prefix_ok <> 1){
 						$this->errorMessage .= $errmsg."<br />\r\n"; 
 					}
-				break;
+				break;
+				*/
 								case 'ISIPV4':
 								$vip=1;
 								if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
@@ -937,31 +939,44 @@
 										}
                                 break;
 								case 'ISIP':
-								//* Check if its a IPv4 or IPv6 address
-								if(function_exists('filter_var')) {
-									if(!filter_var($field_value,FILTER_VALIDATE_IP)) {
-										$errmsg = $validator['errmsg'];
-										if(isset($this->wordbook[$errmsg])) {
-											$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
-										} else {
-											$this->errorMessage .= $errmsg."<br />\r\n";
-										}
-									}
+								if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n';
+								if($validator['allowempty'] == 'y' && $field_value == '') {
+									//* Do nothing
 								} else {
-									//* Check content with regex, if we use php < 5.2
-									$ip_ok = 0;
-									if(preg_match("/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i", $field_value)){
-										$ip_ok = 1;
+								//* Check if its a IPv4 or IPv6 address
+									if(isset($validator['separator']) && $validator['separator'] != '') {
+										//* When the field may contain several IP addresses, split them by the char defined as separator
+										$field_value_array = explode($validator['separator'],$field_value);
+									} else {
+										$field_value_array[] = $field_value;
 									}
-									if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
-										$ip_ok = 1;
-									}
-									if($ip_ok == 0) {
-										$errmsg = $validator['errmsg'];
-										if(isset($this->wordbook[$errmsg])) {
-											$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
+									foreach($field_value_array as $field_value) {
+										if(function_exists('filter_var')) {
+											if(!filter_var($field_value,FILTER_VALIDATE_IP)) {
+												$errmsg = $validator['errmsg'];
+												if(isset($this->wordbook[$errmsg])) {
+													$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
+												} else {
+													$this->errorMessage .= $errmsg."<br />\r\n";
+												}
+											}
 										} else {
-											$this->errorMessage .= $errmsg."<br />\r\n";
+											//* Check content with regex, if we use php < 5.2
+											$ip_ok = 0;
+											if(preg_match("/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i", $field_value)){
+												$ip_ok = 1;
+											}
+											if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
+												$ip_ok = 1;
+											}
+											if($ip_ok == 0) {
+												$errmsg = $validator['errmsg'];
+												if(isset($this->wordbook[$errmsg])) {
+													$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
+												} else {
+													$this->errorMessage .= $errmsg."<br />\r\n";
+												}
+											}
 										}
 									}
 								}
@@ -1057,7 +1072,9 @@
 																$record[$key] = $app->auth->crypt_password(stripslashes($record[$key]));
 																$sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
 														} elseif ($field['encryption'] == 'MYSQL') {
-																$sql_insert_val .= "PASSWORD('".$app->db->quote($record[$key])."'), ";
+																$tmp = $app->db->queryOneRecord("SELECT PASSWORD('".$app->db->quote(stripslashes($record[$key]))."') as `crypted`");
+																$record[$key] = $tmp['crypted'];
+																$sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
 														} elseif ($field['encryption'] == 'CLEARTEXT') {
 																$sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
                                                         } else {
@@ -1084,7 +1101,9 @@
                                                                 $record[$key] = $app->auth->crypt_password(stripslashes($record[$key]));
 																$sql_update .= "`$key` = '".$app->db->quote($record[$key])."', ";
 														} elseif (isset($field['encryption']) && $field['encryption'] == 'MYSQL') {
-																$sql_update .= "`$key` = PASSWORD('".$app->db->quote($record[$key])."'), ";
+																$tmp = $app->db->queryOneRecord("SELECT PASSWORD('".$app->db->quote(stripslashes($record[$key]))."') as `crypted`");
+																$record[$key] = $tmp['crypted'];
+																$sql_update .= "`$key` = '".$app->db->quote($record[$key])."', ";
 														} elseif (isset($field['encryption']) && $field['encryption'] == 'CLEARTEXT') {
 																$sql_update .= "`$key` = '".$app->db->quote($record[$key])."', ";
                                                         } else {

--
Gitblit v1.9.1