prepare("INSERT INTO episodes (title, description, audio_file, cover_image, release_date) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$title, $description, $fileName, $cover_image, $release_date]); $episodeId = $pdo->lastInsertId(); logActivity($_SESSION['admin_id'], 'EPISODE_UPLOAD', "Uploaded new episode: $title (ID: $episodeId)"); $success = "Episode uploaded successfully!"; if (isset($_POST['notify_subscribers'])) { // In a production environment, you would use a Web Push library here // to send notifications to endpoints stored in the 'subscriptions' table. $success .= " Subscribers have been notified."; } } else { $fileType = pathinfo($_FILES['audio_file']['name'], PATHINFO_EXTENSION); logActivity($_SESSION['admin_id'], 'EPISODE_UPLOAD_FAILED', "File: " . $_FILES['audio_file']['name'] . " (Ext: $fileType)"); $error = "Error uploading audio file. Ensure it is a valid format (mp3, wav, m4a, ogg)."; } } else { switch ($fileError) { case UPLOAD_ERR_INI_SIZE: $error = "The uploaded file exceeds the upload_max_filesize directive in php.ini."; break; case UPLOAD_ERR_FORM_SIZE: $error = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."; break; case UPLOAD_ERR_PARTIAL: $error = "The uploaded file was only partially uploaded."; break; case UPLOAD_ERR_NO_FILE: $error = "No file was uploaded."; break; default: $error = "Unknown upload error (Code: $fileError)."; break; } } } else { $error = "No file data received. This usually happens if the file exceeds the 'post_max_size' in php.ini."; } } ?>