<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class user_mod extends module { function __construct() { $this->uid = @$_SESSION['user']['uid']; parent::__construct(); } function userInfo($uq0) { return $this->db->get_one("select * from ".table("member")." where username = '".$uq0."' limit 1"); } function now_user() { return $this->db->get_one("select * from ".table("member")." where uid = ".$this->uid); } function check_user($uq0) { if(verify::is_email($uq0)){ $uq1 = $this->db->get_one("select uid,email,password,rand,refresh_time from ".table("member")." where email='".$uq0."'"); }elseif(verify::is_mobile($uq0)){ $uq1 = $this->db->get_one("select uid,mobile,password,rand,refresh_time from ".table("member")." where mobile='".$uq0."'"); }else{ $uq1 = $this->db->get_one("select uid,username,password,rand,refresh_time from ".table("member")." where username='".$uq0."'"); } return $uq1; } function user_session($uq1) { unset($_SESSION['user']); $uq2['uid'] = $uq1['uid']; $uq2['nick'] = $uq1['nick']??''; $uq2['mobile'] = !empty($uq1['mobile'])?hideMobile($uq1['mobile']):''; $uq2['email'] = !empty($uq1['email'])?hideEmail($uq1['email']):''; $_SESSION['user'] = $uq2; $uq3['login_error_count'] = '0'; $uq3['last_login_ip'] = get_ip(); $uq3['last_login_time'] = time(); $uq3['session_id'] = session_id(); $this->db->update(table('member'), $uq3, 'uid = '.$uq1['uid']); return true; } function avatar_save($uq4) { $uq5 = curl::downloadImgaes($uq4); $uq6 = $this->module('album')->upload_move($uq5, 'avatar'); $uq7 = json_decode($uq6); return $uq7->name; } function get_info($uq8) { $uq9 = $uq8['uid']??''; if(empty($uq9)){ $uq9 = $this->uid; } $uq2 = $this->db->get_one("select * from ".table("member")." where uid = ".$uq9); if($uq2['uid']){ $uq2['mobile_hide'] = hideMobile($uq2['mobile']); return $uq2; }else{ return false; } } function conn_info($uq8) { $uq10 = $uq8['alias']??''; $uq11['nick'] = $_SESSION['connect'][$uq10]['nick']; $uq11['avatar'] = $_SESSION['connect'][$uq10]['avatar']; $uq11['sex'] = $_SESSION['connect'][$uq10]['sex']; return $uq11; } function conn_login() { if(cfg['browser'] == 'wchat'){ if(cfg['wchat_status'] == '1'){ $uq12 = @$_SESSION['connect']['wchat']['openid']; if(!empty($uq12)){ $this->wchat_login($uq12); }else{ $uq13 = $_GET['code']??''; if(!empty($uq13)){ $uq12 = wchat::init()->openid($uq13); @$_SESSION['connect']['wchat']['openid'] = $uq12; $uq14 = wchat::init()->user_info(); @$_SESSION['connect']['wchat']['nick'] = $uq14['nick']; @$_SESSION['connect']['wchat']['avatar'] = $uq14['avatar']; $this->wchat_login($uq12); }else{ wchat::init()->get_code(); } } } } } function wchat_login($uq12) { if(cfg['user_conn_status'] == '1'){ $uq2 = $this->db->get_one("select uid,nick,mobile,email,status from ".table('member')." where wchat_uid = '".$uq12."'"); if($uq2['uid']){ if($uq2['status'] == '1'){ $this->module('user')->user_session($uq2); } }else{ if(cfg['user_conn_isbind'] == '0'){ $this->conn_reg('wchat', $uq12); } } } } function conn_reg($uq15, $uq16) { $uq17 = $uq15.'_uid'; $uq18 = @$_SESSION['connect'][$uq15]['nick']; if(!empty($uq18)){ $uq19['nick'] = $uq18; } $uq20 = @$_SESSION['connect'][$uq15]['avatar']; if(!empty($uq20)){ $uq21 = $this->module('album')->download_upload($uq20, 'avatar', 'jpg'); if(!empty($uq21['name'])){ $uq19['avatar'] = $uq21['name']; } } $uq19[$uq17] = $uq16; $uq19['rand'] = get_rand(4); if(cfg['user_login_check'] == '1'){ $uq19['status'] = '0'; }else{ $uq19['status'] = '1'; } $uq19['register_ip'] = get_ip(); $uq19['last_login_ip'] = get_ip(); $uq19['addtime'] = time(); $uq22 = $this->db->add(table('member'), $uq19); if($uq22){ $uq9 = $this->db->insert_id(); if(cfg['distribute_status'] == '1'){ $this->module('distribute')->create_user($uq9); } if(cfg['user_login_check'] == '0'){ $uq23['uid'] = $uq9; $uq23['nick'] = $uq18; $uq23['mobile'] = ''; $uq23['email'] = ''; $this->module('user')->user_session($uq23); } return true; }else{ return false; } } function shop_reg($uq8) { $uq1 = $this->db->get_one("select * from ".table('shop_auth')." where uid = ".$this->uid." limit 1"); if($uq1['id']){ if($uq1['status'] == '1'){ $uq24 = $this->db->get_one("select * from ".table('shop')." where uid = ".$this->uid." limit 1"); if($uq24['id'] && ($uq24['status'] == '1') && ($uq1['status'] == '1')){ $this->create_shop_session($uq24); } return $uq1; }else{ $uq1['license_start_time'] = _date($uq1['license_start_time']); $uq1['license_end_time'] = _date($uq1['license_end_time']); return $uq1; } }else{ return false; } } } 