Esempio n. 1
0
 public function send_mail()
 {
     $mail = $this->mailer;
     $mail->AddAddress($this->to);
     $mail->Subject = $this->subject;
     $mail->Body = $this->message;
     $mail->CharSet = 'UTF-8';
     if (\CODOF\Util::get_opt('mail_type') == 'smtp') {
         $mail->IsSMTP();
         // enable SMTP
     } else {
         $mail->IsMail();
     }
     $mail->SMTPDebug = 0;
     // debugging: 1 = errors and messages, 2 = messages only
     if (\CODOF\Util::get_opt('smtp_protocol') != 'none') {
         $mail->SMTPAuth = true;
         // authentication enabled
     }
     $mail->SMTPSecure = \CODOF\Util::get_opt('smtp_protocol');
     // SSL TLS secure transfer enabled REQUIRED for Gmail
     $mail->Host = \CODOF\Util::get_opt('smtp_server');
     $mail->Port = \CODOF\Util::get_opt('smtp_port');
     $mail->Username = \CODOF\Util::get_opt('smtp_username');
     $mail->Password = \CODOF\Util::get_opt('smtp_password');
     $mail->SetFrom(\CODOF\Util::get_opt('admin_email'), \CODOF\Util::get_opt('site_title'));
     if (!$mail->Send()) {
         $this->sent = false;
         $this->error = $mail->ErrorInfo;
         \CODOF\Util::log('Mail error: ' . $this->error);
     } else {
         $this->sent = true;
     }
 }
Esempio n. 2
0
 /**
  * Returns user info from database 
  * @param string $qry
  * @param array $vals
  * @param PDO $db
  * @return object
  */
 protected static function getUserObject($qry, $vals, $db)
 {
     $obj = $db->prepare($qry);
     $obj->execute($vals);
     $userDetails = $obj->fetchAll(PDO::FETCH_OBJ);
     foreach ($userDetails as $u) {
         $rids[] = $u->rid;
         if ($u->is_primary == '1') {
             $primary_rid = $u->rid;
         }
     }
     if (isset($userDetails[0])) {
         $user = $userDetails[0];
         $user->rids = $rids;
         $user->rid = $primary_rid;
         unset($user->is_primary);
         //not required and is wrong
     }
     if (isset($user) && property_exists($user, 'id')) {
         $user->rawAvatar = $user->avatar;
         $user->avatar = \CODOF\Util::get_avatar_path($user->avatar, $user->id);
         return $user;
     }
     \CODOF\Util::log('Unable to fetch user data User.php:39 vals= ' . print_r($vals, true) . ' ' . print_r($_SESSION, true));
     return false;
 }