forked from foxgalaxy23g/Meetlook-Open
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.php
More file actions
122 lines (105 loc) · 4.2 KB
/
make.php
File metadata and controls
122 lines (105 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
include("elements/php/db.php");
include("elements/php/closed.php");
include("elements/php/verify.php");
// Получаем список доступных тем
$sql = "SELECT id, name FROM themes";
$result = $conn->query($sql);
$themes = [];
while ($row = $result->fetch_assoc()) {
$themes[] = $row;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['video']) && isset($_FILES['cover_image']) && isset($_POST['description']) && isset($_POST['theme_id'])) {
$video = $_FILES['video'];
$description = trim($_POST['description']);
$coverImage = $_FILES['cover_image'];
$theme_id = intval($_POST['theme_id']);
if (empty($description)) {
die("Video description is required.");
}
if ($video['type'] !== 'video/mp4') {
die("Invalid video format. Only MP4 is allowed.");
}
if ($video['size'] > 50 * 1024 * 1024) {
die("Video file size exceeds 50 MB.");
}
if (empty($coverImage['name'])) {
die("Cover image is required.");
}
if (!in_array($coverImage['type'], ['image/jpeg', 'image/png'])) {
die("Invalid cover image format. Only JPG and PNG are allowed.");
}
if ($coverImage['size'] > 10 * 1024 * 1024) {
die("Cover image size must be at least 10 MB.");
}
$uploadDir = 'uploads/videos/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
$videoPath = $uploadDir . uniqid() . ".mp4";
if (!move_uploaded_file($video['tmp_name'], $videoPath)) {
die("Video upload failed.");
}
$coverImageDir = 'uploads/covers/';
if (!is_dir($coverImageDir)) {
mkdir($coverImageDir, 0777, true);
}
$coverImageExtension = pathinfo($coverImage['name'], PATHINFO_EXTENSION);
$coverImageName = uniqid() . '.' . $coverImageExtension;
$coverImagePath = $coverImageDir . $coverImageName;
if (!move_uploaded_file($coverImage['tmp_name'], $coverImagePath)) {
die("Cover image upload failed.");
}
$sql = "INSERT INTO videos (user_id, path, description, upload_time, cover_image_path, theme_id) VALUES (?, ?, ?, NOW(), ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param('isssi', $user_id, $videoPath, $description, $coverImagePath, $theme_id);
$stmt->execute();
$stmt->close();
echo "Video uploaded successfully with cover image and theme.";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload video on <?php echo htmlentities($project_name); ?></title>
<link rel="stylesheet" href="elements/css/make.css">
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<div class="header-container">
<?php
include("header_old.php");
include("elements/php/closed.php");
?>
</div>
<noscript>
<meta http-equiv="refresh" content="0; url=/javascript.html">
</noscript>
<div class="sidebar">
<a href="make.php"><i></i></a>
<a href="make.php"><i>🎥</i>Upload video</a>
<a href="myvideos.php"><i>🎞</i>Manage videos</a>
<a href="settings.php"><i>⚙</i>Settings</a>
</div>
<div class="content">
<h1>Upload Video</h1>
<form method="post" enctype="multipart/form-data">
<label>Select video (MP4, max 50 MB):</label>
<input type="file" name="video" accept="video/mp4" required><br>
<label>Video description:</label>
<textarea name="description" rows="4" required></textarea><br>
<label>Upload cover image (JPG/PNG, max 10 MB):</label>
<input type="file" name="cover_image" accept="image/jpeg, image/png" required><br>
<label>Select theme:</label>
<select name="theme_id" required>
<?php foreach ($themes as $theme): ?>
<option value="<?php echo $theme['id']; ?>"><?php echo htmlentities($theme['name']); ?></option>
<?php endforeach; ?>
</select><br>
<button type="submit">Upload</button>
</form>
</div>
</body>
</html>