Thread: Forum
View Single Post
Old 01-09-2008, 03:46 PM   #31 (permalink)
Village Idiot
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

A forum is an advanced project, I dont consider doing it bad doing it at all. For such an advanced project, so many newbies do it. I did one in late 2005, look how it turned out
http://www.justanotherportfolio.com/forum.zip

Note:
-The cookie was formatted as "username|pass|id|rank" unencrypted
-All the posts where assigned to an array in a loop, then displayed in another
-The mysql didnt use auto_increment, I assigned the ID based off of the number of rows in the database. I just didnt delete anything to keep it working.

I would show you the version still on the web, but its been hacked over and is now unusable.

PHP Code:
<html>
<head>
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="css.css" />

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php

mysql_connect
("localhost","name","pass");
mysql_select_db("db");

//get and check the login cookie

$login_cookie $_COOKIE["login_cookie"];


$login_info explode('|',$login_cookie);

$login_sn $login_info[0];
$login_pass $login_info[1];
$login_id $login_info[2];
$login_rank $login_info[3];


$loginresult mysql_query("SElECT * FROM user_tbl WHERE user_id = '$login_id'");
$sqlpass mysql_result($loginresult,'0',"user_pass");
$sqlrank mysql_result($loginresult,'0',"user_type_id");
$avatar mysql_result($loginresult,'0',"user_avatar");


//check pass
//if($login_pass != $sqlpass)
//{
//die("please log in");
//}


$id $_GET["forum_id"];
$topic_id $_GET["topic"];

//assign the nessesary data
$all_resp_data mysql_query("SELECT * FROM board_response_tbl WHERE resp_question_id = '$topic_id' AND resp_response_active = '1' ORDER BY resp_response_id ASC");
$resp_count mysql_num_rows($all_resp_data);

$all_question_data mysql_query("SELECT * FROM board_question_tbl WHERE ques_question_id = '$topic_id'");
$topic_origin_post2 mysql_result($all_question_data,'0',"ques_question_txt");
$allow_replys mysql_result($all_question_data,'0',"ques_allow_responses");
$topic_origin_post nl2br($topic_origin_post2);

$user_posts mysql_query("SELECT * FROM board_response_tbl WHERE resp_response_by = 'login_id'");
$user_post_count mysql_num_rows($user_posts);


//nav data
$nav_forum mysql_query("SELECT * FROM board_forum_tbl WHERE forum_id = '$id'");
$nav_forum_name mysql_result($nav_forum,'0',"forum_name");

$nav_topic mysql_query("SELECT * FROM board_question_tbl WHERE ques_question_ID = '$topic_id'");
$nav_topic_name mysql_result($nav_topic,'0',"ques_question_name");

//get the ranks
if($login_rank == 0)
{
$rank "master";
}

if(
$login_rank == 1)
{
$rank "admin";
}

if(
$login_rank == 2)
{
$rank "moderator";
}

if(
$login_rank == 3)
{
$rank "user";
}

//assign the side data
$post_sider "$login_sn<BR><img src = \"$avatar\" alt = \"avatar\" width=\"90\" height=\"78\"> <br><h6>user posts: $user_post_count <br>rank: $rank <br></h6> 
"
;

$post = array();
$post_maker = array();
$date_posted = array();
$post_id = array();
$post_text = array();

#assign the data in the arrays
for($loop=0;$loop<$resp_count;$loop++)
{
    
$post_text[$loop] = mysql_result($all_resp_data,$loop,"resp_response_txt");
    
$post_maker[$loop] = mysql_result($all_resp_data,$loop,"resp_response_by");
    
$date_posted[$loop] = mysql_result($all_resp_data,$loop,"resp_create_dt");
    
$post_id[$loop] =  mysql_result($all_resp_data,$loop,"resp_response_id");
    
$post[$loop] = mysql_result($all_resp_data,$loop,"resp_response_txt");
}


//see what the edition options will be
if($login_rank <4)
{
$topic_options "<a href = \"http://www.cfwebanalysts.com/L2W/nrc/nrcbb/edittopic.php?topic_id=$topic_id\">edit topic</a>";
}


#--------------------------------------
#------------display data--------------
#--------------------------------------

//now display the data


//display the top navagation
echo "<a href = \"http://www.cfwebanalysts.com/L2W/nrc/nrcbb/\">index</a> >> 
      <a href = \"http://www.cfwebanalysts.com/L2W/nrc/nrcbb/gentopic.php?forum=
$id\"> $nav_forum_name</a> >>
      <a href = \"http://www.cfwebanalysts.com/L2W/nrc/nrcbb/genmessage.php?forum=
$id&topic=$topic_id\"> $nav_topic_name</a><BR>";


echo 
"<table width=\"742\" border=\"5\">
  <tr> 
    <td width=\"157\" height=\"127\" valign=\"top\">
$post_sider</td>
    <td width=\"567\" rowspan=\"2\" valign=\"top\">
$topic_origin_post</td>
  </tr>
  <tr> 
    <td height=\"11\"></td>
  </tr>
  <tr> 
    <td height=\"33\" colspan=\"2\" valign=\"top\">
$topic_options</td>
    </tr>
  <tr>
    <td height=\"2\"></td>
    <td></td>
  </tr>
</table><BR>"
;


for(
$loop2=0;$loop2<$resp_count;$loop2++)
{
$post_id mysql_result($all_resp_data,$loop2,"resp_response_id");

if(
$login_rank <4)
{
$options "<a href = \"http://www.cfwebanalysts.com/L2W/nrc/nrcbb/mark.php?post_id=$post_id&forum=$id&topic_id=$topic_id\">report to moderator</a> <a href = \"http://www.cfwebanalysts.com/L2W/nrc/nrcbb/editpost.php?post_id=$post_id&forum=$id&topic_id=$topic_id\">edit post</a>";
}

echo 
"
<table width=\"742\" border=\"5\">
  <tr> 
    <td width=\"157\" height=\"127\" valign=\"top\">
$post_sider</td>
    <td width=\"567\" rowspan=\"2\" class = \"post\" valign=\"top\">
$post[$loop2]</td>
  </tr>
  <tr> 
    <td height=\"11\"></td>
  </tr>
  <tr> 
    <td height=\"33\" colspan=\"2\" valign=\"top\">
$options</td>
    </tr>
  <tr>
    <td height=\"2\"></td>
    <td></td>
  </tr>
<a name=\"
$post_id\"></a>
</table><BR>"
;
}

if(
$allow_replys == 1)
{
echo 
"<BR><BR>
<a href = \"http://www.cfwebanalysts.com/L2W/nrc/nrcbb/postmessage.php?forum=
$id&topic=$topic_id\">Post reply</a>";
}
else
{
echo 
"<B>topic LOCKED</B>";
}
mysql_close();
?>
</body>
</html>
__________________

Village Idiot is offline  
Reply With Quote