-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
165 lines (132 loc) · 4.75 KB
/
contact.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
<?php
require_once("path.php");
require_once(BASE."/include/incl.php");
/**
* Page containing a form for sending e-mail
*
*/
$oUser = new User($_SESSION['current']->iUserId);
$shError = '';
/* Restrict error to logged-in users */
if(!$oUser->isLoggedIn())
{
login_form();
exit;
}
$oRecipient = null;
$sRecipientText = '';
$iRecipientId = null;
$sRecipientGroup = getInput('sRecipientGroup', $aClean);
$sRecipients = '';
if($sRecipientGroup)
{
if(!$oUser->hasPriv('admin'))
util_show_error_page_and_exit("Only admins can do this");
switch($sRecipientGroup)
{
case 'maintainers':
$sRecipientText = 'all maintainers';
$sRecipients = maintainer::getSubmitterEmails();
if($sRecipients === FALSE)
util_show_error_page_and_exit("Failed to get list of maintainers");
break;
case 'admins';
$sRecipientText = 'all AppDB admins';
$sRecipients = user::getAdminEmails();
if($sRecipients === FALSE)
util_show_error_page_and_exit("Failed to get list of admins");
break;
default:
util_show_error_page_and_exit("Invalid recipient group");
}
} else
{
$oRecipient = new User($aClean['iRecipientId']);
$iRecipientId = $oRecipient->iUserId;
$sRecipients = $oRecipient->sEmail;
if(!User::exists($oRecipient->sEmail))
util_show_error_page_and_exit("User not found");
$sRecipientText = $oRecipient->sRealname;
}
/* Check for errors */
if((!$aClean['sMessage'] || !$aClean['sSubject']) && $aClean['sSubmit'])
{
$shError = "<font color=\"red\">Please enter both a subject and a ".
"message.</font>";
$aClean['sSubmit'] = "";
}
/* Display the feedback form if nothing else is specified */
if(!$aClean['sSubmit'])
{
apidb_header("E-mail $sRecipientText");
echo ' ';
echo html_frame_start("Composer",400,"",0);
echo $shError;
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
/* User manager */
if($_SESSION['current']->hasPriv("admin") && $oRecipient)
{
echo "<p><a href=\"".BASE."preferences.php?iUserId=".
$oRecipient->iUserId."&sSearch=Administrator&iLimit".
"=100&sOrderBy=email\">User manager</a></p>";
}
if($oRecipient)
{
echo "<p><a href=\"".BASE."objectManager.php?sClass=maintainerView&iId=".
"{$oRecipient->iUserId}&sTitle=Maintained+Apps\">Maintained apps</a>";
}
echo "<p>E-mail $sRecipientText.</p>";
$oTable = new Table();
$oTable->SetWidth("100%");
$oTable->SetBorder(0);
$oTable->SetCellPadding(2);
$oTable->SetCellSpacing(2);
$oTableRow = new TableRow();
$oTableRow->SetClass("color4");
$oTableRow->AddTextCell("Subject");
$oTableCell = new TableCell("<input type=\"text\" name=\"sSubject\" size=\"71\"".
" value=\"".getInput('sSubject', $aClean)."\">");
$oTableRow->AddCell($oTableCell);
$oTable->AddRow($oTableRow);
$oTableRow = new TableRow();
$oTableRow->SetClass("color4");
$oTableCell = new TableCell("Message");
$oTableCell->SetValign("top");
$oTableRow->AddCell($oTableCell);
$oTableCell = new TableCell("<textarea name=\"sMessage\" rows=\"15\" cols=\"60\">"
.getInput('sMessage', $aClean)."</textarea>");
$oTableRow->AddCell($oTableCell);
$oTable->AddRow($oTableRow);
$oTableRow = new TableRow();
$oTableRow->AddTextCell("");
$oTableRow->AddTextCell("<input type=\"submit\" value=\"Submit\" name=\"sSubmit\">");
$oTable->AddRow($oTableRow);
// output the table
echo $oTable->GetString();
echo "<input type=\"hidden\" name=\"iRecipientId\" ".
"value=\"$iRecipientId\">";
echo "<input type=\"hidden\" name=\"sRecipientGroup\" ".
"value=\"$sRecipientGroup\">";
echo "</form>\n";
echo html_frame_end(" ");
} else if ($aClean['sSubject'] && $aClean['sMessage'])
{
if($oRecipient)
{
$sSubjectRe = $aClean['sSubject'];
if(substr($sSubjectRe, 0, 4) != "Re: ")
$sSubjectRe = "Re: $sSubjectRe";
$sSubjectRe = urlencode($sSubjectRe);
$sMsg = "The following message was sent to you from $oUser->sRealname ";
$sMsg .= "through the Wine AppDB contact form.\nTo Reply, visit ";
$sMsg .= APPDB_ROOT."contact.php?iRecipientId=$oUser->iUserId&sSubject=";
$sMsg .= $sSubjectRe."\n\n";
$sMsg .= $aClean['sMessage'];
} else
{
$sMsg = "The following message was sent to you by the AppDB admins:\n\n";
$sMsg .= $aClean['sMessage'];
}
mail_appdb($sRecipients, '[PM] '.$aClean['sSubject'], $sMsg);
util_redirect_and_exit(BASE."index.php");
}