Example #1
0
function sendMailFromContact($to, $name, $body, $subject)
{
    $mail = new PHPMailer();
    $mail->IsSMTP();
    // telling the class to use SMTP
    $mail->SMTPAuth = true;
    // SMTP authentication
    $mail->Host = "smtp.gmail.com";
    // SMTP server
    $mail->Port = 465;
    // SMTP Port
    $mail->Username = "******";
    // SMTP account username
    $mail->Password = "******";
    // SMTP account password
    $mail->SMTPSecure = 'ssl';
    $mail->SetFrom("*****@*****.**", 'Smarkbook');
    // FROM
    $mail->AddReplyTo("*****@*****.**", 'Smarkbook');
    // Reply TO
    $mail->AddAddress($to, $name);
    // recipient email
    //$mail->AddCC('*****@*****.**', 'Ben White'); //CC email
    $mail->Subject = $subject;
    // email subject
    $mail->Body = $body;
    $mail->IsHTML(true);
    if (!$mail->Send()) {
        infoLog("Email failed to send to {$name} about {$subject}");
        throw new Exception("Email failed to send");
    } else {
        infoLog("Email sent to {$name} about {$subject}");
    }
}
function updateWorksheet($vid, $type)
{
    global $userid;
    if ($type === "DELETE") {
        $query = "UPDATE TWORKSHEETVERSION Set `Deleted` = TRUE WHERE `Version ID` = {$vid}";
        $errorMsg = "There was an error deleted the worksheet.";
        $successMsg = "Worksheet {$vid} succesfully deleted by {$userid}";
        $delete = TRUE;
    } else {
        if ($type === "RESTORE") {
            $query = "UPDATE TWORKSHEETVERSION Set `Deleted` = FALSE WHERE `Version ID` = {$vid}";
            $errorMsg = "There was an error restoring the worksheet.";
            $successMsg = "Worksheet {$vid} succesfully restored by {$userid}";
            $delete = FALSE;
        } else {
            failRequest("There was an error completing your request;");
        }
    }
    try {
        db_begin_transaction();
        db_query_exception($query);
        updateRelatedCompletedQuestions($vid, $delete);
        db_commit_transaction();
    } catch (Exception $ex) {
        db_rollback_transaction();
        returnToPageError($ex, $errorMsg);
    }
    $response = array("success" => TRUE);
    echo json_encode($response);
    infoLog($successMsg);
    exit;
}
Example #3
0
function returnToPageSuccess($userid)
{
    $message = "User switched to user {$userid}";
    infoLog($message);
    header("Location: ../portalhome.php");
    exit;
}
function checkUserLoginStatus($url)
{
    //See if there is a logged in user
    if (isset($_SESSION['user'])) {
        $user = $_SESSION['user'];
        $userid = $user->getUserId();
        $username = $user->getEmail();
        $timeout = $_SESSION['timeout'];
        if (isset($timeout)) {
            if ($timeout + 12 * 60 * 60 < time()) {
                //Session timed out so save the users url and log them out
                $msg = "User {$userid} has been timed out.";
                infoLog($msg);
                if (isset($url)) {
                    $_SESSION['url'] = $url;
                    $_SESSION['urlid'] = $userid;
                }
                logout();
                $url = "Location: ../login.php?email={$username}";
                $bool = false;
            } else {
                //All good so carry on!
                $_SESSION['timeout'] = time();
                $url = '';
                $bool = true;
            }
        } else {
            //No timeout information so log out
            $url = "Location: ../login.php?email={$username}";
            $bool = false;
        }
    } else {
        //Not logged in user so go to homepage
        $url = "Location: ../login.php";
        $bool = false;
    }
    $resultArray = array($bool, $url);
    return $resultArray;
}
Example #5
0
function returnToPageSuccess($message, $url)
{
    infoLog($message);
    header("Location: {$url}");
    exit;
}
Example #6
0
function returnToPageSuccess($message, $vid)
{
    $type = 'SUCCESS';
    $_SESSION['message'] = new Message($type, $message);
    infoLog($message);
    header("Location: ../editWorksheet.php?id={$vid}");
    exit;
}
Example #7
0
function returnToPageSuccess($message)
{
    $type = 'SUCCESS';
    $_SESSION['message'] = new Message($type, $message);
    infoLog($message);
    header("Location: ../createUser.php");
    exit;
}
Example #8
0
function returnToPageSuccess($message)
{
    $type = "SUCCESS";
    $_SESSION['message'] = new Message($type, $message);
    infoLog($message);
    header("Location: ../forgottenPassword.php");
    exit;
}
Example #9
0
function succeedRequest($message, $array)
{
    $response = array("success" => TRUE);
    foreach ($array as $key => $value) {
        $response[$key] = $value;
    }
    if ($message !== null) {
        infoLog($message);
    }
    echo json_encode($response);
    exit;
}