-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsearch.php
More file actions
132 lines (127 loc) · 3.74 KB
/
search.php
File metadata and controls
132 lines (127 loc) · 3.74 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
123
124
125
126
127
128
129
130
131
132
<?php
if(!isset($_GET['q'])) {
echo('<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search</title><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>
<center class="block">
Search : <input type="text" id="sch" class="search" style="width: 500px" onkeydown="checkEnter(event, search)" placeholder="Search for videos..." />
</center>
</body>
</html>');
die();
}
$s = substr($_GET['q'], 0, 4);
$chn = substr($_GET['q'], 0, 9);
$chn2 = substr($_GET['q'], 0, 8);
if($s === "loc:") {
$newquery = $_GET['q'];
$newquery = str_ireplace("loc:", "?q=", $newquery);
header("Location: location.php$newquery");
// $cn = file_get_contents("location.php$newquery");
die();
}
if($chn === "channels:") {
$newquery = $_GET['q'];
$newquery = str_ireplace("channels:", "", $newquery);
if($newquery === "all") {
header("Location: channels.php");
}
else {
die("No results.");
}
}
if($chn === "channel:") {
$newquery = $_GET['q'];
$newquery = str_ireplace("channel:", "", $newquery);
if(file_exists("accounts/data/$newquery.json")) {
header("Location: channel.php?id=$newquery");
}
else {
die("No results.");
}
}
//die($s);
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'];
}
?>
<?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);
// Search for string in video
// echo $num;
// $x2 = $num;
// echo($x2);
// $data['title'] = str_ireplace("'", "", $data['title']);
// $data['title'] = str_ireplace(" ", "", $data['title']);
$data['title'] = str_replace(array("\r", "\n", "\r\n", "\v", "\t", "\0","\x"), "", $data['title']);
$q = $data['title'];
if (strpos($data['title'], $_GET['q']) !== false) {
// echo $id . ": " . $data['title'] . "<br>";
$GLOBALS['result'] = "yes";
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 />" . $data["title"] . " (" . $data["views"] . " views)</a></div>";
} else {
echo "<div class='video-tile'><a title='This video has no thumbnail!' href='view.php?id=" . $id . "'>" . $data["title"] . " (" . $data["views"] . " views)</a></div>";
}
}
else {
if(@$GLOBALS['result'] === "yes") {
}
else {
die("No results.");
}
// $x2 = count($videos);
// echo($x2);
// $x2 = $x2 - 1;
// echo($x2);
// if($x2 === 0) {
// die("No results.");
// }
// echo $id . ": No results.<br>";
}
}
/*
foreach ($json->people as $item) {
if ($item->id == "8097") {
echo $item->content;
}
}
*/