43 lines
2.1 KiB
PHP
43 lines
2.1 KiB
PHP
|
<?php
|
||
|
header("Access-Control-Allow-Origin: *");
|
||
|
header("Content-Type: application/json; charset=UTF-8");
|
||
|
header("Access-Control-Allow-Methods: GET, POST");
|
||
|
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/strings.php');
|
||
|
require_once('../../utils/tools.php');
|
||
|
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');
|
||
|
|
||
|
#$authorization = $_SERVER["HTTP_AUTHORIZATION"];
|
||
|
#if(strcmp($authorization, INTERNAL_API_KEY) !== 0) {
|
||
|
# echo 'STOP TRYING TO STEAL MY DATA!';
|
||
|
# exit;
|
||
|
#}
|
||
|
|
||
|
$connection = connect();
|
||
|
|
||
|
$export = "";
|
||
|
$querystr = "SELECT * FROM li_registrations WHERE imported=0";
|
||
|
|
||
|
$result = mysqli_query($connection, $querystr);
|
||
|
if($result->num_rows !== 0) {
|
||
|
while ($row = mysqli_fetch_object($result)) {
|
||
|
$reference = "LD" . substr(strtoupper(umlaute_as_e($row->firstname)),0,1) . strtoupper(umlaute_as_e($row->lastname));
|
||
|
$price = getRegistrationPrice($row->birthday);
|
||
|
$address = $row->street . ' ' . $row->house . ';' . $row->zip . ' ' . $row->city;
|
||
|
$gender = $row->gender == 0 ? 'm' : ($row->gender == 1 ? 'w' : 'd');
|
||
|
$formattedRegistrationFrom = (new DateTime($row->registrationfrom))->format('d.m.Y');
|
||
|
$formattedBirthday = (new DateTime($row->birthday))->format('d.m.Y');
|
||
|
$export .= "{$row->lastname};{$row->firstname};{$row->iban};;{$row->bic};;{$row->bank};{$row->accountholder};{$reference};1;\t{$formattedRegistrationFrom};{$price}; ; ;\t{$row->phone};{$row->email};{$address};\t{$formattedBirthday};{$gender}\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
mysqli_free_result($result);
|
||
|
|
||
|
header('Content-Type: charset=utf-8');
|
||
|
header('Content-Disposition: attachment; filename="li-dance-export.csv";');
|
||
|
echo chr(239) . chr(187) . chr(191) . mb_convert_encoding($export, 'UTF-8', mb_list_encodings());
|
||
|
?>
|