-
Notifications
You must be signed in to change notification settings - Fork 2
/
cmtFun.php
37 lines (36 loc) · 1.07 KB
/
cmtFun.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
<?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'];
}
echo "Test";
$x = (isset($_GET["vid"]) && isset($_GET["cid"]) && isset($_GET["act"]));
if($x)
{
if(file_exists("ids/" . $_GET["vid"] . ".json")){
// File exists
$json = file_get_contents("ids/" . $_GET["vid"] . ".json");
$jsonD = json_decode($json, true);
if($_GET["act"] === "dislike"){
$jsonD["comments"][$_GET["cid"]]["dislikes"] = $jsonD["comments"][$_GET["cid"]]["dislikes"] + 1;
} else {
if($_GET["act"] === "like"){
$jsonD["comments"][$_GET["cid"]]["likes"] = $jsonD["comments"][$_GET["cid"]]["likes"] + 1;
}
}
$ldFix = json_encode($jsonD, true);
file_put_contents("ids/" . $_GET["vid"]. ".json", $ldFix);
} else {
echo "[FAIL]: Video doesn't exist.";
}
} else {
echo "Why are you here.";
}
?>