/'), array('"', '>'), $name);
$summary = preg_replace(array('/"/', '/>/'), array('"', '>'), $summary);
}
else {
$name = '';
if(! empty($user['lastname']) && ! empty($user['preferredname']))
$name = "{$user["preferredname"]} {$user['lastname']}";
elseif(! empty($user['lastname']) && ! empty($user['preferredname']))
$name = "{$user["firstname"]} {$user['lastname']}";
$email = $user["email"];
$summary = "";
$text = "";
}
if(! in_array('helpform', $noHTMLwrappers))
print "
VCL Help
\n";
print "This form sends a request to the VCL support group. Please provide ";
print "as much information as possible.
\n";
if(HELPFAQURL != '') {
print "Please see our ";
print "FAQ Section before sending your request - it may be an easy ";
print "fix!
\n";
}
print "\n";
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn submitHelpForm()
///
/// \brief processes the help form and notifies the user that it was submitted
///
////////////////////////////////////////////////////////////////////////////////
function submitHelpForm() {
global $user, $submitErr, $submitErrMsg;
$name = processInputVar("name", ARG_STRING);
$email = processInputVar("email", ARG_STRING);
$summary = processInputVar("summary", ARG_STRING);
$text = processInputVar("comments", ARG_STRING);
$testname = $name;
if(get_magic_quotes_gpc())
$testname = stripslashes($name);
if(! preg_match('/^([-A-Za-z \']{1,} [-A-Za-z \']{2,})*$/', $testname)) {
$submitErr |= NAMEERR;
$submitErrMsg[NAMEERR] = "Name can only contain letters, spaces, apostrophes ('), and dashes (-)";
}
if(! preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i',
$email)) {
$submitErr |= EMAILERR;
$submitErrMsg[EMAILERR] = "Invalid email address, please correct";
}
if(empty($summary)) {
$submitErr |= SUMMARYERR;
$submitErrMsg[SUMMARYERR] = "Please fill in a very short summary of the "
. "problem";
}
if(empty($text)) {
$submitErr |= TEXTERR;
$submitErrMsg[TEXTERR] = "Please fill in your problem in the box below.
";
}
if($submitErr) {
printHelpForm();
return;
}
$computers = getComputers();
$requests = array();
$query = "SELECT l.id, "
. "l.start, "
. "l.finalend AS end, "
. "s.computerid, "
. "i.prettyname AS prettyimage "
. "FROM log l, "
. "image i, "
. "sublog s "
. "WHERE l.userid = {$user["id"]} AND "
. "i.id = l.imageid AND "
. "s.logid = l.id AND "
. "l.finalend < DATE_ADD(NOW(), INTERVAL 1 DAY) "
. "ORDER BY l.finalend DESC "
. "LIMIT 5";
$qh = doQuery($query, 290);
while($row = mysql_fetch_assoc($qh)) {
# only include 1 computer from cluster reservations
if(array_key_exists($row['id'], $requests))
continue;
$requests[$row['id']] = $row;
}
$from = $user["email"];
if(get_magic_quotes_gpc())
$text = stripslashes($text);
$message = "Problem report submitted from VCL web form:\n\n"
. "User: " . $user["unityid"] . "\n"
. "Name: " . $testname . "\n"
. "Email: " . $email . "\n"
. "Problem description:\n\n$text\n\n";
$recentrequests = "";
foreach($requests as $request) {
$thisstart = str_replace(' ', ' ',
prettyDatetime($request["start"]));
$thisend = str_replace(' ', ' ',
prettyDatetime($request["end"]));
$recentrequests .= "Image: {$request["prettyimage"]}\n"
. "Computer: {$computers[$request["computerid"]]["hostname"]}\n"
. "Start: $thisstart\n"
. "End: $thisend\n\n";
}
if(! empty($recentrequests)) {
$message .= "-----------------------------------------------\n";
$message .= "User's recent reservations:\n\n" . $recentrequests . "\n";
}
else {
$message .= "User has no recent reservations\n";
}
$indrupal = getContinuationVar('indrupal', 0);
if(! $indrupal)
print "VCL Help
\n";
$mailParams = "-f" . ENVELOPESENDER;
if(get_magic_quotes_gpc())
$summary = stripslashes($summary);
if(! mail(HELPEMAIL, "$summary", $message,
"From: $from\r\nReply-To: $email\r\n", $mailParams)){
print "The Server was unable to send mail at this time. Please e-mail ";
print "" . HELPEMAIL . " for ";
print "help with your problem.";
}
else {
print "Your problem report has been submitted. Thank you for letting ";
print "us know of your problem so that we can improve this site.
\n";
}
}
?>