Jump to content
php.lv forumi

Forums neselecto tēmu


defaultaizz

Recommended Posts

MAn ir paškodēts forums.. Īsi sakot viss strādā, izņemot nelasa tēmas. Posto, vissu saliek pa db kā nākas,

Caur šo failu lasa forumā tēmas, tikai problēma ir tāka ka viņš to nedara. Pievienotu postu var, viņš pat pievienojas db, bet nenolasa visu šo . Ceru ka problēmu sapratāt.

problēma iespējams ir šijā failā kuru zemāk var apskatīties.

Palīdzat lūdzu...

 

 

<?

ini_set('display_errors', 'On');
error_reporting(E_ALL);
define("sub", "level");
include("../includite/includedglobals.php");
include("./theme/gg/styleinfo.php");
 
if($mod[action]){
if($mod[action]=="deleteposts"){
 
foreach($_POST as $id) { 
mysql_query("DELETE FROM forums_posts WHERE id='$id'");
}
 
}
 
}
 
$id = $_GET['id'];
 
$fsettings=mysql_query("SELECT * FROM forums_settings");
$fsettings=mysql_fetch_array($fsettings);
 
$thread=mysql_query("SELECT * FROM forums_threads WHERE id='$id'");
$thread=mysql_fetch_array($thread);
 
$forum=mysql_query("SELECT * FROM forums_forums WHERE id='$thread[forum]'");
$forum=mysql_fetch_array($forum);
 
$pusers=mysql_query("SELECT * FROM forums_privateusers WHERE user='{$_COOKIE['tid']}' AND forum='$forum[id]'");
$pusers=mysql_fetch_array($pusers);
 
