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
344
345
| <link href="include/style.css" rel="stylesheet" type="text/css">
<script>
function sendText(e, text)
{
e.value += text
}
</script>
<?php
include("config.php");
$forum = $_GET['forum'];
$see = $_GET['see'];
$read = $_GET['read'];
$f_id = $_GET['f_id'];
$newtopic = $_GET['newtopic'];
$reply_id = $_GET['reply_id'];
$reply = $_GET['reply'];
if($see == "true"){
$forum = $_GET['forum'];function per_page($link, $offset) {
global $numofpages, $page;
$numofpages = round($numofpages);
$pagesstart = round($page-$offset);
$pagesend = round($page+$offset);
if ($page != "1" && round($numofpages) != "0") {
echo str_replace("%page", round($page-1), '<a href="'.$link.'"><font face="Trebuchet MS">«</font></a> ');
}
for($i = 1; $i <= $numofpages; $i++) {
if ($pagesstart <= $i && $pagesend >= $i) {
if ($i == $page) {
echo "<b>[$i]</b> ";
}
else {
echo str_replace("%page", "$i", '<a href="'.$link.'">'.$i.'</a> ');
}
}
}
if (round($numofpages) == "0") {
echo "[$i]";
}
if ($page != round($numofpages) && round($numofpages) != "0") {
echo str_replace("%page", round($page+1), '<a href="'.$link.'"><font face="Trebuchet MS">»</font></a>');
}
}
$pp = "10";
$table = "forum_content";
$total = mysql_result(mysql_query("SELECT COUNT(id) FROM $table WHERE `forum`= '$forum' ORDER BY `id` DESC"),0);
$numofpages = $total / $pp;
if (!isset($_GET['page'])) {
$page = 1;
}
else {
$page = $_GET['page'];
}
$limitvalue = $page * $pp - ($pp);
$query = "SELECT * FROM $table WHERE `forum`= '$forum' ORDER BY `id` DESC LIMIT $limitvalue, $pp";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
echo "<span class=box4><a href=?id=forum&forum=$r[forum]&see=read&f_id=$r[id]><img src=images/folder.gif width=19 height=18 border=0> $r[title]</a> - Autor: $r[autor]</span>";
}
echo "<br><a href=?id=forum&forum=$forum&newtopic=true><img src=images/newtopic.gif width=93 height=25 border=0></a><br><br>";
echo 'Pages: '.round($numofpages).'<br>';
per_page("?id=forum&forum=$forum&see=true&page=%page", "5");
}else if($see == "read"){
$query = "SELECT * FROM `forum_content` WHERE `forum`= '$forum' and `id`= '$f_id'";
$result = mysql_query($query);
while($r=mysql_fetch_array($result)){
echo "<table align=center width=700 border=0 cellspacing=0 cellpadding=0 class=box5>
<tr>
<td align=center valign=middle></td>
<td class=box2 colspan=3 align=center valign=top width=500>
$r[title]</td>";
if(!(file_exists("avatars/$r[autor].jpg")))
{ echo "</tr>
<tr>
<td width=220 height=200 rowspan=3 align=center valign=top><img src=avatars/noavatar.jpg />
</td>
<td width=500 height=20 class=box2><span >Posted by:$r[autor]</span></td>
<td width=5 height=5></td>
</tr>
<td class=box4 align=left valign=top width=500 height=200><br /><div> $r[content]</div></td>
<td colspan=2></td>
</tr>
</table>"; }
else
{ echo "</tr>
<tr>
<td width=220 height=200 rowspan=3 align=center valign=top><img src=avatars/$r[autor].jpg />
</td>
<td width=500 height=20 class=box2><span >Posted by:$r[autor]</span></td>
<td width=5 height=5></td>
</tr>
<td class=box4 align=left valign=top width=500 height=200><br /><div> $r[content]</div></td>
<td colspan=2></td>
</tr>
</table>"; }
};
$query2 = "SELECT * FROM `forum_reply` WHERE `reply_id`= '$f_id' ORDER BY `id` ASC";
$result2 = mysql_query($query2);
while($r2=mysql_fetch_array($result2)){
echo "<span class=box2>Reply by $r2[autor]</span><span class=box1>$r2[content]</span>";
}
echo "<table border=0>
<tr>
<td><a href=?id=forum&forum=$forum&reply=true&f_id=$f_id><img src=images/reply.gif width=93 height=25 border=0></a></td>
<td><a href=?id=forum&forum=$forum&newtopic=true><img src=images/newtopic.gif width=93 height=25 border=0></a></td>
</tr>
</table>
";
}else if($newtopic == "true"){$user = $_COOKIE['user'];if(empty($user)){
$r = mysql_fetch_array(mysql_query("SELECT * FROM `forum_forums` WHERE `forum`= '$forum'"));
$permission = "$r[permission]";if(empty($permission)){
echo "Не сте влезли с потребителско име за да можете да пишете теми";
die();
}else if($permission == "0"){
echo "Не сте влезли с потребителско име за да можете да пишете теми";
die();
}else if($permission == "1"){
$forum = $_GET['forum'];echo "<form action=?id=forum&forum=$forum&newtopic=submitted method=post name=form>
<table border=0>
<tr>
<td> </td>
<td align=\"center\"><input type=\"button\" onClick=\"sendText(document.form.content, '[b][/b]')\" value=\"b\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[i][/i]')\" value=\"i\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[u][/u]')\" value=\"u\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[url][/url]')\" value=\"url\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[img][/img]')\" value=\"img\" name=\"smile\" class=form></td>
</tr>
<tr>
<td>Username</td>
<td><input name=user type=text id=user class=form></td>
</tr>
<tr>
<td>Title</td>
<td><input name=title type=text id=title class=form></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name=content cols=35 rows=10 id=content class=form></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=Submit value=Post class=form></td>
</tr>
</table>
</form>";
}
}else{
$forum = $_GET['forum'];
echo "<form action=?id=forum&forum=$forum&newtopic=submitted method=post name=\"form\">
<table border=0>
<tr>
<td> </td>
<td align=\"center\"><input type=\"button\" onClick=\"sendText(document.form.content, '[b][/b]')\" value=\"b\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[i][/i]')\" value=\"i\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[u][/u]')\" value=\"u\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[url][/url]')\" value=\"url\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[img][/img]')\" value=\"img\" name=\"smile\" class=form></td>
</tr>
<tr>
<td>Title</td>
<td><input name=title type=text id=title class=form></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name=content cols=35 rows=10 id=content class=form></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=Submit value=Post class=form></td>
</tr>
</table>
</form>";
}
}else if($newtopic == "submitted"){
$title = $_POST['title'];
$forum = $_GET['forum'];
$content = $_POST['content'];
$content = str_replace("
","<br>","$content");
$content = str_replace("[b]","<b>","$content");
$content = str_replace("[/b]","</b>","$content");
$content = str_replace("[i]","<i>","$content");
$content = str_replace("[/i]","</i>","$content");
$content = str_replace("[u]","<u>","$content");
$content = str_replace("[/u]","</u>","$content");
$content = str_replace("[url]","<a href=","$content");
$content = str_replace("[/url]"," target=_blank>[Link]</a>","$content");
$content = str_replace("[img]","<img src=","$content" );
$content = str_replace("[/img]","alt= />","$content" );
$user = $_POST['user'];
if(empty($user)){
$user = $_COOKIE['user'];
}
$ok = mysql_query("INSERT INTO `forum_content` ( `id` , `title` , `autor` , `forum`, `content`)
VALUES (
'NULL', '$title', '$user', '$forum', '$content'
);");
if($ok){
echo "<meta http-equiv='refresh' content=3;url=?id=forum&forum=$forum>The post $title has been sucesfully added, thanks $user<br>You will be redirected in 3 seconds...";
}else{
echo "Oops, error.";
}
}else if($reply == "true"){
$reply_id = $_GET['reply_id'];
$user = $_COOKIE['user'];
if(empty($user)){
$r = mysql_fetch_array(mysql_query("SELECT * FROM `forum_forums` WHERE `forum`= '$forum'"));
$permission = "$r[permission]";
if(empty($permission)){
echo "You are not allowed to reply, please register";
die();
}else if($permission == "0"){
echo "You are not allowed to reply, please register";
die();
}else if($permission == "1"){
$forum = $_GET['forum'];
echo "<form action=?id=forum&forum=$forum&reply=submitted&f_id=$reply_id method=post name=form>
<table border=0>
<tr>
<td> </td>
<td align=\"center\"><input type=\"button\" onClick=\"sendText(document.form.content, '[b][/b]')\" value=\"b\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[i][/i]')\" value=\"i\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[u][/u]')\" value=\"u\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[url][/url]')\" value=\"url\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[img][/img]')\" value=\"img\" name=\"smile\" class=form></td>
</tr>
<tr>
<td>Username</td>
<td><input name=user type=text id=user class=\"form\"></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name=content cols=35 rows=10 id=content class=\"form\"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=Submit value=Post class=form></td>
</tr>
</table>
</form>";
}
}else{
$forum = $_GET['forum'];
echo "<form action=?id=forum&forum=$forum&reply=submitted&f_id=$reply_id method=post name=form>
<table border=0>
<tr>
<td> </td>
<td align=\"center\"><input type=\"button\" onClick=\"sendText(document.form.content, '[b][/b]')\" value=\"b\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[i][/i]')\" value=\"i\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[u][/u]')\" value=\"u\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[url][/url]')\" value=\"url\" name=\"smile\" class=form>
<input type=\"button\" onClick=\"sendText(document.form.content, '[img][/img]')\" value=\"img\" name=\"smile\" class=form></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name=content cols=35 rows=10 id=content class=\"form\"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=Submit value=Reply class=form></td>
</tr>
</table>
</form>";
}
}else if($reply == "submitted"){
$reply_id = $_GET['reply_id'];
$forum = $_GET['forum'];
$content = $_POST['content'];
$content = str_replace("
","<br>","$content");
$content = str_replace("[b]","<b>","$content");
$content = str_replace("[/b]","</b>","$content");
$content = str_replace("[i]","<i>","$content");
$content = str_replace("[/i]","</i>","$content");
$content = str_replace("[u]","<u>","$content");
$content = str_replace("[/u]","</u>","$content");
$content = str_replace("[url]","<a href=","$content");
$content = str_replace("[/url]"," target=_blank>[Link]</a>","$content");
$content = str_replace("[img]","<img src=","$content" );
$content = str_replace("[/img]","alt= />","$content" );
$user = $_POST['user'];
if(empty($user)){
$user = $_COOKIE['user'];
}
$ok = mysql_query("INSERT INTO `forum_reply` ( `id` , `reply_id` , `autor` , `forum`, `content` )
VALUES (
'NULL', '$reply_id', '$user', '$forum', '$content'
);");
if($ok){
echo "The post reply has been sucesfully added, thanks $user, <br> Click <a href=?id=forum&forum=$forum&see=read&f_id=$reply_id>here</a> to see it.";
}else{
echo "Oops, error.1";
}
}else{
$query_forum = "SELECT * FROM `forum_forums` ORDER BY `id` ASC";
$result_forum = mysql_query($query_forum);
while($r=mysql_fetch_array($result_forum)){
$forum_name = "$r[forum]";
$forum_name = str_replace("_"," ","$forum_name");
echo "<span class=box3><img src=images/forum.jpg width=46 height=25 border=0 /><a href=?id=forum&forum=$r[forum]&see=true><b>$forum_name</b></a></span>";
}
};
?> |