Location: PHPKode > projects > ProjectPress > projectpress/profile/add_comment.php
<?php
/**
 * ProjectPress add a wall comment
 *
 * @package ProjectPress
 * @since 2.0
 */

// Starts the session.
session_start();
define('access',true);
require_once(dirname(dirname(__FILE__)). '/config.inc.php');
require_once(PM_DIR . 'pm-includes/global.inc.php');
require_once(PM_DIR . 'pm-includes/functions.php');

// Checks if user is logged in; if not redirect to login page.
if($current_user->hasPermission('access_site') != true) { pm_redirect(PM_URI . '/index.php'); }

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

	if(pmdb::connect()->escape($_REQUEST['comment_text']) && $_REQUEST['post_id'])
	{
		$username = $_SESSION['username'];	
		pmdb::connect()->query("INSERT INTO ". DB ."wall_posts_comments (post_id,comments,c_user,date_created,first_name,last_name,email) VALUES('".$_REQUEST['post_id']."','".pmdb::connect()->escape($_REQUEST['comment_text'])."','".$username."','".strtotime(date("Y-m-d H:i:s"))."','".$_SESSION['first_name']."','".$_SESSION['last_name']."', (SELECT email FROM " . DB . "members where username = '$username'))");
		
		$result = pmdb::connect()->query("SELECT *,
		UNIX_TIMESTAMP() - date_created AS CommentTimeSpent FROM ". DB ."wall_posts_comments order by c_id desc limit 1");
	}

	while ($rows = $result->fetch_object())
	{
		$days2 = floor($rows->CommentTimeSpent / (60 * 60 * 24));
		$remainder = $rows->CommentTimeSpent % (60 * 60 * 24);
		$hours = floor($remainder / (60 * 60));
		$remainder = $remainder % (60 * 60);
		$minutes = floor($remainder / 60);
		$seconds = $remainder % 60;	?>
		<div class="commentPanel" id="record-<?php echo $rows->c_id;?>" align="left">
			<?php echo get_user_avatar($rows->c_user,$rows->email); ?>
			<label class="postedComments">
				<a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $rows->c_user; ?>"><span id="name"><?php echo $rows->first_name; ?> <?php echo $rows->last_name; ?></span></a> <?php echo clickable_link($rows->comments);?>
			</label>
			<br clear="all" />
			
			<span style="margin-left:43px; color:#666666; font-size:11px">
			<?php
			
			if($days2 > 0)
			echo date('F d Y', $rows->date_created);
			elseif($days2 == 0 && $hours == 0 && $minutes == 0)
			echo "few seconds ago";		
			elseif($days2 == 0 && $hours == 0)
			echo $minutes.' minutes ago';
			else
			echo "few seconds ago";	
			
			?>
			</span>
			
			<?php
			$username = $_SESSION['username'];
			if($rows->c_user == $username){?>
			&nbsp;&nbsp;<a href="#" id="CID-<?php echo $rows->c_id;?>" class="c_delete">Delete</a>
			<?php
			}?>
		</div>
	<?php
	}
Return current item: ProjectPress