All checks were successful
Deploy bericht / deploy (push) Successful in 1s
Phase 2.1 Token-System: - Neue Tabelle llx_bericht_upload_token (token, fk_bericht, expires_at, uploads_count, max_uploads) - BerichtUploadToken-Klasse mit create/fetchValid/incrementCount/cleanupExpired - Cronjob 'Bericht: Expired Upload-Tokens bereinigen' täglich - 64-Hex random_bytes-Tokens, 1h Lifetime, 100 Uploads max Phase 2.2 QR-Upload Lite: - mobile_upload.php — Mobile-optimierte Page ohne Dolibarr-Login, Auth nur über Token in URL/Form - 📷 Foto aufnehmen (capture=environment) und 📂 Galerie - Clientseitiges Resize auf max 2000px (Canvas, JPEG q=0.85) - Upload-Status mit Toast-Notifications - Liste der hochgeladenen Bilder live in der Page - ajax/create_upload_token.php — generiert Token für aktiven Bericht - ajax/list_pages.php — Polling-Endpoint für Editor - 📱 Mobil hochladen-Button im Editor → QR-Modal mit qrcodejs - Polling alle 5s nach neuen Pages, auto-reload bei Änderung - QR-Modal styled für Dark-Theme Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> [deploy]
30 lines
1 KiB
PHP
30 lines
1 KiB
PHP
<?php
|
|
/* Erstellt einen Upload-Token für einen Bericht.
|
|
* POST: berichtid, token (Dolibarr CSRF)
|
|
* Liefert: { token, expires_at, url }
|
|
*/
|
|
require_once __DIR__.'/_inc.php';
|
|
require_once __DIR__.'/../class/upload_token.class.php';
|
|
|
|
global $db, $user;
|
|
if (!$user->hasRight('bericht', 'write')) bericht_ajax_fail('Permission denied', 403);
|
|
|
|
$berichtid = (int) ($_POST['berichtid'] ?? 0);
|
|
if (!$berichtid) bericht_ajax_fail('berichtid fehlt');
|
|
|
|
$bericht = new Bericht($db);
|
|
if ($bericht->fetch($berichtid) <= 0) bericht_ajax_fail('Bericht nicht gefunden', 404);
|
|
|
|
$tok = new BerichtUploadToken($db);
|
|
$hex = $tok->create($berichtid, $user->id);
|
|
if (!$hex) bericht_ajax_fail('Token-Erstellung fehlgeschlagen');
|
|
|
|
$base = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https://' : 'http://').$_SERVER['HTTP_HOST'];
|
|
$url = $base.dol_buildpath('/bericht/mobile_upload.php', 1).'?token='.$hex;
|
|
|
|
bericht_ajax_ok(array(
|
|
'token' => $hex,
|
|
'expires_at' => $tok->expires_at,
|
|
'expires_in_min' => round(($tok->expires_at - dol_now()) / 60),
|
|
'url' => $url,
|
|
));
|