-
Notifications
You must be signed in to change notification settings - Fork 4
/
msgchecker.php
52 lines (50 loc) · 1.6 KB
/
msgchecker.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
49
50
51
52
<?php
session_start();
include 'connection.php';
$name = $_POST['name'];
// $sql = "SELECT convs, stored_at, ip FROM conv WHERE name = '$name';";
$sql = "SELECT `convs`, `ip`, `stored_at` FROM `conv` WHERE chatroom = '$name' ORDER BY `id` DESC";
// print_r($sql);
$res = "";
$result = mysqli_query($conn, $sql);
// print_r($result);
if(mysqli_num_rows($result)>0)
{
// $row = mysqli_fetch_assoc($result);
// if($row['ip'] == $_SERVER['REMOTE_ADDR'])
// {
// echo 'same';
$remote_ip = $_SERVER['REMOTE_ADDR'];
while ($row = mysqli_fetch_assoc($result)) {
if($row['ip'] == $remote_ip)
{
$sql1 = "SELECT `convs`, `ip`, `stored_at` FROM `conv` WHERE chatroom = '$name' AND ip = $remote_ip ORDER BY `id` DESC";
$res = $res.'<div class="container1">';
$res = $res.'<b style="color: #fca400">You</b>';
$res = $res."<p>".$row['convs'];
$res = $res.'</p> <span class="time-right">'.$row["stored_at"].'</span></div>';
}
else
{
$res = $res.'<div class="container">';
$res = $res.'<b style="color: #4ef55c">'.$row['ip'];
$res = $res." says</b> <p>".$row['convs'];
$res = $res.'</p> <span class="time-right">'.$row["stored_at"].'</span></div>';
}
}
// }
// else{
// // echo 'not same';
// }
// echo($row['ip']);
// echo $_SERVER['REMOTE_ADDR'];
// exit();
// while ($row = mysqli_fetch_assoc($result)) {
// $res = $res.'<div class="container">';
// $res = $res.'<b>'.$row['ip'];
// $res = $res." says</b> <p>".$row['convs'];
// $res = $res.'</p> <span class="time-right">'.$row["stored_at"].'</span></div>';
// }
}
echo $res;
?>