-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
62 lines (56 loc) · 1.69 KB
/
functions.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
<?php
function checkForLoginBypass() {
if (!$_SESSION['JokeNetLogged']) {
if ($_COOKIE["logged"]) {
print "<center><h2>FLAG-A1WL9S73NSU8S0SNDI6SADAV3</h2></center>";
} else {
header("Location: logout.php");
die();
}
}
}
function checkForBanner() {
if( isset($_SESSION['notify']) ) {
echo "<div id='notify'><b>" . $_SESSION['msg'] . "</b></div>";
unset($_SESSION['notify']);
} elseif( isset($_SESSION['error']) ) {
echo "<div id='error'><b>" . $_SESSION['msg'] . "</b></div>";
unset($_SESSION['error']);
}
unset($_SESSION['msg']);
}
function debug_to_console( $data ) {
$output = $data;
if ( is_array( $output ) )
$output = implode( ',', $output);
echo '<script>console.log("' . $output . '");</script>';
}
function printJoke( $jokeID, $jokeText, $postedBy, $rating, $timeStamp ) {
echo '
<div class="jokePost">
<b>Posted by: <a href="profile.php?user=' . htmlspecialchars($postedBy) . '">' . htmlspecialchars($postedBy) . '</a></b>
<br />' . htmlspecialchars($timeStamp) . '
<hr />
<center>
<div style="width: 80%;">
' . nl2br(htmlspecialchars($jokeText)) . '
</div>
</center>
<hr />
<form action="" method="POST">
<select name="voteVal">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input type="submit" name="vote" value="Vote!">
<input type="hidden" name="jokeNumber" value="' . $jokeID . '">
<span id="rating">Current Rating: ' . htmlspecialchars($rating) . '/5</span>
</form>
</div>
';
}
?>