Bernd Wurst commited on 2023-08-11 11:33:36
Zeige 3 geänderte Dateien mit 11 Einfügungen und 34 Löschungen.
... | ... |
@@ -100,9 +100,10 @@ function api_call($method, $url, $content = []) |
100 | 100 |
print('Es gibt gerade ein technisches Problem.'); |
101 | 101 |
die(); |
102 | 102 |
} |
103 |
- //if ($res->getStatusCode() >= 400) { |
|
104 |
- // |
|
105 |
- //} |
|
103 |
+ if ($res->getStatusCode() >= 400) { |
|
104 |
+ //print($res->getBody()); |
|
105 |
+ //die(); |
|
106 |
+ } |
|
106 | 107 |
return [ |
107 | 108 |
"status_code" => $res->getStatusCode(), |
108 | 109 |
"data" => json_decode( $res->getBody(), true ) |
... | ... |
@@ -110,30 +111,6 @@ function api_call($method, $url, $content = []) |
110 | 111 |
} |
111 | 112 |
|
112 | 113 |
|
113 |
-function old_api_call($method, $url, $content = []) { |
|
114 |
- global $jwt; |
|
115 |
- global $base_url; |
|
116 |
- $url = $base_url . $url; |
|
117 |
- $options = array( |
|
118 |
- 'http' => array( |
|
119 |
- 'method' => strtoupper($method), |
|
120 |
- 'content' => json_encode( $content ), |
|
121 |
- 'header'=> "Content-Type: application/json\r\n" . |
|
122 |
- "Accept: application/json\r\n" . |
|
123 |
- "Authorization: Bearer ".$jwt['token']."\r\n" |
|
124 |
- ) |
|
125 |
- ); |
|
126 |
- |
|
127 |
- $context = stream_context_create( $options ); |
|
128 |
- $result = @file_get_contents( $url, false, $context ); |
|
129 |
- if (!$result) { |
|
130 |
- print('Es gibt gerade ein technisches Problem.'); |
|
131 |
- die(); |
|
132 |
- } |
|
133 |
- $response = json_decode( $result, true ); |
|
134 |
- return $response; |
|
135 |
-} |
|
136 |
- |
|
137 | 114 |
require_once('vendor/autoload.php'); |
138 | 115 |
|
139 | 116 |
function format_number_api($number) { |
... | ... |
@@ -55,7 +55,7 @@ function erstelle_kunde($daten) { |
55 | 55 |
$ret = api_call('POST', 'customers', $json); |
56 | 56 |
if ($ret['status_code'] >= 400) { |
57 | 57 |
foreach ($ret['data']['validation_errors'] as $item) { |
58 |
- $_SESSION['warnings'][] = $item['message']; |
|
58 |
+ $_SESSION['warnings'][] = $item['key'].': '.$item['message']; |
|
59 | 59 |
} |
60 | 60 |
return null; |
61 | 61 |
} |
... | ... |
@@ -63,17 +63,17 @@ if (isset($_REQUEST['form'])) { |
63 | 63 |
$name = trim($_REQUEST['name']); |
64 | 64 |
} |
65 | 65 |
|
66 |
- if (! $number || !$name) { |
|
67 |
- $redirect = 'index.php?error&num='.urlencode($number).'&name='.urlencode($name); |
|
68 |
- break; |
|
69 |
- } |
|
70 |
- |
|
71 | 66 |
if (substr($number, 0, 1) != 0 && substr($number, 0, 3) != '+49') { |
72 | 67 |
$number = '07192'.$number; |
73 | 68 |
} |
74 | 69 |
|
75 | 70 |
$number = format_number_national($number); |
76 | 71 |
|
72 |
+ if (! $number || !$name || !format_number_api($number)) { |
|
73 |
+ $redirect = 'index.php?error&num='.urlencode($number).'&name='.urlencode($name); |
|
74 |
+ break; |
|
75 |
+ } |
|
76 |
+ |
|
77 | 77 |
$_SESSION['name'] = htmlspecialchars($name); |
78 | 78 |
$_SESSION['phone'] = htmlspecialchars($number); |
79 | 79 |
if (isset($_REQUEST['save']) && $_REQUEST['save'] == 'yes' && $_SESSION['mode'] != 'local') { |
... | ... |
@@ -291,7 +291,7 @@ if (isset($_SESSION['neue'])) { |
291 | 291 |
} |
292 | 292 |
if ($ret['status_code'] >= 400) { |
293 | 293 |
foreach ($ret['data']['validation_errors'] as $item) { |
294 |
- $_SESSION['warnings'][] = $item['message']; |
|
294 |
+ $_SESSION['warnings'][] = $item['key'].': '.$item['message']; |
|
295 | 295 |
} |
296 | 296 |
return showError(); |
297 | 297 |
} |
298 | 298 |