03ef9c50c00dc3bc50501cf0785726bd467c08f4
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

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']) {
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

13)         case 'start':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

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) 
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

39)             $_SESSION['phone'] = htmlspecialchars($number);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

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) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

47)             $redirect = 'address.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

48)             break;
49) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

50)         case 'address':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

51)             $fields = array("fname", "lname", "address", "zip", "city");
52)             foreach ($fields as $f) {
53)                 if (isset($_REQUEST[$f])) {
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

54)                     $_SESSION[$f] = trim(htmlspecialchars($_REQUEST[$f]));
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

55)                 } else {
56)                     if (! isset($_SESSION[$f])) {
57)                         $_SESSION[$f] = '';
58)                     }
59)                 }
60)             }
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

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)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

70)             break;
71) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

72)         case 'anlieferung':
73)             if (isset($_REQUEST['schonda'])) {
74)                 $_SESSION['angeliefert'] = true;
75)                 $redirect = 'gitterbox.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

76)             }
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

77)             if (isset($_REQUEST['kommtnoch'])) {
78)                 $_SESSION['angeliefert'] = false;
79)                 $redirect = 'gitterbox_spaeter.php';
80)             }
81)             break;
82)         case 'gitterbox':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

83)             if (isset($_REQUEST['lieferart'])) {
84)                 if ($_REQUEST['lieferart'] == 'gitterbox') {
85)                     $_SESSION['lieferart'] = 'gitterbox';
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

86)                     $_SESSION['gbcount'] = htmlspecialchars($_REQUEST['gbcount']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

87)                 }
88)                 if ($_REQUEST['lieferart'] == 'anhaenger') {
89)                     $_SESSION['lieferart'] = 'anhaenger';
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

90)                     $_SESSION['kennz'] = htmlspecialchars($_REQUEST['kennz']);
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

91)                     if ($_SESSION['angeliefert'] === false && ! $_SESSION['kennz']) {
92)                         $redirect = 'gitterbox_spaeter.php?error';
93)                         break;
94)                     }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

95)                 }
96)             }
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

97)             $redirect = 'gebrauchte.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

98)             break;
99) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

100)          case 'gebrauchte':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

101)             if (isset($_REQUEST['kartonsja'])) {
102)                 $_SESSION['kartons'] = true;
103)             } 
104)             if (isset($_REQUEST['kartonsnein'])) {
105)                 $_SESSION['kartons'] = false;
106)             }
107) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

108)             $redirect = 'auftrag.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

109)             break;
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

110)          case 'auftrag':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

111)             if (isset($_REQUEST['5er'])) {
112)                 $_SESSION['neue'] = '5er';
113)             }
114)             if (isset($_REQUEST['10er'])) {
115)                 $_SESSION['neue'] = '10er';
116)             }
117)             if (isset($_REQUEST['submit']) && isset($_REQUEST['sonstiges']) && $_REQUEST['sonstiges'] != '') {
118)                 $_SESSION['neue'] = 'sonstiges';
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

119)                 $_SESSION['sonstiges'] = htmlspecialchars($_REQUEST['sonstiges']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

120)             }
121) 
122) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

123)             $redirect = 'frischsaft.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

124)             break;
125) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

126)          case 'frischsaft':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

127)             if (isset($_REQUEST['frischsaftnein'])) {
128)                 $_SESSION['frischsaft'] = 0;
129)             } elseif (isset($_REQUEST['frischsaft'])) {
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

130)                 $_SESSION['frischsaft'] = htmlspecialchars($_REQUEST['frischsaft']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

131)             }
132) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

133)             $redirect = 'summary.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

134)             break;
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

135)         case 'summary':
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

136)             if (isset($_REQUEST['anmerkungen'])) {
137)                 $_SESSION['anmerkungen'] = htmlspecialchars($_REQUEST['anmerkungen']);
138)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

139)             if (!isset($_REQUEST['agb'])) {
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

140)                 $redirect = 'summary.php?error';