forked from rlabduke/MolProbity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback_setup.php
134 lines (121 loc) · 5.18 KB
/
feedback_setup.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
<?php # (jEdit options) :folding=explicit:collapseFolds=1:
/*****************************************************************************
This page allows users to send email about bugs/features in MolProbity.
*****************************************************************************/
require_once(MP_BASE_DIR.'/lib/email.php');
// We use a uniquely named wrapper class to avoid re-defining display(), etc.
class feedback_setup_delegate extends BasicDelegate {
#{{{ display - creates the UI for this page
############################################################################
/**
* Context is not used.
*/
function display($context)
{
echo $this->pageHeader("Feedback & bugs", "feedback");
echo makeEventForm("onFeedbackSend");
?>
<div class=alert>Please scroll to the last few lines of the error log below: it will often tell you what to fix. If not, we welcome your bug reports and feedback. </div>
<table border='0' cellspacing='0'>
<tr>
<td align='right'>My name is</td>
<td align='left'><input type='text' name='senderName' value='' size='25' maxlength='100'></td>
</tr><tr>
<td align='right'>My email address is</td>
<td align='left'><input type='text' name='senderEmail' value='' size='25' maxlength='100'></td>
</tr><tr>
<td align='right'>My comment regards</td>
<td align='left'><select name='inRegardTo'>
<option selected value="Bug report">a bug or error in MolProbity</option>
<option value="Suggestion">a suggestion on how to improve MolProbity</option>
<option value="KiNG">the KiNG graphics applet</option>
<option value="Tutorial">the online tutorial</option>
<option value="Documentation">the other online documentation</option>
<option value="Local server setup">installing or configuring a local copy of MolProbity</option>
<option value="General feedback">(none of the above)</option>
</select></td>
</tr><tr>
<td align='left' colspan='2'>
<textarea name='feedbackText' rows='30' cols='76'><?php echo $this->makeTemplateText(); ?></textarea>
</td>
</tr><tr>
<td align='left'><input type='submit' name='cmd' value='Send email >'></td>
<td align='right'><input type='reset' name='cmd' value='Reset'></td>
</tr>
</table>
</form>
<?php
echo $this->pageFooter();
}
#}}}########################################################################
#{{{ makeTemplateText - fills out some user info for email
############################################################################
/**
* Documentation for this function.
*/
function makeTemplateText()
{
$fb_msg = "\n"
. "\n"
. "[PLACE YOUR COMMENTS HERE]\n"
. "\n"
. "==================================================\n"
. " USER / SERVER INFORMATION\n"
. "==================================================\n"
. "User IP : $_SESSION[userIP]\n"
. "User browser : $_SERVER[HTTP_USER_AGENT]\n"
. "Session ID : " . session_id() . "\n"
. "Session URL : http://$_SERVER[SERVER_NAME]$_SERVER[PHP_SELF]?$_SESSION[sessTag]\n"
. "\n"
. "MolProb. ver. : " . MP_VERSION . "\n"
. "Server name : $_SERVER[SERVER_NAME]\n"
. "Server time : " . date("Y M d H:i:s") . "\n"
. "\n"
. "==================================================\n"
. " ERRORS FROM THIS SESSION\n"
. "==================================================\n";
$errfile = $_SESSION['dataDir']."/".MP_DIR_SYSTEM."/errors";
if(file_exists($errfile))
{
$a = file($errfile);
foreach($a as $s) { $fb_msg .= $s; }
}
//return wordwrap($fb_msg, 76); -- not needed; we wordwrap before sending
return $fb_msg;
}
#}}}########################################################################
#{{{ onFeedbackSend
############################################################################
/**
* Documentation for this function.
*/
function onFeedbackSend()
{
$req = $_REQUEST;
$subject = "MolProbity feedback: $req[inRegardTo]";
$msg_text = "\n"
. "User name : $req[senderName]\n"
. "User email : $req[senderEmail]\n"
. "Subject : $req[inRegardTo]\n"
. "\n\n"
. wordwrap($req['feedbackText'], 76);
// Write a local copy of the email in case sendmail isn't working
$tmpfile = tempnam(MP_BASE_DIR.'/feedback', 'email_');
chmod($tmpfile, 0666 & ~MP_UMASK); // tempnam gets wrong permissions sometimes?
$h = fopen($tmpfile, 'wb');
fwrite($h, $msg_text);
fclose($h);
$ok = mpSendEmail($req['senderName'], $req['senderEmail'], $subject, $msg_text);
mpLog("feedback:Sent with subject $req[inRegardTo]; success=$ok");
pageGoto("feedback_done.php", $msg_text);
}
#}}}########################################################################
#{{{ a_function_definition - sumary_statement_goes_here
############################################################################
/**
* Documentation for this function.
*/
//function someFunctionName() {}
#}}}########################################################################
}//end of class definition
?>