array('check' => 'in', 'param' => array('email', 'phone')), 'input' => array('check' => 'require'), )); $type = $data['type']; $input = $data['input']; $source = $data['source'] = 'bind'; // 检查图片验证码 $checkCode = Input::get('checkCode', 'require', ''); Action('user.setting')->checkImgCode($checkCode); // 1.1 判断邮箱是否已绑定-自己 $userInfo = Session::get("kodUser"); if ($userInfo[$data['type']] == $input) { show_json(LNG('common.' . $type) . LNG('user.binded'), false); } // 1.2 判断邮箱是否已绑定-他人 if ($res = Model('User')->userSearch(array($type => $input), 'name,nickName')) { $typeTit = $type . ($type == 'phone' ? 'Number' : ''); $message = $type == 'phone' ? LNG('ERROR_USER_EXIST_PHONE') : LNG('ERROR_USER_EXIST_EMAIL'); show_json($message.'.', false); } // 2 发送邮件/短信 Action('user.setting')->checkMsgFreq($data); // 消息发送频率检查 if($type == 'email'){ $res = $this->sendEmail($input, $type.'_'.$source); }else{ $res = $this->sendSms($input, $type.'_'.$source); } if (!$res['code']) { show_json(LNG('user.sendFail') . ': ' . $res['data'], false); } Action('user.setting')->checkMsgFreq($data, true); // 3. 存储验证码 $param = array( 'type' => 'setting', 'input' => $input ); Action("user.setting")->checkMsgCode($type, $res['data'], $param, true); show_json(LNG('user.sendSuccess'), true); } /** * 发送(验证码)邮件 * @param [type] $input * @param [type] $action * @return void */ public function sendEmail($input, $action,$title = '',$code = false) { $systemName = Model('SystemOption')->get('systemName'); $user = Session::get('kodUser'); $name = _get($user,'name',''); $name = _get($user,'nickName',$name);// _get 连续获取,部分安全软件会误报; $desc = Model('SystemOption')->get('systemDesc'); $code = $code ? $code : rand_string(6,1); if(!$name && isset($user['name'])){$name = $user['name'];} $data = array( 'type' => 'email', 'input' => $input, 'action' => $action, 'config' => array( 'address' => $input, 'subject' => "[".$systemName."]" . LNG('user.emailVerify').$title, 'content' => array( 'type' => 'code', 'data' => array('user' => $name,'code' => $code) ), 'system' => array( // 系统信息 'icon' => STATIC_PATH.'images/icon/fav.png', 'name' => $systemName, 'desc' => $desc ), ) ); return Action('user.msg')->send($data); } /** * 发送(验证码)短信 * @param [type] $input * @param [type] $action * @return void */ public function sendSms($input, $action) { $data = array( 'type' => 'sms', 'input' => $input, 'action' => $action ); return Action('user.msg')->send($data); } /** * 请求Kodapi服务器 * @param type $type * @param type $data * @return type */ public function apiRequest($type, $data = array()) { $kodid = md5(BASIC_PATH . Model('SystemOption')->get('systemPassword')); if(is_array($data) && defined('INSTALL_CHANNEL')){$data['channel'] = INSTALL_CHANNEL;} $post = array( 'type' => $type, 'kodid' => $kodid, 'timestamp' => time(), 'data' => is_array($data) ? json_encode($data) : $data ); $post['sign'] = $this->makeSign($kodid, $post); $url = $this->config['settings']['kodApiServer'] . 'plugin/platform/'; $response = url_request($url, 'GET', $post); if ($response['status']) { $data = json_decode($response['data'], true); if (!$data) { // 平台异常报错(show_tips) if ($response['data']) { preg_match('/