First version, for githup; UNSTABLE, DO NOT USE!
This commit is contained in:
46
www/intern/scripts/logindata/ajax02.php
Normal file
46
www/intern/scripts/logindata/ajax02.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
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']) < 1 ) {
|
||||
http_response_code(403);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($baseDir)) {
|
||||
$baseDir = $_SERVER['DOCUMENT_ROOT'];
|
||||
}
|
||||
|
||||
require $baseDir . '/../scripts/db/db-functions.php';
|
||||
require $baseDir . '/../scripts/db/db-tables.php';
|
||||
require $baseDir . '/../scripts/csrf_functions.php';
|
||||
|
||||
|
||||
$type = 'wkl';
|
||||
|
||||
$dbconnection = require $baseDir . '/../scripts/db/db-verbindung-script.php';
|
||||
|
||||
if ($dbconnection['success'] !== true){
|
||||
echo json_encode(['success' => false, 'message' => 'Critical DB Error.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval($_POST['field_id'] ?? 0);
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid Input.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$deleted = db_delete($mysqli, $tableInternUsers, ['id' => $id]);
|
||||
|
||||
if ($deleted !== true) {
|
||||
// DB query failed (syntax/connection issue)
|
||||
echo json_encode(['success' => false, 'message' => 'DB Error.']);
|
||||
exit;
|
||||
} else {
|
||||
// Success
|
||||
echo json_encode(['success' => true, 'message' => "Benutzer $id erfolgreich gelöscht.", 'id' => $id]);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user