Може ли някой да оправи този код за форума да вади името кой го е побликувал и да вади колко коментара има потребителя в форума
Код:
<?php
$session = $_SESSION['name'];
if($session == null){
echo ' Не си логнат.';
}else{
$name = $_SESSION['name'];
$sql = "SELECT * FROM users WHERE name = '$name'";
$do = mysql_query($sql);
$my = mysql_fetch_array($do);
$id = $my['id'];
$mbtopics = $my['name'];
$forumz = array( 1 => '<img src="images/dot.gif" border="0">Общи дискусии',
2 => '<img src="images/dot.gif" border="0">Забавни',
3 => '<img src="images/dot.gif" border="0">Извън играта',
4 => '<img src="images/dot.gif" border="0">Помощ' );
function thread_children( $postid )
{
$result = mysql_query( "SELECT mID FROM forum_messages WHERE mBelong='$postid'" );
while ( $mbtopics = mysql_fetch_array( $result ) ) {
$childrenz .= "," . $mbtopics['mID'] . thread_children( $mbtopics['mID'] );
}
return $childrenz;
}
if ( $_GET['clp'] ) {
function delete_thread( $parentn )
{
$result = mysql_query( "SELECT * FROM forum_messages WHERE mID=\"" . $_GET['clp'] . "\"" );
$mbtopic = mysql_fetch_array( $result );
$delids = $_GET['clp'] . thread_children( $_GET['clp'] );
$result = mysql_query( "DELETE FROM forum_messages WHERE mID in ($delids)" );
$result = mysql_query( "UPDATE forum_messages SET mChildren=mChildren-1 WHERE mID=\"" . $mbtopic['mBelong'] . "\"" );
}
if ( $ALLOWED_ACTIONS['forums'] ) {
delete_thread( floor( $_GET['clp'] ) );
}
}
if ( $_GET['fd'] ) {
$x = floor( $_GET['fd'] );
$xtratitle = " - <i>$forumz[$x]</i>";
} elseif ( $_GET['stp'] == 'postm' ) {
$xtratitle = ' - Post Message';
} elseif ( $_GET['messid'] ) {
$x = floor( $_GET['messid'] );
$result = mysql_query( "SELECT * FROM forum_messages WHERE mID=\"$x\"" );
$mbtopic = mysql_fetch_array( $result );
$xtratitle = " - <i>" . $mbtopic['mSubject'] . "</i>";
}
?>
<table width="95%" align="center" border="0">
<tr>
<td class="bodycell3">Форуми <?=$xtratitle?></td>
</tr>
<tr>
<td class="bodycell4">
<?php
if ( !$_GET['stp'] && !$_GET['fd'] && !$_GET['messid'] ) {
?>
<p><b>Правила:</b><br>
<img src="images/dot.gif"> Без расизъм в темите/отговорите.<br>
<img src="images/dot.gif"> Забранено е употребата на обидни думи.<br>
<img src="images/dot.gif"> Забранено е публикуването на ваш или на друг потребител статуса.<br>
<img src="images/dot.gif"> Забранен е флоода.<br>
<br>
<b>Възможни Последствия:</b><br>
<img src="images/dot.gif"> Премахване на Златото и в Банка.<br>
<img src="images/dot.gif"> Премахване на Жители, Защита, Оръжия<br>
<img src="images/dot.gif"> Премахване на Платено членство без преоткриване.<br>
<img src="images/dot.gif"> Изтриване на Акаунта.<br>
<BR>
</td></tr>
<tr><td class="bodycell4">
<table border="0" width="95%">
<tr>
<td width="70%"><B>Форуми:</B></td>
<td width="15%"><B>Топици:</B></td>
<td width="10%"><B>Отговори:</B></td>
<td width="5%" border="1"></td>
</tr>
<?php
foreach( $forumz as $bid => $bname ) {
$result = mysql_query( "SELECT count(*) FROM forum_messages WHERE mBelong=0 AND mThread=$bid" );
$mbtopics = mysql_fetch_array( $result );
$topicsnum = $mbtopics[0];
$result = mysql_query( "SELECT count(*) FROM forum_messages WHERE mThread=$bid" );
$mbtopics = mysql_fetch_array( $result );
$postsnum = $mbtopics[0] - $topicsnum;
?>
<tr>
<td width="70%" border="1"><a href="index.php?a=test&fd=<?=$bid?>"><?=$bname?></a></td>
<td width="15%" border="1"><?=$topicsnum?></td>
<td width="10%" border="1"><?=$postsnum?></td>
<td width="5%" border="1">
</td>
</tr>
<?php
}
?>
</table>
<br><br>
<?php
} elseif ( $_GET[fd] ) {
?>
<table border="0" width="95%" border="1" align="center">
<tr>
<td width="50%" border="1"><B>Описание:</B></td>
<td width="20%" border="1"><B>Публикувано от:</B></td>
<td width="15%" border="1"><B>Отговори:</B></td>
<td width="15" border="1"></td>
</tr>
<?php
$result = mysql_query( "SELECT * FROM forum_messages WHERE mBelong=0 AND mThread=\"$x\" ORDER BY mAdmin DESC,mID DESC" );
while ( $mbtopics = mysql_fetch_array( $result ) ) {
$replynum = $mbtopics['mChildren'];
?>
<tr>
<td width="50%" border="1">
<?php
if ( $mbtopics['mAdmin'] == 0 ) {
?>
<a href='index.php?a=test&messid=<?=$mbtopics['mID']?>'><?=stripslashes( $mbtopics['mSubject'] )?></a>
<?php
} else {
?>
[ <a href='index.php?a=test&messid=<?=$mbtopics['mID']?>'><?=stripslashes( $mbtopics['mSubject'] )?></B></a> ]
<?php
}
?>
</td>
<td width="20%" border="1">
<?=$mbtopics['mUser']?>
</td>
<td width="15%" border="1">
<?=$replynum?>
</td>
<td width="15%" border="1">
<?php
if ( $ALLOWED_ACTIONS['forums'] == 1 ) {
?>
<center>
[ <a href='index.php?a=test&fd=<?=$mbtopics['mThread']?>&clp=<?=$mbtopics['mID']?>'>изтрий</a> ]<br>
</center>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</table>
<BR>
<BR>
<center>
<U><B>Нов Топик</B></U>
<form method="POST" action="index.php?a=test&stp=postm">
<input type="hidden" name="thread" value="<?=$x?>">
<input type="hidden" name="belong" value="0">
<table border="0" width="30%">
<tr>
<td width="86%" border="1">Заглавие<BR><input type="text" name="subject" size="46"></td>
</tr>
<tr>
<td width="86%" valign="top" border="1">Текст<BR><textarea rows="10" name="body" cols="45"></textarea></td>
</tr>
<?php
if ( $ALLOWED_ACTIONS['forums'] == 1 ) {
?>
<tr>
<td width="86%" border="1"><input type="checkbox" name="admin" value="1" style="border=none;"> Важен топик</td>
</tr>
<?php
}
?>
<tr>
<td width="86%" border="1"><input type="image" value="Изпрати" name="post" src="images/btn_abschicken.png"></td>
</tr>
</table>
</form>
<br><br>
<a href='index.php?a=test'>Назад</a><br><br><br><br><br><br><br><br>
</center>
<?php
} elseif ( $_GET['stp'] == 'postm' ) {
echo "<center>";
$result = mysql_query( "SELECT * FROM forum_messages WHERE mID=\"" . $_POST['belong'] . "\"" );
$mbtopic = mysql_fetch_array( $result );
if ( !$_POST['subject'] ) {
echo "Не сте въвели заглавие.";
} elseif ( !$_POST['body'] ) {
echo "Не сте въвели текст.";
} else {
$thebody = htmlentities( stripslashes( $_POST['body'] ) );
$thesubject = htmlentities( stripslashes( $_POST['subject'] ) );
$eldator = date( "d/m/Y" );
$eladmin = $_POST['admin'];
if ( !$eladmin ) {
$eladmin = 0;
}
$postedb = "<a href='profile.php?id=" . $user['uID'] . "'>" . $user['uLogin'] . "</a>";
$result = mysql_query( "INSERT INTO forum_messages (mBody,mSubject,mUser,mAdmin,mBelong,mThread,mDate) VALUES (\"$thebody\",\"$thesubject\",\"$postedb\",$eladmin," . $_POST['belong'] . "," . $_POST['thread'] . ",'$eldator')" );
if ( $_POST['belong'] != 0 ) {
$result = mysql_query( "UPDATE forum_messages SET mChildren=mChildren+1 WHERE mID=\"" . $_POST['belong'] . "\"" );
}
?><center><br><br><br><br><br>
Отговора беше публикуван.
<?php
}
?>
<BR>
<BR>
<?php
if ( $_POST['belong'] == 0 ) {
?>
<a href='index.php?a=test&fd=<?=$_POST['thread']?>'>Назад</a><br><br><br><br><br><br><br>
<?php } else {
?>
<a href='index.php?a=test&messid=<?=$_POST['belong']?>'>Назад</a><br><br><br><br><br><br><br>
<?php
}
echo "</center>";
} elseif ( $_GET[messid] ) {
?>
<center>
<i>Публикуван на <?=$mbtopic['mDate']?> от <?=$mbtopic['mUser']?></i>
<?php
if ( $ALLOWED_ACTIONS['forums'] == 1 ) {
?>
<br>[ <a href='index.php?a=test&fd=<?=$mbtopics['mThread']?>&clp=<?=$replies['mID']?>'>изтрий</a> ]
<?php
}
?>
</center>
<br>
<?=nl2br( $mbtopic['mBody'] )?>
<BR>
<BR>
</td></tr>
<tr><td class="bodycell3">
Отговори
</td></tr>
<?php
$result2 = mysql_query( "SELECT * FROM forum_messages WHERE mBelong=\"" . $mbtopic['mID'] . "\"" );
while ( $replies = mysql_fetch_array( $result2 ) ) {
?>
<tr><td class="bodycell4">
<center>
<i>Публикуван на <?=$replies['mDate']?> от <?=$replies['mUser']?></i>
<?php
if ( $ALLOWED_ACTIONS['forums'] == 1 ) {
?>
<br>[ <a href='index.php?a=test&messid=<?=$replies['mBelong']?>&clp=<?=$replies['mID']?>'>Изтрий</a> ]
<?php
}
?>
</center>
<br>
<?=nl2br( $replies['mBody'] )?>
</td></tr>
<?php
}
?>
<tr><td class="bodycell3">
Отговор
</td></tr>
<tr><td class="bodycell4">
<center>
<form method="POST" action="index.php?a=test&stp=postm">
<input type="hidden" name="thread" value="<?=$mbtopic['mThread']?>">
<input type="hidden" name="belong" value="<?=$mbtopic['mID']?>">
<input type="hidden" name="subject" value="n/a">
<table border="0" width="30%">
<tr>
<td width="86%" valign="top"><textarea rows="10" name="body" cols="45"></textarea></td>
</tr>
<tr>
<td width="86%"><input type="image" value="Изпрати" name="Изпрати" src="images/btn_abschicken.png"></td>
</tr>
</table>
</form>
<BR>
<?php if ( $mbtopic['mBelong'] == 0 ) {
?>
<a href='index.php?a=test&fd=<?=$mbtopic['mThread']?>'>Назад</a><br><br><br><br><br><br>
<?php } else {
?>
<a href='index.php?a=test&messid=<?=$mbtopic['mBelong']?>'>Назад</a><br><br><br><br><br><br><br>
<?php }
?>
</center>
<?php
} }
?>
</td>
</tr>
</table>