本文整理匯總了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');
}
示例2: _initialize
function _initialize()
{
parent::_initialize();
$this->order_model = D("Server/Order");
$this->uid = sp_get_current_userid();
$this->serversell_model = D("Server/ServersSell");
}
示例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'));
}
}
}
示例4: _initialize
function _initialize()
{
$adminid = sp_get_current_admin_id();
$userid = sp_get_current_userid();
if (empty($adminid) && empty($userid)) {
exit("非法上傳!");
}
}
示例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__ . "/");
}
}
示例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');
}
示例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");
}
示例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("取消收藏失敗!");
}
}
示例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"));
}
示例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("您已讚過啦!");
}
}
示例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("/"));
}
}
示例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);
}
示例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');
}
示例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("頭像更新失敗!");
}
}
}
示例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("保存失敗!");
}
}
}
}