From 0c5f131e68d9de99c8011ca2b6d66830af5749fc Mon Sep 17 00:00:00 2001 From: cajus Date: Thu, 10 Jan 2008 12:54:47 +0000 Subject: [PATCH] Updated tests:: git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8287 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_location.inc | 1 + gosa-core/include/functions.inc | 217 +--------------- .../sieve/class_sieveElement_Redirect.inc | 2 +- .../sieve/class_sieveElement_Vacation.inc | 2 +- gosa-core/include/utils/class_tests.inc | 238 ++++++++++++++++++ .../addons/addressbook/class_addressbook.inc | 12 +- .../addons/gotomasses/class_goto_task.inc | 8 +- .../addons/gotomasses/class_target_list.inc | 6 +- .../departments/class_departmentGeneric.inc | 6 +- .../plugins/admin/fai/class_faiManagement.inc | 2 +- .../fai/class_faiPartitionTableEntry.inc | 4 +- .../admin/groups/class_groupGeneric.inc | 4 +- .../plugins/admin/groups/class_groupMail.inc | 6 +- .../admin/ogroups/class_mailogroup.inc | 2 +- .../admin/systems/class_componentGeneric.inc | 4 +- .../admin/systems/class_phoneGeneric.inc | 4 +- .../admin/systems/class_printGeneric.inc | 2 +- .../admin/systems/class_servGeneric.inc | 2 +- .../admin/systems/class_terminalGeneric.inc | 2 +- .../systems/class_workstationGeneric.inc | 2 +- .../services/dhcp/class_dhcpNetwork.inc | 2 +- .../systems/services/dhcp/class_dhcpPool.inc | 8 +- .../services/dhcp/class_dhcpService.inc | 4 +- .../services/dhcp/class_dhcpSharedNetwork.inc | 2 +- .../services/dhcp/class_dhcpSubnet.inc | 8 +- .../services/dns/class_servDNSeditZone.inc | 4 +- .../systems/services/dns/class_termDNS.inc | 4 +- .../services/kolab/class_servKolab.inc | 2 +- .../services/mail/class_goMailServer.inc | 4 +- .../services/spam/class_goSpamServer.inc | 2 +- .../blocklists/class_blocklistGeneric.inc | 4 +- .../gofax/faxaccount/class_gofaxAccount.inc | 12 +- .../gofon/phoneaccount/class_phoneAccount.inc | 2 +- .../connectivity/class_kolabAccount.inc | 8 +- .../connectivity/class_pureftpdAccount.inc | 12 +- .../plugins/personal/generic/class_user.inc | 24 +- .../personal/mail/class_mailAccount.inc | 12 +- .../personal/nagios/class_nagiosAccount.inc | 4 +- .../personal/posix/class_posixAccount.inc | 24 +- .../personal/samba/class_sambaAccount.inc | 4 +- .../personal/scalix/class_scalixAccount.inc | 4 +- gosa-core/setup/class_setupStep_Feedback.inc | 2 +- gosa-core/setup/class_setupStep_Migrate.inc | 2 +- 43 files changed, 352 insertions(+), 328 deletions(-) create mode 100644 gosa-core/include/utils/class_tests.inc diff --git a/gosa-core/include/class_location.inc b/gosa-core/include/class_location.inc index dec871a75..ff2ced968 100644 --- a/gosa-core/include/class_location.inc +++ b/gosa-core/include/class_location.inc @@ -29,6 +29,7 @@ $class_mapping= array( "LayersMenu" => "include/utils/layer-menu/lib/layersmenu.inc.php", "LayersMenuCommon" => "include/utils/layer-menu/lib/layersmenu-common.inc.php", "PlainMenu" => "include/utils/layer-menu/lib/plainmenu.inc.php", + "tests" => "include/utils/class_tests.inc", "divlist" => "include/class_divlist.inc", "passwordMethodClear" => "include/password-methods/class_password-methods-clear.inc", "passwordMethodMd5" => "include/password-methods/class_password-methods-md5.inc", diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 87c667de6..07ce7ded7 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -916,7 +916,7 @@ function eval_sizelimit() if (isset($_POST['set_size_action'])){ /* User wants new size limit? */ - if (is_id($_POST['new_limit']) && + if (tests::is_id($_POST['new_limit']) && isset($_POST['action']) && $_POST['action']=="newlimit"){ session::set('size_limit', validate($_POST['new_limit'])); @@ -1101,42 +1101,6 @@ function get_base_from_people($dn) } -function is_phone_nr($nr) -{ - if ($nr == ""){ - return (TRUE); - } - - return preg_match ("/^[\/0-9 ()+*-]+$/", $nr); -} - - -function is_dns_name($str) -{ - return(preg_match("/^[a-z0-9\.\-]*$/i",$str)); -} - - -function is_url($url) -{ - if ($url == ""){ - return (TRUE); - } - - return preg_match ("/^(http|https):\/\/((?:[a-zA-Z0-9_-]+\.?)+):?(\d*)/", $url); -} - - -function is_dn($dn) -{ - if ($dn == ""){ - return (TRUE); - } - - return preg_match ("/^[a-z0-9 _-]+$/i", $dn); -} - - function strict_uid_mode() { return !(isset($config->current['STRICT']) && preg_match('/^(no|false)$/i', $config->current['STRICT'])); @@ -1155,122 +1119,6 @@ function get_uid_regexp() } -function is_uid($uid) -{ - global $config; - - if ($uid == ""){ - return (TRUE); - } - - /* STRICT adds spaces and case insenstivity to the uid check. - This is dangerous and should not be used. */ - if (strict_uid_mode()){ - return preg_match ("/^[a-z0-9_-]+$/", $uid); - } else { - return preg_match ("/^[a-z0-9 _.-]+$/i", $uid); - } -} - - -function is_ip($ip) -{ - return preg_match("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/", $ip); -} - - -function is_mac($mac) -{ - return preg_match("/^[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]$/i", $mac); -} - - -/* Checks if the given ip address dosen't match - "is_ip" because there is also a sub net mask given */ -function is_ip_with_subnetmask($ip) -{ - /* Generate list of valid submasks */ - $res = array(); - for($e = 0 ; $e <= 32; $e++){ - $res[$e] = $e; - } - $i[0] =255; - $i[1] =255; - $i[2] =255; - $i[3] =255; - for($a= 3 ; $a >= 0 ; $a --){ - $c = 1; - while($i[$a] > 0 ){ - $str = $i[0].".".$i[1].".".$i[2].".".$i[3]; - $res[$str] = $str; - $i[$a] -=$c; - $c = 2*$c; - } - } - $res["0.0.0.0"] = "0.0.0.0"; - if(preg_match("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". - "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". - "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". - "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", $ip)){ - $mask = preg_replace("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". - "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". - "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". - "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/","",$ip); - - $mask = preg_replace("/^\//","",$mask); - if((in_array("$mask",$res)) && preg_match("/^[0-9\.]/",$mask)){ - return(TRUE); - } - } - return(FALSE); -} - - -/* Simple is domain check, it checks if the given string looks like "string(...).string" */ -function is_domain($str) -{ - return(preg_match("/^([a-z0-9i\-]*)\.[a-z0-9]*$/i",$str)); -} - - -function is_id($id) -{ - if ($id == ""){ - return (FALSE); - } - - return preg_match ("/^[0-9]+$/", $id); -} - - -function is_path($path) -{ - if ($path == ""){ - return (TRUE); - } - if (!preg_match('/^[a-z0-9%\/_.+-]+$/i', $path)){ - return (FALSE); - } - - return preg_match ("/\/.+$/", $path); -} - - -function is_email($address, $template= FALSE) -{ - if ($address == ""){ - return (TRUE); - } - if ($template){ - return preg_match ("/^[._a-z0-9%-]+@[_a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z0-9-]+)*$/i", - $address); - } else { - return preg_match ("/^[._a-z0-9-]+@[_a-z0-9-]+(\.[a-z0-9i-]+)(\.[a-z0-9-]+)*$/i", - $address); - } -} - - function print_red() { trigger_error("Use of obsolete print_red"); @@ -2184,29 +2032,6 @@ function get_MicroTimeDiff($start , $stop) } -/* Check if the given department name is valid */ -function is_department_name_reserved($name,$base) -{ - $reservedName = array("systems","apps","incomming","internal","accounts","fax","addressbook", - preg_replace("/ou=(.*),/","\\1",get_people_ou()), - preg_replace("/ou=(.*),/","\\1",get_groups_ou())); - $follwedNames['/ou=fai,ou=configs,ou=systems,/'] = array("fai","hooks","templates","scripts","disk","packages","variables","profiles"); - - /* Check if name is one of the reserved names */ - if(in_array_ics($name,$reservedName)) { - return(true); - } - - /* Check all follow combinations if name is in array && parent base == array_key, return false*/ - foreach($follwedNames as $key => $names){ - if((in_array_ics($name,$names)) && (preg_match($key,$base))){ - return(true); - } - } - return(false); -} - - function get_base_dir() { global $BASE_DIR; @@ -2534,46 +2359,6 @@ function get_post($name) } -/* Check if $ip1 and $ip2 represents a valid IP range - * returns TRUE in case of a valid range, FALSE in case of an error. - */ -function is_ip_range($ip1,$ip2) -{ - if(!is_ip($ip1) || !is_ip($ip2)){ - return(FALSE); - }else{ - $ar1 = split("\.",$ip1); - $var1 = $ar1[0] * (16777216) + $ar1[1] * (65536) + $ar1[2] * (256) + $ar1[3]; - - $ar2 = split("\.",$ip2); - $var2 = $ar2[0] * (16777216) + $ar2[1] * (65536) + $ar2[2] * (256) + $ar2[3]; - return($var1 < $var2); - } -} - - -/* Check if the specified IP address $address is inside the given network */ -function is_in_network($network, $netmask, $address) -{ - $nw= split('\.', $network); - $nm= split('\.', $netmask); - $ad= split('\.', $address); - - /* Generate inverted netmask */ - for ($i= 0; $i<4; $i++){ - $ni[$i]= 255-$nm[$i]; - $la[$i]= $nw[$i] | $ni[$i]; - } - - /* Transform to integer */ - $first= $nw[0] * (16777216) + $nw[1] * (65536) + $nw[2] * (256) + $nw[3]; - $curr= $ad[0] * (16777216) + $ad[1] * (65536) + $ad[2] * (256) + $ad[3]; - $last= $la[0] * (16777216) + $la[1] * (65536) + $la[2] * (256) + $la[3]; - - return ($first < $curr&& $last > $curr); -} - - /* Return class name in correct case */ function get_correct_class_name($cls) { diff --git a/gosa-core/include/sieve/class_sieveElement_Redirect.inc b/gosa-core/include/sieve/class_sieveElement_Redirect.inc index 64e71b6f8..bbb2d4bf1 100644 --- a/gosa-core/include/sieve/class_sieveElement_Redirect.inc +++ b/gosa-core/include/sieve/class_sieveElement_Redirect.inc @@ -20,7 +20,7 @@ class sieve_redirect { $msgs = array(); - if(!is_email($this->data)){ + if(!tests::is_email($this->data)){ $msgs[] =_("Please specify a valid email address."); } diff --git a/gosa-core/include/sieve/class_sieveElement_Vacation.inc b/gosa-core/include/sieve/class_sieveElement_Vacation.inc index 43c754637..1af166e9d 100644 --- a/gosa-core/include/sieve/class_sieveElement_Vacation.inc +++ b/gosa-core/include/sieve/class_sieveElement_Vacation.inc @@ -140,7 +140,7 @@ class sieve_vacation $msgs = array(); $err = FALSE; foreach($this->addresses as $addr){ - if(!is_email($addr)){ + if(!tests::is_email($addr)){ $err = true; } } diff --git a/gosa-core/include/utils/class_tests.inc b/gosa-core/include/utils/class_tests.inc new file mode 100644 index 000000000..72d01431f --- /dev/null +++ b/gosa-core/include/utils/class_tests.inc @@ -0,0 +1,238 @@ += 0 ; $a --){ + $c = 1; + while($i[$a] > 0 ){ + $str = $i[0].".".$i[1].".".$i[2].".".$i[3]; + $res[$str] = $str; + $i[$a] -=$c; + $c = 2*$c; + } + } + $res["0.0.0.0"] = "0.0.0.0"; + if(preg_match("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", $ip)){ + $mask = preg_replace("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.". + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/","",$ip); + + $mask = preg_replace("/^\//","",$mask); + if((in_array("$mask",$res)) && preg_match("/^[0-9\.]/",$mask)){ + return(TRUE); + } + } + return(FALSE); + } + + + /* Simple is domain check, it checks if the given string looks like "string(...).string" */ + function is_domain($str) + { + return(preg_match("/^([a-z0-9i\-]*)\.[a-z0-9]*$/i",$str)); + } + + + function is_id($id) + { + if ($id == ""){ + return (FALSE); + } + + return preg_match ("/^[0-9]+$/", $id); + } + + + function is_path($path) + { + if ($path == ""){ + return (TRUE); + } + if (!preg_match('/^[a-z0-9%\/_.+-]+$/i', $path)){ + return (FALSE); + } + + return preg_match ("/\/.+$/", $path); + } + + + function is_email($address, $template= FALSE) + { + if ($address == ""){ + return (TRUE); + } + if ($template){ + return preg_match ("/^[._a-z0-9%-]+@[_a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z0-9-]+)*$/i", + $address); + } else { + return preg_match ("/^[._a-z0-9-]+@[_a-z0-9-]+(\.[a-z0-9i-]+)(\.[a-z0-9-]+)*$/i", + $address); + } + } + + + /* Check if the given department name is valid */ + function is_department_name_reserved($name,$base) + { + $reservedName = array("systems","apps","incomming","internal","accounts","fax","addressbook", + preg_replace("/ou=(.*),/","\\1",get_people_ou()), + preg_replace("/ou=(.*),/","\\1",get_groups_ou())); + $follwedNames['/ou=fai,ou=configs,ou=systems,/'] = array("fai","hooks","templates","scripts","disk","packages","variables","profiles"); + + /* Check if name is one of the reserved names */ + if(in_array_ics($name,$reservedName)) { + return(true); + } + + /* Check all follow combinations if name is in array && parent base == array_key, return false*/ + foreach($follwedNames as $key => $names){ + if((in_array_ics($name,$names)) && (preg_match($key,$base))){ + return(true); + } + } + return(false); + } + + + /* Check if $ip1 and $ip2 represents a valid IP range + * returns TRUE in case of a valid range, FALSE in case of an error. + */ + function is_ip_range($ip1,$ip2) + { + if(!is_ip($ip1) || !is_ip($ip2)){ + return(FALSE); + }else{ + $ar1 = split("\.",$ip1); + $var1 = $ar1[0] * (16777216) + $ar1[1] * (65536) + $ar1[2] * (256) + $ar1[3]; + + $ar2 = split("\.",$ip2); + $var2 = $ar2[0] * (16777216) + $ar2[1] * (65536) + $ar2[2] * (256) + $ar2[3]; + return($var1 < $var2); + } + } + + + /* Check if the specified IP address $address is inside the given network */ + function is_in_network($network, $netmask, $address) + { + $nw= split('\.', $network); + $nm= split('\.', $netmask); + $ad= split('\.', $address); + + /* Generate inverted netmask */ + for ($i= 0; $i<4; $i++){ + $ni[$i]= 255-$nm[$i]; + $la[$i]= $nw[$i] | $ni[$i]; + } + + /* Transform to integer */ + $first= $nw[0] * (16777216) + $nw[1] * (65536) + $nw[2] * (256) + $nw[3]; + $curr= $ad[0] * (16777216) + $ad[1] * (65536) + $ad[2] * (256) + $ad[3]; + $last= $la[0] * (16777216) + $la[1] * (65536) + $la[2] * (256) + $la[3]; + + return ($first < $curr&& $last > $curr); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/addressbook/class_addressbook.inc b/gosa-core/plugins/addons/addressbook/class_addressbook.inc index 1933228b9..b1821bcd0 100644 --- a/gosa-core/plugins/addons/addressbook/class_addressbook.inc +++ b/gosa-core/plugins/addons/addressbook/class_addressbook.inc @@ -680,19 +680,19 @@ class addressbook extends plugin } /* Check phone numbers */ - if (!is_phone_nr($this->homePhone)){ + if (!tests::is_phone_nr($this->homePhone)){ $message[]= _("The field 'Phone' contains an invalid phone number."); } - if (!is_phone_nr($this->telephoneNumber)){ + if (!tests::is_phone_nr($this->telephoneNumber)){ $message[]= _("The field 'Phone' contains an invalid phone number."); } - if (!is_phone_nr($this->facsimileTelephoneNumber)){ + if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){ $message[]= _("The field 'Fax' contains an invalid phone number."); } - if (!is_phone_nr($this->mobile)){ + if (!tests::is_phone_nr($this->mobile)){ $message[]= _("The field 'Mobile' contains an invalid phone number."); } - if (!is_phone_nr($this->pager)){ + if (!tests::is_phone_nr($this->pager)){ $message[]= _("The field 'Pager' contains an invalid phone number."); } @@ -705,7 +705,7 @@ class addressbook extends plugin } /* Check mail */ - if (!is_email($this->mail)){ + if (!tests::is_email($this->mail)){ $message[]= _("Please enter a valid email address in 'Primary address' field."); } diff --git a/gosa-core/plugins/addons/gotomasses/class_goto_task.inc b/gosa-core/plugins/addons/gotomasses/class_goto_task.inc index 8964def48..1fa84d1cb 100644 --- a/gosa-core/plugins/addons/gotomasses/class_goto_task.inc +++ b/gosa-core/plugins/addons/gotomasses/class_goto_task.inc @@ -121,7 +121,7 @@ class goto_task extends plugin if(isset($_POST['task_Name'])){ $NAME = $_POST['task_Name']; } - if(isset($_POST['task_IP']) && is_ip($_POST['task_IP'])){ + if(isset($_POST['task_IP']) && tests::is_ip($_POST['task_IP'])){ $IP = $_POST['task_IP']; } if(isset($_POST['configure_dns']) && isset($_POST['Zone']) && isset($this->Zones[$_POST['Zone']])){ @@ -130,7 +130,7 @@ class goto_task extends plugin if(isset($_POST['configure_dhcp']) && isset($_POST['Section']) && isset($this->Sections[$_POST['Section']])){ $DHCP = $_POST['Section']; } - if(is_mac($MAC)){ + if(tests::is_mac($MAC)){ $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME); } } @@ -156,7 +156,7 @@ class goto_task extends plugin if(isset($tmp[2])){ $NAME = trim($tmp[2]); } - if(is_mac($MAC)){ + if(tests::is_mac($MAC)){ $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME); } } @@ -390,7 +390,7 @@ class goto_task extends plugin */ function is_valid_target($str) { - if(is_mac($str)){ + if(tests::is_mac($str)){ return(TRUE); }else{ $ldap = $this->config->get_ldap_link(); diff --git a/gosa-core/plugins/addons/gotomasses/class_target_list.inc b/gosa-core/plugins/addons/gotomasses/class_target_list.inc index 088c208c7..15d3fb1ae 100644 --- a/gosa-core/plugins/addons/gotomasses/class_target_list.inc +++ b/gosa-core/plugins/addons/gotomasses/class_target_list.inc @@ -225,11 +225,11 @@ class target_list extends MultiSelectWindow $IP_end = $this->IP_end; if($this->IPMatch){ - if(!is_ip($IP_start)){ + if(!tests::is_ip($IP_start)){ print_red(_("Please specify a valid IP range.")); return; } - if(!is_ip($IP_end)){ + if(!tests::is_ip($IP_end)){ print_red(_("Please specify a valid IP range.")); return; } @@ -269,7 +269,7 @@ class target_list extends MultiSelectWindow if($this->IPMatch){ if(isset($val['ipHostNumber'][0])){ - if(is_ip_range($IP_start,$val['ipHostNumber'][0]) && is_ip_range($val['ipHostNumber'][0],$IP_end)){ + if(tests::is_ip_range($IP_start,$val['ipHostNumber'][0]) && tests::is_ip_range($val['ipHostNumber'][0],$IP_end)){ $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; } } diff --git a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc index 429b454f2..e1d637d15 100644 --- a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc @@ -268,17 +268,17 @@ class department extends plugin $message[]= _("Required field 'Description' is not set."); } - if(is_department_name_reserved($this->ou,$this->base)){ + if(tests::is_department_name_reserved($this->ou,$this->base)){ $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$this->ou); } if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){ $message[]= _("The field 'Name' contains invalid characters."); } - if (!is_phone_nr($this->telephoneNumber)){ + if (!tests::is_phone_nr($this->telephoneNumber)){ $message[]= _("The field 'Phone' contains an invalid phone number."); } - if (!is_phone_nr($this->facsimileTelephoneNumber)){ + if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){ $message[]= _("The field 'Fax' contains an invalid phone number."); } diff --git a/gosa-core/plugins/admin/fai/class_faiManagement.inc b/gosa-core/plugins/admin/fai/class_faiManagement.inc index 16ae87f73..1c9b4347e 100644 --- a/gosa-core/plugins/admin/fai/class_faiManagement.inc +++ b/gosa-core/plugins/admin/fai/class_faiManagement.inc @@ -1056,7 +1056,7 @@ class faiManagement extends plugin return(false); }elseif(in_array($name,$this->getBranches($f))) { return(false); - }elseif(is_department_name_reserved($name,$base)){ + }elseif(tests::is_department_name_reserved($name,$base)){ return(false); } return(true); diff --git a/gosa-core/plugins/admin/fai/class_faiPartitionTableEntry.inc b/gosa-core/plugins/admin/fai/class_faiPartitionTableEntry.inc index 431157c26..bb2278ed0 100644 --- a/gosa-core/plugins/admin/fai/class_faiPartitionTableEntry.inc +++ b/gosa-core/plugins/admin/fai/class_faiPartitionTableEntry.inc @@ -446,13 +446,13 @@ class faiPartitionTableEntry extends plugin $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); break; case 1: - if (!is_id(is_id($tmp[0])) &&(!empty($tmp[1]))){ + if (!tests::is_id(is_id($tmp[0])) &&(!empty($tmp[1]))){ $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); } break; case 2: - if((!is_id($tmp[0]))&&(!is_id($tmp[1])) &&(!empty($tmp[1]))){ + if((!tests::is_id($tmp[0]))&&(!tests::is_id($tmp[1])) &&(!empty($tmp[1]))){ $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); }elseif($tmp[0]>=$tmp[1]){ $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); diff --git a/gosa-core/plugins/admin/groups/class_groupGeneric.inc b/gosa-core/plugins/admin/groups/class_groupGeneric.inc index ce23be188..2de314404 100644 --- a/gosa-core/plugins/admin/groups/class_groupGeneric.inc +++ b/gosa-core/plugins/admin/groups/class_groupGeneric.inc @@ -854,7 +854,7 @@ class group extends plugin } /* Check for valid input */ - if (!is_uid($this->cn)){ + if (!tests::is_uid($this->cn)){ $message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed."); } @@ -895,7 +895,7 @@ class group extends plugin /* Check ID */ if ($this->force_gid == "1"){ - if (!is_id($this->gidNumber)){ + if (!tests::is_id($this->gidNumber)){ $message[]= _("Value specified as 'GID' is not valid."); } else { if ($this->gidNumber < $this->config->current['MINID']){ diff --git a/gosa-core/plugins/admin/groups/class_groupMail.inc b/gosa-core/plugins/admin/groups/class_groupMail.inc index b7a2946a4..6f0758355 100644 --- a/gosa-core/plugins/admin/groups/class_groupMail.inc +++ b/gosa-core/plugins/admin/groups/class_groupMail.inc @@ -439,7 +439,7 @@ class mailgroup extends plugin /* Valid email address specified? */ $address= $_POST['forward_address']; - if (!is_email($address)){ + if (!tests::is_email($address)){ print_red (_("You're trying to add an invalid email address ". "to the list of forwarders.")); @@ -472,7 +472,7 @@ class mailgroup extends plugin if (isset($_POST['add_alternate'])){ if ($_POST['alternate_address'] != "" && $this->acl_is_writeable("gosaMailAlternateAddress")){ - if (!is_email($_POST['alternate_address'])){ + if (!tests::is_email($_POST['alternate_address'])){ print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); } elseif (($user= $this->addAlternate ($_POST['alternate_address'])) != ""){ @@ -1025,7 +1025,7 @@ I: Only insider delivery */ if ($this->mail == ""){ $message[]= _("The required field 'Primary address' is not set."); } - if (!is_email($this->mail)){ + if (!tests::is_email($this->mail)){ $message[]= _("Please enter a valid email addres in 'Primary address' field."); } $ldap->cd($this->config->current['BASE']); diff --git a/gosa-core/plugins/admin/ogroups/class_mailogroup.inc b/gosa-core/plugins/admin/ogroups/class_mailogroup.inc index ebf569729..7ab344bbf 100644 --- a/gosa-core/plugins/admin/ogroups/class_mailogroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_mailogroup.inc @@ -81,7 +81,7 @@ class mailogroup extends plugin $ldap= $this->config->get_ldap_link(); /* Check if mail address is valid */ - if (!is_email($this->mail) || $this->mail == ""){ + if (!tests::is_email($this->mail) || $this->mail == ""){ $message[]= _("Please enter a valid email address in 'Primary address' field."); } diff --git a/gosa-core/plugins/admin/systems/class_componentGeneric.inc b/gosa-core/plugins/admin/systems/class_componentGeneric.inc index 4f2657a69..2772f3501 100644 --- a/gosa-core/plugins/admin/systems/class_componentGeneric.inc +++ b/gosa-core/plugins/admin/systems/class_componentGeneric.inc @@ -187,7 +187,7 @@ class componentGeneric extends plugin } /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn)){ + if(!tests::is_dns_name($this->cn)){ $message[] = _("Please specify a valid name for this object."); } @@ -195,7 +195,7 @@ class componentGeneric extends plugin if($this->netConfigDNS->ipHostNumber == ""){ $message[]= _("The required field IP address is empty."); } else { - if (!is_ip($this->netConfigDNS->ipHostNumber)){ + if (!tests::is_ip($this->netConfigDNS->ipHostNumber)){ $message[]= _("The field IP address contains an invalid address."); } } diff --git a/gosa-core/plugins/admin/systems/class_phoneGeneric.inc b/gosa-core/plugins/admin/systems/class_phoneGeneric.inc index e3e279c36..3357e5c0b 100644 --- a/gosa-core/plugins/admin/systems/class_phoneGeneric.inc +++ b/gosa-core/plugins/admin/systems/class_phoneGeneric.inc @@ -329,13 +329,13 @@ class phoneGeneric extends plugin if($this->netConfigDNS->ipHostNumber == ""){ $message[]= _("The required field IP address is empty."); } else { - if (!is_ip($this->netConfigDNS->ipHostNumber)){ + if (!tests::is_ip($this->netConfigDNS->ipHostNumber)){ $message[]= _("The field IP address contains an invalid address."); } } /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn) ){ + if(!tests::is_dns_name($this->cn) ){ $message[] = _("Please specify a valid name for this object."); } diff --git a/gosa-core/plugins/admin/systems/class_printGeneric.inc b/gosa-core/plugins/admin/systems/class_printGeneric.inc index 3020e0d5a..b2954dc04 100644 --- a/gosa-core/plugins/admin/systems/class_printGeneric.inc +++ b/gosa-core/plugins/admin/systems/class_printGeneric.inc @@ -672,7 +672,7 @@ class printgeneric extends plugin } /* must: cn */ - if(($this->BelongsTo == "Printer") && !is_dns_name($this->cn)){ + if(($this->BelongsTo == "Printer") && !tests::is_dns_name($this->cn)){ $message[]= _("Invalid character in printer name."); } diff --git a/gosa-core/plugins/admin/systems/class_servGeneric.inc b/gosa-core/plugins/admin/systems/class_servGeneric.inc index 4bc47245c..c0f1d595c 100644 --- a/gosa-core/plugins/admin/systems/class_servGeneric.inc +++ b/gosa-core/plugins/admin/systems/class_servGeneric.inc @@ -297,7 +297,7 @@ class servgeneric extends plugin } /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn)){ + if(!tests::is_dns_name($this->cn)){ $message[] = _("Please specify a valid name for this object."); } diff --git a/gosa-core/plugins/admin/systems/class_terminalGeneric.inc b/gosa-core/plugins/admin/systems/class_terminalGeneric.inc index 3f3f258fe..6782d8fab 100644 --- a/gosa-core/plugins/admin/systems/class_terminalGeneric.inc +++ b/gosa-core/plugins/admin/systems/class_terminalGeneric.inc @@ -455,7 +455,7 @@ class termgeneric extends plugin } /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn) ){ + if(!tests::is_dns_name($this->cn) ){ $message[] = _("Please specify a valid name for this object."); } diff --git a/gosa-core/plugins/admin/systems/class_workstationGeneric.inc b/gosa-core/plugins/admin/systems/class_workstationGeneric.inc index 1c56e8841..826582189 100644 --- a/gosa-core/plugins/admin/systems/class_workstationGeneric.inc +++ b/gosa-core/plugins/admin/systems/class_workstationGeneric.inc @@ -436,7 +436,7 @@ class workgeneric extends plugin } /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn)){ + if(!tests::is_dns_name($this->cn)){ $message[] = _("Please specify a valid name for this object."); } diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc index 1c3ced065..146b0e21b 100644 --- a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc @@ -207,7 +207,7 @@ class dhcpNetwork extends plugin } $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]); - if (!is_ip($tmp)){ + if (!tests::is_ip($tmp)){ $message[]= sprintf(_("Error in definition of '%s'!"), $typ); } } diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc index 9e9821e8a..eae26ddeb 100644 --- a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc @@ -121,11 +121,11 @@ class dhcpPool extends dhcpPlugin $message[]= _("Required field 'Range' is not filled."); } - if (!is_ip($this->range_start) || !is_ip($this->range_stop)){ + if (!tests::is_ip($this->range_start) || !tests::is_ip($this->range_stop)){ $message[]= _("Field 'Range' contains invalid IP addresses."); } - if(!is_ip_range($this->range_start,$this->range_stop)){ + if(!tests::is_ip_range($this->range_start,$this->range_stop)){ $message[] = _("Field 'Range' contains invalid IP range."); } @@ -138,8 +138,8 @@ class dhcpPool extends dhcpPlugin if ($type == 'dhcpSubnet'){ $network= $cache[$dn]['cn'][0]; $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]); - if (!is_in_network($network, $netmask, $this->range_start) || - !is_in_network($network, $netmask, $this->range_stop)){ + if (!tests::is_in_network($network, $netmask, $this->range_start) || + !tests::is_in_network($network, $netmask, $this->range_stop)){ $message[] = _("'Range' is not inside the configured network."); } } diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc index 57f76cc9e..4989c43fc 100644 --- a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc @@ -136,10 +136,10 @@ class dhcpService extends dhcpPlugin { $message= array(); - if (!is_id($this->statements['default-lease-time'])){ + if (!tests::is_id($this->statements['default-lease-time'])){ $message[]= _('Default lease time needs to be numeric.'); } - if (!is_id($this->statements['max-lease-time'])){ + if (!tests::is_id($this->statements['max-lease-time'])){ $message[]= _('Maximum lease time needs to be numeric.'); } if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){ diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc index 6e55b75d6..5dfd47703 100644 --- a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc @@ -150,7 +150,7 @@ class dhcpSharedNetwork extends dhcpPlugin "max-lease-time" => _("Max. lease time"), "min-lease-time" => _("Min. lease time")) as $key => $val){ if (isset($this->statements[$key]) && $this->statements[$key] != "" && - !is_id($this->statements[$key])){ + !tests::is_id($this->statements[$key])){ $message[]= sprintf(_("The value specified as '%s' is not numeric!"), $val); } } diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc index 8c2da41de..7fa9e9823 100644 --- a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc @@ -152,20 +152,20 @@ class dhcpSubnet extends dhcpPlugin /* IP's? */ foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){ - if ($this->$attr != "" && !is_ip($this->$attr)){ + if ($this->$attr != "" && !tests::is_ip($this->$attr)){ $message[]= sprintf(_("The field '%s' contains an invalid IP address"), $str); } } /* Check ip range */ if ($this->use_range){ - if(!is_ip_range($this->range_start,$this->range_stop)){ + if(!tests::is_ip_range($this->range_start,$this->range_stop)){ $message[] = _("Field 'Range' contains invalid IP range."); } /* Check if range is in the network */ - if (!is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) || - !is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){ + if (!tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) || + !tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){ $message[] = _("'Range' is not inside the configured network."); } } diff --git a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc index d5df0871d..c9ecd96df 100644 --- a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc +++ b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc @@ -448,7 +448,7 @@ class servdnseditZone extends plugin $addr = preg_replace("/^[^\/]*+\//","",$this->ReverseZone); /* Check for valid&complete IP address */ - if(!is_ip($addr)){ + if(!tests::is_ip($addr)){ $message[] = _("The given network address is not a valid, please specify a valid IP address."); } @@ -530,7 +530,7 @@ class servdnseditZone extends plugin foreach(array("sOAprimary","zoneName","sOAmail") as $attr){ if(!preg_match("/\.$/",$ret[$attr])){ - if(!is_ip($ret[$attr])){ + if(!tests::is_ip($ret[$attr])){ $ret[$attr] = $ret[$attr]."."; } } diff --git a/gosa-core/plugins/admin/systems/services/dns/class_termDNS.inc b/gosa-core/plugins/admin/systems/services/dns/class_termDNS.inc index f64650f26..48c191852 100644 --- a/gosa-core/plugins/admin/systems/services/dns/class_termDNS.inc +++ b/gosa-core/plugins/admin/systems/services/dns/class_termDNS.inc @@ -502,7 +502,7 @@ class termDNS extends plugin $message[]= _("The required field 'IP-address' is not set."); } - if (!is_ip($this->ipHostNumber)){ + if (!tests::is_ip($this->ipHostNumber)){ $message[]= _("Wrong IP format in field IP-address."); } } @@ -512,7 +512,7 @@ class termDNS extends plugin if ($this->macAddress == "" ){ $message[]= _("The required field 'MAC-address' is not set."); } - if(!is_mac($this->macAddress)){ + if(!tests::is_mac($this->macAddress)){ $message[]=(_("The given macaddress is invalid. There must be 6 2byte segments seperated by ':'.")); } diff --git a/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc b/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc index 7d31ff58d..08b75ea86 100644 --- a/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc +++ b/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc @@ -262,7 +262,7 @@ class servkolab extends goService { if(($this->kolabFreeBusyFuture=="")) { $message[] = _("Future days in Free/Busy settings must be set."); - }elseif(!is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){ + }elseif(!tests::is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){ $message[] = _("Future days in Free/Busy settings must be a positive value."); } diff --git a/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc b/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc index 742249ef7..9180cfa54 100644 --- a/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc +++ b/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc @@ -341,11 +341,11 @@ class goMailServer extends goService{ $port = trim($tmp[1]); $ip = trim($tmp[0]); - if((is_ip($ip)) && (is_numeric($port))){ + if((tests::is_ip($ip)) && (is_numeric($port))){ $dst = "[".$ip."]:".$port; } } - if(is_ip($dst)){ + if(tests::is_ip($dst)){ $dst = "[".$dst."]"; } $tmp2 ['src'] = $src; diff --git a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc index 82ff0fbaf..68c04e043 100644 --- a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc +++ b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc @@ -216,7 +216,7 @@ class gospamserver extends goService{ function AddTrust($post) { if(!empty($post)){ - if(is_ip($post) || is_domain($post) || (is_ip_with_subnetmask($post))){ + if(tests::is_ip($post) || tests::is_domain($post) || (tests::is_ip_with_subnetmask($post))){ $this->TrustedNetworks[$post] = $post; }else{ print_red(_("Specified value is not a valid 'trusted network' value.")); diff --git a/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc b/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc index 15c4c00ca..a6dab5936 100644 --- a/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc +++ b/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc @@ -116,7 +116,7 @@ class blocklistGeneric extends plugin /* Handle interactions: add */ if (isset($_POST['add_number']) && $_POST['number'] != ""){ - if (is_phone_nr($_POST['number']) || preg_match ("/^[\/0-9 ()\^\.\$+*-]+$/",$_POST['number'])){ + if (tests::is_phone_nr($_POST['number']) || preg_match ("/^[\/0-9 ()\^\.\$+*-]+$/",$_POST['number'])){ $this->addNumber ($_POST['number']); } else { print_red (_("Please specify a valid phone number.")); @@ -204,7 +204,7 @@ class blocklistGeneric extends plugin if ($this->cn == ""){ $message[]= _("Required field 'Name' is not set."); } else { - if (!is_uid($this->cn)){ + if (!tests::is_uid($this->cn)){ $message[]= _("Required field 'Name' contains invalid characters"); } if ($this->dn == 'new'){ diff --git a/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc b/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc index f1b18145a..63f22cee6 100644 --- a/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc +++ b/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc @@ -205,7 +205,7 @@ class gofaxAccount extends plugin } /* Add alternatives */ - if (isset($_POST['add_alternate']) && !empty($_POST['forward_address']) && is_phone_nr($_POST['forward_address'])){ + if (isset($_POST['add_alternate']) && !empty($_POST['forward_address']) && tests::is_phone_nr($_POST['forward_address'])){ if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ $this->addAlternate($_POST['forward_address']); } @@ -243,7 +243,7 @@ class gofaxAccount extends plugin /* Add number to blocklist (dialog) */ if (isset($_POST['add_blocklist_number']) && $_POST['block_number'] != ""){ - if (!is_phone_nr($_POST['block_number'])){ + if (!tests::is_phone_nr($_POST['block_number'])){ print_red (_("You're trying to add an invalid phone number.")); } else { array_push($this->current_blocklist, $_POST['block_number']); @@ -299,7 +299,7 @@ class gofaxAccount extends plugin $this->goFaxRBlockgroups = array(); foreach ($this->current_blocklist as $val){ - if (is_phone_nr($val)){ + if (tests::is_phone_nr($val)){ $this->goFaxRBlocklist[]=$val; } else { $this->goFaxRBlockgroups[]= $val; @@ -311,7 +311,7 @@ class gofaxAccount extends plugin /* Transfer values to ourself */ foreach ($this->current_blocklist as $val){ - if (is_phone_nr($val)){ + if (tests::is_phone_nr($val)){ $this->goFaxSBlocklist[]=$val; } else { $this->goFaxSBlockgroups[]= $val; @@ -678,7 +678,7 @@ class gofaxAccount extends plugin $message[]= _("The required field 'Fax' is not set."); } - if (!is_phone_nr($this->facsimileTelephoneNumber)){ + if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){ $message[]= _("Please enter a valid telephone number in the 'Fax' field."); } @@ -688,7 +688,7 @@ class gofaxAccount extends plugin $this->goFaxDeliveryMode & 32){ if ($this->mail == ""){ $message[]= _("Mail delivery is checked, but no address has been specified."); - } elseif (!is_email($this->mail)){ + } elseif (!tests::is_email($this->mail)){ $message[]= _("The mail address you've entered is invalid."); } } diff --git a/gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc b/gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc index 84c0e037e..a247dec96 100644 --- a/gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc +++ b/gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc @@ -1000,7 +1000,7 @@ class phoneAccount extends plugin /* Add phone number */ if (isset($_POST["add_phonenumber"]) && $_POST['phonenumber']){ - if (is_phone_nr($_POST['phonenumber'])){ + if (tests::is_phone_nr($_POST['phonenumber'])){ $number= $_POST["phonenumber"]; $this->phoneNumbers[$number]= $number; $this->is_modified= TRUE; diff --git a/gosa-core/plugins/personal/connectivity/class_kolabAccount.inc b/gosa-core/plugins/personal/connectivity/class_kolabAccount.inc index ddf92a889..1ff95fe53 100644 --- a/gosa-core/plugins/personal/connectivity/class_kolabAccount.inc +++ b/gosa-core/plugins/personal/connectivity/class_kolabAccount.inc @@ -160,8 +160,8 @@ class kolabAccount extends plugin /* Valid email address specified? */ $address= $_POST['delegate_address']; $valid= FALSE; - if (!is_email($address)){ - if (!is_email($address, TRUE)){ + if (!tests::is_email($address)){ + if (!tests::is_email($address, TRUE)){ print_red (_("You're trying to add an invalid email address to the list of delegations.")); } } else { @@ -357,8 +357,8 @@ class kolabAccount extends plugin } $address= preg_replace('/^([^:]+).*$/', '\1', $policy); - if (!is_email($address)){ - if (!is_email($address, TRUE)){ + if (!tests::is_email($address)){ + if (!tests::is_email($address, TRUE)){ $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address); } } else { diff --git a/gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc b/gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc index dbcf2eba2..ad2cba40b 100644 --- a/gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc +++ b/gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc @@ -184,23 +184,23 @@ class pureftpdAccount extends plugin /* Check for positive integer values */ if ($this->is_account){ - if($this->acl_is_writeable("FTPUploadBandwidth") && !is_id($this->FTPUploadBandwidth)){ + if($this->acl_is_writeable("FTPUploadBandwidth") && !tests::is_id($this->FTPUploadBandwidth)){ $message[]= _("Value specified as 'Upload bandwidth' is not valid."); } - if($this->acl_is_writeable("FTPDownloadBandwidth") && !is_id($this->FTPDownloadBandwidth)){ + if($this->acl_is_writeable("FTPDownloadBandwidth") && !tests::is_id($this->FTPDownloadBandwidth)){ $message[]= _("Value specified as 'Download bandwidth' is not valid."); } - if($this->acl_is_writeable("FTPQuotaFiles") && !is_id($this->FTPQuotaFiles)){ + if($this->acl_is_writeable("FTPQuotaFiles") && !tests::is_id($this->FTPQuotaFiles)){ $message[]= _("Value specified as 'Quota files' is not valid."); } - if($this->acl_is_writeable("FTPQuotaMBytes") && !is_id($this->FTPQuotaMBytes)){ + if($this->acl_is_writeable("FTPQuotaMBytes") && !tests::is_id($this->FTPQuotaMBytes)){ $message[]= _("Value specified as 'Quota size' is not valid."); } - if($this->acl_is_writeable("FTPUploadRatio") && !is_id($this->FTPUploadRatio)){ + if($this->acl_is_writeable("FTPUploadRatio") && !tests::is_id($this->FTPUploadRatio)){ $message[]= _("Value specified as 'Upload ratio' is not valid."); } - if($this->acl_is_writeable("FTPDownloadRatio") && !is_id($this->FTPDownloadRatio)){ + if($this->acl_is_writeable("FTPDownloadRatio") && !tests::is_id($this->FTPDownloadRatio)){ $message[]= _("Value specified as 'Download ratio' is not valid."); } } diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc index 15f8921c7..e1904c07a 100644 --- a/gosa-core/plugins/personal/generic/class_user.inc +++ b/gosa-core/plugins/personal/generic/class_user.inc @@ -472,7 +472,7 @@ class user extends plugin if (isset($_POST["certificateSerialNumber"]) && $_POST["certificateSerialNumber"] != ""){ - if (!is_id($_POST["certificateSerialNumber"])){ + if (!tests::is_id($_POST["certificateSerialNumber"])){ print_red (_("Please enter a valid serial number")); foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){ @@ -1131,10 +1131,10 @@ class user extends plugin } /* Check for valid input */ - if ($this->is_modified && !is_uid($this->uid)){ + if ($this->is_modified && !tests::is_uid($this->uid)){ $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed."); } - if (!is_url($this->labeledURI)){ + if (!tests::is_url($this->labeledURI)){ $message[]= _("The field 'Homepage' contains an invalid URL definition."); } if (preg_match ("/[\\\\]/", $this->sn)){ @@ -1145,16 +1145,16 @@ class user extends plugin } /* Check phone numbers */ - if (!is_phone_nr($this->telephoneNumber)){ + if (!tests::is_phone_nr($this->telephoneNumber)){ $message[]= _("The field 'Phone' contains an invalid phone number."); } - if (!is_phone_nr($this->facsimileTelephoneNumber)){ + if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){ $message[]= _("The field 'Fax' contains an invalid phone number."); } - if (!is_phone_nr($this->mobile)){ + if (!tests::is_phone_nr($this->mobile)){ $message[]= _("The field 'Mobile' contains an invalid phone number."); } - if (!is_phone_nr($this->pager)){ + if (!tests::is_phone_nr($this->pager)){ $message[]= _("The field 'Pager' contains an invalid phone number."); } @@ -1530,7 +1530,7 @@ class user extends plugin if($this->dn == "new") { $this->set_acl_base($this->base); } - if (!is_url($this->labeledURI) && in_array("labeledURI",$this->multi_boxes)){ + if (!tests::is_url($this->labeledURI) && in_array("labeledURI",$this->multi_boxes)){ $message[]= _("The field 'Homepage' contains an invalid URL definition."); } if (preg_match ("/[\\\\]/", $this->sn) && in_array("sn",$this->multi_boxes)){ @@ -1539,16 +1539,16 @@ class user extends plugin if (preg_match ("/[\\\\]/", $this->givenName) && in_array("givenName",$this->multi_boxes)){ $message[]= _("The field 'Given name' contains invalid characters."); } - if (!is_phone_nr($this->telephoneNumber) && in_array("telephoneNumber",$this->multi_boxes)){ + if (!tests::is_phone_nr($this->telephoneNumber) && in_array("telephoneNumber",$this->multi_boxes)){ $message[]= _("The field 'Phone' contains an invalid phone number."); } - if (!is_phone_nr($this->facsimileTelephoneNumber) && in_array("facsimileTelephoneNumber",$this->multi_boxes)){ + if (!tests::is_phone_nr($this->facsimileTelephoneNumber) && in_array("facsimileTelephoneNumber",$this->multi_boxes)){ $message[]= _("The field 'Fax' contains an invalid phone number."); } - if (!is_phone_nr($this->mobile) && in_array("mobile",$this->multi_boxes)){ + if (!tests::is_phone_nr($this->mobile) && in_array("mobile",$this->multi_boxes)){ $message[]= _("The field 'Mobile' contains an invalid phone number."); } - if (!is_phone_nr($this->pager) && in_array("pager",$this->multi_boxes)){ + if (!tests::is_phone_nr($this->pager) && in_array("pager",$this->multi_boxes)){ $message[]= _("The field 'Pager' contains an invalid phone number."); } if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName) && in_array("givenName",$this->multi_boxes)){ diff --git a/gosa-core/plugins/personal/mail/class_mailAccount.inc b/gosa-core/plugins/personal/mail/class_mailAccount.inc index 6df2ca711..1bdd4cefb 100644 --- a/gosa-core/plugins/personal/mail/class_mailAccount.inc +++ b/gosa-core/plugins/personal/mail/class_mailAccount.inc @@ -352,8 +352,8 @@ class mailAccount extends plugin /* Valid email address specified? */ $address= $_POST['forward_address']; $valid= FALSE; - if (!is_email($address)){ - if (!is_email($address, TRUE)){ + if (!tests::is_email($address)){ + if (!tests::is_email($address, TRUE)){ if ($this->is_template){ $valid= TRUE; } else { @@ -390,9 +390,9 @@ class mailAccount extends plugin if (isset($_POST['add_alternate'])){ $valid= FALSE; - if (!is_email($_POST['alternate_address'])){ + if (!tests::is_email($_POST['alternate_address'])){ if ($this->is_template){ - if (!(is_email($_POST['alternate_address'], TRUE))){ + if (!(tests::is_email($_POST['alternate_address'], TRUE))){ print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); } else { $valid= TRUE; @@ -920,11 +920,11 @@ class mailAccount extends plugin $message[]= _("The required field 'Primary address' is not set."); } if ($this->is_template){ - if (!is_email($this->mail, TRUE)){ + if (!tests::is_email($this->mail, TRUE)){ $message[]= _("Please enter a valid email address in 'Primary address' field."); } } else { - if (!is_email($this->mail)){ + if (!tests::is_email($this->mail)){ $message[]= _("Please enter a valid email address in 'Primary address' field."); } } diff --git a/gosa-core/plugins/personal/nagios/class_nagiosAccount.inc b/gosa-core/plugins/personal/nagios/class_nagiosAccount.inc index 66625e213..153f73cd3 100644 --- a/gosa-core/plugins/personal/nagios/class_nagiosAccount.inc +++ b/gosa-core/plugins/personal/nagios/class_nagiosAccount.inc @@ -201,11 +201,11 @@ class nagiosAccount extends plugin $message[]= _("The required field 'NagiosMail' is not set."); } if ($this->is_template){ - if (!is_email($this->NagiosMail, TRUE)){ + if (!tests::is_email($this->NagiosMail, TRUE)){ $message[]= _("Please enter a valid email address in 'NagiosMail' field."); } } else { - if (!is_email($this->NagiosMail)){ + if (!tests::is_email($this->NagiosMail)){ $message[]= _("Please enter a valid email address in 'NagiosMail' field."); } } diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc index 63fabf001..9b0aeccc6 100644 --- a/gosa-core/plugins/personal/posix/class_posixAccount.inc +++ b/gosa-core/plugins/personal/posix/class_posixAccount.inc @@ -973,7 +973,7 @@ class posixAccount extends plugin if ($this->homeDirectory == ""){ $message[]= _("The required field 'Home directory' is not set."); } - if (!is_path($this->homeDirectory)){ + if (!tests::is_path($this->homeDirectory)){ $message[]= _("Please enter a valid path in 'Home directory' field."); } @@ -981,14 +981,14 @@ class posixAccount extends plugin if ($this->force_ids == "1"){ /* Valid uid/gid? */ - if (!is_id($this->uidNumber)){ + if (!tests::is_id($this->uidNumber)){ $message[]= _("Value specified as 'UID' is not valid."); } else { if ($this->uidNumber < $this->config->current['MINID']){ $message[]= _("Value specified as 'UID' is too small."); } } - if (!is_id($this->gidNumber)){ + if (!tests::is_id($this->gidNumber)){ $message[]= _("Value specified as 'GID' is not valid."); } else { if ($this->gidNumber < $this->config->current['MINID']){ @@ -999,17 +999,17 @@ class posixAccount extends plugin /* Check shadow settings, well I like spaghetties... */ if ($this->activate_shadowMin){ - if (!is_id($this->shadowMin)){ + if (!tests::is_id($this->shadowMin)){ $message[]= _("Value specified as 'shadowMin' is not valid."); } } if ($this->activate_shadowMax){ - if (!is_id($this->shadowMax)){ + if (!tests::is_id($this->shadowMax)){ $message[]= _("Value specified as 'shadowMax' is not valid."); } } if ($this->activate_shadowWarning){ - if (!is_id($this->shadowWarning)){ + if (!tests::is_id($this->shadowWarning)){ $message[]= _("Value specified as 'shadowWarning' is not valid."); } if (!$this->activate_shadowMax){ @@ -1023,7 +1023,7 @@ class posixAccount extends plugin } } if ($this->activate_shadowInactive){ - if (!is_id($this->shadowInactive)){ + if (!tests::is_id($this->shadowInactive)){ $message[]= _("Value specified as 'shadowInactive' is not valid."); } if (!$this->activate_shadowMax){ @@ -1050,23 +1050,23 @@ class posixAccount extends plugin if ($this->homeDirectory == "" && in_array("homeDirectory",$this->multi_boxes)){ $message[]= _("The required field 'Home directory' is not set."); } - if (!is_path($this->homeDirectory) && in_array("homeDirectory",$this->multi_boxes)){ + if (!tests::is_path($this->homeDirectory) && in_array("homeDirectory",$this->multi_boxes)){ $message[]= _("Please enter a valid path in 'Home directory' field."); } /* Check shadow settings, well I like spaghetties... */ if ($this->activate_shadowMin && in_array("activate_shadowMin",$this->multi_boxes)){ - if (!is_id($this->shadowMin)){ + if (!tests::is_id($this->shadowMin)){ $message[]= _("Value specified as 'shadowMin' is not valid."); } } if ($this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){ - if (!is_id($this->shadowMax)){ + if (!tests::is_id($this->shadowMax)){ $message[]= _("Value specified as 'shadowMax' is not valid."); } } if ($this->activate_shadowWarning && in_array("activate_shadowWarning",$this->multi_boxes)){ - if (!is_id($this->shadowWarning)){ + if (!tests::is_id($this->shadowWarning)){ $message[]= _("Value specified as 'shadowWarning' is not valid."); } if (!$this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){ @@ -1080,7 +1080,7 @@ class posixAccount extends plugin } } if ($this->activate_shadowInactive && in_array("activate_shadowInactive",$this->multi_boxes)){ - if (!is_id($this->shadowInactive)){ + if (!tests::is_id($this->shadowInactive)){ $message[]= _("Value specified as 'shadowInactive' is not valid."); } if (!$this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){ diff --git a/gosa-core/plugins/personal/samba/class_sambaAccount.inc b/gosa-core/plugins/personal/samba/class_sambaAccount.inc index 1ca0fc5c1..fc93c9c76 100644 --- a/gosa-core/plugins/personal/samba/class_sambaAccount.inc +++ b/gosa-core/plugins/personal/samba/class_sambaAccount.inc @@ -759,7 +759,7 @@ class sambaAccount extends plugin "CtxMaxDisconnectionTime" => _("Disconnection"), "CtxMaxIdleTime" => _("IDLE")) as $key => $val){ - if (isset($this->mungedObject->ctx[$key]) && !is_id($this->mungedObject->ctx[$key]) && $val != 0){ + if (isset($this->mungedObject->ctx[$key]) && !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){ $message[]= sprintf(_("The timeout property '%s' is checked and contains invalid or no characters!"), $val); } } @@ -1250,7 +1250,7 @@ class sambaAccount extends plugin "CtxMaxIdleTime" => _("IDLE")) as $key => $val){ if (in_array($key,$this->multi_boxes) && isset($this->mungedObject->ctx[$key]) && - !is_id($this->mungedObject->ctx[$key]) && $val != 0){ + !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){ $message[]= sprintf(_("The timeout property '%s' is checked and contains invalid or no characters!"), $val); } } diff --git a/gosa-core/plugins/personal/scalix/class_scalixAccount.inc b/gosa-core/plugins/personal/scalix/class_scalixAccount.inc index 2d85f0d88..39b99f59a 100644 --- a/gosa-core/plugins/personal/scalix/class_scalixAccount.inc +++ b/gosa-core/plugins/personal/scalix/class_scalixAccount.inc @@ -437,8 +437,8 @@ class scalixAccount extends plugin $valid= FALSE; /* Valid mail address */ - if( ($this->is_template && !is_email($_POST['email_address'], TRUE)) || - (!$this->is_template && !is_email($_POST['email_address'])) ){ + if( ($this->is_template && !tests::is_email($_POST['email_address'], TRUE)) || + (!$this->is_template && !tests::is_email($_POST['email_address'])) ){ print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); }else{ $valid = TRUE; diff --git a/gosa-core/setup/class_setupStep_Feedback.inc b/gosa-core/setup/class_setupStep_Feedback.inc index 514b6e79f..3243a770d 100644 --- a/gosa-core/setup/class_setupStep_Feedback.inc +++ b/gosa-core/setup/class_setupStep_Feedback.inc @@ -175,7 +175,7 @@ class Step_Feedback extends setup_step function check_feedback() { $msgs = array(); - if(!is_email($this->eMail) || empty($this->eMail)){ + if(!tests::is_email($this->eMail) || empty($this->eMail)){ $msgs[] = _("Please specify a valid email address."); } diff --git a/gosa-core/setup/class_setupStep_Migrate.inc b/gosa-core/setup/class_setupStep_Migrate.inc index a979ba256..16dbf8a27 100644 --- a/gosa-core/setup/class_setupStep_Migrate.inc +++ b/gosa-core/setup/class_setupStep_Migrate.inc @@ -971,7 +971,7 @@ class Step_Migrate extends setup_step return false; } - if(!is_uid($uid) || empty($uid)){ + if(!tests::is_uid($uid) || empty($uid)){ msg_dialog::display(_("Input error"), _("Specify a valid user ID!"), ERROR_DIALOG); return false; } -- 2.30.2