old frineds.php

Viser sine venner.
 avatar
unknown
php
3 years ago
4.8 kB
89
Indexable
<?php
        if (isset($_GET['friends_page'])) {
            $friends_page = $_GET['friends_page'];
        } else {
            $friends_page = 1;
        }
        $no_of_records_per_page = 12;
        $offset = ($friends_page-1) * $no_of_records_per_page;
		$total_pages_sql = "SELECT COUNT(DISTINCT(id)) AS entries FROM `friends` AS pt WHERE `receiver_accept` != 1 AND (`senderid` = '" . $UsersID . "' OR `receiverid` = '" . $UsersID . "')";
        $result = mysqli_query($campist,$total_pages_sql);
        $total_rows = mysqli_fetch_array($result)[0];
        $total_pages = ceil($total_rows / $no_of_records_per_page);
		$entries = $total_rows["entries"];
	    if ($entries > 0):
$sql1 = "SELECT i.*, 
t.nickname AS sendername, 
t.photo AS sbilled, 
t1.nickname AS receivername, 
t1.photo AS rbilled, 
t.online AS senderOnline,
t1.online AS rOnline,
t.last_seen,
t1.last_seen
FROM `friends` i JOIN `users_information` t on t.profileID = i.senderid JOIN `users_information` t1 on t1.profileID = i.receiverid WHERE `receiver_accept` != 1 AND (`senderid` = '" . $UsersID . "' OR `receiverid` = '" . $UsersID . "') ORDER BY `id` ASC";
$sql1 .= " LIMIT $no_of_records_per_page OFFSET " . ($friends_page-1) * $no_of_records_per_page;
$result = mysqli_query($campist, $sql1);
while ($post = mysqli_fetch_array($result)) {
$currentTime = time();
$postTime = strtotime($post["last_seen"]);
$diff = $currentTime - $postTime;
$minutes = $diff / 60;
// Her udskriver vi år,dage,timer,minutter,sekunder.
if ($minutes > (24 * 60 * 365)) {
$text = round($minutes / (60 * 24 * 365), 0);
$text = $text . " år";
}
elseif ($minutes > (24 * 60)) {
$text = round($minutes / (60 * 24), 0);
if($text != 1){
$text = $text . " dage";
}else{
$text = $text . " dag";
} 
} elseif ($minutes > 60) {
$text = round($minutes / 60, 0);
if($text != 1){
$text = $text . " timer";
}else{
$text = $text . " time";
}
} elseif ($minutes > 2) {
$text = round($minutes, 0);
if($text != 1){
$text = $text . " minutter";
}else{
$text = $text . " minut";
}
} elseif ($minutes > 1) {
$text = round($minutes, 0) . " minut";
} else {
$text = "$diff sekunder"; 
}
if($post['receiverid'] == $UsersID) {  // Mine venner!
?>
   <div class="col-md-4">
   <!-- START widget-->
   <div onclick="location.href='brugere/profil/<?php print $post["senderid"]; ?>/';" class="panel widget">
      <div style="background-image: url('/img/profile/profilecover.png')" class="panel-body text-center bg-center">
         <div class="row row-table">	 
<div class="moderatorIconFreinds">
  <div class="moderatorIconFreinds-top-left"><i title="Moderator" class="fas fa-user-shield"></i></div>
  <div class="moderatorIconFreinds-top-right">
  <?php if($post['rOnline'] == 1): ?>
  <i title="Online" style="color:#00ff00;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;" class="fas fa-circle"></i>
  <?php else: ?>
  <i title="Offline" style="color:red;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;" class="fas fa-circle"></i>
  <?php endif; ?>
  </div>
            <div class="col-xs-12 text-white">
               <img src="<?php print $post['sbilled']; ?>" alt="<?php print $post["senderid"]; ?>" class="img-thumbnail img-circle thumb128">
               <h3 class="m0"><?php print $post["sendername"]; ?></h3>
            </div>
         </div>
      </div></div>
   </div>
   <!-- END widget-->
   </div>
<?php

} else { // Venner som står under session ID
?>
   <div class="col-md-4">
   <!-- START widget-->
   <div onclick="location.href='brugere/profil/<?php print $post["receiverid"]; ?>/';" class="panel widget">
      <div style="background-image: url('/img/profile/profilecover.png')" class="panel-body text-center bg-center">
         <div class="row row-table">	 
<div class="moderatorIconFreinds">
  <div class="moderatorIconFreinds-top-left"><i title="Moderator" class="fas fa-user-shield"></i></div>
  <div class="moderatorIconFreinds-top-right">
  <?php if($post['rOnline'] == 1): ?>
  <i title="Online" style="color:#00ff00;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;" class="fas fa-circle"></i>
  <?php else: ?>
  <i title="Offline" style="color:red;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;" class="fas fa-circle"></i>
  <?php endif; ?>
  </div>
            <div class="col-xs-12 text-white">
               <img src="<?php print $post['rbilled']; ?>" alt="<?php print $post["receivername"]; ?>" class="img-thumbnail img-circle thumb128">
               <h3 class="m0"><?php print $post["receivername"]; ?></h3>
            </div>
         </div>
      </div></div>
   </div>
   <!-- END widget-->
   </div>
<?php
}
}
else:
?>
<strong><?php echo $UsersNickname; ?></strong> har ingen venner.
<?php
endif;
?>