QR-Code Upload

Dieses Formular ist derzeit nicht aktiviert.

'; exit; } bratonien_tools_customer_qr_ensure_storage(); bratonien_tools_friendship_code_ensure_storage(); $year_limits = bratonien_tools_customer_qr_year_limits(); $action = (string)($_GET['action'] ?? ''); function bratonien_tools_customer_qr_public_inventory($year) { $year = bratonien_tools_customer_qr_year($year); $limits = bratonien_tools_customer_qr_year_limits(); $limit = (int)$limits[$year]; $present = array(); $table = bratonien_tools_customer_qr_table(); $result = pwg_query( 'SELECT code_number FROM `'.$table.'` ' .'WHERE upload_year='.(int)$year.' ' .'ORDER BY CAST(code_number AS UNSIGNED) ASC' ); while ($row = pwg_db_fetch_assoc($result)) { $number = (int)$row['code_number']; if ($number >= 1 && $number <= $limit) { $present[$number] = true; } } $slots = array(); for ($number = 1; $number <= $limit; $number++) { $slots[] = array( 'number' => $number, 'present' => isset($present[$number]), ); } $present_count = count($present); return array( 'year' => $year, 'limit' => $limit, 'present_count' => $present_count, 'missing_count' => max(0, $limit - $present_count), 'slots' => $slots, ); } if ($action === 'inventory') { header('Content-Type: application/json; charset=utf-8'); header('Cache-Control: no-store, max-age=0'); try { $inventory = bratonien_tools_customer_qr_public_inventory($_GET['year'] ?? ''); echo json_encode(array( 'ok' => true, 'inventory' => $inventory, ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } catch (Throwable $e) { http_response_code(400); echo json_encode(array('ok' => false, 'message' => $e->getMessage()), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } exit; } if ($action === 'check') { header('Content-Type: application/json; charset=utf-8'); header('Cache-Control: no-store, max-age=0'); try { $year = bratonien_tools_customer_qr_year($_GET['year'] ?? ''); $number = bratonien_tools_customer_qr_number_for_year($year, $_GET['number'] ?? ''); $exists = bratonien_tools_customer_qr_exists($year, $number); echo json_encode(array( 'ok' => true, 'available' => !$exists, 'year' => $year, 'number' => $number, 'limit' => (int)$year_limits[$year], 'message' => $exists ? 'Diese QR-Code-Nummer ist für '.$year.' bereits vorhanden.' : 'Nummer ist für '.$year.' frei.', ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } catch (Throwable $e) { http_response_code(400); echo json_encode(array('ok' => false, 'message' => $e->getMessage()), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } exit; } if ($action === 'check_friendship') { header('Content-Type: application/json; charset=utf-8'); header('Cache-Control: no-store, max-age=0'); try { $name = bratonien_tools_friendship_code_name($_GET['name'] ?? ''); $exists = bratonien_tools_friendship_code_exists_for_name($name); echo json_encode(array( 'ok' => true, 'available' => !$exists, 'name' => $name, 'message' => $exists ? 'Für diesen Namen ist bereits ein Freundschaftscode hinterlegt.' : 'Für diesen Namen kann ein Freundschaftscode hinterlegt werden.', ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } catch (Throwable $e) { http_response_code(400); echo json_encode(array('ok' => false, 'message' => $e->getMessage()), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $results = array(); $year = bratonien_tools_customer_qr_default_year(); $upload_type = (string)($_POST['upload_type'] ?? 'qr'); try { if ( empty($_POST) && empty($_FILES) && !empty($_SERVER['CONTENT_LENGTH']) ) { throw new RuntimeException('Der Upload überschreitet das PHP-Limit post_max_size ('.ini_get('post_max_size').').'); } if (function_exists('check_pwg_token')) { check_pwg_token(); } if ($upload_type === 'friendship') { $name = bratonien_tools_friendship_code_name($_POST['friend_name'] ?? ''); if (empty($_FILES['friend_file'])) { throw new RuntimeException('Es wurde keine Freundschaftscode-Datei ausgewählt.'); } $results[] = bratonien_tools_friendship_code_process_upload($name, $_FILES['friend_file']); } else { $upload_type = 'qr'; $year = bratonien_tools_customer_qr_year($_POST['upload_year'] ?? ''); if (empty($_FILES['qr_files'])) { throw new RuntimeException('Es wurden keine QR-Code-Dateien ausgewählt.'); } $numbers = isset($_POST['qr_numbers']) && is_array($_POST['qr_numbers']) ? array_values($_POST['qr_numbers']) : array(); $results = bratonien_tools_customer_qr_process_uploads($year, $_FILES['qr_files'], $numbers); } } catch (Throwable $e) { $results[] = array( 'status' => 'error', 'kind' => $upload_type === 'friendship' ? 'friendship' : 'qr', 'file' => '', 'name' => $upload_type === 'friendship' ? trim((string)($_POST['friend_name'] ?? '')) : '', 'year' => $year, 'number' => '', 'message' => $e->getMessage(), ); } $_SESSION['bratonien_customer_qr_flash'] = array( 'type' => $upload_type, 'year' => $year, 'results' => $results, ); $target = strtok($_SERVER['REQUEST_URI'], '?'); header('Location: '.$target, true, 303); exit; } $flash = array(); if (!empty($_SESSION['bratonien_customer_qr_flash']) && is_array($_SESSION['bratonien_customer_qr_flash'])) { $flash = $_SESSION['bratonien_customer_qr_flash']; unset($_SESSION['bratonien_customer_qr_flash']); } $selected_year = isset($flash['year']) ? (int)$flash['year'] : bratonien_tools_customer_qr_default_year(); if (!isset($year_limits[$selected_year])) { $selected_year = bratonien_tools_customer_qr_default_year(); } $selected_limit = (int)$year_limits[$selected_year]; $inventory = bratonien_tools_customer_qr_public_inventory($selected_year); $results = isset($flash['results']) && is_array($flash['results']) ? $flash['results'] : array(); $token = function_exists('get_pwg_token') ? get_pwg_token() : ''; $max_files = max(1, (int)ini_get('max_file_uploads')); $endpoint = strtok($_SERVER['REQUEST_URI'], '?'); header('Content-Type: text/html; charset=utf-8'); header('Cache-Control: no-store, max-age=0'); ?> QR-Code Upload

QR-Code Upload

QR-Codes und persönliche Freundschaftscodes hochladen.

Ergebnis

Name:
Jahr · QR-Code #

QR-Code

Für sind QR-Code-Nummern 1 bis vorgesehen.
PNG, JPG, WEBP oder GIF. Batch-Upload bis zum Serverlimit von Dateien pro Anfrage.

QR-Code-Bestand

vorhanden · fehlen
Eine Nummer kann innerhalb eines Jahres nur einmal verwendet werden.

Persönlicher Freundschaftscode

Bitte Namen eingeben.
Ein Bild pro Person. PNG, JPG, WEBP oder GIF.
Pro Name wird genau ein persönlicher Freundschaftscode gespeichert.