git.schokokeks.org
Repositories
Help
Report an Issue
bibweb.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
03ef9c5
Branches
Tags
master
bibweb.git
save.php
anmerkungen ermöglicht
Bernd Wurst
commited
03ef9c5
at 2018-03-17 17:22:24
save.php
Blame
History
Raw
<?php session_start(); if (! isset($_SESSION['handle'])) { $_SESSION['handle'] = sprintf('%09s', ( round(microtime(true)*10) % 1000000000)); $_SESSION['date'] = date('c'); $_SESSION['complete'] = false; } $redirect = NULL; if (isset($_REQUEST['form'])) { switch ($_REQUEST['form']) { case 'start': $number = NULL; if (isset($_REQUEST['phone']) && trim($_REQUEST['phone']) != '') { $number = $_REQUEST['phone']; } if (! $number) { $redirect = 'index.php?error&num='; break; } require_once('vendor/autoload.php'); function format_number($number) { $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneNumberUtil->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); $_SESSION['phone'] = htmlspecialchars($number); setcookie('NUMBER', $number, time() + 24*3600*500, ""); if (! $_SESSION['phone']) { header('Location: 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 (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);