-
Notifications
You must be signed in to change notification settings - Fork 0
/
readmessage.php
79 lines (75 loc) · 2.6 KB
/
readmessage.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
<?php
include("include/authentication.php");
if(isset($_GET['id']))
{
$id = $_GET['id'];
$data = mysql_query('SELECT * FROM inbox WHERE id='.$_GET['id'].';', $connection) or header("Location: inbox.php");
$row = mysql_fetch_array($data, MYSQL_ASSOC);
if($row['userid']!=$_COOKIE['userid'] && ($row['senderid'] != $_COOKIE['userid']))
{
ob_end_flush();
ob_start();
header("Location: inbox.php");
}
}
else
{
header("Location: inbox.php");
}
if(isset($_COOKIE['userid']) && ($_COOKIE['userid'] == $row['userid']))
{
mysql_query('UPDATE inbox SET new = 0 where id='.$_GET['id'].';', $connection);
$message = $row['message'];
}
else if(isset($_COOKIE['userid']) && ($_COOKIE['userid'] == $row['senderid']))
{
$message = $row['message'];
}
if($row['showMess'] == 0 && $_COOKIE['userid'] == $row['userid'])
{
header('Location: inbox.php');
}
$data = mysql_query('SELECT login.id, name FROM login, users WHERE login.id = users.id AND users.id='.$row['senderid'].';', $connection);
$sender = mysql_fetch_array($data, MYSQL_ASSOC);
$dataReceive = mysql_query('SELECT login.id, name FROM login, users WHERE login.id = users.id AND users.id='.$row['userid'].';', $connection);
$receiver = mysql_fetch_array($dataReceive, MYSQL_ASSOC);
include("include/header.php");
?>
<html>
<head>
<title>Inbox</title>
</head>
<body>
<div id="mainContentPart">
<div class="schoolIndexCenterbox">
<?php
print '<div id="messageOptions">';
if(isset($_COOKIE['userid']) && ($_COOKIE['userid'] == $row['userid']))
{
print '<a href="profile.php?id='.$sender['id'].'">User\'s Profile</a> ';
print '<a href="compose.php?id='.$row['senderid'].'&re=1&mid='.$_GET['id'].'">Reply</a> ';
print '<a id="delete" href="inbox.php?id='.$_GET['id'].'&delete=1">Delete</a> ';
}
print '<a href="/inbox">Back to Inbox</a>';
print '</div>';
if($_COOKIE['userid'] == $row['userid'])
{
print '<div id="messageBody"><span id="messageFrom"><b><u>From:</u></b> '.$sender['name'].'</span><br />';
}
else
{
print '<div id="messageBody"><span id="messageFrom"><b><u>From:</u></b> You<b><u><br>To:</u></b>'.$receiver['name'].'</span><br />';
}
print '<span id="subjectFrom"><b><u>Subject:</u></b> '.$row['subject'].'</span><br />';
print '<b><u>Message:</u></b><span id="messageContent">'.nl2br($message).'<br /><br /></span>';
print '</div>';
print'<a href="inbox.php">Back to Inbox</a>';
print '</div>';
?>
</div>
</div>
</div>
</div>
<img id="bodyBottom" src="/images/bodybottom.gif"></img>
</body>
</html>