if(!$id OR !$thread[id]){
$out[body].="<br />
<center>
<table width='99%' border='0' cellspacing='1' cellpadding='1'>
<tr bgcolor='$config[altcolora]'>
<td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'>
<strong>Invalid Thread</strong>
</td>
</tr>
<tr bgcolor='$config[altcolorb]'>
<td width='100%' valign='center' align='left'><center>
<b>Invalid thread!<br />
</td></tr>
</table>
</center><br /><br /><br /><br />";
include("$config
");
exit;
}
 
if("{$_COOKIE['tid']}"){
 
$ifviewer=mysql_query("SELECT * FROM forums_read WHERE user='{$_COOKIE['tid']}' AND forum='$forum[id]' AND thread='$thread[id]'");
$ifviewer=mysql_fetch_array($ifviewer);
$postnum="0";
if(!$ifviewer[id]){
 
mysql_query("INSERT INTO forums_read VALUES (
NULL,
'{$_COOKIE['tid']}',
'$forum[id]',
'$thread[id]')");
} else {
}
 
}
 
if(!$page){
$page="1";
}
if($page==1){
$page="0";
}
 
$totalpages=mysql_query("SELECT COUNT(*) FROM forums_posts WHERE thread='$id'");
$totalpages=mysql_fetch_array($totalpages);
$totalpages="$totalpages[0]";
 
if($totalpages=="0"){
mysql_query("DELETE FROM forums_threads WHERE id='$thread[id]'");
 
}
 
 
$pages=1;
 
if($page==1){
$skippages.="[<a href='./viewthread.php?id=$id&page=1'><b>$pages</b></a>] ";
}else{
$skippages.="<a href='./viewthread.php?id=$id&page=1'><b>$pages</b></a> ";
}
 
$apage=1;
$bpage=10;
 
while($bpage < $totalpages){
$apage=($apage + 10);
$bpage=($bpage + 10);
$pages++;
 
if($page=='$apage'){
$skippages.="[<a href='./viewthread.php?id=$id&page=$apage'><b>$pages</b></a>] ";
}else{
$skippages.="<a href='./viewthread.php?id=$id&page=$apage'><b>$pages</b></a> ";
}
}
if($forum[subforum]){
$sforum=mysql_query("SELECT * FROM forums_forums WHERE id='$forum[subforum]'");
$sforum=mysql_fetch_array($sforum);
 
$subforums="<a href='./viewforum.php?id=$forum[subforum]'>$sforum[name]</a> >> ";
} else {
$subforums="";
}
 
$out[body].="<form method='post'><center>
<br><div valign='center' align='left' style='background-color:$config[altcolora];width:90%;border: 1px solid rgb(0, 0, 0);' >
<table width='100%'><tr><td width='50%'>
<a href='./index.php'>$config[sitename]</a> >> $subforums<a href='./viewforum.php?id=$forum[id]'>$forum[name]</a> >> <a href='./viewthread.php?id=$id'>$thread[name]</a><br>
</td><td width='50%' valign='center' align='right'>Pages: $skippages  </td></tr></table></div>";
 
if(mysql_query("SELECT id FROM members WHERE name='{$_COOKIE['user']}' AND password='{$_COOKIE['pass']}'")){
$out[body].="</center><br />             
<a href='./reply.php?thread=$id'><img src='./images/reply.gif' border='0'></a><center>";
}
 
$out[body].="<table width='100%' border='0' cellspacing='1' cellpadding='1' cellpadding='1' cellspacing='1'>
<tr bgcolor='$config[altcolor]'>
<td width='100%' valign='center' background='$config[bg]' colspan='5'><b> $thread[name]</b></td>
</tr>";
 
$posts=mysql_query("SELECT id,post,user,starter,DATE_FORMAT(posted,'%M %d, %Y at %l:%i %p') FROM forums_posts WHERE thread=[id] ORDER BY posted ASC LIMIT $page 10");
while(list($id,$post,$user,$starter,$posted)=mysql_fetch_row($posts)){
 
$thispost="$id";
 
$poster=mysql_query("SELECT *, DATE_FORMAT(joined,'%M %d, %Y')as 'join' FROM members WHERE id='$user'");
$poster=mysql_fetch_array($poster);
 
$timeoutseconds = 300;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
if($poster[lastactive] >= $timeout){
$online="<img src='./images/online.gif' border='0' />";
}else{
$online="<img src='./images/offline.gif' border='0' />";
}
 
 
$ifmod ="$fsettings[admins]";
$ifmod = explode(", ",$ifmod);  
$thismod="{$_COOKIE['tid']}";
 
$ifadmin ="$fsettings[admins]";
$ifadmin = explode(", ",$ifadmin);  
 
if($user=="{$_COOKIE['tid']}"){
$useredit="<a class='content' href='./reply.php?action=editpost&thread=$thread[id]&post=$id'><u><img src='./images/edit.gif' border='0'></u></a>";
} else {
$useredit="";
}
if (in_array($thismod, $ifadmin)){
$useredit="<a class='content' href='./reply.php?action=editpost&thread=$thread[id]&post=$id'><u><img src='./images/edit.gif' border='0'></u></a>";
} else {
$useredit="";
}
 
 
$photo="<img src='$poster[photo]' border='0' onLoad='resize_logo2( this );' /><br /><img src='../images/stats/spacer.gif' border='0'>";
}else{
$photo="<img src='../images/profile/nologo.gif' border='0' />";
}
 
$t2 = stripslashes($poster['signature']);
require_once('bbcode.php');
$bb2 = new Simple_BB_Code();
$poster[signature] = $bb2->parse($t2);
 
if($poster[signature]){
$signature="<div style='vertical-align: bottom;'><strong>____________________________________</strong><br /><br />$poster[signature]";
}else{
$signature="<div>";
}
 
 
$uposts=mysql_query("SELECT COUNT(*) FROM forums_posts WHERE user='$poster[id]'");
$uposts=mysql_fetch_array($uposts);
$uposts="$uposts[0]";
 
if($starter=='no'){
$title="Re: ";
}
 
$post = filter($post);
$post = nl2br(stripslashes($post));
 
$t = stripslashes($post);
require_once('bbcode.php');
$bb = new Simple_BB_Code();
$res = $bb->parse($t);
 
 
 
if (in_array($poster[id], $ifadmin)){
$color="<font color='red'><b>";
$color2="</b></font>";
}else{
$color="";
$color2="";
}
$postnum++;
 
 
if (in_array($thismod, $ifmod)){
$ifadminmod="<input type='checkbox' name='$id' class='button' value='$id'/>";
} else {
}
if($forum['private']=='yes' && $pusers['id'] OR $forum['private']=='no'){
$out[body].="
 
<tr bgcolor='$config[altcolorb]' id='$thispost'>
<td width='10%' valign='center' background='$config[bg2]' align='center' colspan='2'><b>$title$thread[name]</b></td>
 
<tr bgcolor='$config[altcolora]'>
<td width='20%' valign='top' background='$config[altcolora]'><center>
<STRONG><a class='comment' href='../profile.php?account=$poster[id]'>$color$poster[name]$color2</a></STRONG><br />$online<br/><img src='../images/stats/spacer.gif' border='0'><br />$photo<br />
<a href='../mailbox.php?action=create&mem=$poster[name]'><img src='./images/pm.gif' border='0' alt='Click here to send $poster[name]  a Private Message' /></a><br /><br />
 
<strong>Joined:</strong> $poster[join]<br />
<strong>Posts:</strong> $uposts<br /><br />
</td>
<td width='99%' valign='top' background='$config[altcolora]' align='left'>
<div valign='center' align='left' style='background-color:$config[altcolora];border: 1px solid rgb(0, 0, 0);'><table width='100%' cellspacing='0' cellpadding='0'><tr><td width='50%' align='left'><strong>Posted:
</strong> $posted </td><td width='50%' align='right'><a href='./viewthread.php?id=$thread[id]#$thispost'>#$postnum</a></td></tr></table></div>
 
<p>$res</p>
<p> </p>
$signature
 
 
<div align='right'><a class='content' href='./reply.php?action=report&post=$thispost'><img src='./images/report.gif' border='0' alt='Report Post'></a> $useredit 
<a class='content' href='./reply.php?action=reply&thread=$thread[id]&quoting=$id'><u><img src='./images/quote.gif' border='0'></u></a>
$ifadminmod
</div></div>
 
 
</td>
</tr>";
}
 
}
 
 
if($forum['private']==yes && !$pusers['id']){
$out[body].="
<tr bgcolor='$config[altcolora]'>
<td valign='center' align='center' background='$config[altcolorx]' colspan='5'>This thread is private.</td>
</tr>";
 
}
 
