Пример #1
0
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);
    if (!ereg('^([A-Za-z]{1,}( )([A-Za-z]){2,})$', $name)) {
        $submitErr |= NAMEERR;
        $submitErrMsg[NAMEERR] = "You must submit your first and last name";
    }
    if (!eregi('^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$', $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.<br>";
    }
    if ($submitErr) {
        printHelpForm();
        return;
    }
    $computers = getComputers();
    $requests = getUserRequests("all");
    $query = "SELECT l.start AS start, " . "l.finalend AS end, " . "l.computerid AS computerid, " . "i.prettyname AS prettyimage " . "FROM log l, " . "image i " . "WHERE l.userid = " . $user["id"] . " AND " . "i.id = l.imageid AND " . "(unix_timestamp(NOW()) - unix_timestamp(l.finalend)) < 14400";
    $qh = doQuery($query, 290);
    while ($row = mysql_fetch_assoc($qh)) {
        array_push($requests, $row);
    }
    $from = $user["email"];
    if (get_magic_quotes_gpc()) {
        $text = stripslashes($text);
    }
    $message = "Problem report submitted from VCL web form:\n\n" . "User: "******"unityid"] . "\n" . "Name: " . $name . "\n" . "Email: " . $email . "\n" . "Problem description:\n\n{$text}\n\n";
    $end = time();
    $start = $end - 14400;
    $recentrequests = "";
    foreach ($requests as $request) {
        if (datetimeToUnix($request["end"]) > $start || datetimeToUnix($request["start"] < $end)) {
            $thisstart = str_replace('&nbsp;', ' ', prettyDatetime($request["start"]));
            $thisend = str_replace('&nbsp;', ' ', 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 "<H2>VCL Help</H2>\n";
    }
    $mailParams = "-f" . ENVELOPESENDER;
    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 "<a href=\"mailto:" . HELPEMAIL . "\">" . HELPEMAIL . "</a> 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.<br>\n";
    }
}
Пример #2
0
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.<br>";
    }
    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: "******"unityid"] . "\n" . "Name: " . $testname . "\n" . "Email: " . $email . "\n" . "Problem description:\n\n{$text}\n\n";
    $recentrequests = "";
    foreach ($requests as $request) {
        $thisstart = str_replace('&nbsp;', ' ', prettyDatetime($request["start"]));
        $thisend = str_replace('&nbsp;', ' ', 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 "<H2>VCL Help</H2>\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 "<a href=\"mailto:" . HELPEMAIL . "\">" . HELPEMAIL . "</a> 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.<br>\n";
    }
}