3a6b9e82117083b183fa058562e12f1f0ffa748b
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php     1) <?php
step2.php     2) session_start();
step2.php     3) 
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php   4) if (!isset($_SESSION['phone']) || (!isset($_SESSION['name']) && !isset($_SESSION['firma']) && !isset($_SESSION['lname']))) {
address.php   5)     header('Location: index.php?error&num='.urlencode($_SESSION['phone']).'&name='.urlencode($_SESSION['name']));
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

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 4 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 4 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 4 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 4 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 Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php  65)     $fields = array("kundennr" => "kundennr", "firma" => "firma", "fname" => "vorname", "lname" => "nachname", "address" => "adresse", "zip" => "plz", "city" => "ort");
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  66)     foreach ($fields as $sesskey => $arrkey) {
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php  67)         if (isset($kunde[$arrkey])) {
address.php  68)             $_SESSION[$sesskey] = $kunde[$arrkey];
address.php  69)         }
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php  70)     }
address.php  71)     unset($_SESSION['name']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    72) }
step2.php    73) 
step2.php    74) if (isset($_REQUEST['error'])) {
Bernd Wurst Fehlermeldungen auf BS4 por...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

step2.php    78)     </div>';
step2.php    79) }
step2.php    80) 
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php  81) if (!$kunde) {
address.php  82)     $kunde = array('kundennr' => '', 'firma' => '', 'nachname' => '', 'vorname' => '', 'adresse' => '', 'plz' => '', 'ort' => '');
address.php  83)     $fields = array("kundennr" => "kundennr", "firma" => "firma", "fname" => "vorname", "lname" => "nachname", "address" => "adresse", "zip" => "plz", "city" => "ort");
address.php  84) 
address.php  85)     foreach ($fields as $sesskey => $arrkey) {
address.php  86)         if (isset($_SESSION[$sesskey])) {
address.php  87)             $kunde[$arrkey] = $_SESSION[$sesskey];
address.php  88)         }
address.php  89)     }
address.php  90) }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php    91) $headline = 'Adresse eingeben';
step2.php    92) if ($kunde) {
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 3 years ago

address.php  95)         <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    96)     ';
step2.php    97) } else { 
step2.php    98)     $content .= '
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

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

Bernd Wurst authored 6 years ago

step2.php   100)     ';
step2.php   101) }
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php 102) 
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php 103) $fields = array("vorname" => "Vorname",
address.php 104)     "nachname" => "Nachname",
address.php 105)     "firma" => "Firmenname",
address.php 106)     "adresse" => "Adresse",
address.php 107)     "plz" => "PLZ",
address.php 108)     "ort" => "Ort");
address.php 109) $placeholders = $fields;
address.php 110) $contents = $kunde;
address.php 111) foreach ($fields as $field => $label) {
address.php 112)     if (isset($kunde[$field]) && $kunde[$field] == 'bekannt') {
address.php 113)         $placeholders[$field] = $label.' wie beim letzten Besuch';
address.php 114)         $contents[$field] = '';
address.php 115)     } elseif (!isset($contents[$field])) {
address.php 116)         $contents[$field] = '';
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 3 years ago

address.php 117)     }
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php 118) 
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php   119) }
step2.php   120) 
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php 121) 
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php   122) $content .= '
step2.php   123)     <form class="form" action="save.php" method="post">
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php 124)     <input type="hidden" name="form" value="address">';
address.php 125) if (isset($kunde['firma']) && $kunde['firma'] != '') {
address.php 126)     $content .= '
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php   127)     <div class="form-group form-group-lg row">
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php 128)         <div class="col-sm-12"><input class="form-control" id="address" name="address" type="text" placeholder="'.$placeholders['firma'].'" autocomplete="street-address" value="'.$contents['firma'].'"></div>
address.php 129)     </div>';
address.php 130) }
address.php 131) $content .= '   <div class="form-group form-group-lg row">
address.php 132)         <div class="col-sm-6"><input class="form-control" id="fname" name="fname" type="text" placeholder="'.$placeholders['vorname'].'" autocomplete="given-name" value="'.$contents['vorname'].'"></div>
address.php 133)         <div class="col-sm-6"><input class="form-control" id="lname" name="lname" type="text" placeholder="'.$placeholders['nachname'].'" autocomplete="family-name" value="'.$contents['nachname'].'"></div>
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php   134)     </div>
step2.php   135)     <div class="form-group form-group-lg row">
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php 136)         <div class="col-sm-12"><input class="form-control" id="address" name="address" type="text" placeholder="'.$placeholders['adresse'].'" autocomplete="street-address" value="'.$contents['adresse'].'"></div>
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

step2.php   137)     </div>
step2.php   138)     <div class="form-group form-group-lg row">
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 3 years ago

address.php 139)         <div class="col-sm-4"><input class="form-control" id="zip" name="zip" type="text" placeholder="'.$placeholders['plz'].'" autocomplete="postal-code" value="'.$contents['plz'].'"></div>
address.php 140)         <div class="col-sm-8"><input class="form-control" id="city" name="city" type="text" placeholder="'.$placeholders['ort'].'" autocomplete="locality" value="'.$contents['ort'].'"></div>