コード例 #1
0
ファイル: control.php プロジェクト: Maplecms/shopnc-yhmall
 /**
  * 系统通知发送函数
  *
  * @param int $receiver_id 接受人编号
  * @param string $tpl_code 模板标识码
  * @param array $param 内容数组
  * @param bool $flag 是否遵从系统设置
  * @return boolean
  */
 protected function send_notice($receiver_id, $tpl_code, $param, $flag = true)
 {
     $mail_tpl_model = Model('mail_templates');
     $mail_tpl = $mail_tpl_model->getOneTemplates($tpl_code);
     if (empty($mail_tpl) || $mail_tpl['mail_switch'] == 0) {
         return false;
     }
     $member_model = Model('member');
     $receiver = $member_model->infoMember(array('member_id' => $receiver_id));
     if (empty($receiver)) {
         return false;
     }
     $subject = ncReplaceText($mail_tpl['title'], $param);
     $message = ncReplaceText($mail_tpl['content'], $param);
     //根据模板里面确定的通知类型采用对应模式发送通知
     $result = false;
     switch ($mail_tpl['type']) {
         case '0':
             $email = new Email();
             $result = true;
             if ($flag and $GLOBALS['setting_config']['email_enabled'] == '1' or $flag == false) {
                 $result = $email->send_sys_email($receiver['member_email'], $subject, $message);
             }
             break;
         case '1':
             $model_message = Model('message');
             $param = array('member_id' => $receiver_id, 'to_member_name' => $receiver['member_name'], 'msg_content' => $message, 'message_type' => 1);
             $result = $model_message->saveMessage($param);
             break;
     }
     return $result;
 }
コード例 #2
0
ファイル: sendstoremsg.php プロジェクト: 1290800466/mac_win
 /**
  * 发送邮件
  * @param unknown $number
  * @param unknown $subject
  * @param unknown $message
  */
 private function sendMail($number, $subject, $message)
 {
     // 即时发动代码  v3-b11
     $email = new Email();
     $email->send_sys_email($number, $subject, $message);
     // 计划任务代码
     $insert = array();
     $insert['mail'] = $number;
     $insert['subject'] = $subject;
     $insert['contnet'] = $message;
     Model('mail_cron')->addMailCron($insert);
 }
コード例 #3
0
ファイル: mail.php プロジェクト: noikiy/ejia
 /**
  * 发送消息
  */
 public function indexOp() {
     $model_storemsgcron = Model('mail_cron');
     $cron_array = $model_storemsgcron->getMailCronList(array(), $this->_num);
     if (!empty($cron_array)) {
         $email = new Email();
         $mail_array = array();
         foreach ($cron_array as $val) {
             $return = $email->send_sys_email($val['mail'],$val['subject'],$val['contnet']);
             if ($return) {
                 // 记录需要删除的id
                 $mail_array[] = $val['mail_id'];
             }
         }
         // 删除已发送的记录
         $model_storemsgcron->delMailCron(array('mail_id' => array('in', $mail_array)));
     }
 }
コード例 #4
0
ファイル: security.php プロジェクト: Maplecms/shopnc-api
 /**
  * 统一发送身份验证码
  */
 public function send_auth_codeOp()
 {
     if (!in_array($_GET['type'], array('email', 'mobile'))) {
         exit;
     }
     $model_member = Model('member');
     $member_info = $model_member->getMemberInfoByID($_SESSION['member_id'], 'member_email,member_mobile');
     $verify_code = rand(100, 999) . rand(100, 999);
     $data = array();
     $data['auth_code'] = $verify_code;
     $data['send_acode_time'] = TIMESTAMP;
     $update = $model_member->editMemberCommon($data, array('member_id' => $_SESSION['member_id']));
     if (!$update) {
         exit(json_encode(array('state' => 'false', 'msg' => '系统发生错误,如有疑问请与管理员联系')));
     }
     $model_tpl = Model('mail_templates');
     $tpl_info = $model_tpl->getTplInfo(array('code' => 'authenticate'));
     $param = array();
     $param['send_time'] = date('Y-m-d H:i', TIMESTAMP);
     $param['verify_code'] = $verify_code;
     $param['site_name'] = C('site_name');
     $subject = ncReplaceText($tpl_info['title'], $param);
     $message = ncReplaceText($tpl_info['content'], $param);
     if ($_GET['type'] == 'email') {
         $email = new Email();
         $result = $email->send_sys_email($member_info["member_email"], $subject, $message);
     } elseif ($_GET['type'] == 'mobile') {
         $sms = new Sms();
         $result = $sms->send($member_info["member_mobile"], $message);
     }
     if ($result) {
         exit(json_encode(array('state' => 'true', 'msg' => '验证码已发出,请注意查收')));
     } else {
         exit(json_encode(array('state' => 'false', 'msg' => '验证码发送失败')));
     }
 }
