-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_reply.php
298 lines (211 loc) · 8.77 KB
/
add_reply.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
<?php
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// TextfileBB
// Website: http://tfbb.jcink.com
//
// Modify freely, as long as you're not turning the forum
// into a board service of any form. Please ask for permission
// first to redistribute any of the TextfileBB code.
//
// Thanks.
//
// ----------------------------------------------------------------------------------------
// Module: add_reply.php - Last update: September 28, 2006
// ----------------------------------------------------------------------------------------
//
// Santized and Dereglobed: OK
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
//
// Is username posted?
//
require("header.php");
require("stopper.php");
require("clean_message.php");
$sticky='';
$topicid=$_GET['topicid'];
if(!is_numeric($_GET['topicid'])) error("Invalid topic id.");
if(file_exists("./permissions/{$forum}.php")) {
require("./permissions/{$forum}.php");
} else {
error("Invalid Forum ID");
}
if ($allow_posting == 'No') {
error("This forum is read only, no posts may be made.");
}
if ($can_reply["$status"] != allowed) {
error("You do not have permission to make replies in this forum");
}
if ($can_read["$status"] != allowed) {
error("You do not have permission to read this forum");
}
if(file_exists("./locked/{$forum}_{$topicid}.lock")) {
error("This topic has been locked by an admin. Sorry, you will be unable to reply.");
}
if (file_exists("./forumposts_{$forum}/sticky/{$topicid}.php")) {
$sticky = "sticky/";
}
if (file_exists("./forumposts_{$forum}/old/{$topicid}.php")) {
$sticky = "old/";
}
$topic_file_s = @file("./forumposts_{$forum}/{$sticky}{$topicid}.php");
if(!$topic_file_s) error("Invalid topic ID");
if($_GET['tr']) {
?>
<div align='center'>
<div class=tableborder><table width=100% cellpadding='4' cellspacing='1'><td class=arcade1><a href=index.php?do=idx><?php echo "$forum_name" ?></a> » <a href='topicdisplay.php?forum=<?php echo "$forum"; ?>&show=<?php echo "$showtopics"; ?>'><?php if ($forum) { echo "$forum"; } ?></a> » Replying</td></table></div><br>
<div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Adding Reply</td><tr>
<td class=arcade1 valign="top"><div align=center><form action='add_reply.php?topicid=<?php echo $topicid ?>&forum=<?php echo "$forum"; ?>' method=post enctype="multipart/form-data" name="postbox">
<?php
displaybbcode();
?>
<br><textarea cols=60 rows=20 class=input name=message>
<?php
if ($_GET['quote']) {
$quote=$_GET['quote'];
$g = is_a_quote($quote);
if ($g==true) {
$quoted = eregi_replace("<br>", "\n", $topic_file_s[$quote]);
echo "[quote] $quoted [/quote]";
}
}
?>
</textarea><br><br>
<?php
displayemotes();
?>
<br>
<?php
if ($uploads_enabled == "yes") {
require("./permissions/{$forum}.php");
if ($can_upload["$status"] == allowed) {
echo 'Attach File: <input type="file" name="swforpic"> <br /><br>';
}
}
?>
<input type=submit value='Add Reply'></div>
</td>
</table>
</div>
<?php
require("footer.php");
die();
}
$ipa = $_SERVER['REMOTE_ADDR'];
if($_POST['message']) {
$register_id = file("./id_data/member_names_num.txt");
$result = array_search_ci($register_id, $acfile);
$post_write = fopen("./forumposts_{$forum}/{$sticky}{$topicid}.php", "a");
require("./groups/{$status}.php");
if ($can_reply_to_others_topics == "No") {
$checkuser = @file("./forumposts_{$forum}/{$sticky}{$topicid}.php");
if ($result != rtrim($checkuser[3])) {
error("Your group does not allow you to reply to topics that are not your own");
}
}
if ($can_reply_to_own_topic == "No") {
$checkuser = file("./forumposts_{$forum}/{$sticky}{$topicid}.php");
if ($result == rtrim($checkuser[3])) {
error("Your group does not allow you to reply to your own topics");
}
}
if ($result != "") {
$get = $register_id[$result];
} else {
error("Error.");
}
$date = date("m.d.y");
if (strlen($_POST['message']) == 0) {
error("No message was typed");
}
if (!$_FILES['swforpic']['name']) { // Very basic. Just send it.
fwrite($post_write, "$result\n$_SERVER[REMOTE_ADDR]``$date\n$message\n");
fclose($post_write);
} else {
if ($can_upload["$status"] != allowed) {
error("You do not have permission to attach files.");
}
$folder = "./uploads/";
$temporary = $_FILES['swforpic']['tmp_name'];
$realfilename = $_FILES['swforpic']['name'];
$extension = uploaderprotect($realfilename);
$temporary=str_replace(" ", "_", $temporary);
$realfilename=str_replace(" ", "_", $realfilename);
//
// Check the filesize, as defined in forum_conf.php
//
require("./groups/{$status}.php");
if ($_FILES['swforpic']['size'] > $group_max_upload_size) {
unlink($_FILES['swforpic']['tmp_name']);
echo "<div align='center'><div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Attachment</td><tr><td class=arcade1 valign='top'><div align=center>File <b>failed to upload.</b> It is too large to be attached. </div></td></table></div><br>";
echo "<br>";
require("footer.php");
die();
}
//
// Check to see if a file with the exact same name exists
//
if(file_exists("./uploads/$realfilename")) {
echo "<div align='center'><div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Attachment</td><tr><td class=arcade1 valign='top'><div align=center>File <b>failed to upload.</b> This is because a file with the same name as this one has already been uploaded. Please rename the file to a different name ( ex: pic.gif rename to pic1.gif ) </div></td></table></div><br>";
echo "<br>";
require("footer.php");
die();
}
//
// if there are no problems...
//
@move_uploaded_file($temporary, $folder.$realfilename) or die("Problem writing the Attachment. Please contact the admin. ");
echo "<div align='center'><div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Attachment</td><tr><td class=arcade1 valign='top'><div align=center>File $realfilename attached.</div></td></table></div><br><tr><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td></tr>";
$filename = "./uploads/$realfilename";
$thesize = filesize($filename);
$thedividedsize = round($thesize / 1024 ,2);
if($extension != "gif" && $extension !="jpg" && $extension != "bmp" && $extension != "jpeg" && $extension != "png") {
fwrite($post_write, "$result\n$_SERVER[REMOTE_ADDR]``$date\n$message<br><br>[attachment]".$realfilename."[/attachment] \n");
} else {
fwrite($post_write, "$result\n$_SERVER[REMOTE_ADDR]``$date\n$message<br><br>[b]Attachment:[/b]<br>[img]uploads/".$realfilename."[/img] \n");
}
fclose($post_write);
$ulog= fopen("upload_log.php", "a");
fwrite($ulog, "$realfilename``$_SERVER[REMOTE_ADDR]``$result``$topicid``$date``$thedividedsize kb\n");
}
}
if (strlen($_POST['message']) == 0) {
error("No message was typed");
}
if ($sticky == "sticky/") {
@fopen("./forumposts_{$forum}/sticky/tmp.txt", "a");
@unlink("./forumposts_{$forum}/sticky/tmp.txt");
}
// Add to their postcount
if ($increase_postcount != No) {
$newpostcount=$postcount+1;
$postcountupdate ="<?php\n\$email = '$email';\n\$skinchoice = '$skinchoice';\n\$yourpassword = '$yourpassword';\n\$status = '$status';\n\$avatar = '$avatar';\n\$sig = '$sig';\n\$title = '$title';\n\$signup_ipa = '$signup_ipa';\n\$msn = '$msn';\n\$yim = '$yim';\n\$aim='$aim';\n\$icq = '$icq';\n\$www='$www';\n\$notepad = '$notepad';\n\$birthday = '$birthday';\n\$postcount = '$newpostcount';\n?>";
$fp = fopen("./accounts/{$cookies}_user.php","w+");
fwrite($fp, $postcountupdate);
fclose($fp);
}
//
// Add to the forum total postcount
//
$TxtFileCount = file("./postcounts/{$forum}.txt");
eraseandreplace("./postcounts/{$forum}.txt", 1, $TxtFileCount[1]+1);
$q=fopen("./forumposts_{$forum}/f.txt","a");
fclose($q);
unlink("./forumposts_{$forum}/f.txt");
if ($sticky == "old/") {
rename("./forumposts_{$forum}/old/{$topicid}.php", "./forumposts_{$forum}/{$topicid}.php");
}
?>
<div align='center'>
<div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Successful Reply</td><tr>
<td class=arcade1 valign="top"><div align=center>Your reply was submitted successfully.
<?php
echo "<br><br>[ <a href='topicdisplay.php?forum=$forum'><u>Return to forums</u></a> | <a href='viewtopic.php?topicid=$topicid'><u>Return to Topic</u></a> ]<br>";
?>
</div>
</td>
</table>
</div>
<br>
<?php
require("footer.php");
?>