Browse code

Cookie löschbar, Datenschutzhinweise

Bernd Wurst authored on18/03/2018 20:54:39
Showing1 changed files
... ...
@@ -40,7 +40,9 @@ if (isset($_REQUEST['form'])) {
40 40
             $number = format_number($number);
41 41
 
42 42
             $_SESSION['phone'] = htmlspecialchars($number);
43
-            setcookie('NUMBER', $number, time() + 24*3600*500, "");
43
+            if (isset($_REQUEST['save']) && $_REQUEST['save'] == 'yes') {
44
+                setcookie('NUMBER', $number, time() + 24*3600*500, "");
45
+            }
44 46
 
45 47
             if (! $_SESSION['phone']) {
46 48
                 $redirect = 'index.php?error&num='.urlencode($_REQUEST['phone']);
Browse code

Fehlermeldungen auf BS4 portiert. Abbrechen löscht den angefangenen Auftrag.

Bernd Wurst authored on18/03/2018 20:12:58
Showing1 changed files
... ...
@@ -61,6 +61,10 @@ if (isset($_REQUEST['form'])) {
61 61
                     }
62 62
                 }
63 63
             }
64
+            if ($_SESSION['lname'] == '') {
65
+                $redirect = 'address.php?error';
66
+                break;
67
+            }
64 68
             if (isset($_SESSION['angeliefert'])) {
65 69
                 if ($_SESSION['angeliefert']) {
66 70
                     $redirect = 'gitterbox.php';
Browse code

Ergänze lokale Vorwahl bei Nummern ohne Vorwahl

Bernd Wurst authored on17/03/2018 17:30:37
Showing1 changed files
... ...
@@ -13,12 +13,15 @@ if (isset($_REQUEST['form'])) {
13 13
         case 'start':
14 14
             $number = NULL;
15 15
             if (isset($_REQUEST['phone']) && trim($_REQUEST['phone']) != '') {
16
-                $number = $_REQUEST['phone'];
16
+                $number = trim($_REQUEST['phone']);
17 17
             }
18 18
             if (! $number) {
19 19
                 $redirect = 'index.php?error&num=';
20 20
                 break;
21 21
             }
22
+            if (substr($number, 0, 1) != 0 && substr($number, 0, 3) != '+49' && substr($number, 0, 4) != '0049') {
23
+                $number = '07192'.$number;
24
+            }
22 25
 
23 26
             require_once('vendor/autoload.php');
24 27
 
... ...
@@ -40,7 +43,7 @@ if (isset($_REQUEST['form'])) {
40 43
             setcookie('NUMBER', $number, time() + 24*3600*500, "");
41 44
 
42 45
             if (! $_SESSION['phone']) {
43
-                header('Location: index.php?error&num='.urlencode($_REQUEST['phone']));
46
+                $redirect = 'index.php?error&num='.urlencode($_REQUEST['phone']);
44 47
                 break;
45 48
             }   
46 49
 
Browse code

anmerkungen ermöglicht

Bernd Wurst authored on17/03/2018 17:22:24
Showing1 changed files
... ...
@@ -36,7 +36,7 @@ if (isset($_REQUEST['form'])) {
36 36
             }
37 37
             $number = format_number($number);
38 38
 
39
-            $_SESSION['phone'] = $number;
39
+            $_SESSION['phone'] = htmlspecialchars($number);
40 40
             setcookie('NUMBER', $number, time() + 24*3600*500, "");
41 41
 
42 42
             if (! $_SESSION['phone']) {
... ...
@@ -51,7 +51,7 @@ if (isset($_REQUEST['form'])) {
51 51
             $fields = array("fname", "lname", "address", "zip", "city");
52 52
             foreach ($fields as $f) {
53 53
                 if (isset($_REQUEST[$f])) {
54
-                    $_SESSION[$f] = trim($_REQUEST[$f]);
54
+                    $_SESSION[$f] = trim(htmlspecialchars($_REQUEST[$f]));
55 55
                 } else {
56 56
                     if (! isset($_SESSION[$f])) {
57 57
                         $_SESSION[$f] = '';
... ...
@@ -83,11 +83,11 @@ if (isset($_REQUEST['form'])) {
83 83
             if (isset($_REQUEST['lieferart'])) {
84 84
                 if ($_REQUEST['lieferart'] == 'gitterbox') {
85 85
                     $_SESSION['lieferart'] = 'gitterbox';
86
-                    $_SESSION['gbcount'] = $_REQUEST['gbcount'];
86
+                    $_SESSION['gbcount'] = htmlspecialchars($_REQUEST['gbcount']);
87 87
                 }
88 88
                 if ($_REQUEST['lieferart'] == 'anhaenger') {
89 89
                     $_SESSION['lieferart'] = 'anhaenger';
90
-                    $_SESSION['kennz'] = $_REQUEST['kennz'];
90
+                    $_SESSION['kennz'] = htmlspecialchars($_REQUEST['kennz']);
91 91
                     if ($_SESSION['angeliefert'] === false && ! $_SESSION['kennz']) {
92 92
                         $redirect = 'gitterbox_spaeter.php?error';
93 93
                         break;
... ...
@@ -116,7 +116,7 @@ if (isset($_REQUEST['form'])) {
116 116
             }
117 117
             if (isset($_REQUEST['submit']) && isset($_REQUEST['sonstiges']) && $_REQUEST['sonstiges'] != '') {
118 118
                 $_SESSION['neue'] = 'sonstiges';
119
-                $_SESSION['sonstiges'] = $_REQUEST['sonstiges'];
119
+                $_SESSION['sonstiges'] = htmlspecialchars($_REQUEST['sonstiges']);
120 120
             }
121 121
 
122 122
 
... ...
@@ -127,12 +127,15 @@ if (isset($_REQUEST['form'])) {
127 127
             if (isset($_REQUEST['frischsaftnein'])) {
128 128
                 $_SESSION['frischsaft'] = 0;
129 129
             } elseif (isset($_REQUEST['frischsaft'])) {
130
-                $_SESSION['frischsaft'] = (int) $_REQUEST['frischsaft'];
130
+                $_SESSION['frischsaft'] = htmlspecialchars($_REQUEST['frischsaft']);
131 131
             }
132 132
 
133 133
             $redirect = 'summary.php';
134 134
             break;
135 135
         case 'summary':
136
+            if (isset($_REQUEST['anmerkungen'])) {
137
+                $_SESSION['anmerkungen'] = htmlspecialchars($_REQUEST['anmerkungen']);
138
+            }
136 139
             if (!isset($_REQUEST['agb'])) {
137 140
                 $redirect = 'summary.php?error';
138 141
                 break;
Browse code

Spätere Anlieferung eingebaut

Bernd Wurst authored on17/03/2018 17:14:44
Showing1 changed files
... ...
@@ -10,7 +10,7 @@ if (! isset($_SESSION['handle'])) {
10 10
 $redirect = NULL;
11 11
 if (isset($_REQUEST['form'])) {
12 12
     switch ($_REQUEST['form']) {
13
-        case 'step1':
13
+        case 'start':
14 14
             $number = NULL;
15 15
             if (isset($_REQUEST['phone']) && trim($_REQUEST['phone']) != '') {
16 16
                 $number = $_REQUEST['phone'];
... ...
@@ -47,7 +47,7 @@ if (isset($_REQUEST['form'])) {
47 47
             $redirect = 'address.php';
48 48
             break;
49 49
 
50
-        case 'step2':
50
+        case 'address':
51 51
             $fields = array("fname", "lname", "address", "zip", "city");
52 52
             foreach ($fields as $f) {
53 53
                 if (isset($_REQUEST[$f])) {
... ...
@@ -58,13 +58,28 @@ if (isset($_REQUEST['form'])) {
58 58
                     }
59 59
                 }
60 60
             }
61
-            $redirect = 'gitterbox.php';
61
+            if (isset($_SESSION['angeliefert'])) {
62
+                if ($_SESSION['angeliefert']) {
63
+                    $redirect = 'gitterbox.php';
64
+                } else {
65
+                    $redirect = 'gitterbox_spaeter.php';
66
+                }
67
+            } else {
68
+                $redirect = 'anlieferung.php';
69
+            }
62 70
             break;
63 71
 
64
-        case 'step3':
65
-            if (isset($_REQUEST['keinobst'])) {
66
-                $_SESSION['lieferart'] = 'kommtnoch';
72
+        case 'anlieferung':
73
+            if (isset($_REQUEST['schonda'])) {
74
+                $_SESSION['angeliefert'] = true;
75
+                $redirect = 'gitterbox.php';
67 76
             }
77
+            if (isset($_REQUEST['kommtnoch'])) {
78
+                $_SESSION['angeliefert'] = false;
79
+                $redirect = 'gitterbox_spaeter.php';
80
+            }
81
+            break;
82
+        case 'gitterbox':
68 83
             if (isset($_REQUEST['lieferart'])) {
69 84
                 if ($_REQUEST['lieferart'] == 'gitterbox') {
70 85
                     $_SESSION['lieferart'] = 'gitterbox';
... ...
@@ -73,12 +88,16 @@ if (isset($_REQUEST['form'])) {
73 88
                 if ($_REQUEST['lieferart'] == 'anhaenger') {
74 89
                     $_SESSION['lieferart'] = 'anhaenger';
75 90
                     $_SESSION['kennz'] = $_REQUEST['kennz'];
91
+                    if ($_SESSION['angeliefert'] === false && ! $_SESSION['kennz']) {
92
+                        $redirect = 'gitterbox_spaeter.php?error';
93
+                        break;
94
+                    }
76 95
                 }
77 96
             }
78 97
             $redirect = 'gebrauchte.php';
79 98
             break;
80 99
 
81
-         case 'step4':
100
+         case 'gebrauchte':
82 101
             if (isset($_REQUEST['kartonsja'])) {
83 102
                 $_SESSION['kartons'] = true;
84 103
             } 
... ...
@@ -88,7 +107,7 @@ if (isset($_REQUEST['form'])) {
88 107
 
89 108
             $redirect = 'auftrag.php';
90 109
             break;
91
-         case 'step5':
110
+         case 'auftrag':
92 111
             if (isset($_REQUEST['5er'])) {
93 112
                 $_SESSION['neue'] = '5er';
94 113
             }
... ...
@@ -104,7 +123,7 @@ if (isset($_REQUEST['form'])) {
104 123
             $redirect = 'frischsaft.php';
105 124
             break;
106 125
 
107
-         case 'step6':
126
+         case 'frischsaft':
108 127
             if (isset($_REQUEST['frischsaftnein'])) {
109 128
                 $_SESSION['frischsaft'] = 0;
110 129
             } elseif (isset($_REQUEST['frischsaft'])) {
... ...
@@ -113,7 +132,7 @@ if (isset($_REQUEST['form'])) {
113 132
 
114 133
             $redirect = 'summary.php';
115 134
             break;
116
-        case 'step7':
135
+        case 'summary':
117 136
             if (!isset($_REQUEST['agb'])) {
118 137
                 $redirect = 'summary.php?error';
119 138
                 break;
Browse code

Dateinamen geändert

Bernd Wurst authored on17/03/2018 14:57:41
Showing1 changed files
... ...
@@ -44,7 +44,7 @@ if (isset($_REQUEST['form'])) {
44 44
                 break;
45 45
             }   
46 46
 
47
-            $redirect = 'step2.php';
47
+            $redirect = 'address.php';
48 48
             break;
49 49
 
50 50
         case 'step2':
... ...
@@ -58,7 +58,7 @@ if (isset($_REQUEST['form'])) {
58 58
                     }
59 59
                 }
60 60
             }
61
-            $redirect = 'step3.php';
61
+            $redirect = 'gitterbox.php';
62 62
             break;
63 63
 
64 64
         case 'step3':
... ...
@@ -75,7 +75,7 @@ if (isset($_REQUEST['form'])) {
75 75
                     $_SESSION['kennz'] = $_REQUEST['kennz'];
76 76
                 }
77 77
             }
78
-            $redirect = 'step4.php';
78
+            $redirect = 'gebrauchte.php';
79 79
             break;
80 80
 
81 81
          case 'step4':
... ...
@@ -86,7 +86,7 @@ if (isset($_REQUEST['form'])) {
86 86
                 $_SESSION['kartons'] = false;
87 87
             }
88 88
 
89
-            $redirect = 'step5.php';
89
+            $redirect = 'auftrag.php';
90 90
             break;
91 91
          case 'step5':
92 92
             if (isset($_REQUEST['5er'])) {
... ...
@@ -101,7 +101,7 @@ if (isset($_REQUEST['form'])) {
101 101
             }
102 102
 
103 103
 
104
-            $redirect = 'step6.php';
104
+            $redirect = 'frischsaft.php';
105 105
             break;
106 106
 
107 107
          case 'step6':
... ...
@@ -111,11 +111,11 @@ if (isset($_REQUEST['form'])) {
111 111
                 $_SESSION['frischsaft'] = (int) $_REQUEST['frischsaft'];
112 112
             }
113 113
 
114
-            $redirect = 'step7.php';
114
+            $redirect = 'summary.php';
115 115
             break;
116 116
         case 'step7':
117 117
             if (!isset($_REQUEST['agb'])) {
118
-                $redirect = 'step7.php?error';
118
+                $redirect = 'summary.php?error';
119 119
                 break;
120 120
             }
121 121
 
Browse code

Initial commit

Bernd Wurst authored on17/03/2018 11:42:01
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,138 @@
1
+<?php
2
+session_start();
3
+
4
+if (! isset($_SESSION['handle'])) {
5
+    $_SESSION['handle'] = sprintf('%09s', ( round(microtime(true)*10) % 1000000000));
6
+    $_SESSION['date'] = date('c');
7
+    $_SESSION['complete'] = false;
8
+}
9
+
10
+$redirect = NULL;
11
+if (isset($_REQUEST['form'])) {
12
+    switch ($_REQUEST['form']) {
13
+        case 'step1':
14
+            $number = NULL;
15
+            if (isset($_REQUEST['phone']) && trim($_REQUEST['phone']) != '') {
16
+                $number = $_REQUEST['phone'];
17
+            }
18
+            if (! $number) {
19
+                $redirect = 'index.php?error&num=';
20
+                break;
21
+            }
22
+
23
+            require_once('vendor/autoload.php');
24
+
25
+            function format_number($number) {
26
+                $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance();
27
+                try {
28
+                    $phoneNumber = $phoneNumberUtil->parse($number, 'DE');
29
+                } catch (Exception $e) {
30
+                    return NULL;
31
+                }
32
+                if ($phoneNumberUtil->isValidNumber($phoneNumber)) {
33
+                    return $phoneNumberUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::NATIONAL);
34
+                }
35
+                return NULL;
36
+            }
37
+            $number = format_number($number);
38
+
39
+            $_SESSION['phone'] = $number;
40
+            setcookie('NUMBER', $number, time() + 24*3600*500, "");
41
+
42
+            if (! $_SESSION['phone']) {
43
+                header('Location: index.php?error&num='.urlencode($_REQUEST['phone']));
44
+                break;
45
+            }   
46
+
47
+            $redirect = 'step2.php';
48
+            break;
49
+
50
+        case 'step2':
51
+            $fields = array("fname", "lname", "address", "zip", "city");
52
+            foreach ($fields as $f) {
53
+                if (isset($_REQUEST[$f])) {
54
+                    $_SESSION[$f] = trim($_REQUEST[$f]);
55
+                } else {
56
+                    if (! isset($_SESSION[$f])) {
57
+                        $_SESSION[$f] = '';
58
+                    }
59
+                }
60
+            }
61
+            $redirect = 'step3.php';
62
+            break;
63
+
64
+        case 'step3':
65
+            if (isset($_REQUEST['keinobst'])) {
66
+                $_SESSION['lieferart'] = 'kommtnoch';
67
+            }
68
+            if (isset($_REQUEST['lieferart'])) {
69
+                if ($_REQUEST['lieferart'] == 'gitterbox') {
70
+                    $_SESSION['lieferart'] = 'gitterbox';
71
+                    $_SESSION['gbcount'] = $_REQUEST['gbcount'];
72
+                }
73
+                if ($_REQUEST['lieferart'] == 'anhaenger') {
74
+                    $_SESSION['lieferart'] = 'anhaenger';
75
+                    $_SESSION['kennz'] = $_REQUEST['kennz'];
76
+                }
77
+            }
78
+            $redirect = 'step4.php';
79
+            break;
80
+
81
+         case 'step4':
82
+            if (isset($_REQUEST['kartonsja'])) {
83
+                $_SESSION['kartons'] = true;
84
+            } 
85
+            if (isset($_REQUEST['kartonsnein'])) {
86
+                $_SESSION['kartons'] = false;
87
+            }
88
+
89
+            $redirect = 'step5.php';
90
+            break;
91
+         case 'step5':
92
+            if (isset($_REQUEST['5er'])) {
93
+                $_SESSION['neue'] = '5er';
94
+            }
95
+            if (isset($_REQUEST['10er'])) {
96
+                $_SESSION['neue'] = '10er';
97
+            }
98
+            if (isset($_REQUEST['submit']) && isset($_REQUEST['sonstiges']) && $_REQUEST['sonstiges'] != '') {
99
+                $_SESSION['neue'] = 'sonstiges';
100
+                $_SESSION['sonstiges'] = $_REQUEST['sonstiges'];
101
+            }
102
+
103
+
104
+            $redirect = 'step6.php';
105
+            break;
106
+
107
+         case 'step6':
108
+            if (isset($_REQUEST['frischsaftnein'])) {
109
+                $_SESSION['frischsaft'] = 0;
110
+            } elseif (isset($_REQUEST['frischsaft'])) {
111
+                $_SESSION['frischsaft'] = (int) $_REQUEST['frischsaft'];
112
+            }
113
+
114
+            $redirect = 'step7.php';
115
+            break;
116
+        case 'step7':
117
+            if (!isset($_REQUEST['agb'])) {
118
+                $redirect = 'step7.php?error';
119
+                break;
120
+            }
121
+
122
+            $_SESSION['complete'] = true;
123
+            $redirect = 'finish.php?handle='.$_SESSION['handle'];
124
+            break;
125
+
126
+    }
127
+}
128
+
129
+
130
+$filename = '../data/'.date('Y').'/'.$_SESSION['handle'].'.json';
131
+if (!file_exists(dirname($filename))) {
132
+    mkdir(dirname($filename), 0700, true);
133
+}
134
+
135
+$json = json_encode($_SESSION);
136
+file_put_contents($filename, $json);
137
+
138
+header('Location: '.$redirect);