-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquote.php
138 lines (127 loc) · 3.12 KB
/
quote.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
require_once("./class.MySQL.php");
require_once("./sanitizer.php");
require_once("./util.php");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<?php require_once("./script.php") ?>
</head>
<body>
<div id="content">
<?php
session_start();
if (!is_numeric($_GET['id'])) {
http_response_code(400);
echo "Bad ID.";
exit;
}
$db = new MySQL();
$i = 1;
$query = "SELECT * FROM qdb WHERE id = " . sanitize($_GET['id']);
$result = $db->setRunBuild($query);
#print_r($result);
if (! $result) {
http_response_code(404);
echo "Bad ID.";
exit;
}
?>
<span id='header'>
<a href="/">Back to quotes list</a>
<a href="./update.php?id=<?php echo $_GET['id'] ?>">Update</a>
<?php
if (isset($_SESSION['recaptcha_score'])) {
echo "<script> console.log('score: " . $_SESSION['recaptcha_score'] . "')</script>";
unset($_SESSION['recaptcha_score']);
}
if (isset($_SESSION['action_message'])) {
echo $_SESSION['action_message'];
unset($_SESSION['action_message']);
}
echo "</span>";
foreach ($result as $key => $value) {
echo "<div class='quoteContainer'>\n";
echo "<div class='quoteIDBox'>\n";
echo "<a href='./quote.php?id=".$value['id']."'>#".$value['id']."</a>";
echo "<span class='quoteDate'>";
echo $value['date'];
echo "</span>";
echo "<div class='downArrow' id='".$value['id']."'>";
echo "↓";
echo "</div>";
echo "<div class='upArrow' id='".$value['id']."'>";
echo "↑";
echo "</div>";
echo "</div>"; // quote id
echo "<div class='quote' id='quote".$value['id']."'>\n";
echo "<div class='quote_interior' name='".$value['id']."'>";
$value['quote'] = str_replace("<","< ", $value['quote']);
echo str_replace("\n", "<br />", autolink($value['quote']));
echo "<br />\n";
echo "</div>";
echo "</div>\n"; // end quote div
echo "</div>\n"; // end container div
}
?>
<script>
$(".upArrow").hover(
function() {
$(this).css('color','green');
},
function() {
$(this).css('color','');
});
$(".downArrow").hover(
function() {
$(this).css('color','red');
},
function() {
$(this).css('color','');
});
$(".upArrow").click(function(event) {
var p = {};
p['id'] = $(this).attr('id');
p['verb'] = "upvote";
$.post(
'ajax_functions.php',
p,
function(data) {
var jobj = jQuery.parseJSON(data);
event.target.innerHTML = jobj.text;
}
);
});
$(".downArrow").click(function(event) {
console.log("foobar");
var p = {};
p['id'] = $(this).attr('id');
p['verb'] = "downvote";
$.post(
'ajax_functions.php',
p,
function(data) {
var jobj = jQuery.parseJSON(data);
event.target.innerHTML = jobj.text;
console.log(jobj);
}
);
});
function getRandomInt(min,max){
if((typeof min === "number") && Math.floor(min) === min && (typeof max === "number") && Math.floor(max) === max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}else{
//logger.error('min or max number is not a valid number');
throw 'min or max number is not a valid number';
}
}
</script>
<?php
echo "copyright LOLOLOL valve corporation";
echo "</div>"; // end content div
echo "</body></html>";
?>
</body>
</html>