Semi-stable version with old variable names
This commit is contained in:
@@ -10,6 +10,9 @@ check_multiple_allowed_permissions(['trainer', 'wk_leitung']);
|
||||
|
||||
verify_csrf();
|
||||
|
||||
$isTrainer = isset($_SESSION['access_granted_trainer']) && $_SESSION['access_granted_trainer'];
|
||||
$userId = $isTrainer ? intval($_SESSION['user_id_trainer'] ?? 0) : intval($_SESSION['user_id_wk_leitung'] ?? 0);
|
||||
|
||||
// Allow large uploads and enough memory for GD processing
|
||||
ini_set('memory_limit', '256M');
|
||||
ini_set('max_execution_time', '120');
|
||||
@@ -41,7 +44,23 @@ $normalDir = $saveDir;
|
||||
|
||||
$uploadDir = $baseDir . $saveDir;
|
||||
|
||||
$maxLengthMusic = db_get_var($mysqli, "SELECT `value` FROM $tableVar WHERE `name` = ?", ['maxLengthMusic']);
|
||||
$maxLengthMusic = 0;
|
||||
|
||||
if ($isTrainer) {
|
||||
$geraet_id = (int) $_POST['geraetId'] ?? 0;
|
||||
|
||||
$geraet_exists = db_get_var($mysqli, "SELECT 1 FROM $tableGeraete WHERE `id` = ?", [$geraet_id]);
|
||||
|
||||
if ($geraet_exists === null) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['success' => false, 'message' => 'Invalides Gerät angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$geraet_max_duration_audio_db = db_get_var($mysqli, "SELECT `audiofile_max_duration` FROM $tableGeraete WHERE `id` = ?", [$geraet_id]);
|
||||
|
||||
$maxLengthMusic = (int) $geraet_max_duration_audio_db;
|
||||
}
|
||||
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0755, true);
|
||||
@@ -109,10 +128,10 @@ if ($isTrainer && $maxLengthMusic !== null && intval($maxLengthMusic) !== 0) {
|
||||
}
|
||||
|
||||
|
||||
$sql = "INSERT INTO $tableAudiofiles (`file_name`,`file_path`) VALUES (?, ?)";
|
||||
$sql = "INSERT INTO $tableAudiofiles (`file_name`,`file_path`,`edited_by`) VALUES (?, ?, ?)";
|
||||
|
||||
$stmt = $mysqli->prepare($sql);
|
||||
$stmt->bind_param("ss", $originalName, $normalPath);
|
||||
$stmt->bind_param("ssi", $originalName, $normalPath, $userId);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
http_response_code(500);
|
||||
|
||||
Reference in New Issue
Block a user