-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathnewthread.php
343 lines (317 loc) · 13.6 KB
/
newthread.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<?php
require 'lib/function.php';
$forum = $sql->fetchq("SELECT * FROM forums WHERE id=$id");
$windowtitle = "$boardname -- $forum[title] -- New Thread";
$specialscheme = $forum['specialscheme'];
// Stop this insanity. Never index newthread.
$meta['noindex'] = true;
require 'lib/layout.php';
$forumid=$id;
$fonline=fonlineusers($forumid);
$header=makeheader($header1,$headlinks,$header2 ." $tblstart$tccell1s>$fonline$tblend");
$smilies=readsmilies();
replytoolbar(1);
/*
if (false && $id == 27) { //trash forum
print "$header
<br>
$tblstart
$tccell1>
No. Stop that, you idiot.
</td>
$tblend
$footer";
die();
}
if ($forum['nopolls'] && $poll) {
print "$header
<br>
$tblstart
$tccell1>
A for effort, but F for still failing.
</td>
$tblend
$footer";
die();
}
*/
print $header;
if($poll) {
$c=1;
$d=0;
while($chtext[$c+$d] || $c < $_POST['count']) {
if($remove[$c+$d]) $d++;
else {
$choices.="Choice $c: $inpt=chtext[$c] SIZE=30 MAXLENGTH=255 VALUE=\"".stripslashes(htmlspecialchars($chtext[$c+$d]))."\">   Color: $inpt=chcolor[$c] SIZE=7 MAXLENGTH=25 VALUE=\"".stripslashes(htmlspecialchars($chcolor[$c+$d]))."\">   <INPUT type=checkbox class=radio name=remove[$c] value=1> Remove<br>";
$c++;
}
}
$choices.="Choice $c: $inpt=chtext[$c] SIZE=30 MAXLENGTH=255>   Color: $inpt=chcolor[$c] SIZE=7 MAXLENGTH=25><br>$inps=paction VALUE=\"Submit changes\"> and show $inpt=count size=4 maxlength=2 VALUE=\"".stripslashes(htmlspecialchars(($_POST['count']) ? $_POST['count'] : $c))."\"> options";
if($mltvote) $checked1='checked';
else $checked0='checked';
}
$posticons=file('posticons.dat');
for($i=0;$posticons[$i];$i++) {
if($iconid==$i) $checked='checked';
$posticonlist.="$radio=iconid value=$i $checked> <IMG SRC=$posticons[$i] HEIGHT=15 WIDTH=15> ";
$checked='';
if(($i+1)%10==0) $posticonlist.='<br>';
}
if(!$iconid or $iconid==-1) $checked='checked';
$posticonlist.="
<br>$radio=iconid value=-1 $checked> None
Custom: $inpt=custposticon SIZE=40 MAXLENGTH=100 VALUE=\"". stripslashes($custposticon) ."\">
";
if ($nosmilies) $nosmilieschk = " checked";
if ($nohtml) $nohtmlchk = " checked";
if ($nolayout) $nolayoutchk = " checked";
$form=(!$poll?"
<tr>$tccell1><b>Thread icon:</td> $tccell2l colspan=2>$posticonlist</td></tr>
<tr>$tccell1><b>Thread title:</td>$tccell2l colspan=2>$inpt=subject SIZE=40 MAXLENGTH=100 VALUE=\"". stripslashes($subject) ."\"></td></tr>
<tr>$tccell1><b>Post:</td>$tccell2l width=800px valign=top>".replytoolbar(2)."
$txta=message ROWS=21 COLS=$numcols style=\"width: 100%; max-width: 800px; resize:vertical;\">". stripslashes(htmlspecialchars($message)) ."</TEXTAREA></td>
$tccell2l width=*>".moodlist($moodid)."</td></tr>
<tr>$tccell1> </td>$tccell2l colspan=2>
$inph=action VALUE=postthread>
$inph=id VALUE=$id>
$inps=submit VALUE=\"Submit thread\">
$inps=preview VALUE=\"Preview thread\"></td></tr>
<tr>
$tccell1><b>Options:</b></td>$tccell2l colspan=2>
$inpc=\"nosmilies\" id=\"nosmilies\" value=\"1\"$nosmilieschk><label for=\"nosmilies\">Disable Smilies</label> -
$inpc=\"nolayout\" id=\"nolayout\" value=\"1\"$nolayoutchk><label for=\"nolayout\">Disable Layout</label> -
$inpc=\"nohtml\" id=\"nohtml\" value=\"1\"$nohtmlchk><label for=\"nohtml\">Disable HTML</label></td></tr><tr>
<!-- </FORM> -->
":"
<tr>$tccell1><b>Poll icon:</td> $tccell2l colspan=2>$posticonlist</td></tr>
<tr>$tccell1><b>Poll title:</td> $tccell2l colspan=2>$inpt=subject SIZE=40 MAXLENGTH=100 VALUE=\"". htmlspecialchars(stripslashes($subject)) ."\"></td></tr>
<tr>$tccell1><b>Question:</td> $tccell2l colspan=2>$inpt=question SIZE=60 MAXLENGTH=255 VALUE=\"". htmlspecialchars(stripslashes($question)) ."\"></td></tr>
<tr>$tccell1><b>Briefing:</td> $tccell2l colspan=2>$txta=briefing ROWS=2 COLS=$numcols style=\"resize:vertical;\">". htmlspecialchars(stripslashes($briefing)) ."</TEXTAREA></td></tr>
<tr>$tccell1><b>Multi-voting:</td>$tccell2l colspan=2>$radio=mltvote value=0 $checked0> Disabled   $radio=mltvote value=1 $checked1> Enabled</td></tr>
<tr>$tccell1><b>Choices:</td> $tccell2l colspan=2>$choices</td></tr>
<tr>$tccell1><b>Post:</td>$tccell2l width=800px valign=top>".replytoolbar(2)."
$txta=message ROWS=21 COLS=$numcols style=\"width: 100%; max-width: 800px; resize:vertical;\">". htmlspecialchars(stripslashes($message)) ."</TEXTAREA></td>
$tccell2l width=*>".moodlist($moodid)."</td></tr>
<tr>
$tccell1> </td>$tccell2l colspan=2>
$inph=action VALUE=postthread>
$inph=id VALUE=$id>
$inph=poll VALUE=1>
$inps=submit VALUE=\"Submit poll\">
$inps=preview VALUE=\"Preview poll\"></td>
<tr>
$tccell1><b>Options:</b></td>$tccell2l colspan=2>
$inpc=\"nosmilies\" id=\"nosmilies\" value=\"1\"$nosmilieschk><label for=\"nosmilies\">Disable Smilies</label> -
$inpc=\"nolayout\" id=\"nolayout\" value=\"1\"$nolayoutchk><label for=\"nolayout\">Disable Layout</label> -
$inpc=\"nohtml\" id=\"nohtml\" value=\"1\"$nohtmlchk><label for=\"nohtml\">Disable HTML</label></td></tr><tr>
<!-- </FORM> -->
");
if(!$_POST['action'] or $_POST['paction']) {
print "
$fonttag<a href=index.php>$boardname</a> - <a href=forum.php?id=$forumid>".$forum['title']."</a>
<form action=newthread.php name=replier method=post autocomplete=\"off\">
$tblstart
";
if($log and $forums[$id]['minpowerthread']>$power) {
print "$tccell1>Sorry, but you are not allowed to post";
if($banned) print ", because you are banned from this board.<br>".redirect("forum.php?id=$id",'return to the forum',0);
else print ' in this restricted forum.<br>'.redirect('index.php','return to the board',0);
}
else {
if ($log) {
$username=$loguser['name'];
$passhint = 'Alternate Login:';
$altloginjs = "<a href=\"#\" onclick=\"document.getElementById('altlogin').style.cssText=''; this.style.cssText='display:none'\">Use an alternate login</a>
<span id=\"altlogin\" style=\"display:none\">";
}
else {
$username = '';
$passhint = 'Login Info:';
$altloginjs = "<span>";
}
print "
<body onload=window.document.REPLIER.subject.focus()>
$tccellh width=150> </td>$tccellh colspan=2> <tr>
$tccell1><b>{$passhint}</td> $tccell2l colspan=2>
{$altloginjs}
<b>Username:</b> $inpt=username VALUE=\"".htmlspecialchars($username)."\" SIZE=25 MAXLENGTH=25 autocomplete=\"off\">
<!-- Hack around autocomplete, fake inputs (don't use these in the file) -->
<input style=\"display:none;\" type=\"text\" name=\"__f__usernm__\">
<input style=\"display:none;\" type=\"password\" name=\"__f__passwd__\">
<b>Password:</b> $inpp=password SIZE=13 MAXLENGTH=64 autocomplete=\"off\">
</span><tr>";
print $form;
}
print "
</table>
</table>
</form>
$fonttag<a href=index.php>$boardname</a> - <a href=forum.php?id=$forumid>".$forum['title']."</a>
".replytoolbar(4);
}
if($_POST['action']=='postthread' and !$_POST['paction']) {
print "<br>$tblstart";
if ($log && !$password)
$userid = $loguserid;
else
$userid = checkuser($username,$password);
$user=$sql->fetchq("SELECT * FROM users WHERE id=$userid");
if($user['powerlevel']<0) $userid=-1;
// can't be posting too fast now
$limithit = $user['lastposttime'] < (ctime()-30);
// can they post in this forum?
$authorized = $user['powerlevel'] >= $forum['minpowerthread'];
// does the forum exist?
$forumexists = $forum['title'];
if($userid!=-1 && $subject && $message && $forumexists && $authorized && $limithit) {
$msg=$message;
// squot(0,$msg);
$sign=$user['signature'];
$head=$user['postheader'];
// improved post backgrounds
if($user['postbg']) {
$head = "<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><td valign=top background=\"$user[postbg]\">$head";
$sign = "$sign</td></table>";
}
$numposts = $user['posts'] + 1;
$numdays = (ctime()-$user['regdate'])/86400;
$tags = array();
$msg = doreplace($msg, $numposts, $numdays, $username, $tags);
$rsign = doreplace($sign, $numposts, $numdays, $username);
$rhead = doreplace($head, $numposts, $numdays, $username);
$tagval = $sql->escape(json_encode($tags));
$posticons = file('posticons.dat');
$posticon = $posticons[$iconid];
$currenttime = ctime();
$postnum = $numposts;
if($iconid == -1) $posticon='';
if($custposticon) $posticon = $custposticon;
if($submit) {
mysql_query("UPDATE `users` SET `posts` = $numposts, `lastposttime` = '$currenttime' WHERE `id` = '$userid'");
if (filter_bool($nolayout)) {
$headid = 0;
$signid = 0;
} else {
$headid=getpostlayoutid($head);
$signid=getpostlayoutid($sign);
}
mysql_query("INSERT INTO `threads` (`forum`, `user`, `views`, `closed`, `title`, `icon`, `replies`, `firstpostdate`, `lastpostdate`, `lastposter`) ".
"VALUES ('$id', '$userid', '0', '0', '$subject', '$posticon', '0', '$currenttime', '$currenttime', '$userid')");
$t = mysql_insert_id();
mysql_query("INSERT INTO `posts` (`thread`, `user`, `date`, `ip`, `num`, `headid`, `signid`, `moodid`) VALUES ('$t', '$userid', '$currenttime', '$userip', '$postnum', '$headid', '$signid','". $_POST['moodid'] ."')");
$pid=mysql_insert_id();
$options = intval($nosmilies) . "|" . intval($nohtml);
if($pid) mysql_query("INSERT INTO `posts_text` (`pid`, `text`, `tagval`, `options`) VALUES ('$pid', '$msg', '$tagval', '$options')");
mysql_query("UPDATE `forums` SET `numthreads` = `numthreads` + 1, `numposts` = `numposts` + 1, `lastpostdate` = '$currenttime', `lastpostuser` = '$userid', `lastpostid` = '$pid' WHERE id=$id");
if(!$poll) {
print "
$tccell1>Thread posted successfully!
<br>".redirect("thread.php?id=$t", stripslashes($subject), 0).$tblend;
xk_ircout("thread", $user['name'], array(
'forum' => $forum['title'],
'fid' => $forum['id'],
'thread' => str_replace("<", "<", $subject),
'pid' => $pid,
'pow' => $forum['minpower'],
));
}
else {
mysql_query("INSERT INTO `poll` (`question`, `briefing`, `closed`, `doublevote`) VALUES ('$question', '$briefing', '0', '$mltvote')");
$p=mysql_insert_id();
mysql_query("UPDATE `threads` SET `poll` = '$p' where `id` = '$t'");
$c=1;
while($chtext[$c]){
mysql_query("INSERT INTO `poll_choices` (`poll`, `choice`, `color`) VALUES ('$p', '$chtext[$c]', '$chcolor[$c]')");
$c++;
}
print "
$tccell1>Poll created successfully!
<br>".redirect("thread.php?id=$t", stripslashes($subject), 0).$tblend;
xk_ircout("poll", $user['name'], array(
'forum' => $forum['title'],
'fid' => $forum['id'],
'thread' => str_replace("<", "<", $subject),
'pid' => $pid,
'pow' => $forum['minpower'],
));
}
}
else {
if($posticon) $posticon1="<img src='". stripslashes($posticon) ."' height=15 align=absmiddle>";
if($poll) {
for($c=1;$chtext[$c];$c++) {
$chtext[$c]=stripslashes($chtext[$c]);
$chcolor[$c]=stripslashes($chcolor[$c]);
$hchoices.="$inph=chtext[$c] VALUE=\"".htmlspecialchars($chtext[$c])."\">$inph=chcolor[$c] VALUE=\"".htmlspecialchars($chcolor[$c]).'">';
$pchoices.="
$tccell1l width=20%>$chtext[$c]</td>
$tccell2l width=60%><table cellpadding=0 cellspacing=0 width=50% bgcolor='$chcolor[$c]'><td> </table></td>
$tccell1 width=20%>$fonttag ? votes, ??.?%<tr>
";
}
$mlt=($mltvote?'enabled':'disabled');
$subject = htmlspecialchars(stripslashes($subject));
$question = htmlspecialchars(stripslashes($question));
$briefing = htmlspecialchars(stripslashes($briefing));
$pollpreview="
<td colspan=3 class='tbl tdbgc center font'><b>". $question ."<tr>
$tccell2ls colspan=3>". $briefing ."<tr>
$pchoices
$tccell2ls colspan=3>Multi-voting is $mlt.
$tblend<br>$tblstart
";
}
loadtlayout();
$ppost=$user;
$ppost['uid']=$userid;
$ppost['num']=$postnum;
$ppost['posts']++;
$ppost['lastposttime']=$currenttime;
$ppost['date']=$currenttime;
//$ppost['headtext']=$rhead;
//$ppost['signtext']=$rsign;
if ($nolayout) {
$ppost['headtext'] = "";
$ppost['signtext'] = "";
}
else {
$ppost['headtext']=$rhead;
$ppost['signtext']=$rsign;
}
$ppost['moodid']=$_POST['moodid'];
$ppost['text']=stripslashes($message);
$ppost['options'] = $_POST['nosmilies'] . "|" . $_POST['nohtml'];
if($isadmin) $ip=$userip;
$threadtype=($poll?'poll':'thread');
print "
<body onload=window.document.REPLIER.message.focus()>
$tccellh>".($poll?'Poll':'Thread')." preview
$tblend$tblstart
$pollpreview
$tccell2l>$posticon1 <b>". stripslashes($subject) ."</b>
$tblend$tblstart
".threadpost($ppost,1)."
$tblend<br>$tblstart
<FORM ACTION=newthread.php NAME=REPLIER METHOD=POST>
$tccellh width=150> </td>$tccellh colspan=2> <tr>
$inph=username VALUE=\"".htmlspecialchars($username)."\">
$inph=password VALUE=\"".htmlspecialchars($password)."\">
$form
</td></FORM>
$tblend
";
}
}
else {
$reason = "You haven't entered your username and password correctly.";
if (!$limithit) $reason = "You are trying to post too rapidly.";
if (!$message) $reason = "You haven't entered a message.";
if (!$subject) $reason = "You haven't entered a subject.";
if (!$authorized) $reason = "You aren't allowed to post in this forum.";
print "
$tccell1>Couldn't post the thread. $reason
<br>".redirect("forum.php?id=$id", $forum[title], 2).$tblend;
}
}
print $footer;
printtimedif($startingtime);