/** * 用户资料更新 * @param int $mid * @param array $fields **/ public function updateInfo($mid, $fields = array()) { $update = ""; foreach ($fields as $key => $val) { if (is_null($val)) { continue; } $update .= $key . "='" . $val . "',"; } $update = substr($update, 0, -1); $sql = "UPDATE {$this->memberinfo} SET {$update} WHERE mid={$mid} LIMIT 1"; $flag = Loader_Mysql::dbmaster()->query($sql); if ($flag) { //更新成功 更新缓存 $aUser = Member::factory()->getOneById($mid, false); foreach ($fields as $key => $val) { if (isset($aUser[$key])) { $aUser[$key] = $val; } } //更新缓存 $cacheKey = Core_Keys::getOneById($mid); return Loader_Memcached::minfo($mid)->set($cacheKey, Values::combine(Values::getmb(), $aUser), 3 * 24 * 3600); } return false; }
*/ $info = Mobile_Member::factory()->androidGusetLogin($aGuest); if (!$info) { $ret['code'] = '-3'; $ret['msg'] = Core_Loginerror::$index[-3]; Lib_Mobile::jsonRet($ret, 0); } $userInfo = Member::factory()->getOneBySitemid($info['sitemid'], $sid); if (!$userInfo) { $userInfo['sid'] = $sid; $userInfo['sitemid'] = $info['sitemid']; $userInfo['mnick'] = $nick; $userInfo['micon'] = ''; $userInfo['mbig'] = ''; $userInfo['sex'] = 2; $userInfo = Member::factory()->insert($userInfo, $api); if (!$userInfo) { $ret['code'] = '-4'; $ret['msg'] = Core_Loginerror::$index[-4]; Lib_Mobile::jsonRet($ret, 0); } $userInfo['isFirst'] = 1; //用户注册上报 DCDATA && @Data_Dcdata::factory($api)->sendNewLog('user_signup', array('uid' => $userInfo['mid'], 'platform_uid' => $userInfo['sitemid'], 'signup_at' => time(), 'ip' => Helper::getip(), 'entrance_id' => $sid, 'version_info' => $version, 'm_imei' => $imei)); } if ($userInfo['mstatus'] == 1) { $ret['code'] = '-10'; $ret['noAllowLogin'] = 1; $ret['msg'] = Core_Loginerror::$forbidden; Lib_Mobile::jsonRet($ret, 0); }
/** * 获取多个用户的资料 * * @param {array} $mids 用户游戏ID列表 * * @return array */ public function getAllByIds($mids) { if (!is_array($mids)) { return array(); } $mids = array_unique($mids); $keys = $noKeys = $list = $return = array(); foreach ($mids as $mid) { $noKeys[$mid] = $mid; //没有找到用户资料的ID $keys[$mid % 3][] = Core_Keys::getOneById($mid); //[散列][列表] = 缓存键 } foreach ($keys as $hash => $keys) { $tmpList = Loader_Memcached::minfo($hash)->getMulti($keys); $tmpList = is_array($tmpList) ? $tmpList : array(); foreach ($tmpList as $key => $user) { $list[$user[0]] = Values::uncombine(Values::getmb(), $user); unset($noKeys[$user[0]]); //已经找到该用户 //注释掉。 就可以去取缓存信息 } } //沒有找到的,再找一遍 foreach ($noKeys as $mid) { $list[$mid] = Member::factory()->getOneById($mid, true); } foreach ($mids as $mid) { empty($list[$mid]) ? '' : ($return[] = $list[$mid]); } return (array) $return; }
/** * 移动用户更改个人信息 * @uses ios锄大地 * @param mid ,info * @return true */ public function modUserInfo($mid, $info) { if (!($mid = Helper::uint($mid)) || !is_array($info) || !$info) { return false; } $flag = 0; $cachekey = Core_Keys::getOneById($mid); $aInfo = Member::factory()->getMemberUserInfo($mid); if ($aInfo['mid'] != $mid || !($sitemid = $aInfo['sitemid'])) { //无效用户 return false; } $aInfo['sid'] = $info['sid'] ? Helper::uint($info['sid']) : $aInfo['sid']; $aInfo['mnick'] = $info['mnick'] ? Loader_Mysql::DBMaster()->escape($info['mnick']) : $aInfo['mnick']; $aInfo['sex'] = Helper::uint($info['sex']); $aInfo['hometown'] = Loader_Mysql::DBMaster()->escape($info['hometown']); $tableUserInfo = $this->getUserInfo($mid); $query = "UPDATE {$tableUserInfo} SET mnick = '{$aInfo['mnick']}', hometown = '{$aInfo['hometown']}',sex = {$aInfo['sex']} WHERE mid = '{$mid}' LIMIT 1"; Loader_Mysql::DBMaster()->query($query); //if ($flag = Loader_Mysql::DBMaster()->affectedRows()) //{ return Loader_Memcached::minfo($mid)->set($cachekey, values::combine(values::getArrUsers(), $aInfo), 10 * 24 * 60 * 60); //加入缓存 //} }
<?php defined('YUEAI') or exit('Access Denied!'); if ($_GET['debug'] == 1) { ini_set('display_errors', 1); error_reporting(E_ALL); } //ijBTM3pvJ3rIhuen1uTasD7PhitBOGNb_o8949aoPNGEsWjScWTisCa-zEpbok9jKtiGO3ih5FxbIwJhfqz3xw== $cmd = $_GET['cmd']; $mid = $_GET['mid']; switch ($cmd) { case "userinfo": $info = Member::factory()->getOneById($mid); print_R($info); break; case "test": echo "hello world"; break; case "redis": $cachekey = 'sblacktest'; var_dump(Loader_Redis::Redis()->set($cachekey, 1, false, false, 300)); echo Loader_Redis::Redis()->get($cachekey, false, false); print_r(Loader_Redis::Redis()->info()); break; case "memcache": Loader_Memcached::cache()->set('sb', 2, 600); echo Loader_Memcached::cache()->get('sb'); break; default: exit('you are son of bitch'); }
$sitemid = $info['sitemid']; $userinfo = Member::factory()->getOneBySiteMid($sitemid, $sid); if (!$userinfo) { //走注册流程 $info = array(); $info['sitemid'] = $sitemid; $info['sid'] = $sid; $info['mnick'] = $param['username'] ? $param['username'] : "******" . $sitemid; $info['sitemid'] = $sitemid; $info['gender'] = 2; $userinfo = Member::factory()->insert($info); $userinfo['isRegister'] = 1; $userinfo['FirstLogin'] = 1; } else { //更新登录信息 if (empty($userinfo['mnick'])) { $userinfo['mnick'] = $param['username']; } Member::factory()->updateLogin($userinfo); $userinfo['isRegister'] = 0; } //判断用户状态 if ($userinfo['status'] == 1) { $ret = array('code' => '-4', 'msg' => Core_Error::getError(-4)); Lib_Mobile::jsonRet($ret, 0); } //格式化userinfo Core_Member::factory()->formatUserInfo($userinfo); //初始化一些设置 $ret = Core_Member::factory()->loadinit($userinfo, $api, $version); Lib_Mobile::jsonRet($ret, 1);