-
Notifications
You must be signed in to change notification settings - Fork 2
/
email-gateway.php
70 lines (58 loc) · 2.8 KB
/
email-gateway.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
<?php
require "include/bittorrent.php";
$id = 0 + $_GET["id"];
int_check($id,true);
$res = sql_query("SELECT username, class, email FROM users WHERE id=".mysql_real_escape_string($id));
$arr = mysql_fetch_assoc($res) or stderr("Error", "No such user.");
$username = $arr["username"];
if ($arr["class"] < UC_MODERATOR)
stderr("Error", "The gateway can only be used to e-mail staff members.");
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$to = $arr["email"];
$from = substr(htmlspecialchars(trim($_POST["from"])), 0, 80);
if ($from == "") $from = "Anonymous";
$from_email = substr(htmlspecialchars(trim($_POST["from_email"])), 0, 80);
if ($from_email == "") $from_email = "".$SITEEMAIL."";
$from_email = safe_email($from_email);
if (!$from_email)
stderr("Error","You must enter an email address!");
if (!check_email($from_email))
stderr("Error","Invalid email address!");
$from = "$from <$from_email>";
$subject = substr(htmlspecialchars(trim($_POST["subject"])), 0, 80);
if ($subject == "") $subject = "(No subject)";
$subject = "Fw: $subject";
$message = htmlspecialchars(trim($_POST["message"]));
if ($message == "") stderr("Error", "No message text!");
$message = "Message submitted from ".IP::getip()." at " . gmdate("Y-m-d H:i:s") . " GMT.\n" .
"Note: By replying to this e-mail you will reveal your e-mail address.\n" .
"---------------------------------------------------------------------\n\n" .
$message . "\n\n" .
"---------------------------------------------------------------------\n$SITENAME E-Mail Gateway\n";
$success = sent_mail($to,$from,$from_email,$subject,$message,"E-Mail Gateway",false);
if ($success)
stderr("Success", "E-mail successfully queued for delivery.");
else
stderr("Error", "The mail could not be sent. Please try again later.");
}
stdhead("E-mail gateway");
?>
<p><table border=0 class=main cellspacing=0 cellpadding=0><tr>
<td class=embedded><img src=pic/email.gif></td>
<td class=embedded style='padding-left: 10px'><font size=3><b>Send e-mail to <?=$username;?></b></font></td>
</tr></table></p>
<table border=1 cellspacing=0 cellpadding=5>
<form method=post action=email-gateway.php?id=<?=$id?>>
<tr><td class=rowhead>Your name</td><td><input type=text name=from size=80></td></tr>
<tr><td class=rowhead>Your e-mail</td><td><input type=text name=from_email size=80></td></tr>
<tr><td class=rowhead>Subject</td><td><input type=text name=subject size=80></td></tr>
<tr><td class=rowhead>Message</td><td><textarea name=message cols=80 rows=20></textarea></td></tr>
<tr><td colspan=2 align=center><input type=submit value="Send" class=btn></td></tr>
</form>
</table>
<p>
<font class=small><b>Note:</b> Your IP-address will be logged and visible to the recipient to prevent abuse.<br>
Make sure to supply a valid e-mail address if you expect a reply.</font>
</p>
<?php stdfoot(); ?>