This repository was archived by the owner on Oct 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessages.php
More file actions
95 lines (77 loc) · 2.67 KB
/
messages.php
File metadata and controls
95 lines (77 loc) · 2.67 KB
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
<?php
require_once 'header.php';
include_once 'src/Database.php';
$db = new Database();
if (!$loggedin) die("</div></body></html>");
if (isset($_GET['view'])) $view = $db->sanitizeString($_GET['view']);
else $view = $user;
if (isset($_POST['text']))
{
$text = $db->sanitizeString($_POST['text']);
if ($text != "")
{
$pm = substr($db->sanitizeString($_POST['pm']),0,1);
$time = time();
$db->queryMysql("INSERT INTO messages VALUES(NULL, '$user',
'$view', '$pm', $time, '$text')");
}
}
if ($view != "")
{
if ($view == $user) $name1 = $name2 = "Your";
else
{
$name1 = "<a href='members.php?view=$view&r=$randstr'>$view</a>'s";
$name2 = "$view's";
}
echo "<h3>$name1 Messages</h3>";
$db->showProfile($view);
echo <<<_END
<form method='post' action='messages.php?view=$view&r=$randstr'>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Type here to leave a message</legend>
<input type='radio' name='pm' id='public' value='0' checked='checked'>
<label for="public">Public</label>
<input type='radio' name='pm' id='private' value='1'>
<label for="private">Private</label>
</fieldset>
<textarea name='text'></textarea>
<input data-transition='slide' type='submit' value='Post Message'>
</form><br>
_END;
date_default_timezone_set('UTC');
if (isset($_GET['erase']))
{
$erase = $db->sanitizeString($_GET['erase']);
$db->queryMysql("DELETE FROM messages WHERE id='$erase' AND recip='$user'");
}
$query = "SELECT * FROM messages WHERE recip='$view' ORDER BY time DESC";
$result = $db->queryMysql($query);
$num = $result->rowCount();
while ($row = $result->fetch())
{
if ($row['pm'] == 0 || $row['auth'] == $user || $row['recip'] == $user)
{
echo date('M jS \'y g:ia:', $row['time']);
echo " <a href='messages.php?view=" . $row['auth'] .
"&r=$randstr'>" . $row['auth']. "</a> ";
if ($row['pm'] == 0)
echo "wrote: "" . $row['message'] . "" ";
else
echo "whispered: <span class='whisper'>"" .
$row['message']. ""</span> ";
if ($row['recip'] == $user)
echo "[<a href='messages.php?view=$view" .
"&erase=" . $row['id'] . "&r=$randstr'>erase</a>]";
echo "<br>";
}
}
}
if (!$num)
echo "<br><span class='info'>No messages yet</span><br><br>";
echo "<br><a data-role='button'
href='messages.php?view=$view&r=$randstr'>Refresh messages</a>";
?>
</div><br>
</body>
</html>