Не сте регистриран! Регистрирайте се БЕЗПЛАТНО, за да използвате услугите на сайта!

Нова тема
Проблем при постовете в скрипт за форум
Тази тема е погледната 316 пъти
Добави темата към любими | Принтирай темата | Нова тема 
Публикувано на: 03.07.2008 19:54
increadible
Калфа

Мнения: (11)

CODE
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
/* Includes the configuration file */
include("config.php");
/* Set the variables that will be received */
$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'];
/* Now if the url containts &see=true this will activate */
if($see == "true"){
$forum = $_GET['forum'];//optional
/* Pagination... */
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>');
 
}
}


/* Set How many results to display per page */
$pp = "10";

/* Select the table that you want to view, you can add things like WHERE something='something' */
$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);

/* Display the rows */
$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>";

/* Display the pages down the bottom */
echo 'Pages: '.round($numofpages).'<br>';

per_page("?id=forum&forum=$forum&see=true&page=%page", "5");
/* If the url contains &see=read */
}else if($see == "read"){
/* Sets the query */
$query = "SELECT * FROM `forum_content` WHERE `forum`= '$forum' and `id`= '$f_id'";
$result = mysql_query($query);
while($r=mysql_fetch_array($result)){
/* Echoes the content */
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>
"; }

}
;
/* Another query */
$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>";
}
/* This will add the images of Add Reply and New Topic */
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"){//starts a new topic
$user = $_COOKIE['user'];// If the user is logged in
if(empty($user)){
$r = mysql_fetch_array(mysql_query("SELECT * FROM `forum_forums` WHERE `forum`= '$forum'"));
$permission = "$r[permission]";//check the permission, if the forum allow guests to post
if(empty($permission)){
echo "Не сте влезли с потребителско име за да можете да пишете теми";
die();
}else if($permission == "0"){
echo "Не сте влезли с потребителско име за да можете да пишете теми";
die();
}else if($permission == "1"){
$forum = $_GET['forum'];//If the user is logged in it wont display the username box
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'];
/* BB code stuff */
$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 the user box is empty */
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'];
/* BB code Stuff */
$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{
/* Else, if there isn't any &forum=.. or other variable it will show the forums */
$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>";
}
}
;
?>

не ми изкарва постовете в темите


 
---------------------------
Потребител от: 03.07.08 | Всички уроци от increadible | Всички скриптове от increadible
напиши eMail напиши лично съобщение виж профила на increadible
Публикувано на: 03.07.2008 21:10
iwanov
Император

Администратор

Мнения: (510)

Я пообясни малко, закакво е този скрипт, как си го слагал и т.н.
Мислиш ли че като пуснеш тук 350 реда код и ние ще ти разберем проблема.


 
---------------------------
Потребител от: 06.02.07 | Всички уроци от iwanov | Всички скриптове от iwanov

Не е важно да си готин, готино е да си важен.
'Nemo saltat sobrius nisi forte insanit' - 'Nobody dances sober unless he's insane' - Ciccero :)
напиши eMail напиши лично съобщение виж профила на iwanov
Публикувано на: 03.07.2008 23:05
increadible
Калфа

Мнения: (11)

Цитат от iwanov@03.07.2008 21:10:
Я пообясни малко, закакво е този скрипт, как си го слагал и т.н.
Мислиш ли че като пуснеш тук 350 реда код и ние ще ти разберем проблема.

хаха извинявай кода е за форум писан е от мене и съм сложил коментари
обаче 2 дена си блъскам главата и немога да си оправя скрипта
първо бях объркал дб с reply а сега като ги постна те не излизат в съмия форум


 
---------------------------
Потребител от: 03.07.08 | Всички уроци от increadible | Всички скриптове от increadible
напиши eMail напиши лично съобщение виж профила на increadible
Публикувано на: 15.07.2008 23:15
increadible
Калфа

Мнения: (11)

Няма ли някой да ми помогне как да изкарвам последните коментари в текуща тема http://store4.data.bg/increadible/%e5%f2%ee%20%e7%e0%20%f2%f3%ea%e0.JPG


 
---------------------------
Потребител от: 03.07.08 | Всички уроци от increadible | Всички скриптове от increadible
напиши eMail напиши лично съобщение виж профила на increadible
Публикувано на: 15.07.2008 23:58
TheeGhost
Калфа

Мнения: (30)

Сега ми се спи и няма да мога да го разгледам, но ми направи натрапчиво впечатление, че си писал коментари на английски. Първо си помислих, че е възможно да продадеш кода си на някоя чужда компания, но тогава защо съобщенията които излизат са на кирилица...Сигурен ли си, че ти си писал кода? Може да ни улесниш в помощта ако кажеш от къде си го взел или какво си използвал...

PS: Аз за коментари предпочитам виетнамски. Много по - звучен е и по - лесно разчитам какво съм писал.


 
---------------------------
Потребител от: 15.07.08 | Всички уроци от TheeGhost | Всички скриптове от TheeGhost

Karate - way of life...computers - everything else.
напиши eMail напиши лично съобщение виж профила на TheeGhost
Публикувано на: 16.07.2008 00:03
increadible
Калфа

Мнения: (11)

Ми гледах уроци и накрая направих това , то си и личи де
а за коментарите като са на бг не ми правят впечетление и за това са на анг. незнам защо


 
---------------------------
Потребител от: 03.07.08 | Всички уроци от increadible | Всички скриптове от increadible
напиши eMail напиши лично съобщение виж профила на increadible
Публикувано на: 16.07.2008 14:37
TheeGhost
Калфа

Мнения: (30)

Ами честно да ти кажа едва ли ще започна да чета кода ти, но е добре да правиш разни проверки на $_GET величините, които получаваш. Видях че на много места в заявки към БД използваш променливите, които получаваш от $_GET и така си доста уязвим на SQL injections...Освен това е добре да правиш ескейп на кавички и т.н.


 
---------------------------
Потребител от: 15.07.08 | Всички уроци от TheeGhost | Всички скриптове от TheeGhost

Karate - way of life...computers - everything else.
напиши eMail напиши лично съобщение виж профила на TheeGhost
 1 посетител чете тази тема (0 потребители и 1 гост)  
Активни потребители: ---
   





IT-PLACE.NET © 2004 - 2008