<commit_before><?php
namespace Api\Controller;
use Think\Controller;
header('Content-Type: text/html; charset=utf-8;');
class UserController extends Controller {
    /*
    *用户中心
    *获取用户信息
    */
    public function index(){      //用户个人中心
        $id = session('id');
        if($id&&$id!=''){
            //执行用户操作
            $returnJson['error'] = 0;
        }else{
            $returnJson['error'] = 1003;
        }
        $this->ajaxReturn($returnJson);
    }
    public function userinfo(){
        $user = D('User');
        // session('id',1);
        $id  = session('id');
        if(isset($id)){
            $result = $user->userinfo($id);
            $result['error'] = 0;
        }else{
            $result['error'] = 1003;
        }
        $this->ajaxReturn($result);
    }
    public function up_info()
    {
        $msgNO = array(
            'up_faild'              => 0,
            'up_success'            => 1,
            'auth_code_err'         => -1,
            'need_auth_code'        => -2,
            'repassword_err'        => -3,
            'email_err'             => -4,
            'email_has_existed'     => -5,
            'username_has_existed'  => -6,
            'need_password'         => -7,
            'pass_not_long'         => -8,//密码不够长
            'no_auth'               => -9
        );
        $user      = D('User');
        $user_id   = session('user_info.user_id');
        if (!$user_id) {
            $r  = array(
                'msg'       => 'no_auth',
                'status'    => -1
            );
            $this->ajaxReturn($r);
        }
        $usercheck = $user->where('user_id='.$user_id)->find();
        if(!$usercheck){
            $r  = array(
                'msg'       => 'no_auth',
                'status'    => -1
            );
            $this->ajaxReturn($r);
        }
        $data = array(
            'username' => I('post.username'),
            'password' => I('<PASSWORD>'),
            'head_pic' => I('post.head_pic'),
            'qq'       => I('post.qq'),
            'telphone' => I('post.telphone'),
            'email'    => I('post.email')
        );
        $arr = $data;

        // 为了跳过验证 应急方法 todo 
        if(!$arr['password']){
            $arr['password'] = <PASSWORD>;
        }

        $auth = $user->create($arr, 3);
        if(!$auth){
            $err    = $user->getError();
            $r      = array(
                'data'      => array(),
                'msg'       => $err,
                'status'    => $msgNO[$err]
            );
            $this->ajaxReturn($r);
        }

        if(!$data['password']){
            unset($data['password']);
        }
        $data['password'] = <PASSWORD>(I('<PASSWORD>'));
        $result = $user->up_info($data,$user_id);
        if($result)
        {
            $r  = array(
                'msg'       => 'up_success',
                'status'    => 1,
                'data'      => $result<commit_msg>更新个人信息<commit_after><?php
namespace Api\Controller;
use Think\Controller;
header('Content-Type: text/html; charset=utf-8;');
class UserController extends Controller {
    /*
    *用户中心
    *获取用户信息
    */
    public function index(){      //用户个人中心
        $id = session('id');
        if($id&&$id!=''){
            //执行用户操作
            $returnJson['error'] = 0;
        }else{
            $returnJson['error'] = 1003;
        }
        $this->ajaxReturn($returnJson);
    }
    public function userinfo(){
        $user = D('User');
        // session('id',1);
        $id  = session('id');
        if(isset($id)){
            $result = $user->userinfo($id);
            $result['error'] = 0;
        }else{
            $result['error'] = 1003;
        }
        $this->ajaxReturn($result);
    }
    public function up_info()
    {
        $msgNO = array(
            'up_faild'              => 0,
            'up_success'            => 1,
            'auth_code_err'         => -1,
            'need_auth_code'        => -2,
            'repassword_err'        => -3,
            'email_err'             => -4,
            'email_has_existed'     => -5,
            'username_has_existed'  => -6,
            'need_password'         => -7,
            'pass_not_long'         => -8,//密码不够长
            'no_auth'               => -9
        );
        $user      = D('User');
        $user_id   = session('user_info.user_id');
        if (!$user_id) {
            $r  = array(
                'msg'       => 'no_auth',
                'status'    => -1
            );
            $this->ajaxReturn($r);
        }
        $usercheck = $user->where('user_id='.$user_id)->find();
        if(!$usercheck){
            $r  = array(
                'msg'       => 'no_auth',
                'status'    => -1
            );
            $this->ajaxReturn($r);
        }
        $data = array(
            'username' => I('post.username'),
            'password' => I('<PASSWORD>'),
            'head_pic' => I('post.head_pic'),
            'qq'       => I('post.qq'),
            'telphone' => I('post.telphone'),
            'email'    => I('post.email')
        );
        $arr = $data;
        // 为了跳过验证 应急方法 todo 
        if(!$arr['password']){
            $arr['password'] = <PASSWORD>;
        }

        $auth = $user->create($arr, 3);
        if(!$auth){
            $err    = $user->getError();
            $r      = array(
                'data'      => array(),
                'msg'       => $err,
                'status'    => $msgNO[$err]
            );
            $this->ajaxReturn($r);
        }

        if(!$data['password']){
            unset($data['password']);
        } else {
            $data['password'] = <PASSWORD>($data['password']);
        }
        $data['password'] = <PASSWORD>(I('<PASSWORD>'));
        $result = $user->up_info($data,$user_id);
        if($result)
        {
            $r  = array(
                'msg'       => 'up_success',
                'status'    => 1,
                'data'      => $result
{'fraction_non_alphanumeric': 0.17740863787375416, 'fraction_numerical': 0.008970099667774087, 'mean_word_length': 1.1926438455935906, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 88, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6200007', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1889, 'n_words': 296}