First version, for githup; UNSTABLE, DO NOT USE!
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
|
||||
|
||||
if (empty($_SESSION['access_granted_wk_leitung']) || $_SESSION['access_granted_wk_leitung'] !== true || empty($_SESSION['passcodewk_leitung_id']) || intval($_SESSION['passcodewk_leitung_id']) < 0 ) {
|
||||
http_response_code(403);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($baseDir)) {
|
||||
$baseDir = $_SERVER['DOCUMENT_ROOT'];
|
||||
}
|
||||
|
||||
$type = 'wkl';
|
||||
|
||||
|
||||
$dbconnection = require $baseDir . '/../scripts/db/db-verbindung-script.php';
|
||||
|
||||
if ($dbconnection['success'] !== true){
|
||||
echo 'Critical DB Error.';
|
||||
exit;
|
||||
}
|
||||
|
||||
require $baseDir . '/../scripts/db/db-tables.php';
|
||||
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if (!$input || !isset($input['new'])) {
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
$mysqli->begin_transaction();
|
||||
|
||||
try {
|
||||
$stmt = $mysqli->prepare("
|
||||
UPDATE $tableTurnerinnenAbt
|
||||
SET turnerin_index = ?
|
||||
WHERE turnerin_id = ?
|
||||
");
|
||||
|
||||
foreach (['new', 'old'] as $bucket) {
|
||||
if (empty($input[$bucket])) continue;
|
||||
|
||||
foreach ($input[$bucket] as $row) {
|
||||
$stmt->bind_param("ii", $row['order_index'], $row['id']);
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
|
||||
$mysqli->commit();
|
||||
http_response_code(200);
|
||||
|
||||
} catch (Throwable $e) {
|
||||
$mysqli->rollback();
|
||||
http_response_code(500);
|
||||
}
|
||||
Reference in New Issue
Block a user