-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchatter.php
278 lines (227 loc) · 9.6 KB
/
chatter.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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php
/////////////////////////////////////////////////////////////////////////////////////
// xbtit - Bittorrent tracker/frontend
//
// Copyright (C) 2004 - 2020 xbtitFM Team
//
// This file is part of xbtitFM.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
////////////////////////////////////////////////////////////////////////////////////
$HERE=dirname(__FILE__);
require_once("$HERE/include/functions.php");
require_once("$HERE/fun.php");
dbconn(false);
global $CURUSER, $SITEURL, $BASEURL;
if ( ($CURUSER['edit_torrents'] >= "yes") || ($CURUSER['username'] == $row['user']) )
{
function smile() {
print "<div align='center'><table cellpadding='1' cellspacing='1'><tr>";
global $smilies, $count;
reset($smilies);
while ((list($code, $url) = each($smilies)) && $count<16) {
print("\n<td align=center><a href=\"javascript: SmileIT('".str_replace("'","\'",$code)."')\">
<img border=\"0\" src=\"images/smilies/$url\" alt=\"$code\" /></a></td>");
$count++;
}
print "</tr></table></div>";
}
//DELETE MESSAGES
if (isset($_GET['del'])){
if (is_numeric($_GET['del'])){
$query = "SELECT * FROM {$TABLE_PREFIX}chatfun WHERE msgid=".$_GET['del'] ;
$result = mysqli_query($GLOBALS['conn'], $query);
}else{
echo "invalid msg id STOP TRYING TO INJECT SQL";
exit;
}
$row = mysqli_fetch_row($result);
if ( ($CURUSER['edit_torrents'] >= "yes") || ($CURUSER['username'] == $row['user']) )
{
$query = "DELETE FROM {$TABLE_PREFIX}chatfun WHERE msgid=".$_GET['del'] ;
write_log("<B><font color=orange>Shout Deleted: </font> Deleted by ".$CURUSER['username']."</b>");
mysqli_query($GLOBALS['conn'],$query);
}
}
if (isset($_GET['empty'])){
@mysqli_query($GLOBALS['conn'], "TRUNCATE {$TABLE_PREFIX}chatfun");
}
include("include/offset.php");
//INSERT MESSAGE
$_POST['message'] = str_replace("\'","'",$_POST['message']);
$_POST['message'] = str_replace("'","\'",$_POST['message']);
$_POST['message'] = str_replace("---"," - - ",$_POST['message']);
if ($_POST['message'] > ''){
if (isset($CURUSER)){
$query = "SELECT COUNT(*) FROM {$TABLE_PREFIX}chatfun WHERE message='".$_POST['message']."' AND user='".$CURUSER['username']."' AND UNIX_TIMESTAMP()-UNIX_TIMESTAMP(time) < 30";
$result = mysqli_query($GLOBALS['conn'], $query);
$row = mysqli_fetch_row($result);
if ($row[0] == '0') {
$query = "INSERT INTO {$TABLE_PREFIX}chatfun (msgid, user, message, time, userid) VALUES (NULL, '".$CURUSER['username']."', '".($_POST['message'])."', '".time()."', '".$CURUSER['uid']."')";
mysqli_query($GLOBALS['conn'], $query);
}
}
}
//get the current theme
/*
$resheet=do_sqlquery("SELECT * FROM {$TABLE_PREFIX}style where id=".$CURUSER["style"]."");
if (!$resheet)
{
$STYLEPATH="$THIS_BASEPATH/style/xbtitFM";
$STYLEURL="$BASEURL/style/xbtitFM";
}
else
{
$resstyle=mysqli_fetch_array($resheet);
$STYLEPATH="$THIS_BASEPATH/".$resstyle["style_url"];
$STYLEURL="$BASEURL/".$resstyle["style_url"];
}
$style_css=load_css("main.css");
*/
?>
<HTML>
<HEAD>
<TITLE>Shoutbox</TITLE>
<META HTTP-EQUIV="refresh" content="300">
<link rel="stylesheet" type="text/css" href="<?php echo $STYLEURL;?>/main.css" />
</HEAD>
<body class="shoutbox_body">
<?php
if(!isset($_GET['history'])){
echo '<div class="shoutbox_contain"><table border="0" background="#ffffff" style="width: 99%; table-layout:fixed">';
}else{
echo '<div class="shoutbox_history">';
$query = "SELECT COUNT(*) FROM {$TABLE_PREFIX}chatfun";
$result = mysqli_query($GLOBALS['conn'], $query);
$row = mysqli_fetch_row($result);
echo '<div align="middle">Pages: ';
$pages = round($row[0] / 100) + 1;
$i = 1;
while ($pages > 0){
echo "<a href='".$SITEURL."/shoutbox/shoutbox.php?history=1&page=".$i."'>[".$i."]</a> ";
$i++;
$pages--;
}
echo '</div></br><table border="0" background="#ffffff" style="width: 99%; table-layout:fixed">';
}
if (isset($_GET['history'])) {
if (isset($_GET['page'])) {
if($_GET['page'] > '1') {
$lowerlimit = $_GET['page'] * 100 - 100;
$upperlimit = $_GET['page'] * 100;
}else{
$lowerlimit = 0;
$upperlimit = 100;
}
}else{
$lowerlimit = 0;
$upperlimit = 100;
}
$query = "SELECT * FROM {$TABLE_PREFIX}chatfun ORDER BY msgid DESC LIMIT ".$lowerlimit.",".$upperlimit;
}else{
$query = "SELECT * FROM {$TABLE_PREFIX}chatfun ORDER BY msgid DESC LIMIT 10";
}
$result = mysqli_query($GLOBALS['conn'], $query);
$alt = false;
while ($row = mysqli_fetch_array($result)) {
if ($alt){
echo '<tr class="shoutbox_noalt">';
$alt = false;
}else{
echo '<tr class="shoutbox_alt">';
$alt = true;
}
echo '<td style="font-size: 9px; width: 118px;">';
echo "<div align='left' style='float: left'>";
$time = $row['time'];
echo date("d/m/Y H:i:s", $time - $offset);
$bimg2 = @mysqli_fetch_array(@mysqli_query($GLOBALS['conn'], "SELECT avatar FROM {$TABLE_PREFIX}users WHERE id=$row[userid]"));
$avatar = htmlspecialchars($bimg2["avatar"]);
if (!$avatar)
$avatar = "".$STYLEURL."/images/default_avatar.gif";
echo '<center><img src="'.$avatar.'" width="50px"/></center>';
echo "</div>";
$colors = @mysqli_fetch_array(@mysqli_query($GLOBALS['conn'],"SELECT ul.prefixcolor, ul.suffixcolor FROM {$TABLE_PREFIX}users u LEFT JOIN {$TABLE_PREFIX}users_level ul ON u.id_level=ul.id WHERE u.id=$row[userid]"))or sqlerr();
if ( ($CURUSER['edit_torrents'] >= "yes") || ($CURUSER['username'] == $row['user']) )
{
echo '<div align="right" style="float: right"><a href="'.$BASEURL.'/chatter.php?del='.$row['msgid'].'" style="font-size: 8px"><img src="'.$BASEURL.'/images/delete.png"></a> <a href="'.$BASEURL.'/shoutedit.php?action=edit&msgid='.$row['msgid'].'" style="font-size: 8px"><img src="'.$BASEURL.'/images/edit.png"></a><div>';
}
$name=stripslashes($colors['prefixcolor']) . $row['user'] .stripslashes($colors['suffixcolor']);
echo '</td><td style="font-size: 12px; padding-left: 5px"><a href="'.$SITEURL.'/index.php?page=userdetails&id='.$row['userid'].'" target="_parent"><b>'.$name.':</b></a> '.nl2br(format_shout($row['message']));
echo '</td></tr>';
}
?>
</table>
</div>
<br>
<?php
//if the user is logged in, show the shoutbox, if not, dont.
if(!isset($_GET['history'])) {
if (isset($CURUSER)){
echo"<script language=javascript>
function GiveMsgBoxFocus()
{
document.shoutboxform.message.focus();
}
function PopMoreSmiles(form,name) {
newWin=window.open('./index.php?page=moresmiles&form='+form+'&text='+name,'moresmile','height=500,width=450,resizable=yes,scrollbars=yes');
if (window.focus) {newWin.focus()}
}
function ShowHistory() {
var HistoryWindow = window.open('$BASEURL/chatter.php?history=1', 'History','width=600,height=600,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no');
}
</script>";
echo "<form name='shoutboxform' action='".$BASEURL."/chatter.php' method='post'>";
echo "<CENTER><table width=100% border=0 cellpadding=1 cellspacing=1>";
echo "<tr class='shoutbox_messageboxback'>";
echo "<td width='80%' align=center>";
echo "<input type='text' size='45' maxlength='500' name='message' class='shoutbox_msgbox'>";
echo "</td>";
echo "<td>";
echo "<input type='submit' name='submit' value='Shout' class='shoutbox_shoutbtn'>";
echo "</td>";
echo "<td>";
echo "<a title=Refresh href='".$BASEURL."/chatter.php'><img border=0 src='".$BASEURL."/images/bbcode/Refresh.png' alt='refresh'></a>";
echo "<a title=Smiles href=\"javascript: PopMoreSmiles('shoutboxform','message')\"><img border='0' src='".$BASEURL."/images/smile.gif' alt='smiles'></a>";
echo "<a title=History href=\"javascript: ShowHistory();\"><img border='0' src='".$BASEURL."/images/quote.gif' alt='history'></a>";
echo "<a title=Empty href=\"chatter.php?empty\"><img border='0' src='".$BASEURL."/images/delete.png' alt='empty'></a>";
echo "</td>";
echo "</tr>";
echo "</table></CENTER>";
echo "<br><CENTER>";
shoutfun('shoutboxform','message');
echo "</CENTER>";
echo "</form>";
}else{
echo "<br /><div class='shoutbox_error'>You must login to shout.</div>";
}
}
if(!isset($_GET['history'])){
echo "</BODY></HTML>";
}else{
}
}else{
echo("<center><font color=orangered><b>Only Staff can access here!</b></font>");
}
?>