Skip to content

Commit

Permalink
Add comment functions
Browse files Browse the repository at this point in the history
  • Loading branch information
HotPizzaYT authored Jul 16, 2021
1 parent 50e4763 commit ca22aaa
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cmtFun.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?PHP
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.";
}
?>

0 comments on commit ca22aaa

Please sign in to comment.