Example #1
0
 public function ask_confirmation($info, $mode)
 {
     $info["email"] = strtolower($info["email"]);
     $query = "select count(*) as count from subscriptions where email=%s";
     if (($result = $this->db->execute($query, $info["email"])) === false) {
         return false;
     }
     $count = $result[0]["count"];
     if ($mode == "subscribe") {
         /* Subscribe
          */
         if ($count == 1) {
             return true;
         }
         $title = "subscription";
         $action = "subscribe to";
     } else {
         if ($mode == "unsubscribe") {
             /* Unsubscribe
              */
             if ($count == 0) {
                 return true;
             }
             $title = "unsubscription";
             $action = "unsubscribe from";
         } else {
             return false;
         }
     }
     $data = array("mode" => $mode, "email" => $info["email"], "expires" => date("YmdHis", strtotime("+" . $this->settings->newsletter_code_timeout)));
     $data["signature"] = $this->signature($data);
     $code = base64_encode(json_encode($data));
     $code = strtr($code, "/+", "_-");
     $subject = "Confirm " . $this->settings->head_title . " newsletter " . $title;
     $newsletter = new newsletter($subject, $this->settings->newsletter_email, $this->settings->newsletter_name);
     $url = $_SERVER["HTTP_SCHEME"] . "://" . $_SERVER["SERVER_NAME"] . "/newsletter/" . $code;
     $message = "You recieve this e-mail because your e-mail address has been entered at the newsletter " . "form at the " . $this->settings->head_title . " website. Subscribing to or unsubscribing from this " . "newsletter requires confirmation. So, if you do want to " . $action . " the " . $this->settings->head_title . " " . "newsletter, confirm by following <a href=\"" . $url . "\">this link</a>. If that's not " . "what you want, just ignore this e-mail.\n";
     $newsletter->message($message);
     return $newsletter->send($info["email"]);
 }
Example #2
0
 public function preview_newsletter($info)
 {
     $newsletter = new newsletter($info["title"], $this->settings->newsletter_email, $this->settings->newsletter_name);
     $newsletter->message($info["content"]);
     return $newsletter->send($this->user->email);
 }