Esempio n. 1
0
 function loginsave_action()
 {
     $username = yun_iconv("utf-8", "gbk", $_POST['username']);
     if ($this->uid > 0 && $_COOKIE['username'] != "") {
         if ($_COOKIE['usertype'] == '1') {
             $this->ajaxlogin("您现在是个人会员登录状态!");
         } elseif ($_COOKIE['usertype'] == '2') {
             $this->ajaxlogin("您现在是企业会员登录状态!");
         }
     }
     if ($_POST['path'] != "index") {
         if (strstr($this->config['code_web'], '前台登陆')) {
             session_start();
             if (md5($_POST['authcode']) != $_SESSION['authcode']) {
                 unset($_SESSION['authcode']);
                 $this->ajaxlogin("验证码错误!");
             }
         }
     }
     if (!$this->CheckRegUser($username) && !$this->CheckRegEmail($username)) {
         $this->ajaxlogin("无效的用户名!");
     }
     if ($username != "") {
         $Member = $this->MODEL("userinfo");
         if ($this->config['sy_uc_type'] == "uc_center") {
             $this->uc_open();
             $uname = $username;
             list($uid, $username, $password, $email) = uc_user_login($username, $_POST['password']);
             if ($uid < 1) {
                 $user = $Member->GetMemberOne(array("username" => $uname), array("field" => "username,email,uid,password,salt"));
                 $pass = md5(md5($_POST['password']) . $user['salt']);
                 if ($pass == $user['password']) {
                     $uid = $user['uid'];
                     uc_user_register($user['username'], $_POST['password'], $user['email']);
                     list($uid, $username, $password, $email) = uc_user_login($uname, $_POST['password']);
                 } else {
                     $this->ajaxlogin("账户或密码错误!");
                 }
             } else {
                 if ($uid > 0) {
                     $ucsynlogin = uc_user_synlogin($uid);
                     $msg = '登录成功!';
                     $user = $Member->GetMemberOne(array("username" => $username), array("field" => "`uid`,`usertype`,`email_status`"));
                     if (!empty($user)) {
                         if (session_id() == "") {
                             session_start();
                         }
                         if ($_SESSION['qq']['openid']) {
                             $Member->UpdateMember(array("qqid" => $_SESSION['qq']['openid']), array("username" => $username));
                             unset($_SESSION['qq']);
                         }
                         if ($_SESSION['wx']['openid']) {
                             $udate = array('wxopenid' => $_SESSION['wx']['openid']);
                             if ($_SESSION['wx']['unionid']) {
                                 $udate['unionid'] = $_SESSION['wx']['unionid'];
                             }
                             $Member->UpdateMember($udate, array("username" => $username));
                             unset($_SESSION['wx']);
                         }
                         if ($_SESSION['sina']['openid']) {
                             $Member->UpdateMember(array("sinaid" => $_SESSION['sina']['openid']), array("username" => $username));
                             unset($_SESSION['sina']);
                         }
                         if (!$user['usertype']) {
                             $this->unset_cookie();
                             $this->addcookie("username", $username, time() + 3600);
                             $this->addcookie("password", $_POST['password'], time() + 3600);
                             $this->ajaxlogin($ucsynlogin, Url("login", array("c" => "utype"), "1"), '3');
                         }
                         if ($this->config['user_status'] == "1") {
                             if ($user['email_status'] != "1") {
                                 $this->ajaxlogin("您的账户还未激活,请先激活!", Url("activate", '', "1"));
                                 die;
                             }
                         }
                         if ($_POST['loginname']) {
                             setcookie("loginname", $username, time() + 8640000);
                         }
                         $this->autoupjob($user['uid'], $user['usertype']);
                     } else {
                         $this->unset_cookie();
                         $this->addcookie("username", $username, time() + 3600);
                         $this->addcookie("password", $_POST['password'], time() + 3600);
                         $this->ajaxlogin($ucsynlogin, Url("login", array("c" => "utype"), "1"), '3');
                     }
                     $this->ajaxlogin($ucsynlogin, $this->config['sy_weburl'] . "/member", '2');
                 } elseif ($uid == -1) {
                     $msg = '用户不存在,或者被删除';
                 } elseif ($uid == -2) {
                     $msg = '密码错误';
                 } else {
                     $msg = '该用户未定义!';
                 }
             }
             $this->ajaxlogin($ucsynlogin, Url("login", array("c" => "utype"), "1"), '3');
         } else {
             $user = $Member->GetMemberOne(array("username" => $username), array("field" => "`pw_repeat`,`pwuid`,`uid`,`username`,`salt`,`email`,`password`,`usertype`,`status`,`email_status`"));
             if ($this->config['sy_pw_type'] == "pw_center") {
                 if ($user['pw_repeat'] != "1") {
                     include APP_PATH . "/api/pw_api/pw_client_class_phpapp.php";
                     $pw = new PwClientAPI($username, $_POST['password'], "");
                     $pwuser = $pw->user_login();
                     if ($pwuser['uid'] > 0) {
                         if (empty($user)) {
                             $user = $this->newuser($Member, $pwuser['username'], $pwuser['password'], $pwuser['email'], $user['usertype'], $pwuser['uid'], $qqid);
                         } else {
                             if ($pwuser['uid'] == $user['pwuid']) {
                                 $pwrows = $pw->login($pwuser['uid']);
                                 $this->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], $user['usertype'], $_POST['loginname']);
                                 $time = strtotime(date("Y-m-d"));
                                 $row = $Member->GetPayinfoOne(array("`com_id`='" . $user['uid'] . "' and `pay_time`>'" . $time . "' and `pay_remark`='会员登录'"));
                                 if (empty($row)) {
                                     $this->get_integral_action($user['uid'], "integral_login", "会员登录");
                                 }
                                 $this->ajaxlogin('登录成功', '', '2');
                             } else {
                                 $Member->UpdateMember(array("pw_repeat" => "1"), array("uid" => $user['uid']));
                             }
                         }
                     }
                 }
             }
             if (is_array($user)) {
                 $pass = md5(md5($_POST['password']) . $user['salt']);
                 if ($user['password'] == $pass) {
                     if ($user['status'] == "2") {
                         $this->ajaxlogin("您的账号已被锁定!", Url("register", array("c" => "ok", "type" => 2), "1"));
                     }
                     if ($user['usertype'] == "2" && $this->config['com_status'] != "1" && $user['status'] != "1") {
                         $this->ajaxlogin("您还没有通过审核!", Url("register", array("c" => "ok", "type" => 3), "1"));
                     }
                     if ($this->config['user_status'] == "1" && $user['usertype'] == "1" && $user['email_status'] != "1") {
                         $this->ajaxlogin("您的账户还未激活,请先激活!", Url("activate", '', "1"));
                     }
                     if (session_id() == "") {
                         session_start();
                     }
                     if ($_SESSION['qq']['openid']) {
                         $Member->UpdateMember(array("qqid" => $_SESSION['qq']['openid']), array("username" => $username));
                         unset($_SESSION['qq']);
                     }
                     if ($_SESSION['wx']['openid']) {
                         $udate = array('wxopenid' => $_SESSION['wx']['openid']);
                         if ($_SESSION['wx']['unionid']) {
                             $udate['unionid'] = $_SESSION['wx']['unionid'];
                         }
                         $Member->UpdateMember($udate, array("username" => $username));
                         unset($_SESSION['wx']);
                     }
                     if ($_SESSION['sina']['openid']) {
                         $Member->UpdateMember(array("sinaid" => $_SESSION['sina']['openid']), array("username" => $username));
                         unset($_SESSION['sina']);
                     }
                     $time = time();
                     $ip = fun_ip_get();
                     $Member->UpdateMember(array("login_ip" => $ip, "login_date" => $time, "login_hits" => "`login_hits`+1"), array("uid" => $user['uid']));
                     $this->unset_cookie();
                     $this->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], $user['usertype'], $_POST['loginname']);
                     $time = strtotime(date("Y-m-d"));
                     $row = $Member->GetPayinfoOne(array("`com_id`='" . $user['uid'] . "' and `pay_time`>'" . $time . "' and `pay_remark`='会员登录'"));
                     if (empty($row)) {
                         $this->get_integral_action($user['uid'], "integral_login", "会员登录");
                     }
                     if ($qqid) {
                         $Member->UpdateMember(array("qqid" => $qqid, "username" => $username), array("uid" => $user['uid']));
                     }
                     if ($user['usertype'] == '1') {
                         $Resume = $this->MODEL("resume");
                         $info = $Resume->SelectResumeOne(array("uid" => $user['uid']), "`name`,`birthday`");
                     } else {
                         if ($user['usertype'] == '2') {
                             $Company = $this->MODEL("company");
                             $info = $Company->GetCompanyInfo(array("uid" => $user['uid']), array("field" => 'name'));
                             $this->autoupjob($user['uid'], $user['usertype']);
                         }
                     }
                     if ($info['name']) {
                         $this->ajaxlogin('登录成功', $this->config['sy_weburl'] . "/member", '1');
                     } else {
                         if ($info['name'] == '') {
                             $this->ajaxlogin('登录成功', $this->config['sy_weburl'] . "/member/index.php?c=info", '1');
                         }
                     }
                 } else {
                     $this->ajaxlogin("密码不正确!");
                 }
             } else {
                 $this->ajaxlogin("该用户不存在!");
             }
         }
     } else {
         $this->ajaxlogin("用户名不能为空!");
     }
 }