コード例 #5
0
ファイル: slogin.php プロジェクト: noikiy/shopnc-2
 /**
  * 忘记密码
  */
 public function forget_passwordOp()
 {
     if (isset($_POST) && !empty($_POST)) {
         $model = Model();
         $store = $model->table('store')->where(array('account' => trim($_POST['account']), 'email' => trim($_POST['email'])))->find();
         if (empty($store)) {
             //验证是否存在
             $this->showTip(L('nc_member_store_account_email_is_wrong'), 'index.php?act=slogin', 'succ');
         }
         $code = md5(trim($_POST['account']) . time());
         $flag = $model->table('store')->where(array('account' => trim($_POST['account'])))->update(array('email_code' => $code));
         $result = false;
         if ($flag && $GLOBALS['setting_config']['email_enabled'] == '1') {
             $email = new Email();
             $subject = $GLOBALS['setting_config']['site_name'] . Language::get('nc_forget');
             $rurl = BASE_SITE_URL . '/index.php?act=slogin&op=resetpassword&code=' . $code;
             $message = Language::get('nc_password_message_1') . '<a href="' . $rurl . '" target="_blank">' . $rurl . '</a><br>' . Language::get('nc_password_message_2');
             $message .= Language::get('nc_password_message_3') . '【<a href="' . BASE_SITE_URL . '" target="_blank">' . $GLOBALS['setting_config']['site_name'] . '</a>】';
             $result = $email->send_sys_email(trim($_POST['email']), $subject, $message);
         }
         if ($result) {
             $this->showTip(Language::get('nc_forget_up_submit'), 'index.php?act=slogin', 'succ');
         } else {
             $this->showTip(Language::get('nc_forget_up_fail'), 'index.php?act=slogin&op=forget_password', 'html', 'error');
         }
     }
     Tpl::output('sign', 'forget_password');
     Tpl::showpage('sforget_password');
 }
コード例 #6
0
ファイル: control.php プロジェクト: dw250100785/shopnc
 /**
  * 系统通知发送函数
  *
  * @param int $receiver_id 接受人编号
  * @param string $tpl_code 模板标识码
  * @param array $param 内容数组
  * @return bool
  */
 public function send_notice($receiver_id, $tpl_code, $param)
 {
     /**
      * 获取通知内容模板
      */
     $mail_tpl_model = Model('mail_templates');
     $mail_tpl = $mail_tpl_model->getOneTemplates($tpl_code);
     if (empty($mail_tpl) || $mail_tpl['mail_switch'] == 0) {
         return false;
     }
     /**
      * 获取接收人信息
      */
     $member_model = Model('member');
     $receiver = $member_model->infoMember(array('member_id' => $receiver_id));
     if (empty($receiver)) {
         return false;
     }
     /**
      * 为通知模板的主题与内容中变量赋值
      */
     $subject = ncReplaceText($mail_tpl['title'], $param);
     $message = ncReplaceText($mail_tpl['content'], $param);
     /**
      * 根据模板里面确定的通知类型采用对应模式发送通知
      */
     $result = false;
     switch ($mail_tpl['type']) {
         case '0':
             $email = new Email();
             $result = $email->send_sys_email($receiver['member_email'], $subject, $message);
             break;
         case '1':
             $model_message = Model('message');
             $param = array('member_id' => $receiver_id, 'to_member_name' => $receiver['member_name'], 'msg_content' => $message, 'message_type' => 1);
             $result = $model_message->saveMessage($param);
             break;
     }
     return $result;
 }
コード例 #7
0
ファイル: login.php プロジェクト: lehman3087/wanhaoshop
 /**
  * 找回密码的发邮件处理
  */
 public function find_passwordOp()
 {
     Language::read('home_login_register');
     $lang = Language::getLangContent();
     $result = chksubmit(true, true, 'num');
     if ($result !== false) {
         if ($result === -11) {
             showDialog('非法提交');
         } elseif ($result === -12) {
             showDialog('验证码错误');
         }
     }
     if (empty($_POST['username'])) {
         showDialog($lang['login_password_input_username']);
     }
     if (process::islock('forget')) {
         showDialog($lang['nc_common_op_repeat'], 'reload');
     }
     $member_model = Model('member');
     $member = $member_model->getMemberInfo(array('member_name' => $_POST['username']));
     if (empty($member) or !is_array($member)) {
         process::addprocess('forget');
         showDialog($lang['login_password_username_not_exists'], 'reload');
     }
     if (empty($_POST['email'])) {
         showDialog($lang['login_password_input_email'], 'reload');
     }
     if (strtoupper($_POST['email']) != strtoupper($member['member_email'])) {
         process::addprocess('forget');
         showDialog($lang['login_password_email_not_exists'], 'reload');
     }
     process::clear('forget');
     //产生密码
     $new_password = random(15);
     if (!$member_model->editMember(array('member_id' => $member['member_id']), array('member_passwd' => md5($new_password)))) {
         showDialog($lang['login_password_email_fail'], 'reload');
     }
     $model_tpl = Model('mail_templates');
     $tpl_info = $model_tpl->getTplInfo(array('code' => 'reset_pwd'));
     $param = array();
     $param['site_name'] = C('site_name');
     $param['user_name'] = $_POST['username'];
     $param['new_password'] = $new_password;
     $param['site_url'] = SHOP_SITE_URL;
     $subject = ncReplaceText($tpl_info['title'], $param);
     $message = ncReplaceText($tpl_info['content'], $param);
     $email = new Email();
     $result = $email->send_sys_email($_POST["email"], $subject, $message);
     showDialog('新密码已经发送至您的邮箱,请尽快登录并更改密码!', '', 'succ', '', 5);
 }