<?php

    $user='';

    if($_GET['qq_openid']){

       // 禁止重复登录

       $uid = DB::result_first('SELECT uid  FROM '.DB::table('mocuz_connect')." WHERE openid = '$_GET[qq_openid]'");

   //    $result=C::t('common_member')->fetch_all_username_by_uid($uid);

       $user= DB::fetch_all('SELECT *  FROM '.DB::table('common_member')." as u LEFT JOIN "

                          .DB::table('common_usergroup')." as g ON u.groupid = g.groupid   WHERE uid = '$uid'");

       $user=$user[0];

        // 登录成功

       if($uid){

            $result_data = array(

                    'uid' => $uid,

                    'code'=>0,

                    'username' => $user['username'],

                    'avatar' => avatar($uid, 'middle', true),

                    'auth' => authcode("{$user[password]}\t{$uid}", 'ENCODE', '', 31536000), // 登录令牌有效期(31536000=1年)

                    'credits'=>$user['credits'], //积分

                    'grouptitle'=>$user['grouptitle'] //头衔

             );

             // 团购系统登录令牌

            $ttauth = '';

            $result_data['ttauth'] = $ttauth;

            // v2.0 用户扩展资料

            $user_info = DB::fetch_first('SELECT gender,mobile,affectivestatus,birthyear,birthmonth,birthday FROM '.DB::table('common_member_profile').' WHERE uid='.$uid);

            $sightml= DB::fetch_first('SELECT sightml FROM '.DB::table('common_member_field_forum').' WHERE uid = '.$uid);

            $regdate = DB::fetch_first('SELECT regdate FROM '.DB::table('common_member').' WHERE uid = '.$uid);

            $mobiles  = DB::fetch_first('SELECT mobile FROM '.DB::table('mocuz_mobile').' WHERE uid = '.$uid);

            $result_data['regdate'] = date('Y-m-d',$regdate['regdate']);

            $result_data['sightml'] = $sightml['sightml']?$sightml['sightml']:odz_lang('no_message_left');

            $result_data['mobile']  = $mobiles['mobile']?$mobiles['mobile']:odz_lang('no_binding');

            $result_data['gender'] = (string)$user_info['gender'];

            $result_data['affectivestatus'] = $user_info['affectivestatus']?$user_info['affectivestatus']:odz_lang('secrect');

            $result_data['birth'] = $user_info['birthyear'].'-'.add_num_zero($user_info['birthmonth']).'-'.add_num_zero($user_info['birthday']);

            

            //if($user_info['birthyear'] != 0){

              $result_data['isperfect'] = "1";

            //}else{

              //$result_data['isperfect'] = "0";

            //}

       }

       odz_stats(array('typeid'=>3, 'action'=>'login'));

    }

    if(empty($result_data)){

        $result_data['code']=1;

    }

    odz_result($result_data);

?>