当前位置: 首页>>代码示例>>PHP>>正文


PHP sp_get_current_userid函数代码示例

本文整理汇总了PHP中sp_get_current_userid函数的典型用法代码示例。如果您正苦于以下问题:PHP sp_get_current_userid函数的具体用法?PHP sp_get_current_userid怎么用?PHP sp_get_current_userid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sp_get_current_userid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $userid = sp_get_current_userid();
     $user = $this->users_model->where(array("id" => $userid))->find();
     $this->assign($user);
     $this->display(':center');
 }
开发者ID:huangkaijin,项目名称:simei,代码行数:7,代码来源:CenterController.class.php

示例2: _initialize

 function _initialize()
 {
     parent::_initialize();
     $this->order_model = D("Server/Order");
     $this->uid = sp_get_current_userid();
     $this->serversell_model = D("Server/ServersSell");
 }
开发者ID:crab890715,项目名称:GoOut-Panel,代码行数:7,代码来源:OrderController.class.php

示例3: _bang_handle

 private function _bang_handle($user_info, $type, $token)
 {
     $current_uid = sp_get_current_userid();
     $oauth_user_model = M('OauthUser');
     $type = strtolower($type);
     $find_oauth_user = $oauth_user_model->where(array("from" => $type, "openid" => $token['openid']))->find();
     $need_bang = true;
     if ($find_oauth_user) {
         if ($find_oauth_user['uid'] == $current_uid) {
             $this->error("您之前已经绑定过此账号!", U('user/profile/bang'));
             exit;
         } else {
             $this->error("该帐号已被本站其他账号绑定!", U('user/profile/bang'));
             exit;
         }
     }
     if ($need_bang) {
         if ($current_uid) {
             //第三方用户表中创建数据
             $new_oauth_user_data = array('from' => $type, 'name' => $user_info['name'], 'head_img' => $user_info['head'], 'create_time' => date("Y-m-d H:i:s"), 'uid' => $current_uid, 'last_login_time' => date("Y-m-d H:i:s"), 'last_login_ip' => get_client_ip(), 'login_times' => 1, 'status' => 1, 'access_token' => $token['access_token'], 'expires_date' => (int) (time() + $token['expires_in']), 'openid' => $token['openid']);
             $new_oauth_user_id = $oauth_user_model->add($new_oauth_user_data);
             if ($new_oauth_user_id) {
                 $this->success("绑定成功!", U('user/profile/bang'));
             } else {
                 $users_model->where(array("id" => $new_user_id))->delete();
                 $this->error("绑定失败!", U('user/profile/bang'));
             }
         } else {
             $this->error("绑定失败!", U('user/profile/bang'));
         }
     }
 }
开发者ID:elinxer,项目名称:hualilibrary,代码行数:32,代码来源:OauthController.class.php

示例4: _initialize

 function _initialize()
 {
     $adminid = sp_get_current_admin_id();
     $userid = sp_get_current_userid();
     if (empty($adminid) && empty($userid)) {
         exit("非法上传!");
     }
 }
开发者ID:noikiy,项目名称:cmfx,代码行数:8,代码来源:AssetController.class.php

示例5: check_user

 /**
  * 检查用户状态
  */
 protected function check_user()
 {
     $user_status = M('Users')->where(array("id" => sp_get_current_userid()))->getField("user_status");
     if ($user_status == 2) {
         $this->error('您还没有激活账号,请激活后再使用!', U("user/login/active"));
     }
     if ($user_status == 0) {
         $this->error('此账号已经被禁止使用,请联系管理员!', __ROOT__ . "/");
     }
 }
开发者ID:feng8605765,项目名称:xmmusic,代码行数:13,代码来源:HomebaseController.class.php

示例6: index

 public function index()
 {
     $id = sp_get_current_userid();
     $users_model = D("Common/Users");
     $user = $users_model->where(array("id" => $id))->find();
     if (empty($user)) {
         $this->error("查无此人!");
     }
     $this->assign($user);
     $this->display(':user_account');
 }
开发者ID:noikiy,项目名称:luokeke2,代码行数:11,代码来源:IndexController.class.php

