Prüfe Telefonnummer
Bernd Wurst

Bernd Wurst commited on 2018-01-24 10:34:58
Zeige 2 geänderte Dateien mit 33 Einfügungen und 1 Löschungen.

... ...
@@ -71,6 +71,19 @@ function get_contacts() {
71 71
     return $ret;
72 72
 }
73 73
 
74
+
75
+function possible_domainholders() {
76
+    $allcontacts = get_contacts();
77
+    $ret = array();
78
+    foreach ($allcontacts as $id => $c) {
79
+        if ($c['name'] && $c['address'] && $c['zip'] && $c['city'] && $c['country'] && $c['phone'] && $c['email']) {
80
+            $ret[$id] = $c;
81
+        }
82
+    }
83
+    return $ret;
84
+}
85
+
86
+
74 87
 function have_mailaddress($email) 
75 88
 {
76 89
     $cid = (int) $_SESSION['customerinfo']['customerno'];
... ...
@@ -16,6 +16,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 require_once('contacts.php');
18 18
 require_once('inc/debug.php');
19
+require_once('vendor/autoload.php');
19 20
 
20 21
 require_once('session/start.php');
21 22
 
... ...
@@ -51,7 +52,25 @@ $c['address'] = maybe_null($_REQUEST['adresse']);
51 52
 $c['country'] = maybe_null(strtoupper($_REQUEST['land']));
52 53
 $c['zip'] = maybe_null($_REQUEST['plz']);
53 54
 $c['city'] = maybe_null($_REQUEST['ort']);
54
-$c['phone'] = maybe_null($_REQUEST['telefon']);
55
+
56
+    
57
+if ($_REQUEST['telefon']) {
58
+    $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance();
59
+    try {
60
+        $phoneNumber = $phoneNumberUtil->parse($_REQUEST['telefon'], $_REQUEST['land'], null, true);
61
+    } catch (Exception $e) {
62
+        system_failure('Die eingegebene Telefonnummer scheint nicht gültig zu sein!');
63
+    }
64
+    if ($phoneNumberUtil->isValidNumber($phoneNumber)) {
65
+        $c['phone'] = $phoneNumberUtil->format($phoneNumber, 1);
66
+    } else {
67
+        system_failure('Die eingegebene Telefonnummer scheint nicht gültig zu sein!');
68
+        $c['phone'] = NULL;
69
+    }
70
+} else {
71
+    $c['phone'] = NULL;
72
+}
73
+//$c['phone'] = maybe_null($_REQUEST['telefon']);
55 74
 $c['mobile'] = maybe_null($_REQUEST['mobile']);
56 75
 $c['fax'] = maybe_null($_REQUEST['telefax']);
57 76
 
58 77