header("Location:" . $siteRoot . "cancel.php"); exit; } else { $msg = '授权出现错误,错误码:' . $error_code; } } } if ($token) { // 获取用户身份信息 $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $token['access_token']); $sid_get = $c->get_uid(); if_weiboapi_fail($sid_get); $sid = $sid_get['uid']; // 判断是否首次授权,首次授权则登记sina uid $dbo = new dbex($dbServs); if (!$dbo->checkExist($sid, 'sina_uid', 'user_info_sina')) { // 首次授权 在绑定微博或用微博帐号注册 if (isset($_SESSION['uid'])) { //已注册微动力,在绑定微博,完善信息 $id = $_SESSION['uid']; $api_res = $c->show_user_by_id($sid); if_weiboapi_fail($api_res); $sql = "insert into user_info_sina (user_id, sina_uid, sina_token, token_update_at, token_expires_in, sina_screen_name, sina_location, sina_description, bind_time) values ('{$id}', '{$sid}', '{$token['access_token']}', now(), '{$token['expires_in']}', '{$api_res['screen_name']}', '{$api_res['location']}', '{$api_res['description']}', now())"; $num = $dbo->exeUpdate($sql); if (1 != $num) { $msg = "向数据库插入数据出错。file:" . __FILE__ . ";line:" . __LINE__ . "sql:" . $sql; debug($msg); } $sql = "update user set bind_status = bind_status + 1 where user_id = '{$id}' limit 1"; $num = $dbo->exeUpdate($sql); if (1 != $num) {
// 没有带token和email header('Location:' . $siteRoot . 'pre_reg.php'); $dbo->close(); exit; } // token和email有效 if (isset($_POST['submitted'])) { // 当前页面已提交,现在处理提交的数据 $dbo = new dbex($dbServs); $err_msg = array(); $e = $dbo->real_escape_string($email); $n = trim($_POST['name']); if (check_nickname_fail($n)) { $err_msg[] = "请填写符合规定的用户昵称"; } else { if ($dbo->checkExist($n, 'nick_name')) { $err_msg[] = "这个昵称太热门,已经被使用了,您换一个试试"; } } $n = $dbo->real_escape_string($n); $p1 = trim($_POST['pass1']); $p2 = trim($_POST['pass2']); if (check_password_fail($p1)) { $err_msg[] = "请设置符合规定的密码"; } else { if ($p1 !== $p2) { $err_msg[] = "两次密码输入不一致"; } else { $ency_p = md5($p1); } }
} require_once "{$dbConfFile}"; // init $dbServs if (isset($_POST['submitted'])) { // 处理用户提交的数据 $dbo = new dbex($dbServs); $err_msg = array(); $code = trim($_POST['vericode']); if ($code != $_SESSION['verifyCode']) { $err_msg[] = '验证码错误,请重新输入'; } $e = trim($_POST['email']); if (check_email_fail($e)) { $err_msg[] = "请填写正确的邮箱地址"; } else { if ($dbo->checkExist($e)) { $err_msg[] = "对不起,该邮箱已经被使用了"; } } if (empty($err_msg)) { global $token_salt; // initial in config.php $token = generate_token($e, $token_salt); // func in check.php include_once $webRoot . 'mail/class-phpmailer.php'; include_once $webRoot . 'mail/class-smtp.php'; $mail = new PHPMailer(); $mail->IsSmtp(); $mail->CharSet = 'UTF-8'; $mail->AddAddress("{$e}"); $body_message = "Hi,欢迎注册微动力。\n 请点击下面的链接完成微动力帐号的注册,24小时内有效。 \n 如果您并未申请微动力,请忽视此邮件。\n " . $siteRoot . "reg.php?token=" . $token . '&email=' . $e . " \n\n\n 微动力团队 ";