-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.php
More file actions
198 lines (173 loc) · 4.33 KB
/
stats.php
File metadata and controls
198 lines (173 loc) · 4.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
define('PAGE_CACHE_EXPIRES', 10000);
define('PAGE_CACHE_FILEPATH', './.cached_stats.html');
// Get the modification time of the cached page and
// determine if it is within the expiration time
$cached = filemtime(PAGE_CACHE_FILEPATH);
$expired = ($cached !== false && $cached > (microtime(true) - PAGE_CACHE_EXPIRES));
if (!$expired) {
echo file_get_contents(PAGE_CACHE_FILEPATH);
exit();
}
ob_start();
$time = explode(' ', microtime());
$start = $time[1] + $time[0];
?><HTML>
<TITLE>IRCgregate - IRC Big Data Style</TITLE>
<BODY>Welcome to -Gamah's IRC aggregation project! <BR>
The bot is:
<?php
$check = shell_exec("ps aux | grep 'SCREEN -S bot'");
if(strstr($check,"python3")){
echo "online!";
}else{
echo "offline!";
}
header( "refresh:30");
?>
<BR>
Join irc.geekshed.net and type: "/msg statbot suggest [word/smiley] {text}" to add a word to the list!
<BR><BR>
Current channels idling:<BR>
#jupiterbroadcasting<BR>
<BR>
<BR>
<div style="float: left; margin-right: 20px">
Suggested words, last 24 hours:
<?php
$con=mysqli_connect("127.0.0.1","changeme","changeme","ircgregate");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM wordUse2");
echo "<table border='1'>
<tr>
<th>Word</th>
<th>Count</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['word'] . "</td>";
echo "<td>" . $row['count'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</div>
<div style="float: left; margin-right: 20px">
User mentions, last 24 hours:
<?php
$con=mysqli_connect("127.0.0.1","changeme","changeme","ircgregate");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM usermentions2");
echo "<table border='1'>
<tr>
<th>User</th>
<th>Times Mentioned</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['user'] . "</td>";
echo "<td>" . $row['mentions'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</div>
<div style="float: left; margin-right: 20px">
User message count, last 24 hours:
<?php
$con=mysqli_connect("127.0.0.1","changeme","changeme","ircgregate");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM userWordCount2");
echo "<table border='1'>
<tr>
<th>User</th>
<th>Messages</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td><a href=\"http://gamah.net/ircgregate/usermessages.php?user=" . $row['user'] . "\">" . $row['user'] . "</a></td>";
echo "<td>" . $row['messages'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
<BR>
<BR>
</div>
<div style="float: left; margin-right: 20px">
Hyperlinks posted, last 24 hours:
<?php
$con=mysqli_connect("127.0.0.1","changeme","changeme","ircgregate");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM hyperlinks");
echo "<table border='1'>
<tr>
<th>Url</th>
<th>Count</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td><a href=\"" . $row['url'] . "\">" . substr($row['url'], 0, 40) . "</a></td>";
echo "<td>" . $row['Count'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
<BR>
<BR>
</div>
<div style="float: left; margin-right: 20px">
Smiley count, last 24 hours:
<?php
$con=mysqli_connect("127.0.0.1","changeme","changeme","ircgregate");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM smileyuse");
echo "<table border='1'>
<tr>
<th>Smiley</th>
<th>Count</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['smiley'] . "</a></td>";
echo "<td>" . $row['count'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
<BR>
<BR>
<?php
$time = explode(' ', microtime());
$finish = $time[1] + $time[0];
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.';
?>
<BR>
<BR>
</div>
</BODY>
</HTML>
<?php
file_put_contents(PAGE_CACHE_FILEPATH, ob_get_contents());
ob_end_flush();