public function add_subscribe()
 {
     $name = trim(I('post.name'));
     $email = trim(I('post.email'));
     $set_email_status = C('subscribe_send_subscribe_email');
     $owned_user_email = C('subscribe_owned_email');
     $subscribe_tag = C('subscribe_tag');
     $api_key = C('lingxiapi_lingxi_key');
     $api_secret = C('lingxiapi_lingxi_secret');
     $pattern = "/^([a-zA-Z0-9]{1,20})(([_-.])?([a-zA-Z0-9]{1,20}))*@([a-zA-Z0-9]{1,20})(([-_])?([a-zA-Z0-9]{1,20}))*(.[a-z]{2,4}){1,2}\$/";
     if (preg_match($pattern, $email)) {
         return 0;
     }
     if (!$name || !$email) {
         return 0;
     }
     $user = array("name" => $name, "email" => $email, "owned_user_email" => $owned_user_email, "tag" => $subscribe_tag);
     // $id = D('subscribe')->where("email = '".$email."'")->find();
     // $result = D('subscribe')->add($user);
     $lingxi = new LingxiApi($api_key, $api_secret);
     $user_id = $lingxi->createContact($user);
     if ($set_email_status) {
         $subject = C('subscribe_email_title');
         $message = C('subscribe_email_content');
         $message = str_replace('[#name#]', $user['name'], $message);
         MailApi::sendEmail('', $email, $subject, $message);
     }
     echo '1';
 }
Exemplo n.º 2
0
 public function save()
 {
     $data = I('post.');
     $data['update_user_name'] = $this->login_user['username'];
     $data['update_user_id'] = UID;
     $data['update_time'] = date('Y-m-d H:i:s');
     $msg_obj = D('Message');
     if ($msg_obj->create($data)) {
         $id = $msg_obj->saveOrUpdate();
     }
     $m = D("Message")->getById($id);
     if ($data['reply_to'] && valid_email($data['reply_to'])) {
         $subject = '感谢您关注' . D("Config")->getConfigValue('title') . ',你的问题回复如下';
         $body = '<p><b style="color:#e74c3c">问题:</b><br>' . $m['content'] . '</p>';
         $body .= '<p><b style="color:#e74c3c">回答:</b><br>' . nl2br($m['admin_note']) . '</p>';
         $contact_email = D("Config")->getConfigValue('contact_email');
         if ($contact_email) {
             $bcc[] = $contact_email;
         }
         $mail_res = MailApi::sendEmail(NULL, $data['reply_to'], $subject, $body, null, $bcc);
     }
     session('highlight_id', $id);
     $this->success('保存成功', Cookie('__forward__'));
 }
Exemplo n.º 3
0
 public function forgot_pwd()
 {
     if (IS_POST) {
         $data = $_POST;
         /* 检测验证码 */
         if (!check_captcha($data['captcha'])) {
             session('error', '验证码输入错误!');
             redirect("/forgot_pwd");
         }
         if (!valid_email($data['email'])) {
             session('error', '邮箱格式不正确!');
             redirect("/forgot_pwd");
         }
         $user = D('User')->field('id, email, username')->getByEmail($data['email']);
         if ($user) {
             $subject = "找回密码";
             $this->username = $user['username'];
             $repwdcode = gen_password($user['email'] . "+" . time());
             $info['repwdcode'] = $repwdcode;
             $result = D('User')->updateFieldsById($user['id'], $info);
             if ($result) {
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . '/user/resetpwd?rpcode=' . $repwdcode;
                 $this->content = '<a href="' . $url . '">' . $url . '</a>';
                 $html = $this->fetch("public:send_mail_template");
                 $from['reply'] = "*****@*****.**";
                 $from['name'] = "taoshuanghu";
                 MailApi::sendEmail($from, $data['email'], '找回密码', $html);
                 redirect('display_success?username='******'username'] . '&email=' . $user['email']);
             } else {
                 $this->error("申请修改密码未通过,建议重新申请");
             }
         } else {
             session('error', '邮箱不存在, 请重新输入');
             redirect("/forgot_pwd");
         }
     } else {
         $this->display();
     }
 }