示例7: index

 function index()
 {
     $uid = sp_get_current_userid();
     $where = array("uid" => $uid);
     $count = $this->comments_model->where($where)->count();
     $page = $this->page($count, 20);
     $page->setLinkWraper("li");
     $comments = $this->comments_model->where($where)->order("createtime desc")->limit($page->firstRow . ',' . $page->listRows)->select();
     $this->assign("pager", $page->show("default"));
     $this->assign("comments", $comments);
     $this->display(":index");
 }
开发者ID:elinxer,项目名称:hualilibrary,代码行数:12,代码来源:CommentController.class.php

示例8: delete_favorite

 function delete_favorite()
 {
     $id = I("get.id", 0, "intval");
     $uid = sp_get_current_userid();
     $post['uid'] = $uid;
     $user_favorites_model = M("UserFavorites");
     $result = $user_favorites_model->where(array('id' => $id, 'uid' => $uid))->delete();
     if ($result) {
         $this->success("取消收藏成功!");
     } else {
         $this->error("取消收藏失败!");
     }
 }
开发者ID:elinxer,项目名称:hualilibrary,代码行数:13,代码来源:FavoriteController.class.php

示例9: __construct

 function __construct()
 {
     parent::__construct();
     $this->userid = sp_get_current_userid();
     $this->user = $this->users_model->where(array("id" => $this->userid))->find();
     $this->sign_num = $this->exchange->where(array("uid" => $this->userid, "memo" => "网站签到"))->count();
     $this->assign('signNum', $this->sign_num);
     $this->sign_point = D('Config')->val("pc_sign");
     $this->share_point = D('Config')->val('pc_share');
     $this->assign('user', $this->user);
     $this->assign("servePromise", $this->_getAd("servePromise"));
     $this->assign("home_head", $this->_getAd("banner_user"));
 }
开发者ID:noikiy,项目名称:luokeke2,代码行数:13,代码来源:CenterController.class.php

示例10: do_like

 public function do_like()
 {
     $this->check_login();
     $object_id = $_GET['id'];
     //content表中id
     $can_like = sp_check_user_action($object_id, 1);
     //这个函数是会有副作用的,不只是简单的check。如果没有结果会写数据库,坑。
     if ($can_like) {
         D('content')->saveByUUID($object_id, array("post_like" => array("exp", "post_like+1")));
         D('like')->data(['user_id' => sp_get_current_userid(), 'object_id' => $object_id])->add();
         $this->success("赞好啦!");
     } else {
         $this->error("您已赞过啦!");
     }
 }
开发者ID:Njupt-Sast-Network,项目名称:UMR,代码行数:15,代码来源:ArticleController.class.php

示例11: order

 function order()
 {
     /***
      * 1.判断服务器,是否存在。
      * 2.判断用户是否登录。
      * 3.判断购买的服务与价格是否存在
      * 4.下单,再去支付页面
      */
     $serverid = intval(I("post.server_id"));
     if ($serverid) {
         $rst = $this->servers_model->where(array("id" => $serverid, "status" => 1, "isdel" => 0))->find();
         if (!$rst) {
             $this->error("暂未发现该服务器", U("/"));
         }
     } else {
         $this->error('数据传入失败!', U("/"));
     }
     if (!sp_is_user_login()) {
         $_SESSION['login_http_referer'] = U("Server/Index/index", array("id" => $serverid));
         $this->error('请先登录!', U("user/login/index"));
     }
     if (isset($_POST["timechange"])) {
         $timeMode = $_POST["timechange"];
         $sell_re = $this->serversell_model->where(array("id" => $timeMode))->find();
         if (!$sell_re || $sell_re['server_id'] != $serverid) {
             $this->error("暂未发现该服务器的价格", U("Server/index/index", 'id=' . $serverid));
         }
         ////处理下单业务
         $OrderModel = array("order_id" => $this->order_model->CreateOrderId(), "server_id" => $serverid, "user_id" => sp_get_current_userid(), "month" => $timeMode, "price" => $sell_re['price'], "status" => 1, "create_time" => date("Y-m-d H:i:s"));
         $result = $this->order_model->add($OrderModel);
         if ($result !== false) {
             $this->success("下单成功,即将跳转到支付页面!", U("Server/Index/pay", array("id" => $result)));
         } else {
             $this->error('数据传入失败!', U("/"));
         }
     } else {
         $this->error('数据传入失败!', U("/"));
     }
 }
