public function saveAvatar($uid, $path) { //删除旧头像和临时头像 $this->removeAvatar($uid); $this->removeTempAvatar($uid); //保存新头像 $data = array('uid' => $uid, 'path' => $path, 'status' => 1, 'is_temp' => 0); $data = $this->create($data); clean_query_user_cache($uid, array('avatar32', 'avatar64', 'avatar128', 'avatar256', 'avatar512')); return $this->add($data); }
public function unfollow($uid) { $follow['who_follow'] = is_login(); $follow['follow_who'] = $uid; clean_query_user_cache($uid, 'fans'); clean_query_user_cache(is_login(), 'following'); S('atUsersJson_' . is_login(), null); $user = query_user(array('id', 'username', 'space_url')); D('Message')->sendMessage($uid, $user['username'] . '取消了对你的关注', '粉丝数减少', $user['space_url'], is_login(), 0); return $this->where($follow)->delete(); }
function setuserscore($uid, $score, $inc = true) { $member = D('Member'); if ($inc) { $res = $member->where(array('uid' => $uid))->setInc('score', $score); clean_query_user_cache($uid, array('artnum')); } else { $res = $member->where(array('uid' => $uid))->setDec('score', $score); clean_query_user_cache($uid, array('artnum')); } return $res; }
/** * send_weibo 发布分享 * @param $content * @param $type * @param string $feed_data * @param string $from * @return bool * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ function send_weibo($content, $type, $feed_data = '', $from = '') { $uid = is_login(); D('Weibo/Topic')->addTopic($content); $weibo_id = D('Weibo')->addWeibo($uid, $content, $type, $feed_data, $from); if (!$weibo_id) { return false; } action_log('add_weibo', 'weibo', $weibo_id, $uid); $uids = get_at_uids($content); send_at_message($uids, $weibo_id, $content); clean_query_user_cache(is_login(), array('weibocount')); return $weibo_id; }
public function doUserAddRank($id = null, $uid, $reason, $is_show, $rank_id) { $is_Edit = $id ? true : false; $data = array('uid' => $uid, 'reason' => $reason, 'is_show' => $is_show, 'rank_id' => $rank_id); $model = D('rank_user'); if ($is_Edit) { $data = $model->create($data); $data['create_time'] = time(); $result = $model->where('id=' . $id)->save($data); if (!$result) { $this->error('关联失败'); } } else { $rank_user = $model->where(array('uid' => $uid, 'rank_id' => $rank_id))->find(); if ($rank_user) { $this->error('该用户已经拥有该头衔,请选着其他头衔'); } $data = $model->create($data); $data['create_time'] = time(); $result = $model->add($data); if (!$result) { $this->error('关联失败'); } else { $rank = D('rank')->where('id=' . $data['rank_id'])->find(); //$logoUrl=getRootUrl().D('picture')->where('id='.$rank['logo'])->getField('path'); $u_name = D('member')->where('uid=' . $uid)->getField('nickname'); $content = '管理员给你颁发了头衔:[' . $rank['title'] . ']'; //<img src="'.$logoUrl.'" title="'.$rank['title'].'" alt="'.$rank['title'].'">'; $user = query_user(array('username', 'space_link'), $uid); $content1 = '管理员给@' . $user['username'] . ' 颁发了新的头衔:[' . $rank['title'] . '],颁发理由:' . $reason; //<img src="'.$logoUrl.'" title="'.$rank['title'].'" alt="'.$rank['title'].'">'; clean_query_user_cache($uid, array('rank_link')); $this->sendMessage($data, $content); //写入数据库 $model = D('Weibo/Weibo'); $result = $model->addWeibo(is_login(), $content1); } } $this->success($is_Edit ? '编辑关联成功' : '添加关联成功', U('Rank/userRankList?id=' . $uid)); }
public function addFollow($who_follow, $follow_who) { $follow['who_follow'] = $who_follow; $follow['follow_who'] = $follow_who; if ($follow['who_follow'] == $follow['follow_who']) { //禁止关注和被关注都为同一个人的情况。 return 0; } if ($this->where($follow)->count() > 0) { return 0; } $follow = $this->create($follow); clean_query_user_cache($follow_who, 'fans'); clean_query_user_cache($who_follow, 'following'); S('atUsersJson_' . $who_follow, null); /** * @param $to_uid 接受消息的用户ID * @param string $content 内容 * @param string $title 标题,默认为 您有新的消息 * @param $url 链接地址,不提供则默认进入消息中心 * @param $int $from_uid 发起消息的用户,根据用户自动确定左侧图标,如果为用户,则左侧显示头像 * @param int $type 消息类型,0系统,1用户,2应用 */ $user = query_user(array('id', 'username', 'space_url'), $who_follow); D('Message')->sendMessage($follow_who, $user['username'] . ' 关注了你。', '粉丝数增加', $user['space_url'], $who_follow, 0); return $this->add($follow); }
public function cancelWithdraw() { $aId = I('post.id', 0, 'intval'); //取消提现,可以是管理员或者当事人 $withdrawModel = D('Withdraw'); $withdraw = $withdrawModel->getWithdraw($aId); if (empty($withdraw) || $aId <= 0) { $this->error('提现不存在。'); } $this->checkAuth(null, $withdraw['uid']); if ($withdraw['payok'] != 0) { $this->error('该提现不能被取消'); } //取消订单 $rs = $withdrawModel->where(array('id' => $withdraw['id']))->setField('payok', -1); S('withdraw_order_' . $withdraw['id'], null); //返还现金 D('Member')->where(array('uid' => $withdraw['uid']))->setInc('score' . $withdraw['field'], $withdraw['frozen_amount']); clean_query_user_cache($withdraw['uid'], 'score' . $withdraw['field']); if (!$rs) { $withdrawModel->where(array('id' => $withdraw['id']))->setField('payok', 2); //待返还状态 $this->error('返还金额失败。请联系管理员。'); } $this->success('取消订单成功。冻结' . $withdraw['score_type']['title'] . $withdraw['frozen_amount'] . $withdraw['score_type']['unit'] . '已返还到您的指定账户。'); }
public function cleanUserCache($uid, $type) { $uid = is_array($uid) ? $uid : explode(',', $uid); $type = is_array($type) ? $type : explode(',', $type); foreach ($uid as $val) { foreach ($type as $v) { clean_query_user_cache($val, 'score' . $v); } clean_query_user_cache($uid, 'title'); } }
public function userChangeRank($id = null, $uid = '', $reason = '', $is_show = '', $rank_id = '') { if (IS_POST) { $is_Edit = $id ? true : false; $data = array('uid' => $uid, 'reason' => $reason, 'is_show' => $is_show, 'rank_id' => $rank_id); $model = D('rank_user'); if ($is_Edit) { $data = $model->create($data); $data['create_time'] = time(); $result = $model->where('id=' . $id)->save($data); if (!$result) { $this->error('关联失败'); } } else { $rank_user = $model->where(array('uid' => $uid, 'rank_id' => $rank_id))->find(); if ($rank_user) { $this->error('该用户已经拥有该头衔,请选着其他头衔'); } $data = $model->create($data); $data['create_time'] = time(); $result = $model->add($data); if (!$result) { $this->error('关联失败'); } else { $rank = D('rank')->where('id=' . $data['rank_id'])->find(); //$logoUrl=getRootUrl().D('picture')->where('id='.$rank['logo'])->getField('path'); //$u_name = D('member')->where('uid=' . $uid)->getField('nickname'); $content = '管理员给你颁发了头衔:[' . $rank['title'] . ']'; //<img src="'.$logoUrl.'" title="'.$rank['title'].'" alt="'.$rank['title'].'">'; $user = query_user(array('username', 'space_link'), $uid); $content1 = '管理员给@' . $user['username'] . ' 颁发了新的头衔:[' . $rank['title'] . '],颁发理由:' . $reason; //<img src="'.$logoUrl.'" title="'.$rank['title'].'" alt="'.$rank['title'].'">'; clean_query_user_cache($uid, array('rank_link')); $this->sendMessage($data, $content); //写入数据库 $model = D('Weibo/Weibo'); $result = $model->addWeibo(is_login(), $content1); } } $this->success($is_Edit ? '编辑关联成功' : '添加关联成功', U('Rank/userRankList?id=' . $uid)); } else { if (!$id) { $this->error('请选择要修改的头衔关联'); } $data = D('rank_user')->where('id=' . $id)->find(); if (!$data) { $this->error('该头衔关联不存在'); } $ranks = D('rank')->select(); if (!$ranks) { $this->error('还没有头衔,请先添加头衔'); } foreach ($ranks as $val) { $rank_ids[$val['id']] = $val['title']; } $builder = new AdminConfigBuilder(); $builder->title('编辑头衔关联')->keyId()->keyReadOnly('uid', '用户ID')->keyText('reason', '关联理由')->keyRadio('is_show', '是否显示在昵称右侧', null, array(1 => '是', 0 => '否'))->keySelect('rank_id', '头衔编号', null, $rank_ids)->data($data)->buttonSubmit(U('userChangeRank'))->buttonBack()->display(); } }
public function setVerifyStatus($ids, $status) { $model_user = D('rankUser'); $model = D('rank'); if ($status == 1) { foreach ($ids as $val) { $rank_user = $model_user->where(array('id' => $val))->field('uid,rank_id,reason')->find(); $rank = $model->where(array('id' => $rank_user['rank_id']))->find(); $content = '管理员通过了你的头衔申请:[' . $rank['title'] . ']'; $user = query_user(array('username', 'space_link'), $rank_user['uid']); $content1 = '管理员通过了@' . $user['username'] . ' 的头衔申请:[' . $rank['title'] . '],申请理由:' . $rank_user['reason']; clean_query_user_cache($rank_user['uid'], array('rank_link')); $this->sendMessage($rank_user, $content, '头衔申请审核通过'); } } else { if ($status = -1) { foreach ($ids as $val) { $rank_user = $model_user->where(array('id' => $val))->field('uid,rank_id')->find(); $rank = $model->where(array('id' => $rank_user['rank_id']))->find(); $content = '管理员驳回了你的头衔申请:[' . $rank['title'] . ']'; $this->sendMessage($rank_user, $content, '头衔申请审核不通过'); } } } $builder = new AdminListBuilder(); $builder->doSetStatus('rankUser', $ids, $status); }
public function unbindMobile($verify) { $uid = $this->getUid(); clean_query_user_cache($uid, 'mobile'); $this->requireLogin(); //确认用户已经绑定手机 $model = D('User/UcenterMember'); $user = $model->where(array('id' => $this->getUid()))->find(); if (!$user['mobile']) { $this->apiError(1901, "您尚未绑定手机"); } //确认被验证的手机号码与用户绑定的手机号相符 $mobile = getMobileFromSession(); if ($mobile != $user['mobile']) { $this->apiError(1902, "验证的手机与绑定的手机不符合"); } //确认验证码正确 $addon = new TianyiAddon(); if (!$addon->checkVerify($mobile, $verify)) { $this->apiError(1903, "手机验证码错误"); } //写入数据库 $model->where(array('uid' => $uid))->save(array('mobile' => '')); //返回成功结果 $this->apiSuccess("解绑成功"); }
public function update() { //$Api = new UserApi(); $model = D('Member'); $uid = I('post.uid'); $username = I('post.username'); $email = I('post.email'); $nickname = I('post.nickname'); $mroleId = I('post.mroleId', 0); $roleId = I('post.roleId', 0); $score = I('post.score', 0); $data = array('nickname' => $nickname, 'username' => $username, 'email' => $email, 'uid' => $uid, 'score' => $score, 'id' => $uid); if ($roleId == 0) { M('role_user')->delete($uid); } if ($mroleId == 0) { M('mrole_user')->delete($uid); } $res = callApi('Public/updateUser', array($uid, $data)); if (!$res['success']) { $this->mtReturn(300, $res['message']); } else { $this->after_update($uid, $roleId, $mroleId); clean_query_user_cache($uid, array('nickname', 'email', 'username')); $this->mtReturn(200, '编辑成功'); } /* if (false === $data1= $model->create()) { $this->mtReturn(300, $model->getError()); } if(false !== D('Member')->save($data1)){ $data=array( 'id'=>$uid, 'username'=>$username, 'email'=>$email ); $res = $Api->updateInfo($uid, 'admin', $data); if ($res['status']) { $this->_after_update($uid); clean_query_user_cache($uid,array('nickname','email','username')); $this->mtReturn(200,'编辑成功'); } else { $this->mtReturn(300,$res['info']); } }else{ $this->mtReturn(300,'编辑失败'); }*/ }
public function addFollow($who_follow, $follow_who, $invite = 0) { $follow['who_follow'] = $who_follow; $follow['follow_who'] = $follow_who; if ($follow['who_follow'] == $follow['follow_who']) { //禁止关注和被关注都为同一个人的情况。 return 0; } if ($this->where($follow)->count() > 0) { return 0; } $follow = $this->create($follow); clean_query_user_cache($follow_who, 'fans'); clean_query_user_cache($who_follow, 'following'); S('atUsersJson_' . $who_follow, null); /** * @param $to_uid 接受消息的用户ID * @param string $content 内容 * @param string $title 标题,默认为 您有新的消息 * @param $url 链接地址,不提供则默认进入消息中心 * @param $int $from_uid 发起消息的用户,根据用户自动确定左侧图标,如果为用户,则左侧显示头像 * @param int $type 消息类型,0系统,1用户,2应用 */ $user = query_user(array('id', 'nickname', 'space_url'), $who_follow); if ($invite) { if ($who_follow < $follow_who) { $content = '邀请者 ' . $user['nickname'] . ' 关注了你。'; } else { $content = '你邀请的用户 ' . $user['nickname'] . ' 关注了你。'; } } else { if ($who_follow < $follow_who) { $content = '系统推荐用户 ' . $user['nickname'] . ' 关注了你。'; } else { $content = '新入住用户 ' . $user['nickname'] . ' 关注了你。'; } } M('Message')->sendMessage($follow_who, '粉丝数增加', $content, 'Ucenter/Index/index', array('uid' => $who_follow), $who_follow); return $this->add($follow); }
public function artadd() { if (IS_POST) { $input = new \OT\Input(); $input->noGPC(); $uid = $_SESSION['cs_home']['user_auth']['uid']; if (!$uid > 0) { $this->error('请先登录'); } if (false === ($data = D('Article')->create())) { $this->error(D('Article')->getError()); } if ($data['cid'] == null) { $this->error('分类为空'); } $data['description'] = op_h(I('description')); if (mb_strlen(op_h($data['description']), 'utf-8') < 30) { $this->error('文章内容必须大于30字'); } if (mb_strlen($data['title'], 'utf-8') > 80) { $this->error('文章标题必须小于80字'); } foreach ($data['tag'] as $key => $vo) { $data['tag'][$key] = mb_substr($vo, 0, 15, 'utf-8'); } D('Tags')->InsertTags($data['tag'], 1); $data['tag'] = implode(',', $data['tag']); //$this->apiError(0,$data['description']); //$data['description']=$data['description']; $data['title'] = op_t($data['title']); $data['uid'] = $uid; $status = $data['status']; $data['copyright'] = str_replace('{title}', $data['title'], $data['copyright']); $data['copyright'] = str_replace('{url}', $_SERVER["HTTP_HOST"], $data['copyright']); $data['copyright'] = str_replace('{name}', C('WEB_SITE'), $data['copyright']); //保存当前数据对象 $list = D('Article')->add($data); if ($list !== false) { if ($status == 1) { setuserscore($uid, C('ARTSCORE')); } clean_query_user_cache($uid, array('artnum')); $this->success('添加文章成功!', U('Ucenter/userart')); } else { $this->error('添加文章失败!'); } } else { $uid = is_login(); //判断如果是后台管理员则不受限制 if (is_admin($uid) == false) { $roleauth = getmroleauth($uid); // $setting['exts'] =$roleauth['fileext']; $extsarr = explode(',', $roleauth['fileext']); if (!empty($extsarr)) { $extstr = ''; foreach ($extsarr as $key1 => $vo1) { $extstr .= '*.' . $vo1 . ';'; } $this->assign('extstr', $extstr); } if ($roleauth['yesart'] != 1) { $this->error('你无权投稿!'); } } $this->display(); } }
/** * saveAvatar 保存头像 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function saveAvatar() { $aCrop = I('post.crop', '', 'op_t'); $aUid = session('temp_login_uid') ? session('temp_login_uid') : is_login(); $aExt = I('post.ext', '', 'op_t'); if (empty($aCrop)) { $this->success('保存成功!', session('temp_login_uid') ? U('Ucenter/member/step', array('step' => get_next_step('change_avatar'))) : 'refresh'); } $dir = './Uploads/Avatar/' . $aUid; $dh = opendir($dir); while ($file = readdir($dh)) { if ($file != "." && $file != ".." && $file != 'original.' . $aExt) { $fullpath = $dir . "/" . $file; if (!is_dir($fullpath)) { unlink($fullpath); } else { deldir($fullpath); } } } closedir($dh); A('Ucenter/UploadAvatar', 'Widget')->cropPicture($aUid, $aCrop, $aExt); $res = M('avatar')->where(array('uid' => $aUid))->save(array('uid' => $aUid, 'status' => 1, 'is_temp' => 0, 'path' => "/" . $aUid . "/crop." . $aExt, 'create_time' => time())); if (!$res) { M('avatar')->add(array('uid' => $aUid, 'status' => 1, 'is_temp' => 0, 'path' => "/" . $aUid . "/crop." . $aExt, 'create_time' => time())); } clean_query_user_cache($aUid, array('avatar256', 'avatar128', 'avatar64')); $this->success('头像更新成功!', session('temp_login_uid') ? U('Ucenter/member/step', array('step' => get_next_step('change_avatar'))) : 'refresh'); }
public function avatar() { if (IS_POST) { $return = array('status' => 1, 'info' => '上传成功', 'data' => ''); $Avatar = D('Avatar'); $pic_driver = C('PICTURE_UPLOAD_DRIVER'); $info = $Avatar->upload($_FILES, C('AVATAR_PICTURE_UPLOAD'), C('PICTURE_UPLOAD_DRIVER'), C("UPLOAD_{$pic_driver}_CONFIG")); if (isset($info)) { $return['status'] = 1; $return['url'] = U('/index'); $return = array_merge($info['Filedata'], $return); } else { $return['status'] = 0; $return['info'] = $Avatar->getError(); } clean_query_user_cache(get_uid(), 'avatar'); $this->ajaxReturn($return); } else { if (!is_login()) { redirect(U('/index')); } $this->display(); } }
/** * 持有新身份 * @author 郑钟良<*****@*****.**> */ public function registerRole() { $aRoleId = I('post.role_id', 0, 'intval'); $uid = is_login(); $data['status'] = 0; if ($uid > 0 && $aRoleId != get_login_role()) { $roleUser = M('UserRole')->where(array('uid' => $uid, 'role_id' => $aRoleId))->find(); if ($roleUser) { $data['info'] = L('_INFO_INV_ROLE_POSSESS_'); $this->ajaxReturn($data); } else { $memberModel = M('Common/Member'); $memberModel->logout(); UCenterMember()->initRoleUser($aRoleId, $uid); clean_query_user_cache($uid, array('avatar64', 'avatar128', 'avatar32', 'avatar256', 'avatar512', 'rank_link')); $memberModel->login($uid, false, $aRoleId); //登陆 } } else { $data['info'] = L('_ERROR_ILLEGAL_OPERATE_'); $this->ajaxReturn($data); } }
public function doCheckIn() { $time = get_some_day(0); $uid = is_login(); $model = $this->checkInModel(); $memberModel = M('Member'); $check = $model->getCheck($uid); if (!$check) { $model->addCheck($uid); $memberModel->where(array('uid' => $uid))->setInc('total_check'); $model->checkYesterday($uid); clean_query_user_cache($uid, array('con_check', 'total_check')); S('check_rank_today_' . $time, null); S('check_rank_con_' . $time, null); S('check_rank_total_' . $time, null); return true; } else { return false; } }
public function setVerifyStatus($ids, $status) { $model_user = M('rankUser'); $model = M('rank'); if ($status == 1) { foreach ($ids as $val) { $rank_user = $model_user->where('id=' . $val)->field('uid,rank_id,reason')->find(); $rank = $model->where('id=' . $rank_user['rank_id'])->find(); $content = l('_RECEPTION_TITLE_PASSED_BY_ADMIN_') . L('_COLON_') . '[' . $rank['title'] . ']'; $user = query_user(array('nickname', 'space_link'), $rank_user['uid']); $content1 = L('_RECEPTION_PASSED_BY_ADMIN_PARAM_', array('nickname' => $user['nickname'], 'title' => $rank['title'])) . $rank_user['reason']; clean_query_user_cache($rank_user['uid'], array('rank_link')); $this->sendMessage($rank_user, $content, L('_TITLE_APPLICATION_FOR_APPROVAL_')); if (M('Common/Module')->isInstalled('Weibo')) { //安装了轻博客模块 //发轻博客 $model_weibo = M('Weibo/Weibo'); $result = $model_weibo->addWeibo(is_login(), $content1); } } } else { if ($status = -1) { foreach ($ids as $val) { $rank_user = $model_user->where('id=' . $val)->field('uid,rank_id')->find(); $rank = $model->where('id=' . $rank_user['rank_id'])->find(); $content = L('_ASK_REFUSED_BY_ADMIN_') . L('_COLON_') . '[' . $rank['title'] . ']'; $this->sendMessage($rank_user, $content, L('_THE_TITLE_OF_THE_APPLICATION_FOR_APPROVAL_IS_NOT_PASSED_')); } } } $builder = new AdminListBuilder(); $builder->doSetStatus('rankUser', $ids, $status); }
public function setVerifyStatus($ids, $status) { $model_user = D('rankUser'); $model = D('rank'); if ($status == 1) { foreach ($ids as $val) { $rank_user = $model_user->where('id=' . $val)->field('uid,rank_id,reason')->find(); $rank = $model->where('id=' . $rank_user['rank_id'])->find(); $content = '管理员通过了你的头衔申请:[' . $rank['title'] . ']'; $user = query_user(array('username', 'space_link'), $rank_user['uid']); $content1 = '管理员通过了@' . $user['username'] . ' 的头衔申请:[' . $rank['title'] . '],申请理由:' . $rank_user['reason']; clean_query_user_cache($rank_user['uid'], array('rank_link')); $this->sendMessage($rank_user, $content, '头衔申请审核通过'); if (D('Common/Module')->isInstalled('Weibo')) { //安装了微博模块 //发微博 $model_weibo = D('Weibo/Weibo'); $result = $model_weibo->addWeibo(is_login(), $content1); } } } else { if ($status = -1) { foreach ($ids as $val) { $rank_user = $model_user->where('id=' . $val)->field('uid,rank_id')->find(); $rank = $model->where('id=' . $rank_user['rank_id'])->find(); $content = '管理员驳回了你的头衔申请:[' . $rank['title'] . ']'; $this->sendMessage($rank_user, $content, '头衔申请审核不通过'); } } } $builder = new AdminListBuilder(); $builder->doSetStatus('rankUser', $ids, $status); }
public function cancelWithdraw($ids = array()) { if (empty($ids)) { $this->error('请选择要操作的选项'); } $withdrawModel = D('Recharge/Withdraw'); foreach ($ids as $id) { $withdraw = $withdrawModel->getWithdraw($id); if (empty($withdraw) || $id <= 0) { continue; } if ($withdraw['payok'] != 0) { continue; } //取消订单 $rs = $withdrawModel->where(array('id' => $withdraw['id']))->setField('payok', -1); S('withdraw_order_' . $withdraw['id'], null); //返还现金 D('Member')->where(array('uid' => $withdraw['uid']))->setInc('score' . $withdraw['field'], $withdraw['frozen_amount']); clean_query_user_cache($withdraw['uid'], 'score' . $withdraw['field']); if (!$rs) { $withdrawModel->where(array('id' => $withdraw['id']))->setField('payok', 2); //待返还状态 continue; } D("Common/Message")->sendMessageWithoutCheckSelf($withdraw['uid'], '您的提现已被关闭,冻结' . $withdraw['score_type']['title'] . $withdraw['frozen_amount'] . $withdraw['score_type']['unit'] . '已返还到您的账户。', '【充值中心】提现关闭通知', U('recharge/index/withdrawList'), is_login()); } $this->success('关闭订单成功。'); }
/** * 持有新身份 * @author 郑钟良<*****@*****.**> */ public function registerRole() { $aRoleId = I('post.role_id', 0, 'intval'); $uid = is_login(); $data['status'] = 0; if ($uid > 0 && $aRoleId != get_login_role()) { $roleUser = D('UserRole')->where(array('uid' => $uid, 'role_id' => $aRoleId))->find(); if ($roleUser) { $data['info'] = "已持有该身份!"; $this->ajaxReturn($data); } else { $memberModel = D('Common/Member'); $memberModel->logout(); $this->initRoleUser($aRoleId, $uid); clean_query_user_cache($uid, array('avatar64', 'avatar128', 'avatar32', 'avatar256', 'avatar512', 'rank_link')); $memberModel->login($uid, false, $aRoleId); //登陆 } } else { $data['info'] = "非法操作!"; $this->ajaxReturn($data); } }
public function addFollow($who_follow, $follow_who, $invite = 0) { $follow['who_follow'] = $who_follow; $follow['follow_who'] = $follow_who; if ($follow['who_follow'] == $follow['follow_who']) { //禁止关注和被关注都为同一个人的情况。 return 0; } if ($this->where($follow)->count() > 0) { return 0; } $follow = $this->create($follow); clean_query_user_cache($follow_who, 'fans'); clean_query_user_cache($who_follow, 'following'); S('atUsersJson_' . $who_follow, null); /** * @param $to_uid 接受消息的用户ID * @param string $content 内容 * @param string $title 标题,默认为 您有新的消息 * @param $url 链接地址,不提供则默认进入消息中心 * @param $int $from_uid 发起消息的用户,根据用户自动确定左侧图标,如果为用户,则左侧显示头像 * @param int $type 消息类型,0系统,1用户,2应用 */ $user = query_user(array('id', 'nickname', 'space_url'), $who_follow); if ($invite) { if ($who_follow < $follow_who) { $content = L('_INVITED_') . $user['nickname'] . L('_CONCERN_YOU_WITH_PERIOD_'); } else { $content = L('_YOURE_INVITING_THE_USER_') . $user['nickname'] . L('_CONCERN_YOU_WITH_PERIOD_'); } } else { if ($who_follow < $follow_who) { $content = L('_SYSTEM_RECOMMENDED_USERS_') . $user['nickname'] . L('_CONCERN_YOU_WITH_PERIOD_'); } else { $content = L('_NEW_USER_') . $user['nickname'] . L('_CONCERN_YOU_WITH_PERIOD_'); } } D('Message')->sendMessage($follow_who, L('_FANS_NUMBER_INCREASED_'), $content, 'Ucenter/Index/index', array('uid' => $who_follow), $who_follow); return $this->add($follow); }
public function sendWeibo($content, $type = 'feed', $feed_data = '') { $this->requireSendInterval(); $this->requireLogin(); //写入数据库 $weibo_id = $this->weiboModel->addWeibo(get_uid(), $content, $type, $feed_data); if (!$weibo_id) { throw new ApiException('发布失败:' . $this->weiboModel->getError()); } //发送成功,记录动作,更新最后发送时间 $tox_money_before = getMyToxMoney(); $score_increase = action_log_and_get_score('add_weibo', 'Weibo', $weibo_id, is_login()); $tox_money_after = getMyToxMoney(); $this->updateLastSendTime(); //给被AT到的人都发送一条消息 $uids = get_at_uids($content); $this->sendAtMessage($uids, $weibo_id, $content); clean_query_user_cache(is_login(), array('weibocount')); //显示成功页面 $message = '发表微博成功。' . getScoreTip(0, $score_increase) . getToxMoneyTip($tox_money_before, $tox_money_after); return $this->apiSuccess($message, array('score_increase' => $score_increase, 'weibo_id' => $weibo_id)); }
/** * setUserScore 设置用户的积分 * @param $uids * @param $score * @param $type * @param string $action * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function setUserScore($uids, $score, $type, $action = 'inc') { $model = D('Member'); switch ($action) { case 'inc': $score = abs($score); $res = $model->where(array('uid' => array('in', $uids)))->setInc('score' . $type, $score); break; case 'dec': $score = abs($score); $res = $model->where(array('uid' => array('in', $uids)))->setDec('score' . $type, $score); break; case 'to': $res = $model->where(array('uid' => array('in', $uids)))->setField('score' . $type, $score); break; default: $res = false; break; } foreach ($uids as $val) { clean_query_user_cache($val, 'score' . $type); } unset($val); return $res; }
/** * 修改密码 * @param $old_password * @param $new_password * @return bool * @auth 陈一枭 */ public function changePassword($old_password, $new_password) { //检查旧密码是否正确 if (!$this->verifyUser(get_uid(), $old_password)) { $this->error = -41; return false; } //更新用户信息 $model = $this; $data = array('password' => $new_password); $data = $model->create($data); if (!$data) { $this->error = $model->getError(); return false; } $model->where(array('id' => get_uid()))->save($data); //返回成功信息 clean_query_user_cache(get_uid(), 'password'); //删除缓存 D('user_token')->where(array('uid' => get_uid()))->delete(); return true; }
public function edit_expandinfo($profile_group_id) { $field_list = $this->getRoleFieldIds(); if ($field_list) { $map_field['id'] = array('in', $field_list); } else { $this->error(L('_ERROR_INFO_SAVE_NONE_') . L('_EXCLAMATION_')); } $map_field['profile_group_id'] = $profile_group_id; $map_field['status'] = 1; $field_setting_list = M('field_setting')->where($map_field)->order('sort asc')->select(); if (!$field_setting_list) { $this->error(L('_ERROR_INFO_CHANGE_NONE_') . L('_EXCLAMATION_')); } $data = null; foreach ($field_setting_list as $key => $val) { $data[$key]['uid'] = is_login(); $data[$key]['field_id'] = $val['id']; switch ($val['form_type']) { case 'input': $val['value'] = op_t($_POST['expand_' . $val['id']]); if (!$val['value'] || $val['value'] == '') { if ($val['required'] == 1) { $this->error($val['field_name'] . L('_ERROR_CONTENT_NONE_') . L('_EXCLAMATION_')); } } else { $val['submit'] = $this->_checkInput($val); if ($val['submit'] != null && $val['submit']['succ'] == 0) { $this->error($val['submit']['msg']); } } $data[$key]['field_data'] = $val['value']; break; case 'radio': $val['value'] = op_t($_POST['expand_' . $val['id']]); $data[$key]['field_data'] = $val['value']; break; case 'checkbox': $val['value'] = $_POST['expand_' . $val['id']]; if (!is_array($val['value']) && $val['required'] == 1) { $this->error(L('_ERROR_AT_LIST_ONE_') . L('_COLON_') . $val['field_name']); } $data[$key]['field_data'] = is_array($val['value']) ? implode('|', $val['value']) : ''; break; case 'select': $val['value'] = op_t($_POST['expand_' . $val['id']]); $data[$key]['field_data'] = $val['value']; break; case 'time': $val['value'] = op_t($_POST['expand_' . $val['id']]); $val['value'] = strtotime($val['value']); $data[$key]['field_data'] = $val['value']; break; case 'textarea': $val['value'] = op_t($_POST['expand_' . $val['id']]); if (!$val['value'] || $val['value'] == '') { if ($val['required'] == 1) { $this->error($val['field_name'] . L('_ERROR_CONTENT_NONE_') . L('_EXCLAMATION_')); } } else { $val['submit'] = $this->_checkInput($val); if ($val['submit'] != null && $val['submit']['succ'] == 0) { $this->error($val['submit']['msg']); } } $val['submit'] = $this->_checkInput($val); if ($val['submit'] != null && $val['submit']['succ'] == 0) { $this->error($val['submit']['msg']); } $data[$key]['field_data'] = $val['value']; break; } } $map['uid'] = is_login(); $map['role_id'] = get_login_role(); $is_success = false; foreach ($data as $dl) { $dl['role_id'] = $map['role_id']; $map['field_id'] = $dl['field_id']; $res = M('field')->where($map)->find(); if (!$res) { if ($dl['field_data'] != '' && $dl['field_data'] != null) { $dl['createTime'] = $dl['changeTime'] = time(); if (!M('field')->add($dl)) { $this->error(L('_ERROR_INFO_ADD_') . L('_EXCLAMATION_')); } $is_success = true; } } else { $dl['changeTime'] = time(); if (!M('field')->where('id=' . $res['id'])->save($dl)) { $this->error(L('_ERROR_INFO_CHANGE_') . L('_EXCLAMATION_')); } $is_success = true; } unset($map['field_id']); } clean_query_user_cache(is_login(), 'expand_info'); if ($is_success) { $this->success(L('_SUCCESS_SAVE_') . L('_EXCLAMATION_')); } else { $this->error(L('_ERROR_SAVE_') . L('_EXCLAMATION_')); } }
public function edit_expandinfo($profile_group_id) { $field_list = $this->getRoleFieldIds(); if ($field_list) { $map_field['id'] = array('in', $field_list); } else { $this->error('没有要保存的信息!'); } $map_field['profile_group_id'] = $profile_group_id; $map_field['status'] = 1; $field_setting_list = D('field_setting')->where($map_field)->order('sort asc')->select(); if (!$field_setting_list) { $this->error('没有要修改的信息!'); } $data = null; foreach ($field_setting_list as $key => $val) { $data[$key]['uid'] = is_login(); $data[$key]['field_id'] = $val['id']; switch ($val['form_type']) { case 'input': $val['value'] = op_t($_POST['expand_' . $val['id']]); if (!$val['value'] || $val['value'] == '') { if ($val['required'] == 1) { $this->error($val['field_name'] . '内容不能为空!'); } } else { $val['submit'] = $this->_checkInput($val); if ($val['submit'] != null && $val['submit']['succ'] == 0) { $this->error($val['submit']['msg']); } } $data[$key]['field_data'] = $val['value']; break; case 'radio': $val['value'] = op_t($_POST['expand_' . $val['id']]); $data[$key]['field_data'] = $val['value']; break; case 'checkbox': $val['value'] = $_POST['expand_' . $val['id']]; if (!is_array($val['value']) && $val['required'] == 1) { $this->error('请至少选择一个:' . $val['field_name']); } $data[$key]['field_data'] = is_array($val['value']) ? implode('|', $val['value']) : ''; break; case 'select': $val['value'] = op_t($_POST['expand_' . $val['id']]); $data[$key]['field_data'] = $val['value']; break; case 'time': $val['value'] = op_t($_POST['expand_' . $val['id']]); $val['value'] = strtotime($val['value']); $data[$key]['field_data'] = $val['value']; break; case 'textarea': $val['value'] = op_t($_POST['expand_' . $val['id']]); if (!$val['value'] || $val['value'] == '') { if ($val['required'] == 1) { $this->error($val['field_name'] . '内容不能为空!'); } } else { $val['submit'] = $this->_checkInput($val); if ($val['submit'] != null && $val['submit']['succ'] == 0) { $this->error($val['submit']['msg']); } } $val['submit'] = $this->_checkInput($val); if ($val['submit'] != null && $val['submit']['succ'] == 0) { $this->error($val['submit']['msg']); } $data[$key]['field_data'] = $val['value']; break; } } $map['uid'] = is_login(); $map['role_id'] = get_login_role(); $is_success = false; foreach ($data as $dl) { $dl['role_id'] = $map['role_id']; $map['field_id'] = $dl['field_id']; $res = D('field')->where($map)->find(); if (!$res) { if ($dl['field_data'] != '' && $dl['field_data'] != null) { $dl['createTime'] = $dl['changeTime'] = time(); if (!D('field')->add($dl)) { $this->error('信息添加时出错!'); } $is_success = true; } } else { $dl['changeTime'] = time(); if (!D('field')->where('id=' . $res['id'])->save($dl)) { $this->error('信息修改时出错!'); } $is_success = true; } unset($map['field_id']); } clean_query_user_cache(is_login(), 'expand_info'); if ($is_success) { $this->success('保存成功!'); } else { $this->error('没有要保存的信息!'); } }
/** * changeEmail 更改邮箱 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function changeEmail() { $aEmail = I('post.email', '', 'op_t'); $aUid = session('temp_login_uid'); $ucenterMemberModel = Member(); $status = $ucenterMemberModel->where(array('uid' => $aUid))->getField('status'); if ($status != 3) { $this->error('权限不足!'); } $ucenterMemberModel->where(array('uid' => $aUid))->setField('email', $aEmail); clean_query_user_cache($aUid, 'email'); $res = $this->activateVerify(); $this->success('更换成功,请登录邮箱进行激活!如没收到激活信请稍候再试!', 'refresh'); }