-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
115 lines (111 loc) · 4.4 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
<?php
$line = date('Y-m-d H:i:s') . " - " . $_SERVER['REMOTE_ADDR'];
file_put_contents('visitors.log', $line . PHP_EOL, FILE_APPEND);
if(array_key_exists('HTTP_REFERER', $_SERVER)) {
$line = date('Y-m-d H:i:s') . " - " . $_SERVER['HTTP_REFERER'];
file_put_contents('referer.log', $line . PHP_EOL, FILE_APPEND);
}
include("config.php");
include("site_functions.php");
$version = 1.22;
$conn = mysqli_connect($servername, $username, $password, $database);
$user = logIn();
$table = strtolower(filterStringForSqlEntities(gvfw('table', "user")));
$errors = "";
$content = "";
$action = gvfw("action");
if ($action == "login") {
loginUser();
} else if ($action == "logout") {
logOut();
header("Location: ?action=login");
}
if(!$user) {
if(beginswith(strtolower($action), "create")) {
$errors = createUser();
if($errors == ""){
//die("ww");
header("Location: ?action=login");
}
}
if(gvfa("password", $_POST) != "") {
$content .= "<div class='genericformerror'>The credentials you entered have failed.</div>";
}
if (($table == "user" || !is_null($errors)) && $action == "startcreate" ) {
$content .= "<div class='header'>Creating an Account</div>";
$content .= newUserForm($errors);
}
if($action != "startcreate" && $action != "create user"){
$content .= "<div class='info'>You can play complete games without an account. Creating an account gives you more features.</div>";
$content .= loginForm();
}
} else {
if($user) {
$content .= "<div class='loggedin'>You are logged in as <b>" . $user["email"] . "</b> <div class='basicbutton'><a href=\"?action=logout\">logout</a></div></div>\n";
$encryptedUser = encryptLongString($user["user_id"], $encryptionPassword);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<script src='spellingbee.js?v=<?php echo $version?>'></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spelling Bee</title>
<link rel='stylesheet' href='spellingbee.css?v=<?php echo $version?>'>
<link rel="icon" type="image/x-icon" href="./favicon.ico" />
</head>
<body>
<div class="centered-div" id="top-div">
<div id="login" >
<?php echo $content; ?>
</div>
<div id="message" ></div>
<div id="yesterdayanswers" onclick="this.style.display='none'"></div>
<div id="links" >
<a href='javascript:yesterday()'>yesterday's answers</a><br/>
<a href='javascript:showLevels()'>show levels</a><br/>
<a href='javascript:showStats()'>show your stats</a><br/>
<a href='javascript:showHints()'>show hints</a><br/>
<a href='javascript:showOthers()'>show others</a><br/>
<br/><br/>
<a href='https://github.com/judasgutenberg/networked_spellingbee' target='_new'>source code</a><br/>
</div>
<div id="levellist" onclick="this.style.display='none'"></div>
<div id="stats" onclick="this.style.display='none'"></div>
<div id="hints" onclick="this.style.display='none'"></div>
<div id="others"></div>
<div id="foundwordslabel" >Words You Have Found</div>
<div id="config"><input onchange='updateFoundWords()' type='checkbox' id='sortAlphabetically'/>sort alphabetically</div>
<div id="foundwords" ><div id="foundwords1" ></div><div id="foundwords2" ></div></div>
<div id="score" class='score'></div>
<div id="currentword"></div>
<div id="communicationmessage" >
<div id='receivedmessage' class='receivedmessage'></div>
<form>
<div>
<textarea onfocus='allowKeyboardInput = 0' onblur='allowKeyboardInput = 1' id='sendmessage' style='width:280px;height:100px'></textarea>
<button onclick='return(sendMessage())'>send</button>
</div>
</form>
</div>
</div>
<div id="hexagon-container"></div>
<div class="centered-div" id="top-div">
<div class='buttons'>
<button class='largebutton' data-key="Backspace" onclick='return(deleteLetter())' >delete</button>
<button class='largebutton' data-key="Enter" onclick='return(enterWord())' >enter</button>
<button class='largebutton' data-key=" " onclick='return(shuffle())' >shuffle</button>
</div>
<script>
<?php
if($user){
echo "let auth = '" . $encryptedUser . "';". PHP_EOL;
} else {
echo "let auth = '';". PHP_EOL;
}
?>
</script>
</body>
</html>