开发者ID:kozora,项目名称:GoOut-Panel,代码行数:39,代码来源:IndexController.class.php

示例12: savePortrait

 public function savePortrait()
 {
     if (!($userid = sp_get_current_userid())) {
         $this->error("非法操作,封你IP");
     }
     header('Content-Type: text/html; charset=utf-8');
     $result = array();
     $result['success'] = false;
     $success_num = 0;
     $msg = '';
     //上传目录
     $dir = $_SERVER['DOCUMENT_ROOT'] . "/data/upload/avatar";
     //删除之前上传的图片
     $member = M('Member')->where(array('id' => $userid))->find();
     if ($member['avatar_origin']) {
         $old_avatar_origin = explode('?', $member['avatar_origin']);
         unlink($_SERVER['DOCUMENT_ROOT'] . $old_avatar_origin[0]);
         unlink($_SERVER['DOCUMENT_ROOT'] . $member['avatar']);
         unlink($_SERVER['DOCUMENT_ROOT'] . $member['avatar_small']);
         unlink($_SERVER['DOCUMENT_ROOT'] . $member['avatar_large']);
     }
     // 取服务器时间+8位随机码作为部分文件名,确保文件名无重复。
     $filename = date("YmdHis") . '_' . floor(microtime() * 1000) . '_' . $this->createRandomCode(8);
     // 处理原始图片开始------------------------------------------------------------------------>
     //默认的 file 域名称是__source,可在插件配置参数中自定义。参数名:src_field_name
     $source_pic = $_FILES["__source"];
     //如果在插件中定义可以上传原始图片的话,可在此处理,否则可以忽略。
     if ($source_pic) {
         if ($source_pic['error'] > 0) {
             $msg .= $source_pic['error'];
         } else {
             //原始图片的文件名,如果是本地或网络图片为原始文件名、如果是摄像头拍照则为 *FromWebcam.jpg
             $sourceFileName = $source_pic["name"];
             //原始文件的扩展名(不包含“.”)
             $sourceExtendName = substr($sourceFileName, strripos($sourceFileName, "."));
             //保存路径
             $savePath = "{$dir}" . "/" . $userid . "_origin" . $sourceExtendName;
             //当前头像基于原图的初始化参数(只有上传原图时才会发送该数据,且发送的方式为POST),用于修改头像时保证界面的视图跟保存头像时一致,提升用户体验度。
             //修改头像时设置默认加载的原图url为当前原图url+该参数即可,可直接附加到原图url中储存,不影响图片呈现。
             $init_params = $_POST["__initParams"];
             move_uploaded_file($source_pic["tmp_name"], $savePath);
             $result['sourceUrl'] = $this->toVirtualPath($savePath) . $init_params;
             $success_num++;
         }
     }
     //<------------------------------------------------------------------------处理原始图片结束
     // 处理头像图片开始------------------------------------------------------------------------>
     //头像图片(file 域的名称:__avatar1,2,3...)。
     $avatars = array("__avatar1", "__avatar2", "__avatar3");
     $avatars_length = count($avatars);
     for ($i = 0; $i < $avatars_length; $i++) {
         $avatar = $_FILES[$avatars[$i]];
         $avatar_number = $i + 1;
         if ($avatar['error'] > 0) {
             $msg .= $avatar['error'];
         } else {
             $savePath = "{$dir}" . "/" . $userid . '_' . $avatar_number . "_{$filename}.jpg";
             $result['avatarUrls'][$i] = $this->toVirtualPath($savePath);
             move_uploaded_file($avatar["tmp_name"], $savePath);
             $success_num++;
         }
     }
     $result['msg'] = $msg;
     if ($success_num > 0) {
         $result['success'] = true;
     }
     $data = array('id' => $userid, 'avatar' => $result['avatarUrls'][1], 'avatar_small' => $result['avatarUrls'][0], 'avatar_large' => $result['avatarUrls'][2], 'avatar_origin' => $result['sourceUrl']);
     M('Member')->save($data);
     //返回图片的保存结果(返回内容为json字符串)
     print json_encode($result);
 }
