d4c1bfec03cbdcf81ea97332961db13076e30563
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php     1) <?php
step2.php     2) session_start();
step2.php     3) 
step2.php     4) if (!isset($_SESSION['phone'])) {
step2.php     5)     header('Location: index.php?error&num='.urlencode($_REQUEST['phone']));
step2.php     6)     die();
step2.php     7) }
step2.php     8) 
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php   9) function suche_kunde($name, $number) {
Bernd Wurst Änderungen Stand 2019

Bernd Wurst authored 3 years ago

address.php  10)         global $content;
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    11)         if (! $number) {
step2.php    12)             return NULL;
step2.php    13)         }
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  14)        $data = array("name" => $name, "telefon" => $number);
address.php  15) 
address.php  16)         $curl = curl_init();
address.php  17) 
address.php  18)         curl_setopt_array($curl, array(
address.php  19)           CURLOPT_URL => "https://api.mosterei-wurst.de/api/v1/kunde/pruefen",
address.php  20)           CURLOPT_RETURNTRANSFER => true,
address.php  21)           CURLOPT_ENCODING => "",
address.php  22)           CURLOPT_MAXREDIRS => 10,
address.php  23)           CURLOPT_TIMEOUT => 30,
address.php  24)           CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
address.php  25)           CURLOPT_HTTPHEADER => array("Content-Type: application/json"),
address.php  26)           CURLOPT_CUSTOMREQUEST => "POST"));
address.php  27) 
address.php  28)         curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
address.php  29) 
address.php  30)         $response = curl_exec($curl);
address.php  31)         $err = curl_error($curl);
address.php  32)         
address.php  33)         $ret = @json_decode($response, true);
address.php  34)         if (!$ret || $ret["status"] == 'error' || !$ret["kundennr"]) {
address.php  35)             if (isset($ret["errno"]) && $ret["errno"] == "429") {
address.php  36)                 $content .= '<div class="card text-white bg-danger mb-3">
address.php  37)                 <div class="card-header">Fehler</div>
address.php  38)                 <div class="card-body">Die Suche anhand der Telefonnummer wurde verweigert, weil zu viele Zugriffe auf diese Funktion vorgenommen wurden. Bitte geben Sie Ihre Daten neu ein oder versuchen Sie es in wenigen Minuten noch einmal.</div>
address.php  39)                 </div>';
Bernd Wurst Änderungen Stand 2019

Bernd Wurst authored 3 years ago

address.php  40)             }
address.php  41)             return null;
address.php  42)         }
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  43)         
address.php  44)          return $ret;
Bernd Wurst Änderungen Stand 2019

Bernd Wurst authored 3 years ago

address.php  45) 
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  46)         /*
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    47)         $kundenliste = json_decode(file_get_contents('../kunden.json'), TRUE);
step2.php    48)         foreach ($kundenliste as $k) {
step2.php    49)                 foreach ($k['kontakt'] as $kon) {
step2.php    50)                         if ($kon['wert'] == $number) {
step2.php    51)                                 return $k;
step2.php    52)                         }
step2.php    53)                 }
step2.php    54)         }
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  55)         */
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    56) }
step2.php    57) 
Bernd Wurst Änderungen Stand 2019

Bernd Wurst authored 3 years ago

address.php  58) 
address.php  59) $content = '';
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  60) $kunde = null;
address.php  61) if (isset($_SESSION['name'])) {
address.php  62)     $kunde = suche_kunde($_SESSION['name'], $_SESSION['phone']);
address.php  63) }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    64) if ($kunde) {
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  65)     $_SESSION['kundennr'] = $kunde['kundennr'];
address.php  66)     $fields = array("fname" => "vorname", "lname" => "nachname", "address" => "adresse", "zip" => "plz", "city" => "ort");
address.php  67) 
address.php  68)     foreach ($fields as $sesskey => $arrkey) {
address.php  69)         $_SESSION[$sesskey] = $kunde[$arrkey];
address.php  70)     }
address.php  71)     unset($_SESSION['name']);
address.php  72) 
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    73) } else {
step2.php    74)     unset($_SESSION['kundennr']);
step2.php    75) }
step2.php    76) 
step2.php    77) if (isset($_REQUEST['error'])) {
Bernd Wurst Fehlermeldungen auf BS4 por...

Bernd Wurst authored 6 years ago

address.php  78)     $content .= '<div class="card text-white bg-danger mb-3">
address.php  79)     <div class="card-header">Fehler</div>
address.php  80)     <div class="card-body">Bitte geben Sie Ihren Namen an.</div>
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    81)     </div>';
step2.php    82) }
step2.php    83) 
step2.php    84) $headline = 'Adresse eingeben';
step2.php    85) if ($kunde) {
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  86)     $headline = 'Willkommen zurück!';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    87)     $content .= '
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  88)         <p>Schön, wir kennen uns ja schon! Wenn sich an Ihrer Adresse seit Ihrem letztem Besuch etwas geändert hat, ändern Sie es bitte hier. Ansonsten können Sie die Felder so lassen. Aus Datenschutzgründen werden die gespeicherten Daten hier nicht angezeigt.</p>
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    89)     ';
step2.php    90) } else { 
step2.php    91)     $content .= '
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  92)         <p>Bitte geben Sie in diesem Schritt Ihre Adresse ein.</p>
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    93)     ';
step2.php    94) }
step2.php    95) if (!$kunde) {
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  96)     $kunde = array('nachname' => '', 'vorname' => '', 'adresse' => '', 'plz' => '', 'ort' => '');
address.php  97)     $fields = array("fname" => "vorname", "lname" => "nachname", "address" => "adresse", "zip" => "plz", "city" => "ort");
address.php  98) 
address.php  99)     foreach ($fields as $sesskey => $arrkey) {
address.php 100)         if (isset($_SESSION[$sesskey])) {
address.php 101)             $kunde[$arrkey] = $_SESSION[$sesskey];
address.php 102)         }
address.php 103)     }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php   104) }
step2.php   105) 
step2.php   106) $content .= '
step2.php   107)     <form class="form" action="save.php" method="post">
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

address.php 108)     <input type="hidden" name="form" value="address">
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php   109)     <div class="form-group form-group-lg row">
step2.php   110)         <div class="col-sm-6"><input class="form-control" id="fname" name="fname" type="text" placeholder="Vorname" autocomplete="given-name" value="'.$kunde['vorname'].'"></div>
step2.php   111)         <div class="col-sm-6"><input class="form-control" id="lname" name="lname" type="text" placeholder="Nachname" autocomplete="family-name" value="'.$kunde['nachname'].'"></div>
step2.php   112)     </div>
step2.php   113)     <div class="form-group form-group-lg row">
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php 114)         <div class="col-sm-12"><input class="form-control" id="address" name="address" type="text" placeholder="Straße" autocomplete="street-address" value="'.$kunde['adresse'].'"></div>