<?php
// check if classes are valid
$strKlasse = '';
function __autoload($strKlasse)
{ try { if(!preg_match('=^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$=m',$strKlasse))
{ throw new Exception("Class '$strKlasse' is not valid."); }
$strIncludeFile = 'classes/'.$strKlasse. '.class.php';
if (!file_exists($strIncludeFile))
{ throw new Exception("Include file <i>$strIncludeFile</i> not found.<br>"); }
require_once($strIncludeFile);
if(!class_exists($strKlasse))
{ throw new Exception("Include file <i>$strIncludeFile</i>
contains no class '$strKlasse'.<br>"); }
return true; }
catch(Exception $e)
{ die($e->getMessage()); }
}
// create short variable names
$inscode = $_POST['insertcode'];
// all variables for file insert
$marke = $_POST['selectMarke'];
$rahmen = $_POST['selectRahmen'];
$sattel = $_POST['selectSattel'];
$raeder = $_POST['selectRaeder'];
$antrieb = $_POST['selectAntrieb'];
$farbe = $_POST['selectFarbe'];
$alter = $_POST['selectAlter'];
$type = $_POST['selectType'];
$preisklasse = $_POST['selectPreisklasse'];
// all variables for SQLite insert
$modus = $_POST['modus'];
$custid = $_POST['custid'];
$custexist = $_POST['custexist'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$street = $_POST['street'];
$zipcode = $_POST['zipcode'];
$city = $_POST['city'];
$selectLand = $_POST['selectLand'];
$selectRent = $_POST['selectRent'];
$comprent = $_POST['comprent'];
$datum = $_POST['datum'];
?>
<html>
<head>
<title>MyRentABike / manage vehicles and customers / data </title>
<link href="css/filesqlite.css" rel="stylesheet" media="screen">
</head>
<body>
<?php
if($custid == "0") {
echo "<a href=\"vr_inputform.php?choice={$inscode}
&submitChoice\">back</a>"; }
else {
echo "<a href=\"vr_inputform.php?edit_id={$custid}
&choice={$inscode}&submitChoice\">back</a>"; }
?>
<h3>MyRentABike / Manage vehicles and customers</h3>
<b>Submitted data:</b><p></p>
<?php
// Processing the file data
if($inscode == 1) {
$countrec = new VRCounter();
try {
$marke = $_POST['selectMarke'];
$raeder = $_POST['selectRaeder'];
$countrec->isVehicle($marke);
$countrec->isZoll($raeder);
// error exceptions
} catch(VehicleException $e) {
die($e->getMessage());
} catch(ZollException $e) {
die($e->getMessage());
} catch (Exception $e) {
print $e;
exit();
}
$countrec->openFile();
$counter = $countrec->countRecords();
$vrinput = new VRProcessFile($counter,$marke,$rahmen,$sattel,$raeder,$antrieb,
$farbe,$alter,$type,$preisklasse,0);
if($vrinput instanceof VRProcessFile) {
$vrinput->openFile();
}
}
// Processing the SQLite data
elseif($inscode == 2) {
// asking for required data
if($firstname == "" || $lastname == "" || $street == ""
|| $zipcode == "" || $city == "") {
die("<span class=\"mess\">Please submit required data.</span>");
}
$countcrec = new VRCounter();
try {
// is zipcode format correct and bike is not rented by the same customer
$plz = $_POST['zipcode'];
$custid = $_POST['custid'];
$selectRent = $_POST['selectRent'];
$countcrec->isPlz($plz);
$countcrec->isVehicleRentAgain($selectRent,$custid);
// call error exceptions
} catch(PlzException $e) {
die($e->getMessage());
} catch(IsVRentAgException $e) {
die($e->getMessage());
} catch (Exception $e) {
print $e;
exit();
}
// get last inserted id and increment it by one
$newid = $countcrec->countSQLiteRecords();
if($custexist == 0) {
if($newid == "") {
$newid = 1;
} else { $newid = $newid+1; }
}
if($custexist == 1) {
$newid = $custid;
}
// everything okay -> submit data
$vrinput = new VRProcessSQLite($modus,$custexist,$newid,$firstname,$lastname,$street,
$zipcode,$city,$selectLand,$selectRent,$comprent,$datum);
if($vrinput instanceof VRProcessSQLite) {
echo $vrinput->startProcess();
}
}
else {
die("<span class=\"mess\">Error submitting data.</span>");
}
?>
</body>
</html>