/** * 读取缓存文件内容 */ public function process($comment, $token) { $this->init(); // 验证 url 中的 token 和设置的 token 是否一致 if (strcmp($token, Helper::options()->plugin('CommentToMail')->token)) { exit; } //获取评论内容 $this->_email = $comment; //如果本次评论设置了拒收邮件,把coid加入拒收列表 if ($this->_email->banMail) { $this->ban($this->_email->coid, true); } //发件人邮箱 $this->_email->from = $this->_cfg->user; //发件人名称 $this->_email->fromName = $this->_cfg->fromName ? $this->_cfg->fromName : $this->_email->siteTitle; //向博主发邮件的标题格式 $this->_email->titleForOwner = $this->_cfg->titleForOwner; //向访客发邮件的标题格式 $this->_email->titleForGuest = $this->_cfg->titleForGuest; //验证博主是否接收自己的邮件 $toMe = in_array('to_me', $this->_cfg->other) && $this->_email->ownerId == $this->_email->authorId ? true : false; //向博主发信 if (in_array($this->_email->status, $this->_cfg->status) && in_array('to_owner', $this->_cfg->other) && ($toMe || $this->_email->ownerId != $this->_email->authorId) && 0 == $this->_email->parent) { if (empty($this->_cfg->mail)) { Typecho_Widget::widget('Widget_Users_Author@temp' . $this->_email->cid, array('uid' => $this->_email->ownerId))->to($user); $this->_email->to = $user->mail; } else { $this->_email->to = $this->_cfg->mail; } $this->authorMail()->sendMail(); } //向访客发信 if (0 != $this->_email->parent && 'approved' == $this->_email->status && in_array('to_guest', $this->_cfg->other) && !$this->ban($this->_email->parent)) { //如果联系我的邮件地址为空,则使用文章作者的邮件地址 if (empty($this->_email->contactme)) { if (!isset($user) || !$user) { Typecho_Widget::widget('Widget_Users_Author@temp' . $this->_email->cid, array('uid' => $this->_email->ownerId))->to($user); } $this->_email->contactme = $user->mail; } else { $this->_email->contactme = $this->_cfg->contactme; } $original = $this->_db->fetchRow($this->_db->select('author', 'mail', 'text')->from('table.comments')->where('coid = ?', $this->_email->parent)); if (in_array('to_me', $this->_cfg->other) || $this->_email->mail != $original['mail']) { $this->_email->to = $original['mail']; $this->_email->originalText = $original['text']; $this->_email->originalAuthor = $original['author']; $this->guestMail()->sendMail(); } } $date = new Typecho_Date(Typecho_Date::gmtTime()); $time = $date->format('Y-m-d H:i:s'); $this->mailLog(false, $time . " 邮件发送完毕!\r\n"); }
/** * 读取缓存文件内容 */ public function process($fileName) { $this->init(); //获取评论内容 $file = $this->_dir . '/cache/' . $fileName; if (file_exists($file)) { $this->_email = unserialize(file_get_contents($file)); @unlink($file); if (!$this->_user->simpleLogin($this->_email->ownerId)) { $this->widget('Widget_Archive@404', 'type=404')->render(); exit; } } else { $this->widget('Widget_Archive@404', 'type=404')->render(); exit; } //如果本次评论设置了拒收邮件,把coid加入拒收列表 if ($this->_email->banMail) { $this->ban($this->_email->coid, true); } //发件人邮箱 $this->_email->from = $this->_cfg->user; //发件人名称 $this->_email->fromName = $this->_cfg->fromName ? $this->_cfg->fromName : $this->_email->siteTitle; //向博主发邮件的标题格式 $this->_email->titleForOwner = $this->_cfg->titleForOwner; //向访客发邮件的标题格式 $this->_email->titleForGuest = $this->_cfg->titleForGuest; //验证博主是否接收自己的邮件 $toMe = in_array('to_me', $this->_cfg->other) && $this->_email->ownerId == $this->_email->authorId ? true : false; //向博主发信 if (in_array($this->_email->status, $this->_cfg->status) && in_array('to_owner', $this->_cfg->other) && ($toMe || $this->_email->ownerId != $this->_email->authorId) && 0 == $this->_email->parent) { if (empty($this->_cfg->mail)) { Typecho_Widget::widget('Widget_Users_Author@temp' . $this->_email->cid, array('uid' => $this->_email->ownerId))->to($user); $this->_email->to = $user->mail; } else { $this->_email->to = $this->_cfg->mail; } $this->authorMail()->sendMail(); } //向访客发信 if (0 != $this->_email->parent && 'approved' == $this->_email->status && in_array('to_guest', $this->_cfg->other) && !$this->ban($this->_email->parent)) { //如果联系我的邮件地址为空,则使用文章作者的邮件地址 if (empty($this->_email->contactme)) { if (!isset($user) || !$user) { Typecho_Widget::widget('Widget_Users_Author@temp' . $this->_email->cid, array('uid' => $this->_email->ownerId))->to($user); } $this->_email->contactme = $user->mail; } else { $this->_email->contactme = $this->_cfg->contactme; } $original = $this->_db->fetchRow($this->_db->select('author', 'mail', 'text')->from('table.comments')->where('coid = ?', $this->_email->parent)); if (in_array('to_me', $this->_cfg->other) || $this->_email->mail != $original['mail']) { $this->_email->to = $original['mail']; $this->_email->originalText = $original['text']; $this->_email->originalAuthor = $original['author']; $this->guestMail()->sendMail(); } } $date = new Typecho_Date(Typecho_Date::gmtTime()); $time = $date->format('Y-m-d H:i:s'); $this->mailLog(false, $time . " 邮件发送完毕!\r\n"); }