-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_messages.php
139 lines (131 loc) · 4.3 KB
/
my_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
<?php
include ("include/header.php");
?>
<h2>My Unread Messages:</h2><p />
<?php
//Grab the messages for the logged in user
$grab_messages = mysql_query("SELECT * FROM pvt_messages WHERE user_to='$username' && opened='no' && deleted='no'");
$numrows = mysql_numrows($grab_messages);
if ($numrows != 0) {
while ($get_msg = mysql_fetch_assoc($grab_messages)) {
$id = $get_msg['id'];
$user_from = $get_msg['user_from'];
$user_to = $get_msg['user_to'];
$msg_title = $get_msg['msg_title'];
$msg_body = $get_msg['msg_body'];
$date = $get_msg['date'];
$opened = $get_msg['opened'];
$deleted = $get_msg['deleted'];
?>
<script language="javascript">
function toggle<?php echo $id; ?>() {
var ele = document.getElementById("toggleText<?php echo $id; ?>");
var text = document.getElementById("displayText<?php echo $id; ?>");
if (ele.style.display == "block") {
ele.style.display = "none";
}
else
{
ele.style.display = "block";
}
}
</script>
<?php
if (strlen($msg_title) > 50) {
$msg_title = substr($msg_title, 0, 50)." ...";
}
else
$msg_title = $msg_title;
if (strlen($msg_body) > 150) {
$msg_body = substr($msg_body, 0, 150)." ...";
}
else
$msg_body = $msg_body;
if (@$_POST['setopened_' . $id . '']) {
//Update the private messages table
$setopened_query = mysql_query("UPDATE pvt_messages SET opened='yes' WHERE id='$id'");
}
echo "
<form method='POST' action='my_messages.php' name='$msg_title'>
<b><a href='profile.php?u=$user_from'>$user_from</a></b>
<input type='button' name='openmsg' value='$msg_title' onClick='javascript:toggle$id()'>
<input type='submit' name='setopened_$id' value=\"I've Read This\">
</form>
<div id='toggleText$id' style='display: none;'>
<br />$msg_body
</div>
<hr /><br />
";
}
}
else
{
echo "You haven't read any messages yet.";
}
?>
<h2>My Read Messages:</h2><p />
<?php
//Grab the messages for the logged in user
$grab_messages = mysql_query("SELECT * FROM pvt_messages WHERE user_to='$username' && opened='yes' && deleted='no'");
$numrows_read = mysql_numrows($grab_messages);
if ($numrows_read != 0) {
while ($get_msg = mysql_fetch_assoc($grab_messages)) {
$id = $get_msg['id'];
$user_from = $get_msg['user_from'];
$user_to = $get_msg['user_to'];
$msg_title = $get_msg['msg_title'];
$msg_body = $get_msg['msg_body'];
$date = $get_msg['date'];
$opened = $get_msg['opened'];
$deleted = $get_msg['deleted'];
?>
<script language="javascript">
function toggle<? echo $id; ?>() {
var ele = document.getElementById("toggleText<?php echo $id; ?>");
var text = document.getElementById("displayText<?php echo $id; ?>");
if (ele.style.display == "block") {
ele.style.display = "none";
}
else
{
ele.style.display = "block";
}
}
</script>
<?php
if (strlen($msg_title) > 50) {
$msg_title = substr($msg_title, 0, 50)." ...";
}
else
$msg_title = $msg_title;
if (strlen($msg_body) > 150) {
$msg_body = substr($msg_body, 0, 150)." ...";
}
else
$msg_body = $msg_body;
if (@$_POST['delete_' . $id . '']) {
$delete_msg_query = mysql_query("UPDATE pvt_messages SET deleted='yes' WHERE id='$id'");
}
if (@$_POST['reply_' . $id . '']) {
echo "<meta http-equiv=\"refresh\" content=\"0; url=msg_reply.php?u=$user_from\">";
}
echo " <form method='POST' action='my_messages.php' name='$msg_title'>
<b><a href='profile.php?u=$user_from'>$user_from</a></b>
<input type='button' name='openmsg' value='$msg_title' onClick='javascript:toggle$id()'>
<input type='submit' name='delete_$id' value=\"X\" title='Delete Message'>
<input type='submit' name='reply_$id' value=\"Reply\">
</form>
<div id='toggleText$id' style='display: none;'>
<br />$msg_body
</div>
<hr /><br />";
}
}
else
{
echo "You haven't read any messages yet.";
}
?>
<?php
include ("include/footer.php");
?>