Exemple #1
0
 function handler_sendEmailBefore(&$to, &$subject, &$body)
 {
     $phpmailer = dirname(__FILE__) . '/class.phpmailer.php';
     require_once $phpmailer;
     if (!C("plugin.SMTP.server")) {
         return;
     }
     $mail = new PHPMailer(true);
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     if (C("plugin.SMTP.auth")) {
         $mail->SMTPSecure = C("plugin.SMTP.auth");
     }
     $mail->Host = C("plugin.SMTP.server");
     $mail->Port = C("plugin.SMTP.port");
     $mail->Username = C("plugin.SMTP.username");
     $mail->Password = C("plugin.SMTP.password");
     $mail->AddAddress($to);
     $mail->SetFrom(C("esoTalk.emailFrom"), sanitizeForHTTP(C("esoTalk.forumTitle")));
     $mail->Subject = sanitizeForHTTP($subject);
     $mail->Body = $body;
     return $mail->Send();
 }
/**
 * Send a HTTP Location header to redirect to a specific page.
 *
 * @param string $destination The location to redirect to.
 * @param int $code The HTTP code to send with the redirection.
 * @return void
 *
 * @package esoTalk
 */
function redirect($destination, $code = 302)
{
    // Close the database connection.
    if (ET::$database) {
        ET::$database->close();
    }
    // Clear the output buffer, and send the location header.
    @ob_end_clean();
    header("Location: " . sanitizeForHTTP($destination), true, $code);
    exit;
}
Exemple #3
0
function sendEmail($to, $subject, $body)
{
    global $config, $language;
    if (!preg_match("/^[A-Z0-9._%-+]+@[A-Z0-9.-]+.[A-Z]{2,4}\$/i", $to)) {
        return false;
    }
    return mail(sanitizeForHTTP($to), sanitizeForHTTP(desanitize($subject)), desanitize($body), "From: " . sanitizeForHTTP(desanitize($config["forumTitle"]) . " <{$config["emailFrom"]}>") . "\nContent-Type: text/plain; charset={$language["charset"]}; format=flowed");
}
Exemple #4
0
function sendEmail($to, $subject, $body)
{
    $phpmailer = PATH_PLUGINS . '/vendor/class.phpmailer.php';
    require_once $phpmailer;
    $mail = new PHPMailer(true);
    if ($return = ET::first("sendEmailBefore", array($mail, &$to, &$subject, &$body))) {
        return $return;
    }
    $mail->CharSet = 'UTF-8';
    $mail->IsHTML(true);
    $mail->AddAddress($to);
    $mail->SetFrom(C("esoTalk.emailFrom"), sanitizeForHTTP(C("esoTalk.forumTitle")));
    $mail->Subject = sanitizeForHTTP($subject);
    $mail->Body = $body;
    return $mail->Send();
}
 function login($name = false, $password = false, $hash = false)
 {
     // Are we already logged in?
     if (isset($_SESSION["user"])) {
         return true;
     }
     global $config;
     // If a raw password was passed, convert it into a hash
     if ($name and $password) {
         $hash = md5($config["salt"] . $password);
     } elseif ($hash === false) {
         $cookie = @$_COOKIE[$config["cookieName"]];
         $memberId = substr($cookie, 0, strlen($cookie) - 32);
         $hash = substr($cookie, -32);
     }
     // If we successfully have a name and a hash then we attempt to login
     if (($name or $memberId = (int) $memberId) and $hash !== false) {
         $components = array("select" => array("*"), "from" => array("{$config["tablePrefix"]}members"), "where" => array($name ? "name='{$name}'" : "memberId={$memberId}", "password='******'"));
         $ip = (int) ip2long($_SESSION["ip"]);
         if (isset($cookie)) {
             $components["where"][] = "cookieIP=" . ($ip ? $ip : "0");
         }
         $this->callHook("beforeLogin", array(&$components));
         // Check the username and password against the database
         $result = $this->db->query($this->db->constructSelectQuery($components));
         if ($this->db->numRows($result) and $data = $this->db->fetchAssoc($result)) {
             if ($data["account"] == "Unvalidated") {
                 $this->message("accountNotYetVerified", false, makeLink("join", "sendVerification", $data["memberId"]));
                 return false;
             }
             $_SESSION["user"] = $this->user = $data;
             session_regenerate_id();
             regenerateToken();
             if (@$_POST["login"]["rememberMe"]) {
                 $ip = (int) ip2long($_SESSION["ip"]);
                 $this->esoTalk->db->query("UPDATE {$config["tablePrefix"]}members SET cookieIP={$ip} WHERE memberId={$_SESSION["user"]["memberId"]}");
                 setcookie($config["cookieName"], $_SESSION["user"]["memberId"] . sanitizeForHTTP($hash), time() + $config["cookieExpire"], "/");
             }
             if (!$this->ajax) {
                 refresh();
             }
             return true;
         }
         // Incorrect login details - throw an error at the user
         if (!isset($cookie)) {
             $this->message("incorrectLogin", false);
         }
     } elseif ($name or $password) {
         $this->message("incorrectLogin", false);
     }
     return false;
 }