API-Aufrufe über Guzzle um Feedback bekommen zu können
Bernd Wurst

Bernd Wurst commited on 2023-08-11 10:48:24
Zeige 10 geänderte Dateien mit 785 Einfügungen und 21 Löschungen.

... ...
@@ -11,6 +11,7 @@ if (!isset($_SESSION['phone']) || (!isset($_SESSION['name']) && !isset($_SESSION
11 11
 
12 12
 $content = '';
13 13
 $_SESSION['lname'] = ucwords($_SESSION['name']);
14
+$_SESSION['fname'] = '';
14 15
 if (strpos($_SESSION['name'], ' ') !== false) {
15 16
     $parts = explode(" ", ucwords($_SESSION['name']));
16 17
     $_SESSION['lname'] = array_pop($parts);
... ...
@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 session_start();
3 3
 if (isset($_SESSION['mode']) && $_SESSION['mode'] == 'local') {
4
+    $_SESSION['angeliefert'] = true;
4 5
     header("Location: gitterbox.php");
5 6
     die();
6 7
 }
... ...
@@ -31,9 +31,11 @@ if (isset($_REQUEST['error'])) {
31 31
     </div>';
32 32
 }
33 33
 
34
-$gebrauchte = '';
34
+$prefix = '';
35 35
 if ($_SESSION['kartons']) {
36
-    $gebrauchte = 'Zuerst meine gebrauchten Kartons und falls diese nicht reichen, dann ';
36
+    $prefix = 'Zuerst meine gebrauchten Kartons und falls diese nicht reichen, dann ';
37
+} else {
38
+    $prefix = 'Alles in ';
37 39
 }
38 40
 
39 41
 $content .= '
... ...
@@ -42,9 +44,9 @@ $content .= '
42 44
     <p>Welche Karton-Größen sollen wir für Sie herstellen?</p>
43 45
 
44 46
     <div class="form-group form-group-lg row">
45
-        <div class="col-sm-4 col-xs-12"><input type="submit" class="btn btn-block btn-lg btn-light" id="btn-3er" name="3er" value="'.$gebrauchte.'3er"></div>
46
-        <div class="col-sm-4 col-xs-12"><input type="submit" class="btn btn-block btn-lg btn-light" id="btn-5er" name="5er" value="'.$gebrauchte.'5er"></div>
47
-        <div class="col-sm-4 col-xs-12"><input type="submit" class="btn btn-block btn-lg btn-light" id="btn-10er" name="10er" value="'.$gebrauchte.'10er"></div>
47
+        <div class="col-sm-4 col-xs-12"><input type="submit" class="btn btn-block btn-lg btn-light" id="btn-3er" name="3er" value="'.$prefix.'3er"></div>
48
+        <div class="col-sm-4 col-xs-12"><input type="submit" class="btn btn-block btn-lg btn-light" id="btn-5er" name="5er" value="'.$prefix.'5er"></div>
49
+        <div class="col-sm-4 col-xs-12"><input type="submit" class="btn btn-block btn-lg btn-light" id="btn-10er" name="10er" value="'.$prefix.'10er"></div>
48 50
     </div>
49 51
     <div class="form-group form-group-lg">
50 52
         <label for="sonstiges">Falls obiges nicht zutrifft, beschreiben Sie bitte hier Ihren Wunsch.</label>
... ...
@@ -1,5 +1,6 @@
1 1
 {
2 2
     "require": {
3
-        "giggsey/libphonenumber-for-php": "^8.9"
3
+        "giggsey/libphonenumber-for-php": "^8.9",
4
+        "guzzlehttp/guzzle": "^7.7"
4 5
     }
5 6
 }
... ...
@@ -1,10 +1,10 @@
1 1
 {
2 2
     "_readme": [
3 3
         "This file locks the dependencies of your project to a known state",
4
-        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
4
+        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 5
         "This file is @generated automatically"
6 6
     ],
7
-    "content-hash": "cb6eb50764f19b8df22dc63d1de6fcb0",
7
+    "content-hash": "243e0997880280ef81c610a684d958d0",
8 8
     "packages": [
9 9
         {
10 10
             "name": "giggsey/libphonenumber-for-php",
... ...
@@ -122,6 +122,602 @@
122 122
             ],
123 123
             "description": "Locale functions required by libphonenumber-for-php",
124 124
             "time": "2017-11-01T21:34:27+00:00"
125
+        },
126
+        {
127
+            "name": "guzzlehttp/guzzle",
128
+            "version": "7.7.0",
129
+            "source": {
130
+                "type": "git",
131
+                "url": "https://github.com/guzzle/guzzle.git",
132
+                "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5"
133
+            },
134
+            "dist": {
135
+                "type": "zip",
136
+                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5",
137
+                "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5",
138
+                "shasum": ""
139
+            },
140
+            "require": {
141
+                "ext-json": "*",
142
+                "guzzlehttp/promises": "^1.5.3 || ^2.0",
143
+                "guzzlehttp/psr7": "^1.9.1 || ^2.4.5",
144
+                "php": "^7.2.5 || ^8.0",
145
+                "psr/http-client": "^1.0",
146
+                "symfony/deprecation-contracts": "^2.2 || ^3.0"
147
+            },
148
+            "provide": {
149
+                "psr/http-client-implementation": "1.0"
150
+            },
151
+            "require-dev": {
152
+                "bamarni/composer-bin-plugin": "^1.8.1",
153
+                "ext-curl": "*",
154
+                "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999",
155
+                "php-http/message-factory": "^1.1",
156
+                "phpunit/phpunit": "^8.5.29 || ^9.5.23",
157
+                "psr/log": "^1.1 || ^2.0 || ^3.0"
158
+            },
159
+            "suggest": {
160
+                "ext-curl": "Required for CURL handler support",
161
+                "ext-intl": "Required for Internationalized Domain Name (IDN) support",
162
+                "psr/log": "Required for using the Log middleware"
163
+            },
164
+            "type": "library",
165
+            "extra": {
166
+                "bamarni-bin": {
167
+                    "bin-links": true,
168
+                    "forward-command": false
169
+                }
170
+            },
171
+            "autoload": {
172
+                "files": [
173
+                    "src/functions_include.php"
174
+                ],
175
+                "psr-4": {
176
+                    "GuzzleHttp\\": "src/"
177
+                }
178
+            },
179
+            "notification-url": "https://packagist.org/downloads/",
180
+            "license": [
181
+                "MIT"
182
+            ],
183
+            "authors": [
184
+                {
185
+                    "name": "Graham Campbell",
186
+                    "email": "hello@gjcampbell.co.uk",
187
+                    "homepage": "https://github.com/GrahamCampbell"
188
+                },
189
+                {
190
+                    "name": "Michael Dowling",
191
+                    "email": "mtdowling@gmail.com",
192
+                    "homepage": "https://github.com/mtdowling"
193
+                },
194
+                {
195
+                    "name": "Jeremy Lindblom",
196
+                    "email": "jeremeamia@gmail.com",
197
+                    "homepage": "https://github.com/jeremeamia"
198
+                },
199
+                {
200
+                    "name": "George Mponos",
201
+                    "email": "gmponos@gmail.com",
202
+                    "homepage": "https://github.com/gmponos"
203
+                },
204
+                {
205
+                    "name": "Tobias Nyholm",
206
+                    "email": "tobias.nyholm@gmail.com",
207
+                    "homepage": "https://github.com/Nyholm"
208
+                },
209
+                {
210
+                    "name": "Márk Sági-Kazár",
211
+                    "email": "mark.sagikazar@gmail.com",
212
+                    "homepage": "https://github.com/sagikazarmark"
213
+                },
214
+                {
215
+                    "name": "Tobias Schultze",
216
+                    "email": "webmaster@tubo-world.de",
217
+                    "homepage": "https://github.com/Tobion"
218
+                }
219
+            ],
220
+            "description": "Guzzle is a PHP HTTP client library",
221
+            "keywords": [
222
+                "client",
223
+                "curl",
224
+                "framework",
225
+                "http",
226
+                "http client",
227
+                "psr-18",
228
+                "psr-7",
229
+                "rest",
230
+                "web service"
231
+            ],
232
+            "support": {
233
+                "issues": "https://github.com/guzzle/guzzle/issues",
234
+                "source": "https://github.com/guzzle/guzzle/tree/7.7.0"
235
+            },
236
+            "funding": [
237
+                {
238
+                    "url": "https://github.com/GrahamCampbell",
239
+                    "type": "github"
240
+                },
241
+                {
242
+                    "url": "https://github.com/Nyholm",
243
+                    "type": "github"
244
+                },
245
+                {
246
+                    "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
247
+                    "type": "tidelift"
248
+                }
249
+            ],
250
+            "time": "2023-05-21T14:04:53+00:00"
251
+        },
252
+        {
253
+            "name": "guzzlehttp/promises",
254
+            "version": "2.0.1",
255
+            "source": {
256
+                "type": "git",
257
+                "url": "https://github.com/guzzle/promises.git",
258
+                "reference": "111166291a0f8130081195ac4556a5587d7f1b5d"
259
+            },
260
+            "dist": {
261
+                "type": "zip",
262
+                "url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d",
263
+                "reference": "111166291a0f8130081195ac4556a5587d7f1b5d",
264
+                "shasum": ""
265
+            },
266
+            "require": {
267
+                "php": "^7.2.5 || ^8.0"
268
+            },
269
+            "require-dev": {
270
+                "bamarni/composer-bin-plugin": "^1.8.1",
271
+                "phpunit/phpunit": "^8.5.29 || ^9.5.23"
272
+            },
273
+            "type": "library",
274
+            "extra": {
275
+                "bamarni-bin": {
276
+                    "bin-links": true,
277
+                    "forward-command": false
278
+                }
279
+            },
280
+            "autoload": {
281
+                "psr-4": {
282
+                    "GuzzleHttp\\Promise\\": "src/"
283
+                }
284
+            },
285
+            "notification-url": "https://packagist.org/downloads/",
286
+            "license": [
287
+                "MIT"
288
+            ],
289
+            "authors": [
290
+                {
291
+                    "name": "Graham Campbell",
292
+                    "email": "hello@gjcampbell.co.uk",
293
+                    "homepage": "https://github.com/GrahamCampbell"
294
+                },
295
+                {
296
+                    "name": "Michael Dowling",
297
+                    "email": "mtdowling@gmail.com",
298
+                    "homepage": "https://github.com/mtdowling"
299
+                },
300
+                {
301
+                    "name": "Tobias Nyholm",
302
+                    "email": "tobias.nyholm@gmail.com",
303
+                    "homepage": "https://github.com/Nyholm"
304
+                },
305
+                {
306
+                    "name": "Tobias Schultze",
307
+                    "email": "webmaster@tubo-world.de",
308
+                    "homepage": "https://github.com/Tobion"
309
+                }
310
+            ],
311
+            "description": "Guzzle promises library",
312
+            "keywords": [
313
+                "promise"
314
+            ],
315
+            "support": {
316
+                "issues": "https://github.com/guzzle/promises/issues",
317
+                "source": "https://github.com/guzzle/promises/tree/2.0.1"
318
+            },
319
+            "funding": [
320
+                {
321
+                    "url": "https://github.com/GrahamCampbell",
322
+                    "type": "github"
323
+                },
324
+                {
325
+                    "url": "https://github.com/Nyholm",
326
+                    "type": "github"
327
+                },
328
+                {
329
+                    "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
330
+                    "type": "tidelift"
331
+                }
332
+            ],
333
+            "time": "2023-08-03T15:11:55+00:00"
334
+        },
335
+        {
336
+            "name": "guzzlehttp/psr7",
337
+            "version": "2.6.0",
338
+            "source": {
339
+                "type": "git",
340
+                "url": "https://github.com/guzzle/psr7.git",
341
+                "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77"
342
+            },
343
+            "dist": {
344
+                "type": "zip",
345
+                "url": "https://api.github.com/repos/guzzle/psr7/zipball/8bd7c33a0734ae1c5d074360512beb716bef3f77",
346
+                "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77",
347
+                "shasum": ""
348
+            },
349
+            "require": {
350
+                "php": "^7.2.5 || ^8.0",
351
+                "psr/http-factory": "^1.0",
352
+                "psr/http-message": "^1.1 || ^2.0",
353
+                "ralouphie/getallheaders": "^3.0"
354
+            },
355
+            "provide": {
356
+                "psr/http-factory-implementation": "1.0",
357
+                "psr/http-message-implementation": "1.0"
358
+            },
359
+            "require-dev": {
360
+                "bamarni/composer-bin-plugin": "^1.8.1",
361
+                "http-interop/http-factory-tests": "^0.9",
362
+                "phpunit/phpunit": "^8.5.29 || ^9.5.23"
363
+            },
364
+            "suggest": {
365
+                "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
366
+            },
367
+            "type": "library",
368
+            "extra": {
369
+                "bamarni-bin": {
370
+                    "bin-links": true,
371
+                    "forward-command": false
372
+                }
373
+            },
374
+            "autoload": {
375
+                "psr-4": {
376
+                    "GuzzleHttp\\Psr7\\": "src/"
377
+                }
378
+            },
379
+            "notification-url": "https://packagist.org/downloads/",
380
+            "license": [
381
+                "MIT"
382
+            ],
383
+            "authors": [
384
+                {
385
+                    "name": "Graham Campbell",
386
+                    "email": "hello@gjcampbell.co.uk",
387
+                    "homepage": "https://github.com/GrahamCampbell"
388
+                },
389
+                {
390
+                    "name": "Michael Dowling",
391
+                    "email": "mtdowling@gmail.com",
392
+                    "homepage": "https://github.com/mtdowling"
393
+                },
394
+                {
395
+                    "name": "George Mponos",
396
+                    "email": "gmponos@gmail.com",
397
+                    "homepage": "https://github.com/gmponos"
398
+                },
399
+                {
400
+                    "name": "Tobias Nyholm",
401
+                    "email": "tobias.nyholm@gmail.com",
402
+                    "homepage": "https://github.com/Nyholm"
403
+                },
404
+                {
405
+                    "name": "Márk Sági-Kazár",
406
+                    "email": "mark.sagikazar@gmail.com",
407
+                    "homepage": "https://github.com/sagikazarmark"
408
+                },
409
+                {
410
+                    "name": "Tobias Schultze",
411
+                    "email": "webmaster@tubo-world.de",
412
+                    "homepage": "https://github.com/Tobion"
413
+                },
414
+                {
415
+                    "name": "Márk Sági-Kazár",
416
+                    "email": "mark.sagikazar@gmail.com",
417
+                    "homepage": "https://sagikazarmark.hu"
418
+                }
419
+            ],
420
+            "description": "PSR-7 message implementation that also provides common utility methods",
421
+            "keywords": [
422
+                "http",
423
+                "message",
424
+                "psr-7",
425
+                "request",
426
+                "response",
427
+                "stream",
428
+                "uri",
429
+                "url"
430
+            ],
431
+            "support": {
432
+                "issues": "https://github.com/guzzle/psr7/issues",
433
+                "source": "https://github.com/guzzle/psr7/tree/2.6.0"
434
+            },
435
+            "funding": [
436
+                {
437
+                    "url": "https://github.com/GrahamCampbell",
438
+                    "type": "github"
439
+                },
440
+                {
441
+                    "url": "https://github.com/Nyholm",
442
+                    "type": "github"
443
+                },
444
+                {
445
+                    "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
446
+                    "type": "tidelift"
447
+                }
448
+            ],
449
+            "time": "2023-08-03T15:06:02+00:00"
450
+        },
451
+        {
452
+            "name": "psr/http-client",
453
+            "version": "1.0.2",
454
+            "source": {
455
+                "type": "git",
456
+                "url": "https://github.com/php-fig/http-client.git",
457
+                "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31"
458
+            },
459
+            "dist": {
460
+                "type": "zip",
461
+                "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31",
462
+                "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31",
463
+                "shasum": ""
464
+            },
465
+            "require": {
466
+                "php": "^7.0 || ^8.0",
467
+                "psr/http-message": "^1.0 || ^2.0"
468
+            },
469
+            "type": "library",
470
+            "extra": {
471
+                "branch-alias": {
472
+                    "dev-master": "1.0.x-dev"
473
+                }
474
+            },
475
+            "autoload": {
476
+                "psr-4": {
477
+                    "Psr\\Http\\Client\\": "src/"
478
+                }
479
+            },
480
+            "notification-url": "https://packagist.org/downloads/",
481
+            "license": [
482
+                "MIT"
483
+            ],
484
+            "authors": [
485
+                {
486
+                    "name": "PHP-FIG",
487
+                    "homepage": "https://www.php-fig.org/"
488
+                }
489
+            ],
490
+            "description": "Common interface for HTTP clients",
491
+            "homepage": "https://github.com/php-fig/http-client",
492
+            "keywords": [
493
+                "http",
494
+                "http-client",
495
+                "psr",
496
+                "psr-18"
497
+            ],
498
+            "support": {
499
+                "source": "https://github.com/php-fig/http-client/tree/1.0.2"
500
+            },
501
+            "time": "2023-04-10T20:12:12+00:00"
502
+        },
503
+        {
504
+            "name": "psr/http-factory",
505
+            "version": "1.0.2",
506
+            "source": {
507
+                "type": "git",
508
+                "url": "https://github.com/php-fig/http-factory.git",
509
+                "reference": "e616d01114759c4c489f93b099585439f795fe35"
510
+            },
511
+            "dist": {
512
+                "type": "zip",
513
+                "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35",
514
+                "reference": "e616d01114759c4c489f93b099585439f795fe35",
515
+                "shasum": ""
516
+            },
517
+            "require": {
518
+                "php": ">=7.0.0",
519
+                "psr/http-message": "^1.0 || ^2.0"
520
+            },
521
+            "type": "library",
522
+            "extra": {
523
+                "branch-alias": {
524
+                    "dev-master": "1.0.x-dev"
525
+                }
526
+            },
527
+            "autoload": {
528
+                "psr-4": {
529
+                    "Psr\\Http\\Message\\": "src/"
530
+                }
531
+            },
532
+            "notification-url": "https://packagist.org/downloads/",
533
+            "license": [
534
+                "MIT"
535
+            ],
536
+            "authors": [
537
+                {
538
+                    "name": "PHP-FIG",
539
+                    "homepage": "https://www.php-fig.org/"
540
+                }
541
+            ],
542
+            "description": "Common interfaces for PSR-7 HTTP message factories",
543
+            "keywords": [
544
+                "factory",
545
+                "http",
546
+                "message",
547
+                "psr",
548
+                "psr-17",
549
+                "psr-7",
550
+                "request",
551
+                "response"
552
+            ],
553
+            "support": {
554
+                "source": "https://github.com/php-fig/http-factory/tree/1.0.2"
555
+            },
556
+            "time": "2023-04-10T20:10:41+00:00"
557
+        },
558
+        {
559
+            "name": "psr/http-message",
560
+            "version": "2.0",
561
+            "source": {
562
+                "type": "git",
563
+                "url": "https://github.com/php-fig/http-message.git",
564
+                "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
565
+            },
566
+            "dist": {
567
+                "type": "zip",
568
+                "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
569
+                "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
570
+                "shasum": ""
571
+            },
572
+            "require": {
573
+                "php": "^7.2 || ^8.0"
574
+            },
575
+            "type": "library",
576
+            "extra": {
577
+                "branch-alias": {
578
+                    "dev-master": "2.0.x-dev"
579
+                }
580
+            },
581
+            "autoload": {
582
+                "psr-4": {
583
+                    "Psr\\Http\\Message\\": "src/"
584
+                }
585
+            },
586
+            "notification-url": "https://packagist.org/downloads/",
587
+            "license": [
588
+                "MIT"
589
+            ],
590
+            "authors": [
591
+                {
592
+                    "name": "PHP-FIG",
593
+                    "homepage": "https://www.php-fig.org/"
594
+                }
595
+            ],
596
+            "description": "Common interface for HTTP messages",
597
+            "homepage": "https://github.com/php-fig/http-message",
598
+            "keywords": [
599
+                "http",
600
+                "http-message",
601
+                "psr",
602
+                "psr-7",
603
+                "request",
604
+                "response"
605
+            ],
606
+            "support": {
607
+                "source": "https://github.com/php-fig/http-message/tree/2.0"
608
+            },
609
+            "time": "2023-04-04T09:54:51+00:00"
610
+        },
611
+        {
612
+            "name": "ralouphie/getallheaders",
613
+            "version": "3.0.3",
614
+            "source": {
615
+                "type": "git",
616
+                "url": "https://github.com/ralouphie/getallheaders.git",
617
+                "reference": "120b605dfeb996808c31b6477290a714d356e822"
618
+            },
619
+            "dist": {
620
+                "type": "zip",
621
+                "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
622
+                "reference": "120b605dfeb996808c31b6477290a714d356e822",
623
+                "shasum": ""
624
+            },
625
+            "require": {
626
+                "php": ">=5.6"
627
+            },
628
+            "require-dev": {
629
+                "php-coveralls/php-coveralls": "^2.1",
630
+                "phpunit/phpunit": "^5 || ^6.5"
631
+            },
632
+            "type": "library",
633
+            "autoload": {
634
+                "files": [
635
+                    "src/getallheaders.php"
636
+                ]
637
+            },
638
+            "notification-url": "https://packagist.org/downloads/",
639
+            "license": [
640
+                "MIT"
641
+            ],
642
+            "authors": [
643
+                {
644
+                    "name": "Ralph Khattar",
645
+                    "email": "ralph.khattar@gmail.com"
646
+                }
647
+            ],
648
+            "description": "A polyfill for getallheaders.",
649
+            "support": {
650
+                "issues": "https://github.com/ralouphie/getallheaders/issues",
651
+                "source": "https://github.com/ralouphie/getallheaders/tree/develop"
652
+            },
653
+            "time": "2019-03-08T08:55:37+00:00"
654
+        },
655
+        {
656
+            "name": "symfony/deprecation-contracts",
657
+            "version": "v3.3.0",
658
+            "source": {
659
+                "type": "git",
660
+                "url": "https://github.com/symfony/deprecation-contracts.git",
661
+                "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf"
662
+            },
663
+            "dist": {
664
+                "type": "zip",
665
+                "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf",
666
+                "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf",
667
+                "shasum": ""
668
+            },
669
+            "require": {
670
+                "php": ">=8.1"
671
+            },
672
+            "type": "library",
673
+            "extra": {
674
+                "branch-alias": {
675
+                    "dev-main": "3.4-dev"
676
+                },
677
+                "thanks": {
678
+                    "name": "symfony/contracts",
679
+                    "url": "https://github.com/symfony/contracts"
680
+                }
681
+            },
682
+            "autoload": {
683
+                "files": [
684
+                    "function.php"
685
+                ]
686
+            },
687
+            "notification-url": "https://packagist.org/downloads/",
688
+            "license": [
689
+                "MIT"
690
+            ],
691
+            "authors": [
692
+                {
693
+                    "name": "Nicolas Grekas",
694
+                    "email": "p@tchwork.com"
695
+                },
696
+                {
697
+                    "name": "Symfony Community",
698
+                    "homepage": "https://symfony.com/contributors"
699
+                }
700
+            ],
701
+            "description": "A generic function and convention to trigger deprecation notices",
702
+            "homepage": "https://symfony.com",
703
+            "support": {
704
+                "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0"
705
+            },
706
+            "funding": [
707
+                {
708
+                    "url": "https://symfony.com/sponsor",
709
+                    "type": "custom"
710
+                },
711
+                {
712
+                    "url": "https://github.com/fabpot",
713
+                    "type": "github"
714
+                },
715
+                {
716
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
717
+                    "type": "tidelift"
718
+                }
719
+            ],
720
+            "time": "2023-05-23T14:45:45+00:00"
125 721
         }
126 722
     ],
127 723
     "packages-dev": [],
... ...
@@ -131,5 +727,6 @@
131 727
     "prefer-stable": false,
132 728
     "prefer-lowest": false,
133 729
     "platform": [],
134
-    "platform-dev": []
730
+    "platform-dev": [],
731
+    "plugin-api-version": "2.1.0"
135 732
 }
... ...
@@ -1,5 +1,11 @@
1 1
 <?php
2 2
 session_start();
3
+
4
+if(!isset($_SESSION['phone'])) {
5
+    header('Location: index.php');
6
+    die();
7
+}
8
+
3 9
             require_once('vendor/autoload.php');
4 10
 
5 11
             function format_number($number) {
... ...
@@ -1,5 +1,7 @@
1 1
 <?php
2 2
 
3
+use GuzzleHttp\Client;
4
+use GuzzleHttp\Psr7\Request;
3 5
 require_once("config.php");
4 6
 $base_url = $config['api_url'];
5 7
 
... ...
@@ -14,6 +16,34 @@ if (file_exists($TOKEN_FILE)) {
14 16
     $jwt = json_decode(file_get_contents($TOKEN_FILE), true);
15 17
 }
16 18
 
19
+if ($jwt['refresh_token'] && $jwt['exp'] < time()+5) {
20
+    // refresh token
21
+    $url = $base_url . 'token/refresh';
22
+    $data = ["refresh_token" => $jwt['refresh_token']];
23
+    $options = array(
24
+      'http' => array(
25
+        'method'  => 'POST',
26
+        'content' => json_encode( $data ),
27
+        'header'=>  "Content-Type: application/json\r\n" .
28
+                    "Accept: application/json\r\n"
29
+        )
30
+    );
31
+
32
+    $context = stream_context_create( $options );
33
+    $result = @file_get_contents( $url, false, $context );
34
+    if (!$result) {
35
+        print('Es gibt gerade ein technisches Problem.');
36
+        die();
37
+    }
38
+    $response = json_decode( $result, true);
39
+
40
+    $jwt['token'] = $response["token"];
41
+    $jwt['refresh_token'] = $response["refresh_token"];
42
+    $fields = explode('.', $jwt['token']);
43
+    $data = json_decode(base64_decode($fields[1]), true);
44
+    $jwt['exp'] = $data['exp'];
45
+}
46
+
17 47
 if (!$jwt['token'] || $jwt['exp'] < time()+5) {
18 48
     // get new token
19 49
     # init API
... ...
@@ -32,7 +62,11 @@ if (!$jwt['token'] || $jwt['exp'] < time()+5) {
32 62
     );
33 63
 
34 64
     $context = stream_context_create( $options );
35
-    $result = file_get_contents( $url, false, $context );
65
+    $result = @file_get_contents( $url, false, $context );
66
+    if (!$result) {
67
+        print('Es gibt gerade ein technisches Problem.');
68
+        die();
69
+    }
36 70
     $response = json_decode( $result, true);
37 71
 
38 72
     $jwt['token'] = $response["token"];
... ...
@@ -45,7 +79,38 @@ if (!$jwt['token'] || $jwt['exp'] < time()+5) {
45 79
 file_put_contents($TOKEN_FILE, json_encode($jwt));
46 80
 
47 81
 
48
-function api_call($method, $url, $content = []) {
82
+function api_call($method, $url, $content = []) 
83
+{
84
+    global $jwt;
85
+    global $base_url;
86
+    $url = $base_url . $url;
87
+
88
+
89
+    $headers = [
90
+        "Content-Type" => "application/json",
91
+        "Accept" => "application/json",
92
+        "Authorization" => "Bearer ".$jwt['token']
93
+        ];
94
+    $body = json_encode( $content );
95
+    $client = new Client(["http_errors" => false]);
96
+    $request = new Request(strtoupper($method), $url, $headers, $body);
97
+    $res = $client->send($request, ['timeout' => 5]);
98
+
99
+    if ($res->getStatusCode() >= 500) {
100
+        print('Es gibt gerade ein technisches Problem.');
101
+        die();
102
+    }
103
+    //if ($res->getStatusCode() >= 400) {
104
+    //
105
+    //}
106
+    return [
107
+        "status_code" => $res->getStatusCode(),
108
+        "data" => json_decode( $res->getBody(), true )
109
+        ];
110
+}
111
+
112
+
113
+function old_api_call($method, $url, $content = []) {
49 114
     global $jwt;
50 115
     global $base_url;
51 116
     $url = $base_url . $url;
... ...
@@ -60,7 +125,11 @@ function api_call($method, $url, $content = []) {
60 125
     );
61 126
 
62 127
     $context  = stream_context_create( $options );
63
-    $result = file_get_contents( $url, false, $context );
128
+    $result = @file_get_contents( $url, false, $context );
129
+    if (!$result) {
130
+        print('Es gibt gerade ein technisches Problem.');
131
+        die();
132
+    }
64 133
     $response = json_decode( $result, true );
65 134
     return $response;
66 135
 }
... ...
@@ -7,7 +7,13 @@ function suche_kunde($name, $number) {
7 7
             return NULL;
8 8
         }
9 9
         $ret = api_call('GET', 'customerContacts/search/'.format_number_api($number));
10
-
10
+        if ($ret['status_code'] >= 400) {
11
+            foreach ($ret['data']['validation_errors'] as $item) {
12
+                $_SESSION['warning'][] = $item['message'];
13
+            }
14
+            return null;
15
+        }
16
+        $ret = $ret['data'];
11 17
         if (count($ret) > 0) {
12 18
             $name = strtolower($name);
13 19
             foreach ($ret as $item) {
... ...
@@ -37,14 +43,23 @@ function suche_kunde($name, $number) {
37 43
 
38 44
 function erstelle_kunde($daten) {
39 45
     $json = [
40
-        "firstname" => $daten['fname'],
46
+        "firstname" => $daten['fname'] ?: null,
41 47
         "lastname" => $daten['lname'],
42 48
         "phone" => format_number_api($daten['phone']),
43
-        "street" => $daten['address'],
44
-        "zip" => $daten['zip'],
45
-        "city" => $daten['city'],
49
+        "street" => $daten['address'] ?: null,
50
+        "zip" => $daten['zip'] ?: null,
51
+        "city" => $daten['city'] ?: null,
46 52
         "contacts" => []];
53
+    $filename = '../data/'.date('Y').'/neukunde-'.time().'.json';
54
+    @file_put_contents($filename, json_encode($json));
47 55
     $ret = api_call('POST', 'customers', $json);
56
+    if ($ret['status_code'] >= 400) {
57
+        foreach ($ret['data']['validation_errors'] as $item) {
58
+            $_SESSION['warnings'][] = $item['message'];
59
+        }
60
+        return null;
61
+    }
62
+    $ret = $ret['data'];
48 63
     if (isset($ret['id'])) {
49 64
         return $ret['id'];
50 65
     } else {
... ...
@@ -2,6 +2,9 @@
2 2
 require_once "lib/api.php";
3 3
 require_once "lib/auftrag.php";
4 4
 session_start();
5
+$_SESSION['warnings'] = [];
6
+
7
+$_SESSION['angeliefert'] = true;
5 8
 
6 9
 $handle_length = 8;
7 10
 if (! isset($_SESSION['handle']) || !$_SESSION['handle']) {
... ...
@@ -12,6 +15,41 @@ if (! isset($_SESSION['handle']) || !$_SESSION['handle']) {
12 15
 }
13 16
 
14 17
 
18
+function showError()
19
+{
20
+    switch ($_REQUEST['form']) {
21
+        case 'start':
22
+                $redirect = 'index.php?error&num='.urlencode($number).'&name='.urlencode($name);
23
+                break;
24
+        case 'address':
25
+                $redirect = 'address.php?error';
26
+                break;
27
+        case 'anlieferung':
28
+                $redirect = 'anlieferung.php?error';
29
+                break;
30
+        case 'gitterbox':
31
+            $redirect = 'gitterbox.php?error';
32
+            break;
33
+        case 'obstart':
34
+            $redirect = 'obstart.php?error';
35
+            break;
36
+        case 'gebrauchte':
37
+            $redirect = 'gebrauchte.php?error';
38
+            break;
39
+        case 'auftrag':
40
+            $redirect = 'auftrag.php?error';
41
+            break;
42
+         case 'frischsaft':
43
+            $redirect = 'frischsaft.php?error';
44
+            break;
45
+        case 'summary':
46
+            $redirect = 'summary.php?error';
47
+            break;
48
+    }
49
+    header('Location: '.$redirect);
50
+    die();
51
+}
52
+
15 53
 $redirect = NULL;
16 54
 if (isset($_REQUEST['form'])) {
17 55
     switch ($_REQUEST['form']) {
... ...
@@ -63,6 +101,9 @@ if (isset($_REQUEST['form'])) {
63 101
             }
64 102
             if (!isset($_SESSION['kundennr']) || !$_SESSION['kundennr']) {
65 103
                 $_SESSION['kundennr'] = erstelle_kunde($_SESSION);
104
+                if (!$_SESSION['kundennr']) {
105
+                    showError();
106
+                    }
66 107
             }
67 108
 
68 109
             if ($_SESSION['mode'] == 'local') {
... ...
@@ -176,10 +217,12 @@ if (isset($_SESSION['neue'])) {
176 217
     // customer
177 218
     if (isset($_SESSION['kundennr'])) {
178 219
         $auftrag['customer'] = $_SESSION['kundennr'];
179
-        $auftrag['notification_name'] = $_SESSION['name'];
220
+        $auftrag['notificationName'] = $_SESSION['name'];
221
+        $auftrag['notificationPhone'] = $_SESSION['phone'];
180 222
     }
181 223
     // fruitType
182 224
     $ret = api_call('GET', 'fruitTypes');
225
+    $ret = $ret['data'];
183 226
     foreach ($ret as $fruit) {
184 227
         if ($_SESSION['obstart'] == $fruit['label']) {
185 228
             $auftrag['fruitType'] = $fruit['id'];
... ...
@@ -211,6 +254,7 @@ if (isset($_SESSION['neue'])) {
211 254
         } else {
212 255
             $plan = [];
213 256
             $ret = api_call('GET', 'packageTypes');
257
+            $ret = $ret['data'];
214 258
             foreach ($ret as $pt) {
215 259
                 if ($pt['label'] == $_SESSION['neue']) {
216 260
                     $plan[] = [ "packageType" => $pt['id'],
... ...
@@ -232,12 +276,28 @@ if (isset($_SESSION['neue'])) {
232 276
         $auftrag['notes'] = $_SESSION['anmerkungen'] . (isset($_SESSION["sonstiges"]) ? "\n\n" . $_SESSION["sonstiges"] : '');
233 277
     }
234 278
 
279
+    // Auftrag lokal speichern
280
+    $filename = "../data/".date('Y').'/'.time().'.json';
281
+    if (isset($_SESSION['orderid'])) {
282
+        $filename = "../data/".date('Y').'/'.$_SESSION['orderid'].'-'.time().'.json';
283
+    }
284
+    @file_put_contents($filename, json_encode($auftrag));
235 285
      if (isset($_SESSION['orderid']) && $_SESSION['orderid']) {
236 286
         // update
237 287
         $ret = api_call('PUT', 'orders/'.$_SESSION['orderid'], $auftrag);
238 288
     } else {
239 289
         // neu
240 290
         $ret = api_call('POST', 'orders', $auftrag);
291
+    }
292
+    if ($ret['status_code'] >= 400) {
293
+        foreach ($ret['data']['validation_errors'] as $item) {
294
+            $_SESSION['warnings'][] = $item['message'];
295
+        }
296
+        return showError();
297
+    }
298
+    $ret = $ret['data'];
299
+    $_SESSION['orderid'] = $ret['id'];
300
+
241 301
     if (!isset($ret['id'])) {
242 302
         echo "Es gabe einen Fehler beim Abspeichern des Auftrags. Wir bitten dies zu entschuldigen und einen Papierauftrag auszufüllen.";
243 303
         file_put_contents("../error.log", 
... ...
@@ -245,9 +305,12 @@ if (isset($_SESSION['neue'])) {
245 305
             print_r($ret, true).'\n', FILE_APPEND | LOCK_EX);
246 306
         die();
247 307
     }
248
-        $_SESSION['orderid'] = $ret['id'];
249
-    }
250 308
 
309
+    // Auftrag lokal speichern
310
+    if (isset($_SESSION['orderid'])) {
311
+        $filename = "../data/".date('Y').'/'.$_SESSION['orderid'].'-'.time().'.json';
312
+    }
313
+    @file_put_contents($filename, json_encode($auftrag));
251 314
     /*
252 315
     if ($ret['status'] == 'error') {
253 316
         echo 'Es gibt ein Problem beim Speichern des Auftrags. Bitte verwenden Sie diesmal einen Papier-Auftrag.';
... ...
@@ -53,6 +53,15 @@ if ($previous > 0) {
53 53
         <div id="banner-clear"></div>
54 54
      </div>
55 55
   <div class="container text-center">
56
+    <?php
57
+    if (isset($_SESSION['warnings'])) {
58
+        foreach($_SESSION['warnings'] as $warning) {
59
+            echo '<div class="card text-white bg-danger mb-3">
60
+    <div class="card-header">Fehler</div>';
61
+            echo '<div class="card-body">'.$warning.'</div>';
62
+            echo ' </div>'; 
63
+        }
64
+    }?>
56 65
 <?= $content ?>
57 66
     <?php if (basename($_SERVER['PHP_SELF']) != 'finish.php') { ?>
58 67
     <nav aria-label="Zu anderen Schritten springen">
... ...
@@ -84,7 +93,7 @@ if ($previous > 0) {
84 93
     </div>
85 94
     <div class="card" id="footer">
86 95
         <div class="card-header">Hilfe?</div>
87
-        <div class="card-body"><p class="card-text">Für Unterstützung bei der Nutzung dieses Formulars können Sie gerne unsere Telefonnummer <a href="tel:+497192936434">07192-936434</a> anrufen.</p></div>
96
+        <div class="card-body"><p class="card-text">Für Unterstützung bei der Nutzung dieses Formulars können Sie uns unter der Telefonnummer <a href="tel:+497192936434">07192-936434</a> erreichen.</p></div>
88 97
 <?php if ($_SESSION['mode'] != 'local') { ?>
89 98
     <div class="card-footer"><a target="_blank" href="https://mosterei-wurst.de/impressum/">Impressum</a> · <a target="_blank" href="https://mosterei-wurst.de/">Website besuchen</a></div>
90 99
 <?php } /* if ($_SESSION['mode'] != 'local') */ ?>
91 100