-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat.php
184 lines (151 loc) · 4.95 KB
/
chat.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
require_once("config.php");
require_once("sec.php");
echo "<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'>";
$email=$_COOKIE["u"];
$me=hell(clean(base64_decode($email),$conn),$conn)["id"];
$id=$_GET["user"];
function ider($id,$conn){
$qry="SELECT * FROM members WHERE id = '".clean($id,$conn)."'";
$result=mysqli_query($conn,$qry);
if($result) {
if(mysqli_num_rows($result) > 0) {
//Login Successful
$row = mysqli_fetch_assoc($result);
return $row;
}else {
//Login failed
return mysqli_error($conn);
}
}
}
if (isset($id)){
if ($id == $me){
header("location: chat.php");
}else{
$cook=ider($id,$conn);
?>
<link rel="stylesheet" href="test.css">
<link rel="stylesheet" href="log.css">
<link rel="stylesheet" href="common/font-awesome/css/font-awesome.css">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<style>
.l{
margin-bottom: 5px;
color:white;
background-color:blue;
width:90%;
padding: 5px;
border-radius: 20px 9px 9px 0px;
}
.ll{
margin-bottom: 5px;
color:black;
background-color:#c9c7c7;
padding: 5px;
width:90%;
border-radius: 9px 20px 0px 9px;
}
</style>
<body>
<div class="app-wrapper">
<nav class="main-menu">
<a href="#">Something</a>
<a href="#">Something</a>
<a href="#">Something</a>
</nav><!--#main-menu-->
<header>
<div style="top: 0px;width: 60px;height: 55px;left: 0px;" class="main-menu-button main-menu-button-left"><img src=<?php echo "offers/users/".md5($cook["email"]).".png" ?> width="100%" style="height: 100%;"></div>
<div class="main-menu-button main-menu-button-right"><a href="dashboard.php"><button class="logo btn"></button></a></div>
<h1 style="letter-spacing: 5px;"><?php echo $cook["name"]." ".$cook["last"];?></h1>
</header>
<div class="app-content">
<center>
<div style="height: 80%; float: none;padding-bottom: 60px;" class="content" id=main></div>
<div style="position:fixed;bottom: 5px;width: 100%;background: transparent;">
<!--<button style="border:0;border-radius:20px 0px 0px 20px;background:#f8a61b;color:black;height: 40px;" onclick="hell()">SEND</button>
--><input onkeydown="if (event.keyCode == 13) hell()" style="width: 100%;font-size: 14px;background:#000;float: right;color: #f8a61b;border-radius:30px;" id="text" class="fuu" placeholder="SEND..." style="font-size: 14px;background:#adc7f5;">
</div></center>
</div>
<script src="common/js/jQuery2.0.2.min.js"></script>
<script>
function hell(){
item=document.all["text"].value;
var d=0;
if (item.length == 0){
d=d+1;
}
if (d == 0){
$.ajax({
type: 'POST',
url: 'offers/chat-data.php',
//async: true,
data:{"text":item,"user":<?php echo $id;?>},
success:function fuck(kill){
document.all["main"].innerHTML=kill;
document.all["text"].value="";
}
})
}
}
function updater(){
$.ajax({
type: 'POST',
url: 'offers/chat-data.php',
//async: true,
data:{"xer":"xe","user":<?php echo $id;?>},
success:function fuck(kill){
document.all["main"].innerHTML=kill;
}
})
setTimeout('updater()', 5000);
}
updater();
</script>
<?php
}
}else{
$email=$_COOKIE["u"];
$cook=base64_decode($email);
?>
<link rel="stylesheet" href="test.css">
<link rel="stylesheet" href="log.css">
<link rel="stylesheet" href="common/font-awesome/css/font-awesome.css">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<body>
<div class="app-wrapper">
<nav class="main-menu">
<a href="#">Something</a>
<a href="#">Something</a>
<a href="#">Something</a>
</nav><!--#main-menu-->
<header>
<div style="top: 0px;width: 60px;height: 55px;left: 0px;" class="main-menu-button main-menu-button-left"><img src=<?php echo "offers/users/".md5($cook).".png" ?> width="100%" style="height: 100%;"></div>
<div class="main-menu-button main-menu-button-right"><a href="dashboard.php"><button class="logo btn"></button></a></div>
<h1 style="letter-spacing: 5px;">الرسائل</h1>
</header>
<div class="app-content">
<section>
<div class="content" id=main>
<?php
$qry="SELECT * FROM chat where idone = '".$me."' or idtwo='".$me."'";
$result=mysqli_query($conn,$qry);
if(mysqli_num_rows($result) > 0){
$ss="";
foreach($result as $f){
if ($f["idtwo"] ==$me){$x=$f["idone"];}else{$x=$f["idtwo"];}
$l=md5(ider($x,$conn)["email"]);
$name=ider($x,$conn)["name"]." ".ider($x,$conn)["last"];
if (!strpos($ss,$l)){
if (!($x == $me)){
echo '<a href="chat.php?user='.$x.'">
<div style="width:100%;display:-webkit-box;background: #fce0b5;border-radius: 30px 0px 0px 30px;height: 100px;">
<div style="width:30%;float;left;"><img style="" src="offers/users/'.$l.'.png" width=100% height=100%></div>
<div style="float;right;padding:20px 0px 0px 20px;color: black;">'.$name." : ".$f["messages"].'</div>
</div></a><br>';
$ss=$ss." ".$l;}}
}
}
}
?>
<!-- Tarik Bakir :\) --\>