PacketFence - BTS - PacketFence
View Issue Details
0001813PacketFencecaptive portalpublic2014-06-25 05:142014-07-07 12:36
sisu 
 
normalminorhave not tried
newopen 
LinuxUbuntu12.04
4.2.2 
 
0001813: Phone number check with regex
On Packetfence 4.1

In the File /pf/lib/pf/web/util.pm i changee the text form :


sub validate_phone_number {
    my ($phone_number) = @_;

    # north american regular expression
    if ($phone_number =~ /
        ^(?:\+?(1)[-.\s]?)? # optional 1 in front with -, ., space or nothing seperator
        \(?([2-9]\d{2})\)? # captures first 3 digits allows optional parenthesis
        [-.\s]? # separator -, ., space or nothing
        (\d{3}) # captures 3 digits
        [-.\s]? # separator -, ., space or nothing
        (\d{4})$ # captures last 4 digits
        /x) {
        return "$1$2$3$4" if defined($1);
        return "$2$3$4";
    }
    # rest of world regular expression
    if ($phone_number =~ /
        ^\+?\s? # optional + on front with optional space
        ((?:[0-9]\s?){6,14} # between 6 and 14 groups of digits seperated by spaces or not
        [0-9])$ # end with a digit
        /x) {
        # trim spaces
        my $return = $1;
        $return =~ s/\s+//g;
        return $return;
    }
    return;
}


to


sub validate_phone_number {
    my ($phone_number) = @_;

    $phone_number =~ s/\s+//g; # Leerzeichen rausnehmen
    $phone_number =~ s/\s-//g; # Minuszeichen rausnehmen
    $phone_number =~ s/^\+/00/; # + mit 00 ersetzen
    $phone_number =~ s/^0041/0/; # 0041 mit 0 ersetzen


    # Schweiz: ^07[5-9]\d{7}$

    #Frankreich ^00336(0(7|8)|3[0-2]|54|[6-8]\d{1})\d{6}$

    #Oesterreich ^00436(50|6(0|3|4)|7(6|8)|8(0|1|8)|99)\d{7}$

    #Deutschland ^00491(5(1|2|5|7|9)|6(0|2|3)|7)\d{8,9}$

    #Italien ^00393([2-4]\d{1}|6[0-8]|8\d{1}|9[0-3])\d{7}$

    #England ^00447(4|5|[7-9]|7624)\d{6,8}$


    if ($phone_number =~ /^07[5-9]\d{7}$|^00336(0(7|8)|3[0-2]|54|[6-8]\d{1})\d{6}$|^00491(5(1|2|5|7|9)|6(0|2|3)|7)\d{8,9}$|^00393([2-4]\d{1}|6[0-8]|8\d{1}|9[0-3])\d{7}$|^00447(4|5|[7-9]|7624)\d{6,8}$/) {
        return $phone_number;
    }
    return;
}


if I sign up with the number +49... the system sending sms to 0049....

On Packetfence 4.2 who i do the same if not send to 0049.... it sends to 49...


Thanks for help

Best Regards

Sisu
No tags attached.
Issue History
2014-06-25 05:14sisuNew Issue

There are no notes attached to this issue.