public function index() { $id = intval($_GET['id']); $uid = get_current_userid(); $anwser = $_GET['anwser']; $game = sp_sql_game($id, ''); if ($game['anwser'] == $anwser) { //Ёи╧╕ echo 'xx'; } else { echo 'failer'; } $userid = 111111; $users_model = D("Users"); $user = $users_model->where(array("id" => $userid))->find(); var_dump($user); }
function get_games_log($gid, $uid = 0) { $res = array(); $uid = $uid == 0 ? get_current_userid() : $uid; $m_gl = M("GamesLog"); $gl = $m_gl->where("uid={$uid} and gid={$gid}")->select(); if ($uid == 0) { $res = array('right' => 0, 'tiped' => 0, 'trycount' => 0); } else { if ($gl == false) { //没有记录 $m_gl->add(array('uid' => $uid, 'gid' => $gid)); $res = array('right' => 0, 'tiped' => 0, 'trycount' => 0); } else { $res = $gl[0]; } } return $res; }
public function index() { $qiushi_cat_model = M("QiushiCat"); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $where = array("b.uid" => get_current_userid()); $totalsize = $qiushi_cat_model->alias("a")->join($join)->where($where)->count(); import('Page'); $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, 10); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}'; $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $qiushi_cats = $qiushi_cat_model->where(array("status" => 1))->select(); $this->assign("qiushi_cats", $qiushi_cats); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $qiushis = $qiushi_cat_model->field("a.cat_name,b.*,c.user_login,c.user_nicename")->alias("a")->join($join)->join($join2)->where($where)->order("b.createtime desc")->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign("pager", $page->show('default')); $this->assign("qiushis", $qiushis); $this->display(); }
/** * 编辑糗事 */ public function edit_post() { if (IS_POST) { $this->check_login(); $uid = get_current_userid(); $_POST = I("post."); $find_qiushi = $this->qiushi_model->where(array("id" => intval($_POST['id']), "uid" => $uid))->find(); if (empty($find_qiushi)) { $this->error("糗事不存在!"); } $_POST['content'] = h(htmlspecialchars_decode($_POST['content'])); if ($this->qiushi_model->field("id,cid,title,content")->create($_POST)) { if ($this->qiushi_model->save() !== false) { $this->success("糗事发表成功!", U("qiushi/index/index")); } else { $this->error("糗事发表失败!"); } } else { $this->error($this->qiushi_model->getError()); } } }
public function tip() { $gid = intval($_GET['id']); $uid = get_current_userid(); if ($uid == 0) { $result = array('errcode' => 1, 'str' => "首先,你需要登录。。"); echo json_encode($result); exit; } $game = sp_sql_game($gid, ''); if ($game['score'] < 2) { $result = array('errcode' => 2, 'str' => "这么简单的题你也好意思要提示?"); } else { $m_gl = M("GamesLog"); $gl = M("GamesLog")->where("uid={$uid} and gid={$gid}")->save(array('tiped' => 1)); $result = array('errcode' => 0, 'str' => $game['tip']); } echo json_encode($result); }
/** * 检查用户对某个url,内容的可访问性,用于记录如是否赞过,是否访问过等等;开发者可以自由控制,对于没有必要做的检查可以不做,以减少服务器压力 * @param number $object 访问对象的id,格式:不带前缀的表名+id;如posts1表示xx_posts表里id为1的记录;如果object为空,表示只检查对某个url访问的合法性 * @param number $count_limit 访问次数限制,如1,表示只能访问一次 * @param boolean $ip_limit ip限制,false为不限制,true为限制 * @param number $expire 距离上次访问的最小时间单位s,0表示不限制,大于0表示最后访问$expire秒后才可以访问 * @return true 可访问,false不可访问 */ function sp_check_user_action($object = "", $count_limit = 1, $ip_limit = false, $expire = 0) { $common_action_log_model = M("CommonActionLog"); $action = MODULE_NAME . "-" . CONTROLLER_NAME . "-" . ACTION_NAME; $userid = get_current_userid(); $ip = get_client_ip(); $where = array("user" => $userid, "action" => $action, "object" => $object); if ($ip_limit) { $where['ip'] = $ip; } $find_log = $common_action_log_model->where($where)->find(); $time = time(); if ($find_log) { $common_action_log_model->where($where)->save(array("count" => array("exp", "count+1"), "last_time" => $time, "ip" => $ip)); if ($find_log['count'] >= $count_limit) { return false; } if ($expire > 0 && $time - $find_log['last_time'] < $expire) { return false; } } else { $common_action_log_model->add(array("user" => $userid, "action" => $action, "object" => $object, "count" => array("exp", "count+1"), "last_time" => $time, "ip" => $ip)); } return true; }
function balanceadd($total_fee) { $users = M("Users"); $userid = get_current_userid(); $result = $users->where('id=' . $userid)->getField('balance'); $sum_balance = bcadd($result, $total_fee, 2); $data['balance'] = $sum_balance; $users->where('id=' . $userid)->save($data); }
<?php $key = get_current_user_key(); $userId = get_current_userid(); if (isset($key)) { include wpmlm_get_template_file_path('classes/wpmlm-my-dashboard.class.php'); $objMyDashboard = new MyDashboard($key); $userDetail = $objMyDashboard->GetUserInfoById($userId); $totalBus = $objMyDashboard->TotalBusiness($userId); $myLeftArr = $objMyDashboard->MyTop5LeftLegMember($userId); $myRightArr = $objMyDashboard->MyTop5RightLegMember($userId); $myPerSalesArr = $objMyDashboard->MyTop5PersonalSales($userId); $payoutArr = $objMyDashboard->MyTop5PayoutDetails($userId); $myRightTotal = $objMyDashboard->MyRightLegMemberTotal($userId); $myLeftTotal = $objMyDashboard->MyLeftLegMemberTotal($userId); $myPerSalesTotal = $objMyDashboard->MyPersonalSalesTotal($userId); //echo "<pre>";print_r($myLeftArr); exit; global $current_user; get_currentuserinfo(); $sponsor_name = $current_user->user_login; $reg_page_id = wpmlm_get_the_post_id_by_shortcode('[registration]'); $affiliateURL = get_permalink($reg_page_id) . '&sp=' . $key; } ?> <div class="dashboard"> <br /> <p class="affiliate_url"><strong>Affiliate URL :</strong> <?php echo $affiliateURL; ?> </p> <div class="leftSide">