开发者ID:kmlzh1983,项目名称:diamond,代码行数:71,代码来源:ProfileController.class.php

示例13: record_list

 /**
  * 用户消费记录列表
  * WJAZZ 2016-01-22 17:13:07
  * @param
  * @return
  */
 public function record_list()
 {
     if ($_GET['p'] == '') {
         $_GET['p'] = 1;
     }
     $userid = sp_get_current_userid();
     $posts = $this->payrecord_model->field(array('cmf_payrecord.*', 'cmf_charge.project_name'))->join('LEFT JOIN __CHARGE__ ON __PAYRECORD__.typeid = __CHARGE__.id')->where('userid=' . $userid)->page($_GET['p'] . ',10')->order('created_at desc')->select();
     $count = $this->payrecord_model->where('userid=' . $userid)->count();
     //分页页数20
     $Page = new \Think\Page($count, 10);
     $Page->setConfig('prev', '上一页');
     $Page->setConfig('next', '下一页');
     $Page->setConfig('first', '首页');
     $Page->setConfig('end', '末页');
     $show = $Page->show();
     $this->assign('page', $show);
     $this->assign('posts', $posts);
     $this->display(':recordlist');
 }
开发者ID:wjazz3911,项目名称:jcjy,代码行数:25,代码来源:CenterController.class.php

示例14: avatar_update

 function avatar_update()
 {
     if (!empty($_SESSION['avatar'])) {
         $targ_w = intval($_POST['w']);
         $targ_h = intval($_POST['h']);
         $x = $_POST['x'];
         $y = $_POST['y'];
         $jpeg_quality = 90;
         $avatar = $_SESSION['avatar'];
         $avatar_dir = C("UPLOADPATH") . "avatar/";
         if (sp_is_sae()) {
             //TODO 其它存储类型暂不考虑
             $src = C("TMPL_PARSE_STRING.__UPLOAD__") . "avatar/{$avatar}";
         } else {
             $src = $avatar_dir . $avatar;
         }
         $avatar_path = $avatar_dir . $avatar;
         if (sp_is_sae()) {
             //TODO 其它存储类型暂不考虑
             $img_data = sp_file_read($avatar_path);
             $img = new \SaeImage();
             $size = $img->getImageAttr();
             $lx = $x / $size[0];
             $rx = $x / $size[0] + $targ_w / $size[0];
             $ty = $y / $size[1];
             $by = $y / $size[1] + $targ_h / $size[1];
             $img->crop($lx, $rx, $ty, $by);
             $img_content = $img->exec('png');
             sp_file_write($avatar_dir . $avatar, $img_content);
         } else {
             $image = new \Think\Image();
             $image->open($src);
             $image->crop($targ_w, $targ_h, $x, $y);
             $image->save($src);
         }
         $userid = sp_get_current_userid();
         $result = $this->users_model->where(array("id" => $userid))->save(array("avatar" => $avatar));
         $_SESSION['user']['avatar'] = $avatar;
         if ($result) {
             $this->success("头像更新成功!");
         } else {
             $this->error("头像更新失败!");
         }
     }
 }
开发者ID:feng8605765,项目名称:xmmusic,代码行数:45,代码来源:ProfileController.class.php

示例15: usercontact_post

 function usercontact_post()
 {
     if (IS_POST) {
         $userid = sp_get_current_userid();
         $_POST['id'] = $userid;
         if ($this->users_model->create($_POST)) {
             if ($this->users_model->save()) {
                 $this->success("保存成功!", U("user/profile/usercontact"));
             } else {
                 $this->error("保存失败!");
             }
         }
     }
 }
开发者ID:noikiy,项目名称:luokeke2,代码行数:14,代码来源:ProfileController.class.php


注:本文中的sp_get_current_userid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。