public function register($username = '', $nickname = '', $password = '', $repassword = '', $email = '', $verify = '', $type = 'start') { $type = op_t($type); if (!C('USER_ALLOW_REGISTER')) { $this->error('注册已关闭'); } $verifyarr = explode(',', C('VERIFY_OPEN')); if (in_array('1', $verifyarr)) { $this->assign('isverify', 1); } else { $this->assign('isverify', 0); } if (IS_POST) { //注册用户 /* 检测验证码 TODO: */ if (in_array('1', $verifyarr)) { if (!$this->check_verify($verify)) { $this->error('验证码输入错误!'); } } if ($password != $repassword) { $this->error('两次密码输入不一致'); } /* 调用注册接口注册用户 */ $User = new UserApi(); $uid = $User->register($username, $nickname, $password, $email); if (0 < $uid) { //注册成功 sendMessage($uid, 0, '注册成功', '恭喜您!您已经注册成功,请尽快<a href="' . U('Ucenter/yzmail') . '">验证邮箱地址</a>,第一时间获取网站动态!', 0); $uid = $User->login($username, $password); //通过账号密码取到uid D('Member')->login($uid, false); //登陆 asyn_sendmail($email, 2); setuserscore($uid, C('REGSCORE')); $this->success('注册成功并登陆!', cookie('referurl')); } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { //显示注册表单 if (is_login()) { redirect(cookie('referurl')); } if (cookie('referurl') == '') { cookie('referurl', $_SERVER['HTTP_REFERER']); } $this->display(); } }
<?php function asyn_sendmail() { $fp = fsockopen("localhost", 80, $errno, $errstr, 30); if (!$fp) { echo "{$errstr} ({$errno})<br />\n"; } fputs($fp, "GET http://localhost/socket/sendmail.php\r\n"); fclose($fp); } echo time() . ''; echo 'call asyn_sendmail'; asyn_sendmail(); echo time() . '';