This repository was archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmessages.php
410 lines (381 loc) · 11.4 KB
/
messages.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<?php
session_start();
include "exec/dbconnect.php";
include "exec/check_user.php";
include "exec/datefn.php";
if($_SESSION['loginin'] != "1"){
$_SESSION['errormsg'] = "Пожалуйста, авторизируйтесь.";
header("Location: blank/..");
exit();
}
include "exec/header.php";
include "exec/leftmenu.php";
?>
<style>
#content-infoname{
margin-bottom:0px;
}
.im{
text-decoration:none;
color:black;
margin: 0px;
}
.im:hover{
text-decoration:none;
color:black;
}
.im-mess{
border-top:solid 1px #e7e8ec;
}
.im-mess:hover{
background:#F5F7FA;
}
.im-mess-unread{
border-top:solid 1px #e7e8ec;
background:#FAFBFD;
}
.im-mess-unread:hover{
background:#F5F7FA;
}
.messages-listelement{
width:639px;
}
</style>
<? if ($_GET == null){ ?>
<div id="content-infoname"><b>Личные сообщения</b><div style="float:right;"><a href="sendmessage.php">Написать сообщение</a></div></div>
<div>
<ul id="Tabs">
<li id="RecivedTab" class="SelectedTab"><a href="#" onclick=" Recived(); return false;">Полученные</a></li>
<li id="SendedTab" class="Tab"><a href="#" onclick="Sended(); return false;">Отправленные</a></li>
</ul>
<div id="Content" style="width:619px;">
<!-- Первая -->
<div style="display: block; margin-top: 22px;" id="Recived">
<p>
<?php
$qim1 = $dbh1->prepare("SELECT * FROM `messages` WHERE id2 = '".$_SESSION['id']."' ORDER BY id DESC");
$qim1->execute();
while($im1 = $qim1->fetch()){
if($im1['topic']){
$top = ' / '.$im1['topic'];
}
if($im1['readed'] == "0"){
$redit = "-unread";
}else{
$redit = "";
}
$imc1 = "1";
$quser = $dbh1->prepare("SELECT * FROM `users` WHERE id = '".$im1['id1']."'");
$quser->execute();
$user = $quser->fetch();
if ($im1['readed'] == "0") {
$readedd = 'style="background-color: #CCC"';
}else{
$readedd = '';
}
if ($user['avatar'] == "") {
$avatar = 'img/camera_200.png';
}else{
$avatar = 'avatarc.php?image='.$user['avatar'];
}
/*echo '
<a href="messages.php?id='.$im1['id'].'">
<table class="messages-listelement" '.$readedd.'>
<tr>
<td>
<img src="'.$avatar.'" width="50">
</td>
<td width="559px">
<table>
<tr>
<td style="font-size: 11px;">
'.$user['name'].' '.$user['surname'].'
</td>
<td style="font-size: 11px;color: #555;">
'.$im1['topic'].'
</td>
</tr>
<tr>
<td style="font-size: 11px;color: #111;">
'.zmdate($im1['date']).'
</td>
<td style="font-size: 11px;color: #777;">
'.$im1['text'].'
</td>
</tr>
</table>
</td>
</tr>
</table>
</a>';*/
?>
<a href="messages.php?id=<?php echo $im1['id']; ?>" class="im">
<div class="im-mess<?php echo $redit; ?>" style="padding: 5px 15px;margin:0 -10px;">
<table border="0" style="font-size:11px;">
<tr>
<td style="width: 44px;"><img src="<?php echo $avatar; ?>" width="40px" height="auto"></td>
<div style="float:right;"><?php
$daydate = date("z",$im1['date']);
$daynow = date("z",time());
if($daynow == $daydate){
echo date("H:i",$im1['date']);
}else{
echo zmdate($im1['date']);
}
$im1['text'] = preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '<a href="$1://$2">$1://$2</a>$3', $im1['text']);
?></div>
<td style="padding-left:10px;"><b style="color: #2b587a;font-size: 13px;"><?php echo $user['name'].' '.$user['surname']; ?></b><br><div style="margin-top:8px;"></div>
<?php echo str_replace('<br>', ' ', $im1['text']); ?>
</td>
</tr>
</table>
</div>
</a>
<?php
}
if($imc1 != "1"){
echo '<center><div style="margin:80px 120px;">
<table>
<tr>
<td style="width:80px;">
<img src="new/img/msnofo-error.png" style="border-radius:50%;margin-bottom:-3px;">
</td>
<td style="margin-left:8px;">
<b style="font-size:26px;">Пусто.</b><br>
<span style="font-size:13px;color:#000;">Вы можете зайти в список <a href="friends.php">своих друзей</a> и выбрать того, с кем Вы хотите пообщаться.</span>
</td>
</tr>
</table>
</div></center>';
} ?>
</p>
</div>
<div id="Sended" style="display: none;margin-top: 22px;">
<p><?php
$qim2 = $dbh1->prepare("SELECT * FROM `messages` WHERE id1 = '".$_SESSION['id']."' ORDER BY id DESC");
$qim2->execute();
while($im2 = $qim2->fetch()){
if($im2['topic']){
$top = ' / '.$im2['topic'];
}
if($im2['readed'] == "0"){
$redit = "-unread";
}else{
$redit = "";
}
$imc2 = "1";
$quser = $dbh1->prepare("SELECT * FROM `users` WHERE id = '".$im2['id2']."'");
$quser->execute();
$user = $quser->fetch();
if ($im2['readed'] == "0") {
$readedd = 'style="background-color: #CCC"';
}else{
$readedd = '';
}
if ($user['avatar'] == null) {
$avatar = "img/camera_200.png";
}else{
$avatar = 'avatarc.php?image='.$user['avatar'];
}
/*echo '
<table class="messages-listelement" '.$readedd.'>
<tr>
<td>
<img width="50" src="'.$avatar.'">
</td>
<td width="559px">
<table>
<tr>
<td style="font-size: 11px;">
'.$user['name'].' '.$user['surname'].'
</td>
<td style="font-size: 11px;color: #555;">
'.$im2['topic'].'
</td>
</tr>
<tr>
<td style="font-size: 11px;color: #111;">
'.zmdate($im2['date']).'
</td>
<td style="font-size: 11px;color: #777;">
'.$im2['text'].'
</td>
</tr>
</table>
</td>
</tr>
</table>';*/
?>
<div class="im" style="margin:0 -10px;">
<div class="im-mess<?php echo $redit; ?>" style="padding: 5px 15px;">
<table border="0" style="font-size:11px;">
<tr>
<td style="width:44px;"><img src="<?php echo $avatar; ?>" width="40px" height="auto"></td>
<td style="padding-left:10px;width: 100%;"><b style="color: #2b587a;font-size: 13px;"><?php echo $user['name'].' '.$user['surname']; ?></b><div style="float:right;"><?php
$daydate = date("z",$im2['date']);
$daynow = date("z",time());
if($daynow == $daydate){
echo date("H:i",$im2['date']);
}else{
echo zmdate($im2['date']);
}
$im2['text'] = preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '<a href="$1://$2">$1://$2</a>$3', $im2['text']);
?></div><br><div style="margin-top:8px;"></div>
<text style="padding-right:5px;color:#8b939b;">Вы:</text><?php echo str_replace('<br>', ' ', $im2['text']); ?>
<a href="del_mess.php?id=<?php echo $im2['id'];?>" style="float:right;">удалить</a>
</td>
</tr>
</table>
</div>
</div>
<?php
}
if($imc2 != "1"){
echo '<center><div style="margin:80px 120px;">
<table>
<tr>
<td style="width:80px;">
<img src="new/img/msnofo-error.png" style="border-radius:50%;margin-bottom:-3px;">
</td>
<td style="margin-left:8px;">
<b style="font-size:26px;">Пусто.</b><br>
<span style="font-size:13px;color:#000;">Вы можете зайти в список <a href="friends.php">своих друзей</a> и выбрать того, с кем Вы хотите пообщаться.</span>
</td>
</tr>
</table>
</div></center>';
}
?></p>
</div>
</div>
<script type="text/javascript">
// 1
function Recived()
{
// Табы
document.getElementById('RecivedTab').className = 'SelectedTab';
document.getElementById('SendedTab').className = 'Tab';
// Страницы
document.getElementById('Recived').style.display = 'block';
document.getElementById('RecivedTab').className = 'SelectedTab';
document.getElementById('Sended').style.display = 'none';
}
// 2
function Sended()
{
// Табы
document.getElementById('RecivedTab').className = 'Tab';
document.getElementById('SendedTab').className = 'SelectedTab';
// Страницы
document.getElementById('Recived').style.display = 'none';
document.getElementById('Sended').style.display = 'block';
}
</script>
<!--
<a href="#" class="testim">
<div class="testim-mess" style="padding:15px;margin:0 -10px;">
<table border="0" style="font-size:11px;">
<tr>
<td style="width:54px;"><img src="content/avatars/5150282922.jpg" width="50px" height="auto"></td>
<div style="float:right;">13:37</div>
<td style="padding-left:10px;"><b style="font-size:14px;">Илья Прокопенко</b><br><div style="margin-top:8px;"></div><text style="padding-right:5px;color:#8b939b;">Вы:</text>тест
</td>
</tr>
</table>
</div>
</a>
-->
</div>
<?php }else{
$qim = $dbh1->prepare("SELECT * FROM `messages` WHERE id = '".$_GET['id']."' ORDER BY id DESC");
$qim->execute();
$im = $qim->fetch();
if ($im['id2'] != $_SESSION['id']) {
echo 'Security Error!';
echo '<script type="text/javascript">';
echo 'window.location.href="index.php";';
echo '</script>';
exit();
}
$qimq = $dbh1->prepare("UPDATE `messages` SET `readed` = '1' WHERE id = ".$_GET['id']);
$qimq->execute();
$qimq->fetch();
$quser = $dbh1->prepare("SELECT * FROM `users` WHERE id = '".$im['id1']."'");
$quser->execute();
$user = $quser->fetch();
$im['topic'] = htmlentities($im['topic'],ENT_QUOTES);
$im['topic'] = htmlentities($im['topic'],ENT_QUOTES);
$im['topic'] = str_replace(array("\r\n", "\r", "\n"), '<br>', $im['topic']);
$im['text'] = preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '<a href="$1://$2">$1://$2</a>$3', $im['text']);
?>
<div id="content-infoname"><b><a href="messages.php">Личные сообщения</a> » Просмотр сообщения</b></div>
<div>
<div class="messages-view">
<h3>Сообщение:</h3>
<hr>
<span style="font-size: 9px"><?php echo zmdate($im['date']) ?></span>
<table>
<tr>
<td>
<?php if($user['avatar'] != ""){?>
<img src="avatarc.php?image=<?php echo $user['avatar'] ?>">
<?php }else{?>
<img src="img/camera_200.png" width="50">
<?php }?>
</td>
<td>
<table>
<tr>
<td style="font-size: 11px;">
<span>От кого:</span>
</td>
<td style="font-size: 11px;">
<?php echo '<a href="id'.$user['id'].'">'.$user['name'].' '.$user['surname'].'</a>'?>
</td>
</tr>
<tr>
<td style="font-size: 11px;">
<span>Кому:</span>
</td>
<td style="font-size: 11px;">
Вам
</td>
</tr>
<tr>
<td style="font-size: 11px;">
<span>Тема:</span>
</td>
<td style="font-size: 11px;">
<?php echo $im['topic']?>
</td>
</tr>
<tr>
<td style="font-size: 11px;vertical-align: top;">
<span>Сообщение:</span>
</td>
<td style="font-size: 11px;">
<?php echo $im['text']?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<form action="send_message.php" method="post">
<input name="id" type="hidden" value="<?php echo $user['id'] ?>">
<input type="hidden" name="topic" value="<?php echo 'Re: '.$im['topic']?>">
<textarea rows="5" id="text" name="text" style="min-width:420px;max-width:420px;min-height:71px;"></textarea><br><br>
<input type="submit" id="button" value="Отправить">
</form>
</div><br>
</p>
</div>
</div>
</div>
<?php } ?>
</div>
<div>
<?php include "exec/footer.php"; ?>
</div>
</body>
</html>