-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory.php
48 lines (42 loc) · 1.29 KB
/
history.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require 'db.php';
session_start();
if ($_SESSION['email']==null){
$_SESSION['msg']="Try to access your account through the login page.";
$_SESSION['msg_head']='ERROR';
header("location: msg.php");
}
$from = $mysqli->escape_string($_SESSION['username']);
$to = $mysqli->escape_string($_POST['to_user_id']);
echo fetch_all_data($from, $to, $mysqli);
function fetch_all_data($from, $to, $mysqli){
$fetchin = $mysqli->query("SELECT * from gagan_msg where (gfrom='$from' and gto = '$to') or (gfrom='$to' and gto = '$from') order by occur desc");
$output = '<ul class="list-unstyled">';
while( $row = $fetchin->fetch_assoc())
{
$message=trim($row["msg"]);
str_replace("<","<",$message);
str_replace(">",">",$message);
$user_name = '';
if($row["gfrom"] == $from)
{
$uname = '<b class="text-success">You</b>';
}
else
{
$uname = '<b class="text-danger">'.$to.'</b>';
}
$output .= '
<li style="border-bottom:1px dotted #ccc">
<p>'.$uname.' - '.htmlspecialchars($message, ENT_COMPAT | ENT_HTML5, 'UTF-8').'
<div align="right">
- <small><em>'.$row['occur'].'</em></small>
</div>
</p>
</li>
';
}
$output .= '</ul>';
return $output;
}
?>