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:
|
<?php
$filename = 'editpost.php';
require('./global.php');
require('./acp/lib/class_parse.php');
require('./acp/lib/class_parsecode.php');
$lang->load('POST,POSTINGS');
if (!isset($postid)) error($lang->get("LANG_GLOBAL_ERROR_FALSELINK", array('$adminmail' => $adminmail)));
$isuser = 0;
$ismod = 0;
if ($wbbuserdata['userid'] && $wbbuserdata['userid'] == $post['userid']) $isuser = 1;
if (checkmodpermissions('m_can_post_del') == 1 || checkmodpermissions('m_can_post_edit') == 1) $ismod = 1;
if (($isuser == 0 || (!checkpermissions('can_edit_own_post') && !checkpermissions('can_del_own_post')) || $thread['closed'] != 0) && $ismod == 0) access_error();
if ($ismod == 0 && $wbbuserdata['edit_posttime_limit'] != -1 && (time() - $post['posttime']) > $wbbuserdata['edit_posttime_limit'] * 60) {
error($lang->get("LANG_POST_EDITERROR1", array('$edit_posttime_limit' => $wbbuserdata['edit_posttime_limit'])));
}
$preview_window = '';
$editpost_error = '';
/* delete post */
if (isset($_POST['send']) && $_POST['send'] == 'send2') {
if ($_POST['deletepost'] == 1) {
if (($isuser == 1 && $wbbuserdata['can_del_own_post'] == 1) || checkmodpermissions("m_can_post_del")) {
if ($post['postid']) {
$db->query("DELETE FROM bb".$n."_posts WHERE postid = '$postid'");
if ($thread['replycount'] == 0) {
/* delete post & thread */
if ($thread['visible'] == 1 && $post['visible'] == 1) $db->unbuffered_query("UPDATE bb".$n."_boards SET threadcount=threadcount-1, postcount=postcount-1 WHERE boardid IN ($boardid,$board[parentlist])", 1);
$db->unbuffered_query("DELETE FROM bb".$n."_subscribethreads WHERE threadid = '$threadid'", 1);
if ($thread['pollid']) {
$db->unbuffered_query("DELETE FROM bb".$n."_polls WHERE pollid = '$thread[pollid]'", 1);
$pollvotes = " OR (id = '$thread[pollid]' AND votemode=1)";
$db->unbuffered_query("DELETE FROM bb".$n."_polloptions WHERE pollid = '$thread[pollid]'", 1);
}
else $pollvotes = '';
$db->unbuffered_query("DELETE FROM bb".$n."_votes WHERE (id = '$threadid' AND votemode=2)$pollvotes", 1);
$db->unbuffered_query("DELETE FROM bb".$n."_threads WHERE threadid = '$threadid'", 1);
$db->unbuffered_query("DELETE FROM bb".$n."_threads WHERE pollid = '$threadid' AND closed=3", 1);
if ($thread['important'] == 2) $db->unbuffered_query("DELETE FROM bb".$n."_announcements WHERE threadid = '$threadid'", 1);
/* update global threadcount & postcount */
if ($thread['visible'] == 1 && $post['visible'] == 1) $db->unbuffered_query("UPDATE bb".$n."_stats SET threadcount=threadcount-1, postcount=postcount-1", 1);
}
else {
/* delete only post */
/* for threaded view -> */
$db->unbuffered_query("UPDATE bb".$n."_posts SET parentpostid = '$post[parentpostid]' WHERE threadid = '".$threadid."' AND parentpostid = '$postid'", 1);
if ($post['visible'] == 1) {
$db->unbuffered_query("UPDATE bb".$n."_boards SET postcount=postcount-1 WHERE boardid IN ($boardid,$board[parentlist])", 1);
if ($thread['lastposttime'] <= $post['posttime']) {
$result = $db->query_first("SELECT userid, username, posttime FROM bb".$n."_posts WHERE threadid='$threadid' ORDER BY posttime DESC", 1);
$db->unbuffered_query("UPDATE bb".$n."_threads SET replycount=replycount-1, lastposttime='$result[posttime]', lastposterid='$result[userid]', lastposter='".addslashes($result['username'])."' WHERE threadid='$threadid'", 1);
}
else {
$db->unbuffered_query("UPDATE bb".$n."_threads SET replycount=replycount-1".(($post['attachmentid']) ? (", attachments=attachments-1") : (""))." WHERE threadid='$threadid'", 1);
}
/* update global postcount */
$db->unbuffered_query("UPDATE bb".$n."_stats SET postcount=postcount-1", 1);
}
}
updateBoardInfo("$boardid,$board[parentlist]", $post['posttime']);
## Start - Attachment-Mod v1.1 by Merides #####
if($wbbuserdata['externer_space_upload']==1) $ftp = attachftp_connect($ftpuser,$ftppassword);
$attachment=$db->query("SELECT * FROM bb".$n."_attachments WHERE postid = '$post[postid]'");
while($attach = $db->fetch_array($attachment))
{
if($attach['ftppath']) @ftp_delete($ftp,$ftppath."/attachment-".$attach['attachmentid'].".".$attach['attachmentextension']);
else @unlink("attachments/attachment-".$attach['attachmentid'].".".$attach['attachmentextension']);
$db->query("DELETE FROM bb".$n."_attachments WHERE attachmentid='".$attach['attachmentid']."'");
}
@ftp_quit($ftp);
## Ende - Attachment-Mod v1.1 by Merides #####
if ($board['countuserposts'] && $post['userid'] && $post['visible'] == 1) $db->unbuffered_query("UPDATE bb".$n."_users SET userposts=userposts-1 WHERE userid = '$post[userid]'", 1);
if ($thread['replycount'] == 0) header("Location: board.php?boardid=$boardid".$SID_ARG_2ND_UN);
else header("Location: thread.php?threadid=$threadid".$SID_ARG_2ND_UN);
exit();
}
}
else access_error();
}
else {
header("Location: thread.php?postid=$postid".$SID_ARG_2ND_UN."#post$postid");
exit();
}
}
if ($editpost_default_checked_0 == 1) $checked[0] = 'checked="checked"';
else $checked[0] = '';
if ($wbbuserdata['emailnotify'] == 1) $checked[1] = 'checked="checked"';
else $checked[1] = '';
if (isset($_POST['send'])) {
// post options
if (isset($_POST['parseurl'])) $parseurl = intval($_POST['parseurl']);
else $parseurl = 0;
if (isset($_POST['emailnotify'])) $emailnotify = intval($_POST['emailnotify']);
else $emailnotify = 0;
if (isset($_POST['disablesmilies'])) $disablesmilies = intval($_POST['disablesmilies']);
else $disablesmilies = 0;
if (isset($_POST['disablehtml'])) $disablehtml = intval($_POST['disablehtml']);
else $disablehtml = 0;
if (isset($_POST['disablebbcode'])) $disablebbcode = intval($_POST['disablebbcode']);
else $disablebbcode = 0;
if (isset($_POST['disableimages'])) $disableimages = intval($_POST['disableimages']);
else $disableimages = 0;
if (isset($_POST['showsignature'])) $showsignature = intval($_POST['showsignature']);
else $showsignature = 0;
if (isset($_POST['dont_append_editnote'])) $dont_append_editnote = intval($_POST['dont_append_editnote']);
else $dont_append_editnote = 0;
/* get topic & stop shooting */
$topic = wbb_trim($_POST['topic']);
if ($dostopshooting == 1) $topic = stopShooting($topic);
/* get message & strip crap */
$message = stripcrap(wbb_trim($_POST['message']));
/* posting feature rights:start */
if (isset($_POST['iconid']) && checkpermissions("can_use_post_icons") == 1) $iconid = intval($_POST['iconid']);
else $iconid = 0;
if (!checkpermissions("can_use_post_smilies") || $disablesmilies == 1) $allowsmilies = 0;
else $allowsmilies = 1;
if (!checkpermissions("can_use_post_html") || $disablehtml == 1) $allowhtml = 0;
else $allowhtml = 1;
if (!checkpermissions("can_use_post_bbcode") || $disablebbcode == 1) $allowbbcode = 0;
else $allowbbcode = 1;
if (!checkpermissions("can_use_post_images") || $disableimages == 1) $allowimages = 0;
else $allowimages = 1;
/* posting feature rights:end */
if (!isset($_POST['preview']) && !$_POST['change_editor']) {
$error = '';
/* check message */
if (!$message) $error .= $lang->items['LANG_POSTINGS_ERROR1'];
if ($wbbuserdata['max_post_image'] != -1 && wbb_substr_count(wbb_strtolower($message), "[img]") > $wbbuserdata['max_post_image']) $error .= $lang->items['LANG_POST_ERROR4'];
if ($error) eval("\$editpost_error .= \"".$tpl->get("newthread_error")."\";");
else {
/* parse url */
if ($parseurl == 1 && $allowbbcode == 1) $message = parseURL($message);
/* update posts */
$db->query("UPDATE bb".$n."_posts SET iconid='$iconid', posttopic='".addslashes($topic)."', message='".addslashes($message)."', ".(($dont_append_editnote == 0) ? ("edittime='".time()."', editorid='$wbbuserdata[userid]', editor='".addslashes($wbbuserdata['username'])."', editcount=editcount+1, ") : (""))."allowsmilies='$allowsmilies', allowhtml='$allowhtml', allowbbcode='$allowbbcode', allowimages='$allowimages', showsignature='".$showsignature."', reindex='1' WHERE postid='$postid'");
/* create postcache */
$parse = &new parse($docensor, 75, 1, '', $usecode, 1, 1);
$cache = $parse->doparse($message, $allowsmilies, $allowhtml, $allowbbcode, $allowimages);
$db->query("REPLACE INTO bb".$n."_postcache (postid, threadid, cache) VALUES ('".$postid."', '".$threadid."', '".addslashes($cache)."')");
/* update thread */
if ($post['posttime'] == $thread['starttime']) $db->query("UPDATE bb".$n."_threads SET iconid='$iconid'".(($topic != '') ? (", topic='".addslashes($topic)."'") : (""))." WHERE threadid='$threadid'");
/* update subscription */
if ($wbbuserdata['userid']) {
if ($emailnotify == 1) {
$result = $db->query_first("SELECT userid, emailnotify FROM bb".$n."_subscribethreads WHERE userid='$wbbuserdata[userid]' AND threadid='$threadid'");
if (!$result['userid']) $db->query("INSERT INTO bb".$n."_subscribethreads (userid,threadid,emailnotify,countemails) VALUES ($wbbuserdata[userid],$threadid,1,0)");
elseif ($result['emailnotify'] == 0) $db->query("UPDATE bb".$n."_subscribethreads SET emailnotify=1 WHERE userid='$wbbuserdata[userid]' AND threadid='$threadid'");
}
else $db->query("DELETE FROM bb".$n."_subscribethreads WHERE userid='$wbbuserdata[userid]' AND threadid='$threadid'");
}
header("Location: thread.php?postid=$postid".$SID_ARG_2ND_UN."#post$postid");
exit();
}
}
else if (!$_POST['change_editor']) {
$parse = &new parse($docensor, 75, $wbbuserdata['showimages'], "", $usecode);
$preview_topic = htmlconverter(textwrap($topic));
$preview_message = $parse->doparse((($parseurl == 1 && $allowbbcode == 1) ? (parseURL($message)) : ($message)), $allowsmilies, $allowhtml, $allowbbcode, $allowimages);
if ($iconid) {
$result = $db->query_first("SELECT * FROM bb".$n."_icons WHERE iconid = '$iconid'");
$preview_posticon = makeimgtag($result['iconpath'], getlangvar($result['icontitle'], $lang), 0);
}
else $preview_posticon = '';
eval("\$preview_window = \"".$tpl->get("newthread_preview")."\";");
}
if ($parseurl == 1 && !$disablebbcode) $checked[0] = 'checked="checked"';
else $checked[0] = '';
if ($emailnotify == 1) $checked[1] = 'checked="checked"';
else $checked[1] = '';
if ($disablesmilies == 1) $checked[2] = 'checked="checked"';
else $checked[2] = '';
if ($disablehtml == 1) $checked[3] = 'checked="checked"';
else $checked[3] = '';
if ($disablebbcode == 1) $checked[4] = 'checked="checked"';
else $checked[4] = '';
if ($disableimages == 1) $checked[5] = 'checked="checked"';
else $checked[5] = '';
if ($showsignature == 1) $checked[6] = 'checked="checked"';
else $checked[6] = '';
if ($dont_append_editnote == 1) $checked[7] = 'checked="checked"';
else $checked[7] = '';
}
else {
$message = $post['message'];
$topic = $post['posttopic'];
$iconid = $post['iconid'];
$disablesmilies = 1 - $post['allowsmilies'];
$disablehtml = 1 - $post['allowhtml'];
$disablebbcode = 1 - $post['allowbbcode'];
$disableimages = 1 - $post['allowimages'];
$showsignature = $post['showsignature'];
if ($wbbuserdata['userid']) list($emailnotify) = $db->query_first("SELECT emailnotify FROM bb".$n."_subscribethreads WHERE userid='".$wbbuserdata['userid']."' AND threadid='".$threadid."'");
else $emailnotify = 0;
if ($emailnotify == 1) $checked[1] = 'checked="checked"';
else $checked[1] = '';
if ($disablesmilies == 1) $checked[2] = 'checked="checked"';
else $checked[2] = '';
if ($disablehtml == 1) $checked[3] = 'checked="checked"';
else $checked[3] = '';
if ($disablebbcode == 1) $checked[4] = 'checked="checked"';
else $checked[4] = '';
if ($disableimages == 1) $checked[5] = 'checked="checked"';
else $checked[5] = '';
if ($showsignature == 1) $checked[6] = 'checked="checked"';
else $checked[6] = '';
if ($wbbuserdata['dont_append_editnote'] == 1) $checked[7] = 'checked="checked"';
else $checked[7] = '';
$navbar = getNavbar($board['parentlist']);
eval("\$navbar .= \"".$tpl->get("navbar_board")."\";");
$wbbuserdata['username'] = htmlconverter($wbbuserdata['username']);
eval("\$newthread_username = \"".$tpl->get("newthread_username")."\";");
if (!isset($iconid)) $iconid = 0;
if (checkpermissions('can_use_post_icons') == 1) $newthread_icons = getIcons($iconid);
if (checkpermissions("can_use_post_bbcode") == 1 && $wbbuserdata['usewysiwyg'] != 1) $bbcode_buttons = getcodebuttons();
if (checkpermissions("can_use_post_smilies") == 1) {
if ($wbbuserdata['usewysiwyg'] == 1) $smilies = getAppletSmilies();
$bbcode_smilies = getclickysmilies($smilie_table_cols, $smilie_table_rows);
}
$note = '';
if (checkpermissions('can_use_post_html') == 0) $note .= $lang->items['LANG_POSTINGS_HTML_NOT_ALLOW'];
else $note .= $lang->items['LANG_POSTINGS_HTML_ALLOW'];
if (checkpermissions('can_use_post_bbcode') == 0) $note .= $lang->items['LANG_POSTINGS_BBCODE_NOT_ALLOW'];
else $note .= $lang->items['LANG_POSTINGS_BBCODE_ALLOW'];
if (checkpermissions('can_use_post_smilies') == 0) $note .= $lang->items['LANG_POSTINGS_SMILIES_NOT_ALLOW'];
else $note .= $lang->items['LANG_POSTINGS_SMILIES_ALLOW'];
if (checkpermissions('can_use_post_images') == 0) $note .= $lang->items['LANG_POSTINGS_HTML_IMAGES_ALLOW'];
else $note .= $lang->items['LANG_POSTINGS_IMAGES_ALLOW'];
## Start - Attachment-Mod v1.1 by Merides #####
if(checkpermissions("can_upload_attachments")==1){
$posthash = md5($post['username'] . $post['userid']);
$count=0;
$result = $db->query("SELECT * FROM bb".$n."_attachments WHERE posthash='$posthash' OR postid='$post[postid]'");
while($attach = $db->fetch_array($result))
{
$dateisize = formatFilesize($attach['attachmentsize']);
$attach['extensionview']=$attach['attachmentextension'];
if(!file_exists("images/filetypes/".$attach['attachmentextension'].".gif")) $attach['extensionview']="unknown";
$langname=$attach['attachmentname'].".".$attach['attachmentextension'];
if(strlen($attach['attachmentname'])>40) $attach['attachmentname']=substr($attach['attachmentname'],0,37)."...";
eval("\$datei_uploadbit .= \"".$tpl->get("attachment_modbit2")."\";");
$count++;
}
$attachthreadid=$threadid;
$attachpostid=$postid;
$attachuserid=$post['userid'];
$extensionview = getAllowedExtensions($wbbuserdata['allowed_attachment_extensions']);
eval ("\$attachment = \"".$tpl->get("newthread_attachment")."\";");
}else $attachment="";
## Ende - Attachment-Mod v1.1 by Merides #####
if (isset($message)) $message = htmlconverter($message);
if (isset($topic)) $topic = htmlconverter($topic);
$thread['topic'] = htmlconverter(textwrap($thread['topic']));
eval("\$headinclude .= \"".$tpl->get("bbcode_script")."\";");
eval("\$editor = \"".$tpl->get("editor")."\";");
eval("\$tpl->output(\"".$tpl->get("editpost")."\");");
?> |