<?php
 $msg_id=$data['msg_id'];
 $orimessage=$data['message'];
 $message=htmlcode($orimessage);
 $time=$data['created'];
 $mtime=date("c", $time);
 $username=$data['username'];
 // instead check if it is set or use null:
 $uploads = isset($data['uploads']) ? $data['uploads'] : NULL;
 $privacy  = isset($data['secret_option']) ? $data['secret_option'] : NULL;
 $msg_uid = isset($data['uid_fk']) ? $data['uid_fk'] : NULL;
 $like_count = isset($data['like_count']) ? $data['like_count'] : NULL;
 $omsg_id=$msg_id;		
  /* User Avatar*/
  $face = $MatAdmin->User_Profilepic($msg_uid,$base_url); 
  /* End Avatar */ 				
?>
<div class="user-post" id="stbody<?php echo $msg_id;?>">
   <div class="user-post-area">
     <div class="who-posted">
     <a href="<?php echo $base_url.$username;?>"><div class="user-pimg"><img src="<?php echo $face;?>" /></div>
     <div class="user-pname"><?php echo htmlspecialchars($WallAdmin->UserFullName($username));?></div></a>
     <div class="posted-time ShowStatus" data-id="<?php echo $msg_id;?>">
      <div class="icon-time icon-clock-3"></div>
       <a href='#' class="timeago" title='<?php echo $mtime; ?>'></a></div>
       <div class="report_delete_pop ReportupdateDelete" id="<?php echo $data["msg_id"] ?>">Delete this post</div>
</div>
<div class="posted-photo">
<?php
if($uploads){
   echo '<div class="photo">';
   $s = explode(",", $uploads); // Explode the images string value
   $r=1;
   $f=count($s);
   // Add to array the available images
   foreach($s as $a) {
	 // Get the uploaded image ids
     $newdata=$MatAdmin->Get_Upload_Image_Id($a);
     if($newdata) {
		 // The path to be parsed
        $final_image=$base_url."uploads/".$newdata['image_path'];
         echo '<div class="fphoto-item"><a href="'.$final_image.'" data-lightbox="lightbox'.$msg_id.'"><img src="'.$final_image.'" class="imgpreview" id="'.$omsg_id.'" rel="'.$msg_id.'"/></a></div>';
      }
      $r=$r+1;
      }
      echo '</div>';
   }
?>
<?php
// This is the Mat_Expand.php statemnt
// If the update (orimessage = message) have a link
if(textlink($orimessage)) {
	$codesrc='';
    $code='';
	$link =textlink($orimessage);
    $em = new Mat_Expand($link);
	// Get the link size
    $site = $em->get_site();
    if($site != ""){
		// If code is iframe then show the link in iframe
       $code = $em->get_iframe();
       if($code == ""){
		   // If code is embed then show the link in embed
          $code = $em->get_embed();
          if($code == "") {
			  // If code is thumb then show the link medium
             $codesrc=$em->get_thumb("medium");
           }
        }
        if($codesrc) {
			// Get the codesrc medium thumb (image)
           echo '<div class="img_container"><img src='.$codesrc.' class="imgpreview" /></div>';
          } else if($code)
                   echo $code;
          }
     }
?>		
<?php 
if($message) {
	// If the update have a text then show the text 
    echo '<div class="post-text">'.$message.'</div>';
  }
?>
</div>
<div class="post-like-unlike-comment">
  </div>
<?php 
if($like_count>0) { 
   // If like cound is not 0 
   // Check the liked user
   $likesuserdata=$MatAdmin->Like_Users($msg_id);
   if($likesuserdata){
	   // Show the liked user data
      echo '<div class="who-likes-this-post likes" id="likes'.$omsg_id.'">';
      $i=1;
      $j=count($likesuserdata);
	  // Add to array the like user data
      foreach($likesuserdata as $likesdata) {
         $you="likeuser".$omsg_id;
         $likeusername=$likesdata['username'];
		  // Liked user echoing
           echo '<a href="'.$base_url.$likeusername.'">
		   <span class="b-renk" id="'.$you.'">'.htmlspecialchars($MatAdmin->UserFullName($likeusername)).'</span>
		   </a>';
           if($j!=$i) {
              echo ', ';
             }
             $i=$i+1;
             }
             if($like_count>3) {
				 // If total like is greater than 3 then collapse the next like
                $like_count=$like_count-3;
				// and show the echo
                echo ' and <span id="like_count'.$omsg_id.'" class="numcount">'.$like_count.'</span> other people like this.'; 
              } else {
                  echo ' like this.'; 
              }
               echo '</div>';
              }
              } else {
            echo '<div class="likes" id="elikes'.$omsg_id.'" style="display:none"></div>';
    }
?>
</div>
<div class="comments-area" id="commentload<?php echo $omsg_id;?>">
<?php 
$x=1;
// Load all comments
include('comment_load.php');
?>
</div>
 </div>
