Initial commit
This commit is contained in:
commit
5ced3cb83a
|
@ -0,0 +1,5 @@
|
|||
vendor/
|
||||
composer.lock
|
||||
.idea
|
||||
.vscode
|
||||
config.php
|
|
@ -0,0 +1,39 @@
|
|||
build_docker:
|
||||
image: gitlab.jonasled.de/jonasled/buildx-docker:latest
|
||||
stage: build
|
||||
services:
|
||||
- docker:dind
|
||||
tags:
|
||||
- docker
|
||||
before_script:
|
||||
- docker context create build
|
||||
- docker buildx create build --use
|
||||
- docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
- |
|
||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||
tag=""
|
||||
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
||||
else
|
||||
tag=":$CI_COMMIT_REF_SLUG"
|
||||
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
||||
fi
|
||||
- docker buildx build --platform linux/amd64,linux/arm,linux/arm64 --push --tag "$CI_REGISTRY_IMAGE${tag}" .
|
||||
# Run this job in a branch where a Dockerfile exists
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
exists:
|
||||
- Dockerfile
|
||||
|
||||
|
||||
build_linux:
|
||||
stage: build
|
||||
tags:
|
||||
- docker
|
||||
image: registry.itbyhf.xyz/images/alpine-php8-http:latest
|
||||
script:
|
||||
- "composer install"
|
||||
artifacts:
|
||||
paths:
|
||||
- "./"
|
|
@ -0,0 +1,10 @@
|
|||
FROM gitlab.jonasled.de/jonasled/nginx-php-minimal:7-3.10
|
||||
RUN apk update
|
||||
RUN apk add php7-pdo php7-pdo_mysql php7-gd
|
||||
|
||||
WORKDIR /var/ww/html
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/
|
||||
|
||||
RUN ln -s /usr/bin/php73 /usr/bin/php
|
||||
|
||||
RUN composer install
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"require": {
|
||||
"mpdf/mpdf": "v7.1.7",
|
||||
"chillerlan/php-qrcode": "^3.4",
|
||||
"ext-pdo": "*",
|
||||
"ext-mbstring": "*"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
version: "3.3"
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
ports:
|
||||
- 6432:80
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
|
||||
//Database & secrets
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use Mpdf\Mpdf;
|
||||
use Mpdf\MpdfException;
|
||||
|
||||
include "config.php";
|
||||
|
||||
if(empty($_GET["code"])){
|
||||
die('Fehler! Bitte überprüfen Sie den Link!');
|
||||
}
|
||||
|
||||
//PHP Composer dependency management
|
||||
require("vendor/autoload.php");
|
||||
|
||||
//access var from config.php
|
||||
global $CONFIG;
|
||||
|
||||
|
||||
//Establish Database Connection using PHP Data Objects
|
||||
try {
|
||||
$pdo = new PDO('mysql:host=' . $CONFIG["database"]["server"] . ';dbname=' . $CONFIG["database"]["dbname"], $CONFIG["database"]["user"], $CONFIG["database"]["password"]);
|
||||
} catch (PDOException $ex) {
|
||||
echo 'Exception abgefangen: ', $ex->getMessage(), "\n<br/>";
|
||||
}
|
||||
|
||||
|
||||
//Primary SQL Statement
|
||||
$statement = $pdo->prepare("SELECT zf_bap_orders.*,zbs.name as zbs_name
|
||||
FROM zf_bap_orders
|
||||
JOIN zf_bap_schemes zbs on zf_bap_orders.scheme_id = zbs.scheme_id
|
||||
WHERE code = :code AND status_id = :status_id");
|
||||
|
||||
//Bind parameters
|
||||
$statement->bindParam("code", $_GET["code"]); // "Auth" 2
|
||||
$expected_status = 2; // 2 equals "is paid"
|
||||
$statement->bindParam(":status_id", $expected_status); //Only show, if ticket is paid
|
||||
|
||||
//Execute Statement and fetch Data
|
||||
$statement->execute();
|
||||
$row2 = $statement->fetch();
|
||||
|
||||
if(!($row2["order_id"]>0)){
|
||||
die('Fehler! Ticket ist ungültig.');
|
||||
}
|
||||
|
||||
//PDF Library
|
||||
$mpdf = new Mpdf();
|
||||
$mpdf->allow_charset_conversion = true;
|
||||
|
||||
//Get Payment methode using ternary operator
|
||||
$zahlung = $row2["paypal_token"] != "" ? "Paypal" : "Barzahlung";
|
||||
|
||||
//Looks like shit, but works :D (PHP Serialized Class -> JSON -> PHP stdClass -> PHP Object)
|
||||
$seats = json_decode(json_encode(unserialize($row2["places"], ['allowed_classes' => false])), true);
|
||||
|
||||
|
||||
//Convert object to HTML List
|
||||
$seat_html = "";
|
||||
|
||||
foreach ($seats as $seat) {
|
||||
$seat_html .= $seat["place_name"] . " (" . $seat["place_price"] . "€), "; // results in e.g. 'Reihe 1, Platz 2 (5€)'
|
||||
}
|
||||
|
||||
// QR Code with Ticket Information
|
||||
//Build HTML Site, which will be converted into a PDF
|
||||
$data = '<!doctype html>
|
||||
<html lang="de-AT">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Zauberflöte - Ticketbuchung</title>
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
|
||||
<style>
|
||||
body{
|
||||
margin: 50px;
|
||||
}
|
||||
.td_desc{
|
||||
padding-right: 10px;
|
||||
width: 30vw;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="container">
|
||||
<h1>Ihre Zauberflöte - Tickets</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="td_desc">Ticket-Nummer: </td>
|
||||
<td>' . $row2["order_id"] . "_" . $row2["code"] . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Name</td>
|
||||
<td>' . sonderzeichen($row2["first_name"]) . " " . sonderzeichen($row2["last_name"]) . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Bestelldatum</td>
|
||||
<td>' . $row2["date"] . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Kontakt</td>
|
||||
<td>' . $row2["email"] . " / " . $row2["phone"] . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Vorstellung</td>
|
||||
<td>' . $row2["zbs_name"] . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Platz</td>
|
||||
<td>' . $seat_html . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Zahlung</td>
|
||||
<td>' . $zahlung . '</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="padding: 15px; "></div>
|
||||
<img src="' . (new QRCode)->render('https://borg-kindberg.at/zf-print/ticket-check.php?order_id='.$row2["order_id"]."&code=".$row2["code"]) . '" alt="QR Code" style="height:200px;" />
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
|
||||
//Convert from HTML
|
||||
try {
|
||||
$mpdf->WriteHTML(mb_convert_encoding($data, 'UTF-8', 'UTF-8'));
|
||||
} catch (MpdfException $ex) {
|
||||
echo 'Exception abgefangen: ', $ex->getMessage(), "\n<br/>";
|
||||
die();
|
||||
}
|
||||
|
||||
//Print to Webpage
|
||||
try {
|
||||
$mpdf->Output();
|
||||
} catch (MpdfException $ex) {
|
||||
echo 'Exception abgefangen: ', $ex->getMessage(), "\n<br/>";
|
||||
}
|
||||
|
||||
function sonderzeichen($string): string
|
||||
{
|
||||
$res = $string;
|
||||
$res = str_replace("ä", "ae", $res);
|
||||
$res = str_replace("ü", "ue", $res);
|
||||
$res = str_replace("ö", "oe", $res);
|
||||
$res = str_replace("Ä", "Ae", $res);
|
||||
$res = str_replace("Ü", "Ue", $res);
|
||||
$res = str_replace("Ö", "Oe", $res);
|
||||
$res = str_replace("ß", "ss", $res);
|
||||
return $res;
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
//Database & secrets
|
||||
|
||||
include "config.php";
|
||||
|
||||
if(empty($_GET["code"])){
|
||||
die('Fehler! Bitte überprüfen Sie den Link!');
|
||||
}
|
||||
//access var from config.php
|
||||
global $CONFIG;
|
||||
|
||||
|
||||
//Establish Database Connection using PHP Data Objects
|
||||
try {
|
||||
$pdo = new PDO('mysql:host=' . $CONFIG["database"]["server"] . ';dbname=' . $CONFIG["database"]["dbname"], $CONFIG["database"]["user"], $CONFIG["database"]["password"]);
|
||||
} catch (PDOException $ex) {
|
||||
echo 'Exception abgefangen: ', $ex->getMessage(), "\n<br/>";
|
||||
}
|
||||
|
||||
|
||||
//Primary SQL Statement
|
||||
$statement = $pdo->prepare("SELECT zf_bap_orders.*,zbs.name as zbs_name
|
||||
FROM zf_bap_orders
|
||||
JOIN zf_bap_schemes zbs on zf_bap_orders.scheme_id = zbs.scheme_id
|
||||
WHERE code = :code AND status_id = :status_id");
|
||||
|
||||
//Bind parameters
|
||||
$statement->bindParam("code", $_GET["code"]); // "Auth" 2
|
||||
$expected_status = 2; // 2 equals "is paid"
|
||||
$statement->bindParam(":status_id", $expected_status); //Only show, if ticket is paid
|
||||
|
||||
//Execute Statement and fetch Data
|
||||
$statement->execute();
|
||||
$row2 = $statement->fetch();
|
||||
|
||||
|
||||
if(!($row2["order_id"]>0)){
|
||||
die('Fehler! Ticket ist ungültig.');
|
||||
}
|
||||
|
||||
//Get Payment methode using ternary operator
|
||||
$zahlung = $row2["paypal_token"] != "" ? "Paypal" : "Barzahlung";
|
||||
|
||||
//Looks like shit, but works :D (PHP Serialized Class -> JSON -> PHP stdClass -> PHP Object)
|
||||
$seats = json_decode(json_encode(unserialize($row2["places"])), true);
|
||||
|
||||
//Convert object to HTML List
|
||||
$seat_html = "";
|
||||
foreach ($seats as $seat) {
|
||||
$seat_html .= $seat["place_name"] . " (" . $seat["place_price"] . "€), "; // results in e.g. 'Reihe 1, Platz 2 (5€)'
|
||||
}
|
||||
|
||||
echo '<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Zauberflöte - Ticketbuchung</title>
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
|
||||
<style>
|
||||
body{
|
||||
margin: 50px;
|
||||
}
|
||||
.td_desc{
|
||||
padding-right: 10px;
|
||||
width: 30vw;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="container">
|
||||
<h1>Ticket: '.$row2["order_id"] . "_" . $row2["code"].'</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="td_desc">Name</td>
|
||||
<td>' . $row2["first_name"] . " " . $row2["last_name"] . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Bestelldatum</td>
|
||||
<td>' . $row2["date"] . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Vorstellung</td>
|
||||
<td>' . $row2["zbs_name"] . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Platz</td>
|
||||
<td>' . $seat_html . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_desc">Zahlung</td>
|
||||
<td>' . $zahlung . '</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>';
|
Loading…
Reference in New Issue