$out[body].="</table>";
 
$id = $_GET['id'];
if(mysql_num_rows(mysql_query("SELECT id FROM members WHERE name='{$_COOKIE['user']}' AND password='{$_COOKIE['pass']}'"))){
$out[body].="</center><div style='float:left'>
<img src='../images/stats/spacer.gif' border='0'><br />             
<a href='./reply.php?thread=$id'><img src='./images/reply.gif' border='0'></a><br /><center></div>";
}
 
$forum=mysql_query("SELECT * FROM forums_forums WHERE id='$thread[forum]'");
$forum=mysql_fetch_array($forum);
 
 
if(mysql_num_rows(mysql_query("SELECT id FROM members WHERE name='{$_COOKIE['user']}' AND password='{$_COOKIE['pass']}'"))){
 
$ifmod ="$fsettings[admins]";
$ifmod = explode(", ",$ifmod);  
$thismod="{$_COOKIE['tid']}";
 
if (in_array($thismod, $ifmod)){
 
 
$out[body].="</center>
<div style='float:right'>
<strong>Moderācija</strong><br />
<select name='mod[action]' class='button'>
<optgroup label='Opcijas'>
<option value='deleteposts'>Dzēst Ierakstus</option>
 
</optgroup>
 
</select> 
<input type='submit' name='submit' value='Aiziet' class='button'>             </form>
</div>";
}
 
$out[body].="
<div valign='center' align='left' style='background-color:$config[altcolora];width:99%;border: 1px solid rgb(0, 0, 0);' >
<table width='100%' cellspacing='1' cellpadding='0'><tr bgcolor='$config[altcolora]'>
<td width='100%' align='right' valign='center'>Lapas: $skippages  </td></tr><tr bgcolor='$config[altcolora]'>
<td align='center'>
<form method='post' action='./reply.php'><B>Ātrā Atbilde.</B></br>
<textarea class='button' name='quick[reply]' value='' maxlength='1575' style='width:430px; height:140px;'></textarea><br />
<table width='100%'><tr><td align='right'>
<input type='hidden' name='quick[thread]' value='$id'>
<input type='hidden' name='quick[forum]' value='$forum[id]'>
<input type='hidden' name='action' value='quickreply'>
<input type='submit' name='submit' value='Apstiprināt' class='button'></form></td><td align='left'><form method='post' action='./reply.php?thread=$id'>
<input type='submit' name='submit' value='Uzlabots Editors' class='button'></form></td></tr></table>
</td></tr>
</table></div><br /><br />";
}
 
 
$newviews=($thread[views] + 1);
mysql_query("UPDATE forums_threads SET 
views='$newviews'
WHERE id='$thread[id]'");
 
include($config[html]);
?>
Edited by defaultaizz
Link to comment
Share on other sites

Jesus Christ, viens slikts piemērs pēc otra...

1. mysql_* - deprecated, neizmanto to! Izmanto mysqli vai PDO.

2. Saistībā ar #1 - izmanto prepared statements.

3. Par CSS stylesheets neko laikam neesi dzirdējis?

4. mysql_num_rows(mysql_query("SELECT id ...")) - kas tas par murgu? Kāpēc tu neizmanto MySQL COUNT() funkciju?

Utt.

Kāpēc tu vispār programmē pats savu forumu, ja, acīmredzot, neesi normāli mācījies programmēt, pat ne labus piemērus izmantojis par pamatu? Šis kods ir drausmīgs!

 

Par konkrēto problēmu - kur vispār tev kaut kas izvadās, piemēram, tas pats $out masīvs? Šajā failā nekas netiek izvadīts.

Edited by jurchiks
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...