Location: PHPKode > projects > ProjectPress > projectpress/projects/forum/view_ptopic.php
<?php
/**
 * ProjectPress view project forum topic
 *
 * @package ProjectPress
 * @since 2.0
 */

// Starts the session.
session_start();

define('access',true);

include(dirname(dirname(dirname(__FILE__))) . '/config.inc.php');
include(PM_DIR . 'pm-includes/global.inc.php');
require(PM_DIR . 'pm-includes/functions.php');
include(PM_DIR . 'pm-includes/header.php');

if($current_user->hasPermission('access_site') != true) { pm_redirect(PM_URI . '/index.php'); }

// Enable for error checking and troubleshooting.
# display_errors();


// get value of id that sent from address bar 
$id = $_GET['id'];

$sql = "SELECT * FROM " . DB . "project_forum_topics, " . DB . "members WHERE pt_id = '".$_GET['p_id']."' AND pft_id = '$id' AND pft_user = username";
$result = pmdb::connect()->query($sql);

$row_a = $result->fetch_object();
?>

				<div id="page-title">
					<img src="<?php echo PM_URI; ?>/images/comment.png" alt="" /><h1>Project Forum</h1>
				</div>
				
				<div id="tabs">
					<ul>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "project.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/project.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Project</span></a>
						</li>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "discussions.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>
							<?php if (basename($_SERVER["REQUEST_URI"]) == "add_ptopic.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/forum/discussions.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Forum</span></a>
						</li>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "contact.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/contact.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Email</span></a>
						</li>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "project_members.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/project_members.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Members</span></a>
						</li>
					</ul>
				</div>
				
<div id="middle">
<h2>Topic: <a href="<?php echo PM_URI; ?>/projects/forum/view_ptopic.php?p_id=<?php echo $_GET['p_id']; ?>&id=<?php echo $_GET['id']; ?>"><?php echo $row_a->pft_topic; ?></a></h2>
<a href="<?php echo PM_URI ?>/projects/forum/discussions.php?p_id=<?php echo $_GET['p_id']; ?>">Go Back Forum Homepage</a><br /><br />
<table width="504" align="center" border="0" bgcolor="#DDD">
	<tr>
		<td align="left"><strong>Title:</strong> <?php echo $row_a->pft_topic; ?> </td> <td align="right"><strong>Date: </strong><?php echo date('M d, Y h:i A',strtotime($row_a->pft_datetime)); ?></td>
	</tr>
</table>

<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>
<td vAlign="top" class="forum">
	<table width="484" border="0">
		<tr>
			<td width="100%" class="forum-topic"><a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $row_a->pft_user;?>"><strong><? echo $row_a->first_name; ?> <?php echo $row_a->last_name; ?></strong></a> <?php echo $row_a->pft_detail; ?></td>
		</tr>
		<?php if($row_a->signature != '') { ?>
		<tr>
			<td class="forum-signature">
				<div class="avatar">
				<?php echo get_user_avatar($row_a->username,$row_a->email); ?>
				</div>
				
				<div class="signature">
				<?php echo nl2br($row_a->signature); ?>
				</div>
			</td>
		</tr>
		<?php } ?>
	</table>
</td>
</tr>
</table>

<br />
<?php 

$sql2 = "SELECT * FROM " . DB . "project_forum_posts, " . DB . "members WHERE topic_id='$id' AND pp_id = ".$_GET['p_id']." AND pfp_user = username ORDER BY p_id ASC";
$result2 = pmdb::connect()->query($sql2);

while($row_b = $result2->fetch_object()){
?>
<table width="504" align="center" border="0" bgcolor="#C6E2FF">
	<tr>
		<td align="left"><strong>Re:</strong> <?php echo $row_a->pft_topic; ?> </td> <td align="right"><strong>Reply Date: </strong><?php echo date('M d, Y h:i A',strtotime($row_b->pfp_datetime)); ?></td>
	</tr>
</table>

<table width="504" border="0" align="center" cellpadding="0" cellspacing="0" class="forum-1">

<tr>
<td vAlign="top" class="forum">
	<table width="484" border="0">
		<tr>
			<td width="100%"><a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $row_b->pfp_user;?>"><strong><?php echo $row_b->first_name; ?> <?php echo $row_b->last_name; ?></strong></a> <?php echo nl2br($row_b->pfp_post); ?></td>
		</tr>
		<tr>
			<td class="forum-topic"><?php if($row_b->pfp_post && $row_b->pfp_user == $_SESSION['username']) echo '<a href="edit_preply.php?p_id='.$_GET['p_id'].'&p_id='.$row_b->p_id.'">Edit</a> | ';?> <?php if($row_b->pfp_post && $row_b->pfp_user == $_SESSION['username']) echo '<a href="delete_pfp.php?p_id='.$_GET['p_id'].'&p_id='.$row_b->p_id.'">Delete</a>';?></td>
		</tr>
		<?php if($row_b->signature != '') { ?>
		<tr>
			<td class="forum-signature">
				<div class="avatar">
				<?php echo get_user_avatar($row_b->username,$row_b->email); ?>
				</div>
				
				<div class="signature">
				<?php echo nl2br($row_b->signature); ?>
				</div>
			</td>
		</tr>
		<?php } ?>
	</table>
</td>
</tr>
</table>

<?
}

$sql3 = "SELECT pft_view FROM " . DB . "project_forum_topics WHERE pft_id='$id' AND pt_id = '".$_GET['p_id']."'";
$result3 = pmdb::connect()->query($sql3);

$rows = $result3->fetch_array();
$pft_view = $rows['pft_view'];

// if have no counter value set counter = 1
if(empty($pft_view)){
$pft_view = 1;
$sql4 = "INSERT INTO " . DB . "project_forum_topics(pft_view) VALUES('$pft_view') WHERE pft_id='$id' AND pt_id = '".$_GET['p_id']."'";
$result4 = pmdb::connect()->query($sql4);
}

// count more value
$addview = $pft_view+1;
$sql5 = "update " . DB . "project_forum_topics set pft_view='$addview' WHERE pft_id='$id' AND pt_id = '".$_GET['p_id']."'";
$result5 = pmdb::connect()->query($sql5);
?>
<br />
<table width="495" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="<?php echo PM_URI ?>/projects/forum/preply.php?p_id=<?php echo $_GET['p_id']; ?>&id=<?php echo $_GET['id']; ?>">
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td valign="top"><strong>Quick Reply</strong><br />
<textarea class="forminput" name="pfp_post" cols="45" rows="3" id="pfp_post" style="width:500px;"></textarea></td>
</tr>
<tr>
<td><br />
<input name="id" type="hidden" value="<?php echo $id; ?>">
<input type="submit" name="Submit" value="Submit" id="sub_button"> <input type="reset" name="Submit2" value="Reset" id="sub_button"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>

<?php
include(PM_DIR . 'pm-includes/footer.php');
Return current item: ProjectPress