-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmessage.php
172 lines (143 loc) · 5.1 KB
/
sendmessage.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
<?php
require_once("configuration/main.php");
if(!$permissions['sendprivatemessage'])
{
redirect("errors/permissions.html");
}
$mQuery = $mysql->query("SELECT `id` FROM `accounts` WHERE `id` = '" . escape($_GET['to']) . "'");
if(!$mQuery->num_rows)
{
die("You have followed an invalid link.");
}
if($_POST['sendmessage'])
{
if(strlen($_POST['title']) >= 3)
{
if(strlen($_POST['message']) >= 3)
{
if(time() - $_SESSION['lastcomment'] >= 60)
{
$mysql->query("INSERT INTO `privatemessages` (`to`, `from`, `date`, `title`, `message`) VALUES ('" . escape($_GET['to']) . "', '" . $_SESSION['accountid'] . "', '" . time() . "', '" . escape($_POST['title']) . "', '" . escape($_POST['message']) . "')");
$_SESSION['lastcomment'] = time();
echo "Your message has been sent.";
redirect("settings?view=profile", 2);
}
else
{
$timeBeforeComment = 60 - (time() - $_SESSION['lastcomment']);
echo
"<div class='box'>
<div class='boxHeading'>
You must wait $timeBeforeComment seconds before posting another thread, comment, profile message, or private message.
</div>
</div>
<br>";
}
}
else
{
echo
"<div class='box'>
<div class='boxHeading'>
Your message must be at least 3 characters long.
</div>
</div>
<br>";
}
}
else
{
echo
"<div class='box'>
<div class='boxHeading'>
Your title must be at least 3 characters long.
</div>
</div>
<br>";
}
}
echo
"<form action='sendmessage?to=" . $_GET['to'] . "' method='POST'>
<div class='box'>
<div class='boxHeading'>
Send Private Message
</div>
<div class='boxMain'>
<div class='boxArea'>
<table>
<tr>
<td width='100%'>Title:</td>
<td><input type='text' name='title' placeholder='Title' value='" . $_POST['title'] . "' maxlength='200' class='boxFormInput' autofocus required></td>
</tr>
</table>
</div>
<div class='boxArea'>
<button type='button' data-tag='B' class='bbcode boxButton'>bold</button>
<button type='button' data-tag='I' class='bbcode boxButton'>italic</button>
<button type='button' data-tag='U' class='bbcode boxButton'>underline</button>
<button type='button' data-tag='LEFT' class='bbcode boxButton'>left</button>
<button type='button' data-tag='CENTER' class='bbcode boxButton'>center</button>
<button type='button' data-tag='RIGHT' class='bbcode boxButton'>right</button>
<button type='button' data-tag='LIST' class='bbcode boxButton'>bullet list</button>
<button type='button' data-tag='NLIST' class='bbcode boxButton'>number list</button>
<button type='button' data-tag='LI' class='bbcode boxButton'>list item</button>
<button type='button' data-tag='EMAIL' class='bbcode boxButton'>email</button>
<button type='button' data-tag='IMG' class='bbcode boxButton'>image</button>
<button type='button' data-tag='QUOTE' class='bbcode boxButton'>quote</button>
<button id='bbcode-link' type='button' data-tooltip='Example: [URL=http://example.com]Click here[/URL]' class='boxButton'>link</button>
<button id='bbcode-font' type='button' data-tooltip='Example: [FONT=Arial]Hello world![/FONT]' class='boxButton'>font</button>
<button id='bbcode-size' type='button' data-tooltip='Example: [SIZE=5]Hello world![/SIZE]' class='boxButton'>size</button>
<button id='bbcode-color' type='button' data-tooltip='Example: [COLOR=RED]Hello[/COLOR] [COLOR=#00FF00]world![/COLOR]' class='boxButton'>color</button> ";
if($permissions['mentionusers'])
{
echo "<button type='button' data-tag='MENTION' data-tooltip='Example: [MENTION]Jimmy[/MENTION]' class='bbcode boxButton'>mention</button>";
}
echo
"<br><br>
<textarea id='message' name='message' placeholder=' Message' maxlength='15000' class='boxTextArea' required>" . $_POST['message'] . "</textarea>
</div>
</div>
</div>
<div align='right'>
<input type='submit' name='sendmessage' value='Send Message' class='boxButton'>
</div>
</form>";
?>
<script>
$(document).ready(function()
{
function insertString(string, insert, position)
{
return string.substr(0, position) + insert + string.substr(position);
}
function wrapText(before, after)
{
var textSelection = $('#message').getSelection(), selectionStart = textSelection.start, selectionEnd = textSelection.end;
$('#message').val(insertString($('#message').val(), after, selectionEnd)).val(insertString($('#message').val(), before, selectionStart));
$('#message').setSelection(selectionStart + before.length);
}
$('.bbcode').click(function()
{
wrapText("[" + $(this).data("tag") + "]", "[/" + $(this).data("tag") + "]");
});
$('#bbcode-link').click(function()
{
wrapText("[URL=http://example.com]", "[/URL]");
});
$('#bbcode-font').click(function()
{
wrapText("[FONT=Arial]", "[/FONT]");
});
$('#bbcode-size').click(function()
{
wrapText("[SIZE=5]", "[/SIZE]");
});
$('#bbcode-color').click(function()
{
wrapText("[COLOR=RED]", "[/COLOR]");
});
});
</script>
<?php
require_once("includes/footer.php");
?>