parse($number, 'DE'); } catch (Exception $e) { return NULL; } if ($phoneNumberUtil->isValidNumber($phoneNumber)) { return $phoneNumberUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::NATIONAL); } return NULL; } $number = format_number($number); $name = trim($_REQUEST['name']); if (! $name) { $redirect = 'index.php?error&name='; break; } $_SESSION['name'] = htmlspecialchars($name); $_SESSION['phone'] = htmlspecialchars($number); if (isset($_REQUEST['save']) && $_REQUEST['save'] == 'yes') { setcookie('NAME', $name, time() + 24*3600*500, ""); setcookie('NUMBER', $number, time() + 24*3600*500, ""); } if (! $_SESSION['phone']) { $redirect = 'index.php?error&num='.urlencode($_REQUEST['phone']); break; } $redirect = 'address.php'; break; case 'address': $fields = array("fname", "lname", "address", "zip", "city"); foreach ($fields as $f) { if (isset($_REQUEST[$f])) { $_SESSION[$f] = trim(htmlspecialchars($_REQUEST[$f])); } else { if (! isset($_SESSION[$f])) { $_SESSION[$f] = ''; } } } if ($_SESSION['lname'] == '') { $redirect = 'address.php?error'; break; } if (isset($_SESSION['angeliefert'])) { if ($_SESSION['angeliefert']) { $redirect = 'gitterbox.php'; } else { $redirect = 'gitterbox_spaeter.php'; } } else { $redirect = 'anlieferung.php'; } break; case 'anlieferung': if (isset($_REQUEST['schonda'])) { $_SESSION['angeliefert'] = true; $redirect = 'gitterbox.php'; } if (isset($_REQUEST['kommtnoch'])) { $_SESSION['angeliefert'] = false; $redirect = 'gitterbox_spaeter.php'; } break; case 'gitterbox': if (isset($_REQUEST['lieferart'])) { if ($_REQUEST['lieferart'] == 'gitterbox') { $_SESSION['lieferart'] = 'gitterbox'; $_SESSION['gbcount'] = htmlspecialchars($_REQUEST['gbcount']); } if ($_REQUEST['lieferart'] == 'anhaenger') { $_SESSION['lieferart'] = 'anhaenger'; $_SESSION['kennz'] = htmlspecialchars($_REQUEST['kennz']); if ($_SESSION['angeliefert'] === false && ! $_SESSION['kennz']) { $redirect = 'gitterbox_spaeter.php?error'; break; } } } $redirect = 'gebrauchte.php'; break; case 'gebrauchte': if (isset($_REQUEST['kartonsja'])) { $_SESSION['kartons'] = true; } if (isset($_REQUEST['kartonsnein'])) { $_SESSION['kartons'] = false; } $redirect = 'auftrag.php'; break; case 'auftrag': if (isset($_REQUEST['5er'])) { $_SESSION['neue'] = '5er'; } if (isset($_REQUEST['10er'])) { $_SESSION['neue'] = '10er'; } if (isset($_REQUEST['submit']) && isset($_REQUEST['sonstiges']) && $_REQUEST['sonstiges'] != '') { $_SESSION['neue'] = 'sonstiges'; $_SESSION['sonstiges'] = htmlspecialchars($_REQUEST['sonstiges']); } $redirect = 'frischsaft.php'; break; case 'frischsaft': if (isset($_REQUEST['frischsaftnein'])) { $_SESSION['frischsaft'] = 0; } elseif (isset($_REQUEST['frischsaft'])) { $_SESSION['frischsaft'] = htmlspecialchars($_REQUEST['frischsaft']); } $redirect = 'summary.php'; break; case 'summary': if (isset($_REQUEST['anmerkungen'])) { $_SESSION['anmerkungen'] = htmlspecialchars($_REQUEST['anmerkungen']); } if (!isset($_REQUEST['agb'])) { $redirect = 'summary.php?error'; break; } $_SESSION['complete'] = true; $redirect = 'finish.php?handle='.$_SESSION['handle']; break; } } $filename = '../data/'.date('Y').'/'.$_SESSION['handle'].'.json'; if (!file_exists(dirname($filename))) { mkdir(dirname($filename), 0700, true); } $json = json_encode($_SESSION); file_put_contents($filename, $json); header('Location: '.$redirect);