Esempio n. 2
0
 function loginsave_action()
 {
     $username = $this->stringfilter($_POST['username']);
     if ($_COOKIE['uid'] != "" && $_COOKIE['username'] != "") {
         $this->ajaxlogin($_POST['comid'], "您已经登陆了,您不是个人用户!");
         echo "您已经登录了!";
         die;
     }
     if ($_POST['path'] != "index") {
         if (strstr($this->config['code_web'], '前台登陆')) {
             if (md5($_POST['authcode']) != $_SESSION['authcode']) {
                 unset($_SESSION['authcode']);
                 $this->ajaxlogin($_POST['comid'], "验证码错误!");
                 echo "验证码错误!";
                 die;
             }
         }
     }
     if (!$this->CheckRegUser($username) && !$this->CheckRegEmail($username)) {
         echo "无效的用户名!";
         die;
     }
     if ($username != "") {
         if ($this->config['sy_uc_type'] == "uc_center") {
             $this->obj->uc_open();
             $uname = $username;
             list($uid, $username, $password, $email) = uc_user_login($username, $_POST['password']);
             if ($uid < 1) {
                 $user = $this->obj->DB_select_once("member", "`username`='" . $uname . "'", "username,email,uid,password,salt");
                 $pass = md5(md5($_POST['password']) . $user['salt']);
                 if ($pass == $user['password']) {
                     $uid = $user['uid'];
                     uc_user_register($user['username'], $_POST['password'], $user['email']);
                     list($uid, $username, $password, $email) = uc_user_login($uname, $_POST['password']);
                 } else {
                     echo $msg = '账户或密码错误!';
                     die;
                 }
             } else {
                 if ($uid > 0) {
                     $ucsynlogin = uc_user_synlogin($uid);
                     $msg = '登录成功!';
                     $user = $this->obj->DB_select_once("member", "`username`='" . $username . "'", "`uid`,`usertype`,`email_status`");
                     if ($_SESSION['qq']['openid']) {
                         $this->obj->DB_update_all("member", "`qqid`='" . $_SESSION['qq']['openid'] . "'", "`username`='" . $username . "'");
                         unset($_SESSION['qq']);
                     }
                     if ($_SESSION['wx']['openid']) {
                         $this->obj->DB_update_all("member", "`wxid`='" . $_SESSION['wx']['openid'] . "'", "`username`='" . $username . "'");
                         unset($_SESSION['wx']);
                     }
                     if ($_SESSION['sina']['openid']) {
                         $this->obj->DB_update_all("member", "`sinaid`='" . $_SESSION['wx']['openid'] . "'", "`username`='" . $username . "'");
                         unset($_SESSION['sina']);
                     }
                     if (!is_array($user)) {
                         $this->unset_cookie();
                         echo "没有该用户!";
                         die;
                     } else {
                         echo $ucsynlogin;
                     }
                     if ($this->config['user_status'] == "1") {
                         echo $ucsynlogin;
                         if ($user['email_status'] != "1") {
                             echo "您的账户还未激活,请先激活!";
                             die;
                         }
                     }
                     if ($_POST['loginname']) {
                         setcookie("loginname", $username, time() + 8640000);
                     }
                     $this->autoupjob($user['uid'], $_POST['usertype']);
                     echo $ucsynlogin;
                     echo 1;
                     die;
                 } elseif ($uid == -1) {
                     $msg = '用户不存在,或者被删除';
                 } elseif ($uid == -2) {
                     $msg = '密码错误';
                 } else {
                     $msg = '该用户未定义!';
                 }
             }
             $this->ajaxlogin($_POST['comid'], $msg);
             echo $msg;
             die;
         } else {
             $user = $this->obj->DB_select_once("member", "`username`='" . $username . "'", "`pw_repeat`,`pwuid`,`uid`,`username`,`salt`,`email`,`password`,`usertype`,`status`,`email_status`");
             if ($this->config['sy_pw_type'] == "pw_center") {
                 if ($user['pw_repeat'] != "1") {
                     include APP_PATH . "/api/pw_api/pw_client_class_phpapp.php";
                     $pw = new PwClientAPI($username, $_POST['password'], "");
                     $pwuser = $pw->user_login();
                     if ($pwuser['uid'] > 0) {
                         if (empty($user)) {
                             $user = $this->newuser($pwuser['username'], $pwuser['password'], $pwuser['email'], $user['usertype'], $pwuser['uid'], $qqid);
                         } else {
                             if ($pwuser['uid'] == $user['pwuid']) {
                                 $pwrows = $pw->login($pwuser['uid']);
                                 $this->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], $user['usertype'], $_POST['loginname']);
                                 $this->ajaxlogin($_POST['comid'], "1");
                                 $time = strtotime(date("Y-m-d"));
                                 $row = $this->obj->DB_select_once("company_pay", "`com_id`='" . $user['uid'] . "' and `pay_time`>'" . $time . "' and `pay_remark`='会员登录'");
                                 if (empty($row)) {
                                     $this->get_integral_action($user['uid'], "integral_login", "会员登录");
                                 }
                                 echo 1;
                                 die;
                             } else {
                                 $this->obj->DB_update_all("member", "`pw_repeat`='1'", "`uid`='" . $user['uid'] . "'");
                             }
                         }
                     }
                 }
             }
             if (is_array($user)) {
                 $pass = md5(md5($_POST['password']) . $user['salt']);
                 if ($user['password'] == $pass) {
                     if ($user['status'] == "2") {
                         $this->ajaxlogin($_POST['comid'], "您的账号已被锁定!");
                         echo "您的账号已被锁定!";
                         die;
                     }
                     if ($user['usertype'] == "2" && $this->config['com_status'] != "1" && $user['status'] != "1") {
                         $this->ajaxlogin($_POST['comid'], "您还没有通过审核!");
                         echo "您还没有通过审核!";
                         die;
                     }
                     if ($this->config['user_status'] == "1" && $user['usertype'] == "1" && $user['email_status'] != "1") {
                         $this->ajaxlogin($_POST['comid'], "您的账户还未激活,请先激活!");
                         echo "您的账户还未激活,请先激活!";
                         die;
                     }
                     if ($_SESSION['qq']['openid']) {
                         $this->obj->DB_update_all("member", "`qqid`='" . $_SESSION['qq']['openid'] . "'", "`username`='" . $user['username'] . "'");
                         unset($_SESSION['qq']);
                     }
                     if ($_SESSION['sinaid']) {
                         $this->obj->DB_update_all("member", "`sinaid`='" . $_SESSION['sinaid'] . "'", "`username`='" . $username . "'");
                         unset($_SESSION['sinaid']);
                         unset($_SESSION['sinainfo']);
                     }
                     $time = time();
                     $ip = $this->obj->fun_ip_get();
                     $this->obj->DB_update_all("member", "`login_ip`='{$ip}',`login_date`='{$time}',`login_hits`=`login_hits`+1", "`uid`='" . $user['uid'] . "'");
                     $this->unset_cookie();
                     $this->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], $user['usertype'], $_POST['loginname']);
                     $time = strtotime(date("Y-m-d"));
                     $row = $this->obj->DB_select_once("company_pay", "`com_id`='" . $user['uid'] . "' and `pay_time`>'" . $time . "' and `pay_remark`='会员登录'");
                     if (empty($row)) {
                         $this->get_integral_action($user['uid'], "integral_login", "会员登录");
                     }
                     if ($qqid) {
                         $this->obj->DB_update_all("member", "`qqid`='{$qqid}'", "`username`='{$username}'");
                     }
                     $this->ajaxlogin($_POST['comid'], "1");
                     if ($user['usertype'] == '1') {
                         $resume = $this->obj->DB_select_once("resume", "`uid`='" . $user['uid'] . "'", "`name`,`birthday`");
                         if ($resume['name'] && $resume['birthday']) {
                             echo 1;
                             die;
                         } else {
                             echo 2;
                             die;
                         }
                     } else {
                         $this->autoupjob($user['uid'], $user['usertype']);
                         echo 1;
                         die;
                     }
                 } else {
                     $this->ajaxlogin($_POST['comid'], "密码不正确!");
                     echo "密码不正确!";
                     die;
                 }
             } else {
                 $this->ajaxlogin($_POST['comid'], "该用户不存在!");
                 echo "该用户不存在!";
                 die;
             }
         }
     } else {
         echo "用户名不能为空!";
         die;
     }
 }