File manager - Edit - /home/custbahd/irungikitchen.com/admin/chat/get-chat/index.php
Back
<?php session_start(); if(isset($_SESSION['user_id'])){ include_once "../../db/config.php"; echo '<img src="../../images/logo-light.png" class="chat_img float-bounce-right">'; $outgoing_id = $_SESSION['user_id']; $incoming_id = mysqli_real_escape_string($conn, $_POST['incoming_id']); $output = ""; $sql = "SELECT * FROM messages WHERE (outgoing_msg_id = '$outgoing_id' AND incoming_msg_id = '$incoming_id') OR (outgoing_msg_id = '$incoming_id' AND incoming_msg_id = '$outgoing_id') ORDER BY id"; $query = mysqli_query($conn, $sql); if(mysqli_num_rows($query) > 0){ while($row = mysqli_fetch_assoc($query)){ //Time date_default_timezone_set('Africa/Kampala'); $start_count = date("Y-m-d H:i:s", strtotime($row['timestamp'] . "+1 days")); $today = date("Y-m-d H:i:s",time()); $start_diff = new DateTimeImmutable($row['timestamp']); $endd_diff = new DateTimeImmutable($today); $duration = $start_diff->diff($endd_diff); $today_diff = new DateTimeImmutable($today); $days_diff = $today_diff->diff($start_diff); if ($days_diff->format('%i')==0) { $time = "<small class='d-block'>Just Now</small>"; } elseif ($days_diff->format('%i')>=0 & $days_diff->format('%h')>=0 & $days_diff->format('%d')>=0 & $days_diff->format('%m')>=0 & $days_diff->format('%y')==1) { $time = "<small class='d-block'>".date("d/m/y", strtotime($row['timestamp']))."</small>"; } elseif ($days_diff->format('%i')>=0 & $days_diff->format('%h')>=0 & $days_diff->format('%d')>=0 & $days_diff->format('%m')>=0 & $days_diff->format('%y')>=1) { $time = "<small class='d-block'>".date("d/m/y", strtotime($row['timestamp']))."</small>"; } elseif ($days_diff->format('%i')==1 & $days_diff->format('%h')==0 & $days_diff->format('%d')==0) { $time = "<small class='d-block'>".$days_diff->format("%i min")." ago</small>"; } elseif ($days_diff->format('%i')>=0 & $days_diff->format('%h')==0 & $days_diff->format('%d')==0) { $time = "<small class='d-block'>".$days_diff->format("%i mins")." ago</small>"; } elseif ($days_diff->format('%h')==1 & $days_diff->format('%d')==0 & $days_diff->format('%m')==0) { $time = "<small class='d-block'>".$days_diff->format("%h hour")." ago</small>"; } elseif ($days_diff->format('%h')>=0 & $days_diff->format('%d')==0 & $days_diff->format('%m')==0) { $time = "<small class='d-block'>".$days_diff->format("%h hours")." ago</small>"; } elseif ($days_diff->format('%d')==1) { $time = "<small class='d-block'>Yesterday at ".date("h:ia", strtotime($row['timestamp']))."</small>"; } elseif ($days_diff->format('%m')==0) { $time = "<small class='d-block'>".date("D", strtotime($row['timestamp']))." at ".date("h:ia", strtotime($row['timestamp']))."</small>"; } elseif ($days_diff->format('%m')==1) { $time = "<small class='d-block'>Last Month</small>"; } elseif ($days_diff->format('%m')>=1) { $time = "<small class='d-block'>".date("M jS", strtotime($row['timestamp']))."</small>"; } //User Image if ($row['user_image'] != '' & $row['outgoing_msg_id'] == $outgoing_id) { $user_image = '<img src="../../'.$row["sender_image"] .'" alt="'.$row['sender_name'].'">'; } elseif ($row['sender_image'] != '' & $row['outgoing_msg_id'] != $outgoing_id) { $sender_image = '<img src="../../'.$row["sender_image"] .'" alt="'.$row['sender_name'].'">'; } elseif ($row['user_image'] == '' & $row['outgoing_msg_id'] == $outgoing_id) { $user_image = '<img src="../../'.$row["sender_image"] .'" alt="'.$row['sender_name'].'">'; } elseif ($row['sender_image'] == '' & $row['outgoing_msg_id'] != $outgoing_id) { $sender_image = '<img src="../../'.$row["sender_image"] .'" alt="'.$row['sender_name'].'">'; } if ($row['incoming_msg_unread'] != '') { $tick = "<i class='fa fa-check'></i>"; $msg_unread = "msg_unread"; } else { $tick = "<i class='fa fa-check one'></i>"; $msg_unread = ""; } //Message if($row['outgoing_msg_id'] === $outgoing_id){ $output .= '<div class="chat outgoing"> <div class="details"> <p>'.$tick.' '. $row['user_message'] .' '.$time.'</p> </div> '.$user_image.' </div>'; }else{ $output .= '<div class="chat incoming"> '.$sender_image.' <div class="details"> <p class="'.$msg_unread.'">'. $row['user_message'] .' '.$time.'</p> </div> </div>'; } } }else{ $output .= '<div class="text">No messages are available. Once you send message they will appear here.</div>'; } echo $output; }else{ header("location: ../../"); } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 1.8 |
proxy
|
phpinfo
|
Settings