| Server IP : 127.0.0.1 / Your IP : 216.73.216.48 Web Server : Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 System : Windows NT DESKTOP-3H4FHQJ 10.0 build 19045 (Windows 10) AMD64 User : win 10 ( 0) PHP Version : 8.2.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/xampp/htdocs-coblaa/Cinevaa/ |
Upload File : |
<?php
include("db.php");
session_start();
// Security Check
if (!isset($_SESSION['my_id'])) {
header("Location: login.php");
exit();
}
// PHP Upload Logic
if (isset($_POST['submit_upload'])) {
$title = mysqli_real_escape_string($con, $_POST['title']);
$description = mysqli_real_escape_string($con, $_POST['description']);
$video_name = $_FILES['video']['name'];
$video_tmp = $_FILES['video']['tmp_name'];
$clean_video_name = preg_replace("/[^a-zA-Z0-9.]/", "_", $video_name);
$new_video_name = time() . '_' . $clean_video_name;
$video_path = "movies/" . $new_video_name;
$thumbnail_data = $_POST['thumbnail_data'];
$new_thumbnail_name = time() . '_thumb.jpg';
$thumbnail_path = "thumbnail/" . $new_thumbnail_name;
if (!empty($thumbnail_data)) {
list($type, $data) = explode(';', $thumbnail_data);
list(, $data) = explode(',', $data);
$data = base64_decode($data);
file_put_contents($thumbnail_path, $data);
}
if (move_uploaded_file($video_tmp, $video_path)) {
$insert_query = "INSERT INTO sn_moviestb (title, movieCategory, thumbnail, video_path)
VALUES ('$title', '$description', '$new_thumbnail_name', '$new_video_name')";
if (mysqli_query($con, $insert_query)) {
echo "<script>alert('Movie uploaded successfully!'); window.location='index.php';</script>";
} else {
$error_msg = "Database Error: " . mysqli_error($con);
}
} else {
$error_msg = "Upload failed. Check file size limits.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Movie | CINEVAA</title>
<style>
:root {
--gold: #d4af37;
--dark-bg: #000;
--panel-bg: #111;
--border: #333;
}
body { background-color: var(--dark-bg); color: #fff; font-family: 'Segoe UI', sans-serif; margin: 0; padding: 20px; }
.header-nav {
max-width: 660px;
margin: 0 auto 20px;
display: flex;
justify-content: flex-start;
}
/* Back Button Style */
.btn-back {
color: #888;
text-decoration: none;
display: flex;
align-items: center;
font-size: 14px;
transition: color 0.3s;
}
.btn-back:hover { color: var(--gold); }
.btn-back svg { margin-right: 8px; }
.upload-container {
max-width: 600px;
margin: 0 auto;
padding: 30px;
border: 1px solid var(--gold);
border-radius: 12px;
background: var(--panel-bg);
box-shadow: 0 4px 15px rgba(212, 175, 55, 0.1);
}
h2 { color: var(--gold); text-align: center; margin-top: 0; text-transform: uppercase; letter-spacing: 2px; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: bold; color: var(--gold); font-size: 13px; }
input[type="text"], input[type="file"], select {
width: 100%; padding: 12px; box-sizing: border-box;
border: 1px solid var(--border); border-radius: 6px;
background: #1a1a1a; color: #fff; outline: none;
}
input[type="text"]:focus, select:focus { border-color: var(--gold); }
#video-preview-container { display: none; margin-top: 20px; text-align: center; padding-top: 20px; border-top: 1px solid var(--border); }
video { width: 100%; border-radius: 6px; border: 1px solid var(--gold); }
canvas { display: none; }
.ratio-selector { margin: 20px 0; display: flex; gap: 10px; justify-content: center; }
.ratio-btn {
padding: 8px 15px; border: 1px solid var(--gold); background: transparent;
color: var(--gold); cursor: pointer; border-radius: 4px; font-size: 12px;
}
.ratio-btn.active { background: var(--gold); color: #000; }
#thumbnail-preview { margin-top: 15px; border: 2px solid var(--gold); display: none; border-radius: 6px; object-fit: cover; }
.preview-16-9 { width: 280px; height: 157px; }
.preview-9-16 { width: 150px; height: 266px; }
button#submit-btn { background-color: var(--gold); color: #000; border: none; padding: 14px; cursor: pointer; border-radius: 6px; width: 100%; font-weight: bold; text-transform: uppercase; margin-top: 20px; }
#capture-btn { background: transparent; border: 1px solid var(--gold); color: var(--gold); padding: 10px; width: 100%; border-radius: 6px; cursor: pointer; }
</style>
</head>
<body>
<div class="header-nav">
<a href="index.php" class="btn-back">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>
Back to Dashboard
</a>
</div>
<div class="upload-container">
<h2>Upload Movie</h2>
<form id="uploadForm" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="title">MOVIE TITLE</label>
<input type="text" name="title" id="title" required placeholder="Ex: Interstellar (2014)">
</div>
<div class="form-group">
<label for="description">CATEGORY / GENRE</label>
<select name="description" id="description">
<option>Action</option>
<option>Adventure</option>
<option>Animation</option>
<option>Comedy</option>
<option>Drama</option>
<option>Documentary</option>
<option>Horror</option>
<option>Romance</option>
<option>Science Fiction</option>
<option>Musical</option>
<option>Crime & Mystery</option>
<option>Fantasy</option>
<option>Thriller</option>
<option>Sci-Fi</option>
<option>War</option>
<option>Western</option>
</select>
</div>
<div class="form-group">
<label for="video">VIDEO FILE</label>
<input type="file" name="video" id="video" accept="video/*" required>
</div>
<div id="video-preview-container">
<label>THUMBNAIL GENERATOR</label>
<video id="main-video" controls></video>
<div class="ratio-selector">
<button type="button" class="ratio-btn active" data-ratio="16/9">16:9 Landscape</button>
<button type="button" class="ratio-btn" data-ratio="9/16">9:16 Portrait</button>
</div>
<button type="button" id="capture-btn">Capture Current Frame</button>
<div id="capture-result" style="text-align:center;">
<img id="thumbnail-preview" alt="Thumbnail Preview">
<input type="hidden" name="thumbnail_data" id="thumbnail_data">
</div>
</div>
<button type="submit" name="submit_upload" id="submit-btn" style="display:none;">Publish Movie</button>
</form>
</div>
<canvas id="conversion-canvas"></canvas>
<script>
// JS Logic remains the same, but ensuring submitBtn visibility is handled
const videoInput = document.getElementById('video');
const videoElement = document.getElementById('main-video');
const previewContainer = document.getElementById('video-preview-container');
const captureBtn = document.getElementById('capture-btn');
const submitBtn = document.getElementById('submit-btn');
const thumbnailPreview = document.getElementById('thumbnail-preview');
const thumbnailDataInput = document.getElementById('thumbnail_data');
const canvas = document.getElementById('conversion-canvas');
const ratioBtns = document.querySelectorAll('.ratio-btn');
let selectedRatio = "16/9";
ratioBtns.forEach(btn => {
btn.addEventListener('click', () => {
ratioBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
selectedRatio = btn.getAttribute('data-ratio');
});
});
videoInput.addEventListener('change', function() {
const file = this.files[0];
if (file) {
const url = URL.createObjectURL(file);
videoElement.src = url;
previewContainer.style.display = 'block';
}
});
captureBtn.addEventListener('click', function() {
const [wRatio, hRatio] = selectedRatio.split('/').map(Number);
let targetHeight = videoElement.videoHeight;
let targetWidth = (targetHeight * wRatio) / hRatio;
canvas.width = targetWidth;
canvas.height = targetHeight;
const ctx = canvas.getContext('2d');
const videoRatio = videoElement.videoWidth / videoElement.videoHeight;
const targetRatio = targetWidth / targetHeight;
let sx, sy, sWidth, sHeight;
if (videoRatio > targetRatio) {
sHeight = videoElement.videoHeight;
sWidth = sHeight * targetRatio;
sx = (videoElement.videoWidth - sWidth) / 2;
sy = 0;
} else {
sWidth = videoElement.videoWidth;
sHeight = sWidth / targetRatio;
sx = 0;
sy = (videoElement.videoHeight - sHeight) / 2;
}
ctx.drawImage(videoElement, sx, sy, sWidth, sHeight, 0, 0, targetWidth, targetHeight);
const dataUrl = canvas.toDataURL('image/jpeg', 0.9);
thumbnailPreview.src = dataUrl;
thumbnailPreview.className = (selectedRatio === "16/9") ? "preview-16-9" : "preview-9-16";
thumbnailPreview.style.display = 'inline-block';
thumbnailDataInput.value = dataUrl;
submitBtn.style.display = 'block';
captureBtn.innerText = "Change Thumbnail Frame";
});
</script>
</body>
</html>