2024-04-29 16:09:02 +02:00
|
|
|
<?php
|
|
|
|
header("Access-Control-Allow-Origin: *");
|
|
|
|
header("Content-Type: application/json; charset=UTF-8");
|
2024-05-20 18:13:17 +02:00
|
|
|
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
2024-04-29 16:09:02 +02:00
|
|
|
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
|
|
|
|
|
|
|
require_once('../../utils/config.php');
|
|
|
|
require_once('../../utils/db.php');
|
|
|
|
require_once('../../utils/tools.php');
|
2024-05-20 18:13:17 +02:00
|
|
|
require_once('../../libs/fpdf/fpdf.php'); // DON'T TRY TO MOVE THIS INSIDE REGISTRATION.PHP, THIS FUCKS UP CORS
|
|
|
|
require_once('../../libs/registration/registration.php');
|
2024-05-04 02:41:04 +02:00
|
|
|
|
2024-04-29 16:09:02 +02:00
|
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
2024-05-20 18:13:17 +02:00
|
|
|
if ('OPTIONS' === $method) {
|
|
|
|
header("HTTP/1.1 204 NO CONTENT");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2024-04-29 16:09:02 +02:00
|
|
|
if ('POST' === $method) {
|
|
|
|
parse_str(file_get_contents('php://input'), $_POST);
|
2024-05-20 18:13:17 +02:00
|
|
|
}
|
2024-04-29 16:09:02 +02:00
|
|
|
|
2024-05-20 18:13:17 +02:00
|
|
|
$authorization = $_SERVER["HTTP_AUTHORIZATION"];
|
|
|
|
if(strcmp($authorization, PUBLIC_API_KEY) !== 0) {
|
|
|
|
echo 'STOP TRYING TO STEAL MY DATA!';
|
|
|
|
exit;
|
|
|
|
}
|
2024-04-29 16:09:02 +02:00
|
|
|
|
2024-05-20 18:13:17 +02:00
|
|
|
try {
|
|
|
|
|
|
|
|
$connection = connect();
|
2024-04-29 16:09:02 +02:00
|
|
|
|
2024-05-20 18:13:17 +02:00
|
|
|
$rid = intval($_POST["rid"]);
|
|
|
|
$firstname = escape($connection, $_POST["firstname"]);
|
|
|
|
$lastname = escape($connection, $_POST["lastname"]);
|
|
|
|
$birthday = escape($connection, $_POST["birthday"]);
|
|
|
|
$gender = intval($_POST["gender"]);
|
|
|
|
$street = escape($connection, $_POST["street"]);
|
|
|
|
$house = intval($_POST["house"]);
|
|
|
|
$zip = escape($connection, $_POST["zip"]);
|
|
|
|
$city = escape($connection, $_POST["city"]);
|
|
|
|
$phone = escape($connection, $_POST["phone"]);
|
|
|
|
$email = escape($connection, $_POST["email"]);
|
2024-04-29 16:09:02 +02:00
|
|
|
|
2024-05-20 18:13:17 +02:00
|
|
|
$accountholder = escape($connection, $_POST["accountHolder"]);
|
|
|
|
$iban = escape($connection, $_POST["iban"]);
|
|
|
|
$bic = escape($connection, $_POST["bic"]);
|
|
|
|
$bank = escape($connection, $_POST["bank"]);
|
2024-09-02 01:37:42 +02:00
|
|
|
|
|
|
|
$contracttype = intval($_POST["contractType"]);
|
2024-04-29 16:09:02 +02:00
|
|
|
|
2024-05-20 18:13:17 +02:00
|
|
|
$applicationconsent = $_POST["applicationConsent"] === "true";
|
|
|
|
$datachangeconsent = $_POST["dataChangeConsent"] === "true";
|
|
|
|
$privacypolicyconsent = $_POST["privacyPolicyConsent"] === "true";
|
|
|
|
$directdebitconsent = $_POST["directDebitConsent"] === "true";
|
|
|
|
$returndebitconsent = $_POST["returnDebitConsent"] === "true";
|
|
|
|
$datastorageconsent = $_POST["dataStorageConsent"] === "true";
|
|
|
|
$multimediaconsent = $_POST["multimediaConsent"] === "true";
|
|
|
|
|
|
|
|
$registrationfrom = getRegistrationDate()->format('Y-m-d');
|
|
|
|
|
|
|
|
$querystr = "SELECT * FROM li_registrations
|
|
|
|
WHERE li_registrations.rid = ${rid}";
|
|
|
|
|
|
|
|
$result = mysqli_query($connection, $querystr);
|
|
|
|
if($result->num_rows !== 0) {
|
|
|
|
$querystr = "UPDATE li_registrations SET firstname='${firstname}', lastname='${lastname}', birthday='${birthday}',
|
|
|
|
gender=${gender}, street='${street}', house=${house},
|
|
|
|
zip='${zip}', city='${city}', phone='${phone}', email='${email}',
|
2024-09-02 01:37:42 +02:00
|
|
|
accountholder='${accountHolder}', iban='${iban}', bic='${bic}', bank='${bank}', contracttype=${contracttype},
|
2024-05-20 18:13:17 +02:00
|
|
|
applicationconsent=${applicationconsent}, datachangeconsent=${datachangeconsent}, privacypolicyconsent=${privacypolicyconsent},
|
|
|
|
directdebitconsent=${directdebitconsent}, returndebitconsent=${returndebitconsent}, datastorageconsent=${datastorageconsent},
|
|
|
|
multimediaconsent=${multimediaconsent},
|
|
|
|
WHERE rid=${rid}";
|
|
|
|
} else {
|
|
|
|
$querystr = "INSERT INTO li_registrations (firstname, lastname, birthday, gender, street, house, zip, city, phone, email,
|
2024-09-02 01:37:42 +02:00
|
|
|
accountholder, iban, bic, bank, contracttype,
|
2024-05-20 18:13:17 +02:00
|
|
|
applicationconsent, datachangeconsent, privacypolicyconsent, directdebitconsent,
|
|
|
|
returndebitconsent, datastorageconsent, multimediaconsent, registrationfrom)
|
|
|
|
|
|
|
|
VALUES('{$firstname}', '{$lastname}', '{$birthday}', {$gender}, '{$street}', {$house}, '{$zip}', '{$city}', '{$phone}', '{$email}',
|
2024-09-02 01:37:42 +02:00
|
|
|
'{$accountholder}', '{$iban}', '{$bic}', '{$bank}', ${contracttype},
|
2024-05-20 18:13:17 +02:00
|
|
|
{$applicationconsent}, {$datachangeconsent}, {$privacypolicyconsent}, {$directdebitconsent},
|
|
|
|
{$returndebitconsent}, {$datastorageconsent}, {$multimediaconsent}, '{$registrationfrom}')";
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = mysqli_query($connection, $querystr);
|
|
|
|
|
|
|
|
$currentDate = new DateTime();
|
|
|
|
$formattedRegistrationFrom = new DateTime($registrationfrom);
|
|
|
|
$formattedBirthday = new DateTime($birthday);
|
2024-05-14 00:05:57 +02:00
|
|
|
|
2024-05-20 18:13:17 +02:00
|
|
|
$data = (object) [
|
|
|
|
'firstname' => $firstname,
|
|
|
|
'lastname' => $lastname,
|
|
|
|
'birthdate' => $formattedBirthday->format('d.m.Y'),
|
|
|
|
'gender' => gender($gender),
|
|
|
|
'street' => $street,
|
|
|
|
'house' => $house,
|
|
|
|
'zip' => $zip,
|
|
|
|
'city' => $city,
|
|
|
|
'phone' => $phone,
|
|
|
|
'email' => $email,
|
|
|
|
'accountholder' => $accountholder,
|
|
|
|
'iban' => $iban,
|
|
|
|
'bic' => $bic,
|
|
|
|
'bank' => $bank,
|
2024-09-02 01:37:42 +02:00
|
|
|
'contracttype' => $contracttype,
|
2024-05-20 18:13:17 +02:00
|
|
|
'registrationFrom' => $formattedRegistrationFrom->format('d.m.Y'),
|
2024-09-02 01:37:42 +02:00
|
|
|
'rate' => getRegistrationPrice($birthday, $contracttype) . ',00' . chr(128),
|
2024-05-20 18:13:17 +02:00
|
|
|
'pdfname' => "{$currentDate->format('Y-m-d')}-lidance-registrierung.pdf",
|
|
|
|
'pdfcontent' => ''
|
|
|
|
];
|
2024-05-14 00:05:57 +02:00
|
|
|
|
2024-05-20 18:13:17 +02:00
|
|
|
|
|
|
|
$data->pdfcontent = getRegistrationPdf($data);
|
|
|
|
|
|
|
|
sendRegistrationMail($data);
|
|
|
|
sendConfirmationMail($data);
|
|
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$result = $e;
|
|
|
|
}
|
|
|
|
|
2024-04-29 16:09:02 +02:00
|
|
|
echo json_encode('{ "result": "' . $result . '" }');
|
|
|
|
?>
|