This repository has been archived by the owner on Jan 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
224 lines (184 loc) · 6.8 KB
/
edit.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
<?php
/*
ThWboard - PHP/MySQL Bulletin Board System
==============================================
(c) 2000-2004 by ThWboard Development Group
download the latest version:
http://www.thwboard.de
This program is free software; you can
redistribute it and/or modify it under the
terms of the GNU General Public License as
published by the Free Software Foundation;
either version 2 of the License, or (at
your option) any later version.
==============================================
*/
include "./inc/header.inc.php";
function is_firstpost($threadid, $postid)
{
global $pref;
$r_post = thwb_query("SELECT postid FROM $pref"."post WHERE threadid='$threadid' ORDER BY posttime ASC");
$post = mysql_fetch_array($r_post);
if( $post['postid'] == $postid )
return 1;
else
return 0;
}
// http://www.securiteam.com/securitynews/5FP0C204KE.html
$newpost['posttext'] = ((isset($HTTP_POST_VARS['newpost'])) ? $HTTP_POST_VARS['newpost']['posttext'] : '');
if(!isset($newpost['postcode']))
{
$newpost['postcode'] = 0;
}
if(!isset($newpost['postsmilies']))
{
$newpost['postsmilies'] = 0;
}
if(!isset($newpost['postemailnotify']))
{
$newpost['postemailnotify'] = 0;
}
$navpath .= 'Post editieren';
if( $g_user['userid'] == 0 )
{
message("Fehler", "Nur registrierte/eingeloggte Benutzer können Beiträge editieren!");
}
if(empty($thread))
{
die('pwnd.');
}
if( $thread['threadclosed'] == 1 )
{
if( !$P->has_permission( P_EDITCLOSED ) )
{
message('Fehler', 'Dieser Thread ist leider geschlossen. Es können keine Beiträge mehr editiert
werden.');
}
}
$r_post = thwb_query("SELECT postid, posttext, userid, threadid, postcode, postsmilies, postemailnotify, posttime FROM ".$pref."post WHERE postid='$post[postid]'");
$post = mysql_fetch_array($r_post);
$post['threadtopic'] = htmlspecialchars($thread['threadtopic']);
$post['posttext'] = htmlspecialchars($post['posttext']);
// First Post of Thread ?
// dp: dieser weg ist besser als via time-vergleich
$firstpost = is_firstpost($thread['threadid'], $post['postid']);
if( $firstpost && $P->has_permission( P_EDITTOPIC) )
{
$post['printtopic'] = '<input class="tbinput" type="text" name="newpost[threadtopic]" size="50" value="'.$post['threadtopic'].'" maxlength="75">';
}
else
{
$post['printtopic'] = "$post[threadtopic]";
}
if( ($post['userid'] == $g_user['userid'] && $P->has_permission( P_EDIT )) || $P->has_permission( P_OEDIT ) )
{
if( $config['editlimit'] && !$P->has_permission( P_NOEDITLIMIT ) && ($post['posttime'] + $config['editlimit']) < time() )
{
message('Fehler', 'Sie können diesen Post nicht mehr editieren. (Zeitlimit überschritten)');
}
if( !isset($Submit) )
{
if( $post['postcode'] )
{
$codechecked = ' checked';
}
else
{
$codechecked = '';
}
if( $post['postsmilies'] )
{
$smilieschecked = ' checked';
}
else
{
$smilieschecked = '';
}
if( $post['postemailnotify'] )
{
$mailchecked = ' checked';
}
else
{
$mailchecked = '';
}
if( $config['smilies'] )
{
$smilies_on_off = "AN";
}
else
{
$smilies_on_off = "AUS";
}
$Tframe = new Template("templates/" . $style['styletemplate'] . "/frame.html");
$Tform = new Template("templates/" . $style['styletemplate'] . "/edit.html");
eval($Tform->GetTemplate("CONTENT"));
eval($Tframe->GetTemplate());
}
else
{
$msg = '';
$newpost['posttext'] = strip_session($newpost['posttext']);
// Bannedwords-Protection
if( $config["usebwordprot"] >= BWORD_POST )
{
$post["posttext"] = check_banned($post["posttext"]);
}
if( $firstpost && $P->has_permission( P_EDITTOPIC) )
{
if( $config["usebwordprot"] == BWORD_TOPIC || $config["usebwordprot"] == BWORD_ALL )
{
$thread["threadtopic"] = check_banned($thread["threadtopic"]);
}
if( strlen($newpost['threadtopic']) > $config['subject_maxlength'] )
{
$msg .= "Das Subject ist zu lang!<br>";
}
if( strlen(preparse_code($newpost['threadtopic'])) < $config['subject_minlength'] )
{
$msg .= "Das Subject ist zu kurz!<br>";
}
}
if( strlen($newpost['posttext']) < $config['message_minlength'] )
{
$msg .= "Ihr Text ist zu kurz!<br>";
}
if( strlen($newpost['posttext']) > $config['message_maxlength'] )
{
$msg .= "Ihr Text ist zu lang!<br>";
}
if( isset($msg) && strlen($msg) > 0 )
{
message("Fehler", "Es sind leider folgende Fehler aufgetreten:<br><br><font color='$style[color_err]'>$msg</font>");
}
$c_time = time();
thwb_query("UPDATE ".$pref."post SET posttext='" . addslashes(preparse_code($newpost['posttext'])) . "',
postlasteditby='$g_user[username]', postlastedittime='" . time() . "',
postsmilies='" . ($newpost['postsmilies'] ? 1 : 0) . "',
postcode='" . ($newpost['postcode'] ? 1 : 0) . "',
postemailnotify='" . (isset($newpost['postemailnotify']) && $newpost['postemailnotify'] ? 1 : 0) . "' WHERE postid='$post[postid]'");
// topic updaten, (auch board), nicht als normaluser
if( $firstpost && $P->has_permission( P_EDITTOPIC ) )
{
$newpost['threadtopic'] = addslashes(preparse_code($newpost['threadtopic']));
// topic setten
thwb_query("UPDATE ".$pref."thread SET threadtopic = '". $newpost['threadtopic'] ."' WHERE threadid = '$post[threadid]'");
// board updaten
updateboard($thread['boardid']);
// eventuell vorhandene threadlinks updaten
$r_link = thwb_query( "SELECT threadid, boardid FROM ".$pref."thread WHERE threadlink = ". $post['threadid'] );
if( mysql_num_rows( $r_link ) )
{
$a_link = mysql_fetch_array( $r_link );
thwb_query( "UPDATE ".$pref."thread SET threadtopic = '". $newpost['threadtopic'] ."' WHERE threadid = ". $a_link['threadid'] );
// nicht updaten, threadlinks werden eh nicht im boardlastpost angezeigt
// updateboard( $a_link['boardid'] );
}
}
header("Location: ".build_link("showtopic.php?threadid=$thread[threadid]&pagenum=lastpage#".$post['postid'], true));
}
}
else
{
message("Fehler", "Sie können diesen Post nicht editieren");
}