forked from Talishar/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubmitChat.php
More file actions
83 lines (68 loc) · 3.33 KB
/
SubmitChat.php
File metadata and controls
83 lines (68 loc) · 3.33 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
<?php
include "Libraries/HTTPLibraries.php";
include "Libraries/SHMOPLibraries.php";
SetHeaders();
$gameName = $_GET["gameName"];
if (!IsGameNameValid($gameName)) {
echo ("Invalid game name.");
exit;
}
$playerID = $_GET["playerID"];
$authKey = $_GET["authKey"];
session_start();
if ($authKey == "") $authKey = $_COOKIE["lastAuthKey"];
$targetAuthKey = "";
if ($playerID == 1 && isset($_SESSION["p1AuthKey"])) $targetAuthKey = $_SESSION["p1AuthKey"];
else if ($playerID == 2 && isset($_SESSION["p2AuthKey"])) $targetAuthKey = $_SESSION["p2AuthKey"];
if ($targetAuthKey != "" && $authKey != $targetAuthKey) exit;
$uid = "-";
if (isset($_SESSION['useruid'])) $uid = $_SESSION['useruid'];
if($uid == "starmorgs") exit;
$displayName = ($uid != "-" ? $uid : "Player " . $playerID);
$chatText = "";
if (tryGet("quickChat")) {
$chatText = parseQuickChat($_GET["quickChat"]);
} else {
$chatText = htmlspecialchars($_GET["chatText"]);
}
//array for contributors
$contributors = array("sugitime", "OotTheMonk", "Launch", "LaustinSpayce", "Star_Seraph", "Tower", "Etasus", "scary987", "Celenar", "DKGaming");
//its sort of sloppy, but it this will fail if you're in the contributors array because we want to give you the contributor icon, not the patron icon.
if(isset($_SESSION["isPatron"]) && isset($_SESSION['useruid']) && !in_array($_SESSION['useruid'], $contributors)) $displayName = "<img title='I am a patron of Talishar!' style='margin-bottom:2px; margin-right:-2px; height:18px;' src='./images/patronHeart.webp' /> " . $displayName;
//This is the code for Contributor's icon.
if(isset($_SESSION['useruid']) && in_array($_SESSION['useruid'], $contributors)) $displayName = "<img title='I am a contributor to Talishar!' style='margin-bottom:2px; margin-right:-2px; height:18px;' src='./images/copper.webp' /> " . $displayName;
//This is the code for PvtVoid Patreon
if(isset($_SESSION["isPvtVoidPatron"]) || isset($_SESSION['useruid']) && in_array($_SESSION['useruid'], array("PvtVoid"))) $displayName = "<img title='I am a patron of PvtVoid!' style='margin-bottom:5px; margin-right:-2px; height:18px;' src='./images/patronEye.webp' /> " . $displayName;
$filename = "./Games/" . $gameName . "/gamelog.txt";
$handler = fopen($filename, "a");
$output = "<span style='font-weight:bold; color:<PLAYER" . $playerID . "COLOR>;'>" . $displayName . ": </span>" . $chatText;
fwrite($handler, $output . "\r\n");
if (GetCachePiece($gameName, 11) >= 3) fwrite($handler, "The lobby is reactivated.\r\n");
fclose($handler);
GamestateUpdated($gameName);
if ($playerID == 1) SetCachePiece($gameName, 11, 0);
function parseQuickChat($inputEnum)
{
switch($inputEnum) {
case "1": return "Hello";
case "2": return "Good luck, have fun";
case "3": return "Are you there?";
case "4": return "Be right back";
case "5": return "Can I undo?";
case "6": return "Do you want to undo?";
case "7": return "Good game!";
case "8": return "Got to go";
case "9": return "I think there is a bug";
case "10": return "No";
case "11": return "No problem!";
case "12": return "Okay!";
case "13": return "Refresh the page";
case "14": return "Sorry!";
case "15": return "Thanks!";
case "16": return "Thinking... Please bear with me!";
case "17": return "Want to Chat?";
case "18": return "Whoops!";
case "19": return "Yes";
default: return "";
};
}