/
chatbox.php
148 lines (98 loc) · 4.11 KB
/
chatbox.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<html>
<head>
<meta charset="UTF-8">
<title>Chat Box</title>
<link rel='stylesheet prefetch' href='down/bootstrap.min.css'>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php
require_once 'header.php';
?>
<?php
#echo $rand = md5(substr(md5(microtime()),rand(0,26),11));
?>
<?php
require_once 'include/db_connect.php';
require_once 'include/essential.php';
$user=$_GET['user'];
$receiver= getuser($user, 'fname');
$sender= getuser($pid1, 'fname');
$rava= getavatar($user, 'avatar');
$senava= getavatar($pid1, 'avatar');
?>
<link rel="stylesheet" href="css/chat.css">
<div class="container">
<div class="row">
<div class="col-md-5">
<div class="panel panel-primary">
<div class="panel-heading" id="accordion">
<span class="glyphicon glyphicon-comment"></span> Chat
<div class="btn-group pull-right">
<a type="button" class="btn btn-default btn-xs" data-toggle="collapse" data-parent="#accordion"
href="#collapseOne">
<span class="glyphicon glyphicon-chevron-down"></span>
</a>
</div>
</div>
<div class="panel-collapse collapse" id="collapseOne">
<div class="panel-body" >
<?php
require_once 'include/db_connect.php';
if(isset($_GET['user'])and isset($_GET['hash']))
{
$hash=$_GET['hash'];
$user=$_GET['user'];
$ext= mysql_query("select * from conversation where chash='$hash' ");
while ($row = mysql_fetch_array($ext)) {
$cfrom=$row['cfrom'];
$cfrom1= getuser($cfrom, 'user_name');
$msg=$row['msg'];
echo "<ul class='chat'>
<li class='left clearfix'><span class='chat-img pull-left'>
<img src='img/user.png' height='50' width='50' alt='User Avatar' class='img-circle' />
</span>
<div class='chat-body clearfix'>
<div class='header'>
<strong class='primary-font'>". $cfrom1."</strong> <small class='pull-right text-muted'>
<span class='glyphicon glyphicon-time'></span></small>
</div>
<p>
". $msg."
</p>
</div>
</li>
</ul>";
}
}
?>
</div>
<form action="chatupdate.php" method="post">
<div class="panel-footer">
<div class="input-group">
<input id="btn-input" type="text" class="form-control input-sm" name="message" placeholder="Type your message
here..." />
<input type="hidden" name="user" value="<?php echo $user;?>">
<button onclick="myFunction()">Reload Messages</button>
<script>
function myFunction() {
location.reload();
}
</script>
<span class="input-group-btn">
<button class="btn btn-warning btn-sm" id="btn-chat">
Send</button>
</span>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
<?php
require_once 'footer.php';
?>
</html>