D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
skyconb
/
newsyacine
/
Filename :
edit_video.php
back
Copy
<?php // =============================================== // edit_video.php (صفحة تعديل الفيديو - مع رابط البث iframe) // =============================================== session_start(); include 'db_connect.php'; // التحقق من تسجيل الدخول والصلاحية if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) { header("Location: login.php"); exit(); } $error = ''; $video_data = []; // لتهيئة البيانات قبل الجلب // ---------------------------------------------------- // 1. معالجة تحديث البيانات (POST) // ---------------------------------------------------- if ($_SERVER["REQUEST_METHOD"] == "POST") { $video_id = $_POST['video_id'] ?? null; $title = $_POST['title'] ?? ''; $m3u8_link = $_POST['m3u8_link'] ?? ''; $iframe_link = $_POST['iframe_link'] ?? ''; // 🎯 جلب رابط iframe الجديد if (empty($video_id)) { $error = "معرّف الفيديو مفقود."; } elseif (empty($title) || (empty($m3u8_link) && empty($iframe_link))) { $error = "الرجاء إدخال عنوان، ويجب إدخال رابط M3U8 أو رابط البث (iframe) على الأقل."; } else { // إعداد استعلام التحديث الآمن // 🎯 الاستعلام الآن يشمل iframe_link $sql = "UPDATE videos SET title = ?, m3u8_link = ?, iframe_link = ? WHERE id = ?"; $stmt = $conn->prepare($sql); // "sssi" تعني 3 سلاسل نصية (title, m3u8_link, iframe_link) ورقم صحيح (id) $stmt->bind_param("sssi", $title, $m3u8_link, $iframe_link, $video_id); if ($stmt->execute()) { $_SESSION['message'] = "تم تحديث الفيديو بنجاح."; header("Location: admin.php?section=videos"); exit(); } else { $error = "خطأ في قاعدة البيانات: " . $stmt->error; } $stmt->close(); } } // ---------------------------------------------------- // 2. جلب بيانات الفيديو الحالية (GET) // ---------------------------------------------------- $video_id = $_GET['id'] ?? ($_POST['video_id'] ?? null); // يمكن أن يأتي ID من GET أو POST if (!$video_id) { die("معرّف الفيديو المطلوب تعديله مفقود."); } // جلب البيانات من القاعدة (يجب أن يتم بعد معالجة POST لتحديث المتغيرات في حالة فشل POST) // 🎯 تم إضافة iframe_link إلى جملة SELECT $sql = "SELECT id, title, m3u8_link, iframe_link FROM videos WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $video_id); $stmt->execute(); $result = $stmt->get_result(); $video_data = $result->fetch_assoc(); $stmt->close(); $conn->close(); if (!$video_data) { die("لم يتم العثور على الفيديو بهذا المعرّف."); } // تعيين المتغيرات لاستخدامها في النموذج $title = $video_data['title']; $m3u8_link = $video_data['m3u8_link']; $iframe_link = $video_data['iframe_link']; // 🎯 المتغير الجديد ?> <!DOCTYPE html> <html lang="ar" dir="rtl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>تعديل فيديو: <?php echo htmlspecialchars($title); ?></title> <style> body { font-family: Tahoma, sans-serif; background-color: #f4f4f4; margin: 0; padding: 20px; } .container { max-width: 600px; margin: 50px auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); } h1 { text-align: center; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 10px; } label { display: block; margin: 10px 0 5px; font-weight: bold; } input[type="text"], textarea { width: 100%; padding: 10px; margin-bottom: 20px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } textarea { resize: vertical; height: 100px; } button { background-color: #f39c12; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; transition: background-color 0.3s; } button:hover { background-color: #e67e22; } .error { color: #e74c3c; background-color: #f8d7da; padding: 10px; border-radius: 4px; margin-bottom: 15px; border: 1px solid #f5c6cb; } .back-link { display: block; text-align: center; margin-top: 20px; color: #3498db; text-decoration: none; } </style> </head> <body> <div class="container"> <h1>تعديل فيديو: <?php echo htmlspecialchars($title); ?></h1> <?php if ($error): ?> <div class="error"><?php echo $error; ?></div> <?php endif; ?> <form method="POST"> <input type="hidden" name="video_id" value="<?php echo htmlspecialchars($video_data['id']); ?>"> <label for="title">عنوان الفيديو:</label> <input type="text" id="title" name="title" required value="<?php echo htmlspecialchars($title); ?>"> <label for="m3u8_link">رابط M3U8 (للفيديوهات المسجلة - اختياري):</label> <textarea id="m3u8_link" name="m3u8_link"><?php echo htmlspecialchars($m3u8_link); ?></textarea> <hr style="margin: 30px 0; border-top: 1px dashed #ccc;"> <label for="iframe_link">رابط البث المباشر (كود iframe أو رابط مباشر - اختياري):</label> <textarea id="iframe_link" name="iframe_link" placeholder="ضع كود iframe كاملاً هنا"><?php echo htmlspecialchars($iframe_link); ?></textarea> <hr style="margin: 30px 0; border-top: 1px dashed #ccc;"> <button type="submit">حفظ التعديلات</button> </form> <a href="admin.php?section=videos" class="back-link">العودة إلى إدارة الفيديوهات</a> </div> </body> </html>