-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
117 lines (111 loc) · 3.71 KB
/
index.php
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
<?php
if(!file_exists("config.json")) {
die("Error loading configuration. Please reinstall.");
}
else {
$config = json_decode(file_get_contents("config.json"), true);
if($config['installed'] === "no") {
header("Location: install.php?page=welcome");
}
$name = $config['name'];
$path = $config['path'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo($name); ?> - Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<?php echo($name); ?> 2.0">
<style>
.top-bar {
background-color: #f0f0f0;
top: 0;
left: 0;
width: 100%;
height: 48px;
padding-top: 8px;
padding-bottom: 8px;
}
.logo {
float: left;
display: inline-block;
}
.block {
display: inline-block;
float: right;
}
.video-tile {
background-color: #f0f0f0;
width: 50%;
}
</style>
<script>
function checkEnter(event, fun) {
if (event.keyCode == 13) {
fun();
}
}
function search() {
try {
x = document.getElementById("sch").value;
// Do something with X.
console.log(x);
window.location = `search.php?q=${x}`
}
catch {
window.location = "error.php?c=3";
}
}
</script>
</head>
<body>
<div class="top-bar">
<div class="logo" href="<?php echo($path); ?>" ><h1 title="<?php echo($name); ?>" href="<?php echo($path); ?>"><?php echo($name); ?></h1></div>
<center class="block">
Search : <input type="text" id="sch" class="search" style="width: 500px" onkeydown="checkEnter(event, search)" placeholder="Search for videos..." />
</center>
</div>
<center>
<h2>Here is a list of videos we currently have available for watch.</h2>
<?php
$dir = "ids/";
$videos = scandir($dir);
// var_dump($videos);
// echo $videos[2];
$nov = count($videos);
for($x = 2; $x < $nov; $x++){
$jsonFile = $videos[$x];
$id = str_replace(".json", "", $jsonFile);
$jsonContents = file_get_contents("ids/" . $jsonFile);
$data = json_decode($jsonContents, true);
$title = htmlspecialchars($data["title"]);
if(file_exists("thb/" . $id . ".jpg")){
// Changed where link goes!
echo "<div class='video-tile'><a href='view.php?id=" . $id . "'><img src='thb/" . $id . ".jpg' width='320' height='240' /><br />" . $title . " (" . $data["views"] . " views)</a></div>";
} else {
echo "<div class='video-tile'><a title='This video has no thumbnail!' href='view.php?id=" . $id . "'>" . $title . " (" . $data["views"] . " views)</a></div>";
}
}
?>
<br />
<h3>Want to upload your own video?</h3>
<a href="upload.php">Go to this link to upload your video!</a>
<h3>Want to have a profile?</h3>
<a href="accounts/index.php">Go here to login, or manage your own account</a>
<br>
<h3>Want to see all channels?</h3>
<a href="channels.php">Click here to see all channels</a>
<br>
<div style="background-color: #f0f0f0; width: 50%; border-radius: 16px;">
<h1>News</h1>
<?php
$x = file_get_contents("news.txt");
$x = str_replace("\n", "<br >", $x);
echo $x;
?>
</div>
</center>
<font color="#808080">Copyright © HxOr1337/(*DripDog*) 2021 - <?php echo date("Y"); ?></font>
</body>
</html>