-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlog.php
More file actions
106 lines (90 loc) · 3.79 KB
/
log.php
File metadata and controls
106 lines (90 loc) · 3.79 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
define('PUN_ROOT', '/srv/http/forum/');
include PUN_ROOT.'include/common.php';
ob_start();
//error_reporting(E_ALL);
//$time_start = microtime(true);
$html_header = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Quaddicted.com Quake Map Reviews, User Activity Log</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/static/style.css" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="alternate" type="application/rss+xml" title="Quaddicted.com - Quake Singleplayer Archive and News RSS Feed" href="/?feed=rss2" />
</head>
<body>
<div id="wrapper">
EOT;
echo $html_header;
require("_header.php");
echo '<div id="content">';
$dbq = new PDO('sqlite:/srv/http/quaddicted.sqlite');
$redirect_url = "/reviews/log.php";
include("userbar.php"); // include the top login bar, provides $loggedin = true/false
if (!$loggedin) {
header('HTTP/1.0 403 Forbidden');
echo "This feature is only for registered users. Register and/or login.";
require("_footer.php");
die();
}
// number of items to fetch
if ($_GET['number']) {
if (!preg_match('/^[0-9]+$/', $_GET['number'])) {
echo "malformed number, you get 10";
$number = 10;
} else {
$number = $_GET["number"];
if ($number > 50) {
echo "number too big, you get 50";
$number = 50;
}
}
} else {
$number = 10;
}
$dbq = new SQLite3('/srv/http/quaddicted.sqlite');
echo "<h1>Latest Activity</h1>";
echo '<div style="float:left; margin:10px;"><h2>Users</h2>';
$results = $dbq->query('SELECT username FROM users ORDER BY rowid DESC LIMIT 10');
while ($row = $results->fetchArray()) {
echo "<a href=\"user.php?username=".htmlspecialchars($row['username'])."\">".htmlspecialchars($row['username'])."</a><br />\n";
}
echo '</div><div style="float:left; margin:10px;"><h2>Tags</h2>';
$results = $dbq->query('SELECT * FROM tags ORDER BY id DESC LIMIT '.$number);
while ($row = $results->fetchArray()) {
echo htmlspecialchars($row['tag'])." <small>on</small> <a href=\"".$row['zipname'].".html\">".$row['zipname']."</a> <small>by</small> ".htmlspecialchars($row['username'])."<br />\n";
}
echo '</div><div style="float:left; margin:10px;"><h2>Comments</h2>';
$results = $dbq->query('SELECT * FROM comments ORDER BY timestamp DESC LIMIT '.$number);
while ($row = $results->fetchArray()) {
echo htmlspecialchars($row['username'])." <small>on</small> <a href=\"".$row['zipname'].".html#comments\">".$row['zipname']."</a>: ";
// cut long comments
$commenttext = htmlspecialchars($row['comment']);
if (strlen($commenttext) > 100) {
echo substr($commenttext,0,100)."...";
} else {
echo $commenttext;
}
echo "<br />\n";
}
echo '</div><div style="float:left; margin:10px;"><h2>Maps</h2>';
$results = $dbq->query('SELECT zipname,author,title,date FROM maps ORDER BY id DESC LIMIT '.$number);
while ($row = $results->fetchArray()) {
echo "<small>".htmlspecialchars($row['date'])."</small> <a href=\"".$row['zipname'].".html\">".htmlspecialchars($row['zipname'])."</a> by ".htmlspecialchars($row['author'])."<br />\n";
}
echo '</div><div style="float:left; margin:10px;"><h2>Demos</h2>';
$results = $dbq->query('SELECT zipname,username,skill FROM demos ORDER BY id DESC LIMIT '.$number);
while ($row = $results->fetchArray()) {
echo "<a href=\"".$row['zipname'].".html\">".htmlspecialchars($row['zipname'])."</a> on Skill ".htmlspecialchars($row['skill'])." by ".htmlspecialchars($row['username'])."<br />\n";
}
echo "</div>";
unset($dbq);
//$time_end = microtime(true);
//$time = $time_end - $time_start;
//echo "Rendered in ".($time*1000)." ms\n";
require("_footer.php");
ob_end_flush();
?>