コード例 #1
0
 /**
  * 更新注册控制统计记录
  * @param array $data
  * @return boolean
  */
 public function update_regctrl($data)
 {
     if (empty($data)) {
         return false;
     } else {
         $this->db = K_Model::getInstanceDb(true);
         $log = $this->getRow(array('ip' => $data['ip']), array('count', 'lastregdate'), $this->member_control);
         if (empty($log)) {
             $id = $this->add($data, 'id', $this->member_control);
             return $id ? true : false;
         } else {
             $cur_time = time();
             $regctrl = read_static_cache('website_config');
             if ($cur_time - $data['lastregdate'] > $regctrl['regist_t'] * 3600) {
                 //超过时间限制,更新时间、次数归1
                 $result = $this->update(array('ip' => $data['ip']), array('lastregdate' => $cur_time, 'count' => 1), $this->member_control);
                 return $result ? true : false;
             } else {
                 //没有超过次数限制
                 $result = $this->update(array('ip' => $data['ip']), array('lastregdate' => $cur_time, 'count' => $log['count'] + 1), $this->member_control);
                 return $result ? true : false;
             }
         }
     }
 }
コード例 #2
0
 /**
  *获取一个公告 
  */
 public function get_item($article_id)
 {
     $this->db = K_Model::getInstanceDb(false);
     $article_id = intval($article_id);
     if (!$article_id) {
         return false;
     }
     $where = array('id' => $article_id);
     return $this->getRow($where, array('*'), $this->model_name);
 }
コード例 #3
0
 /**
  * 获取订阅
  *
  * @access  public
  * @paras  int $rid  节目ID
  *
  * @return  array
  */
 public function my($uid, $state = 0, $page = 1, $size = 6)
 {
     $this->db = K_Model::getInstanceDb(false);
     $where['uid'] = $uid;
     if ($state >= 0) {
         $where['state'] = $state;
     }
     if ($page <= 0) {
         $page = 1;
     }
     $offset = ($page - 1) * $size;
     $sql = "select p.rid, p.name, p.desc, p.pic_name, p.is_live, p.videos, m.uid, m.username, p.record_time from sk_programs as p" . " inner join sk_member as m on m.uid=p.uid" . " where p.visible=0 and p.status = 1 order by p.is_live desc, p.videos desc" . " limit {$offset}, {$size}";
     $query = $this->db->query($sql);
     return $query->result_array();
 }
コード例 #4
0
 public function get_html($fid)
 {
     $html = read_fragment_cache($fid);
     if (empty($html)) {
         $this->db = K_Model::getInstanceDb(false);
         $row = $this->getRow(array('fid' => $fid, 'status' => 1), array('data, temp'));
         if (!empty($row)) {
             $row['data'] = unserialize($row['data']);
             $row['data'] = json_decode($row['data'], true);
             $html = parse_frag_template($row['temp'], $row['data'], $this->img_path);
             write_fragment_cache($fid, $html);
         }
     }
     return $html;
 }
コード例 #5
0
 function __construct()
 {
     parent::__construct();
     $this->db = K_Model::getInstanceDb(true);
 }
コード例 #6
0
 /**
  * 根据评论ID获取用户ID
  *
  * @access  public
  * @param   int     $cid   评论ID
  *
  * @return  int/bool                 用户ID
  */
 public function get_uid_by_cid($cid)
 {
     if ($cid > 0) {
         $this->db = K_Model::getInstanceDb(false);
         $where = array('c_id' => $cid);
         $row = $this->getRow($where);
         if ($row) {
             return $row['uid'];
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #7
0
 public function callback_update_videos($where, $set)
 {
     $this->db = K_Model::getInstanceDb(true);
     if (!empty($where) && !empty($set)) {
         $r = $this->getRow($where, array(), $this->model_video_name);
         if ($r) {
             return $this->update($where, $set, $this->model_video_name);
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #8
0
 /**
  * 更新关系表
  * @param array $where
  * @param array $field
  * @return boolean
  */
 public function update_relation($where, $field)
 {
     $this->db = K_Model::getInstanceDb(true);
     return $this->update($where, $field, $this->member_follow);
 }
コード例 #9
0
 /**
  * 获取金币列表
  *
  * @access public
  * @param int $uid
  *        	用户ID
  * @param int $method
  *        	1:获取金币 2:使用金币 0:所以的
  * @param int $page
  *        	动作等级
  * @param int $size
  *        	页面大小
  * @param int $is_count
  *        	是否返回总数
  *        	
  * @return array 返回金币记录
  */
 public function get_list_by_uid($uid, $method = 0, $page = 1, $size = 10, $is_count = FALSE)
 {
     $this->db = K_Model::getInstanceDb(true);
     $offset = ($page - 1) * $size;
     $limit = $size;
     $where = 'where cl.uid =' . $uid;
     if (in_array($method, array(0, 1, 2))) {
         if ($method > 0) {
             $where .= ' and cl.method = ' . $method;
         }
     }
     $sql = 'select cl.*, cc.name as act_name, cc.level as cat_level, cc.desc from ' . $this->model_name_log . ' as cl left join ' . $this->model_name_config . ' as cc on cl.act=cc.act ' . $where . ' order by cl.record_time desc limit ' . $offset . ', ' . $limit;
     $query = $this->db->query($sql);
     $result['list'] = $query->result_array();
     if ($is_count) {
         $sql = 'select count(*) as c from ' . $this->model_name_log . ' as cl ' . $where;
         $query = $this->db->query($sql);
         $rec = $query->result_array();
         if (isset($rec[0])) {
             $result['count'] = $rec[0]['c'];
         } else {
             $result['count'] = 0;
         }
     }
     return $result;
 }
コード例 #10
0
 /**
  * 获取关注某个人的记录
  * @param array $where
  * @param array $field
  * @return array
  */
 public function get_follow_by_uid($where, $field = array())
 {
     $this->db = K_Model::getInstanceDb(false);
     $data = $this->slave->select($field)->get_where($this->member_follow, $where);
     return !empty($data) ? $data : array();
 }
コード例 #11
0
 public function update_pushsatus_by_uid($uid)
 {
     $this->db = K_Model::getInstanceDb(true);
     $row = $this->getRow(array('uid' => $uid), '', $this->model_name_record);
     if (!empty($row)) {
         $last_mi_id = intval($row['last_mi_id']);
         $sql = 'update ' . $this->model_name_publish . ' set status = 0 where ex_id = ' . $uid . ' and type = 0 and mi_id < ' . $last_mi_id;
         return $this->db->query($sql);
     }
 }
コード例 #12
0
 /**
  * 更新订单记录
  * @param string 订单号
  * @param array 更新字段
  * @return boolean
  */
 public function update_order($order_id, $set)
 {
     $this->db = K_Model::getInstanceDb(true);
     $where = array('oid' => $order_id);
     return $this->update($where, $set, $this->model_name_log);
 }
コード例 #13
0
 /**
  * 获取社团参加的所有比赛的开始时间
  * @param int $tid 社团tid
  * @return array
  */
 public function get_game_starttime($tid)
 {
     $this->db = K_Model::getInstanceDb(true);
     $sql = "select b.starttime,b.endtime from {$this->sign} a left join {$this->game} b on a.gid=b.id where a.tid={$tid}";
     $data = $this->db->query($sql)->result_array();
     $this->db->query($sql)->free_result();
     return $data;
 }
コード例 #14
0
 public function recommended($keys = "", $cate = "", $size = 10)
 {
     if (!empty($keys)) {
     } elseif (!empty($cate)) {
     } else {
         $this->db = K_Model::getInstanceDb(false);
         $sql = "select pv.rid, v.title as name, p.duration, v.pic_name, pv.views, m.uid, m.username, pv.record_time from sk_program_videos as pv" . " inner join sk_programs as p on p.rid=pv.rid" . " inner join sk_video as v on v.id=pv.vid" . " inner join sk_member as m on m.uid=v.uid" . " where v.status=3 order by rand()" . " limit 0, {$size}";
         $query = $this->db->query($sql);
         return $query->result_array();
     }
 }
コード例 #15
0
 /**
  * 获取充值记录
  *
  * @access public
  * @param int $uid
  *        	用户ID
  * @param int $page
  *        	当前页
  * @param int $size
  *        	页面大小
  * @param int $is_count
  *        	是否返回总数
  *
  * @return array 返回充值记录
  */
 public function get_inpour($uid, $page = 1, $size = 10, $is_count = FALSE)
 {
     $this->db = K_Model::getInstanceDb(true);
     $offset = ($page - 1) * $size;
     $limit = $size;
     $where = 'where r.uid =' . $uid;
     $sql = 'select r.* from ' . $this->model_recharge . ' as r ' . $where . ' order by r.dateline desc limit ' . $offset . ', ' . $limit;
     $query = $this->db->query($sql);
     $result['list'] = $query->result_array();
     if ($is_count) {
         $sql = 'select count(*) as c from ' . $this->model_recharge . ' as r ' . $where;
         $query = $this->db->query($sql);
         $rec = $query->result_array();
         if (isset($rec[0])) {
             $result['count'] = $rec[0]['c'];
         } else {
             $result['count'] = 0;
         }
     }
     return $result;
 }
コード例 #16
0
 /**
  * 获取推荐数量
  *
  * @access public
  * @param string $position  推荐频道ID
  *        	
  *
  * @return boolean 
  */
 public function get_count($position)
 {
     if ($position > 0) {
         $this->db = K_Model::getInstanceDb(false);
         $where = array('position' => $position);
         return $this->getCount($where);
     } else {
         return 0;
     }
 }
コード例 #17
0
 /**
  * 获取道具明细列表
  *
  * @access public
  * @param int $uid
  *        	用户ID
  * @param string $mg_cate
  *        	道具类型
  * @param int $page
  *        	分页
  * @param int $size
  *        	页面大小
  * @param int $is_count
  *        	是否返回总数
  *
  * @return array 返回积分记录
  */
 public function get_list_by_uid($uid, $mg_cate, $page = 1, $size = 10, $is_count = FALSE)
 {
     $this->db = K_Model::getInstanceDb(false);
     $offset = ($page - 1) * $size;
     $limit = $size;
     $where = 'where ml.uid =' . $uid;
     if (!empty($mg_cate)) {
         $where = ' and m.mg_cate = \'' . $mg_cate . '\'';
     }
     $sql = 'select ml.*, m.name as ide_name, m.description from ' . $this->model_name_log . ' as ml left join ' . $this->model_name . ' as m on ml.identifier=m.identifier ' . $where . ' order by ml.dateline desc limit ' . $offset . ', ' . $limit;
     $query = $this->db->query($sql);
     $result['list'] = $query->result_array();
     if ($is_count) {
         $sql = 'select count(*) as c from ' . $this->model_name_log . ' as ml left join ' . $this->model_name . ' as m on ml.identifier=m.identifier ' . $where;
         $query = $this->db->query($sql);
         $rec = $query->result_array();
         if (isset($rec[0])) {
             $result['count'] = $rec[0]['c'];
         } else {
             $result['count'] = 0;
         }
     }
     return $result;
 }
コード例 #18
0
 /**
  * 获取回答
  *
  * @access  public
  * @param   int     $parent_qid   父ID
  * @param   int     $page         当前页数
  * @param   int     $size         页面大小
  * @param   int     $is_count     是否返回总数
  *
  * @return  array                 返回列表
  */
 public function get_reply_by_qid($parent_qid = 0, $page = 1, $size = 10, $is_count = FALSE)
 {
     $this->db = K_Model::getInstanceDb(true);
     $offset = ($page - 1) * $size;
     $limit = $size;
     $where = ' where q.is_answer = 1 and q.parent_qid=' . $parent_qid;
     $sql = 'select q.qid, q.content, q.record_time, m.admin_name from ' . $this->model_name . ' as q ' . 'left join sk_manager as m on q.uid=m.id' . $where . ' order by q.record_time desc limit ' . $offset . ', ' . $limit;
     $query = $this->db->query($sql);
     $result['list'] = $query->result_array();
     if ($is_count) {
         $sql = 'select count(*) as c from ' . $this->model_name . ' as q ' . $where;
         $query = $this->db->query($sql);
         $rec = $query->result_array();
         if (isset($rec[0])) {
             $result['count'] = $rec[0]['c'];
         } else {
             $result['count'] = 0;
         }
     }
     return $result;
 }
コード例 #19
0
 /**
  * 获取节目信息
  *
  * @access  public
  * @paras  int $rid  节目ID
  * 
  * @return  array
  */
 public function getRow($id)
 {
     $this->db = K_Model::getInstanceDb(false);
     $where = array('id' => $id, 'status' => 1);
     return $this->getRow($where);
 }
コード例 #20
0
 public function get_range_by_lid($lid)
 {
     if ($lid > 0) {
         $this->db = K_Model::getInstanceDb(true);
         $where = array('lid' => $lid);
         return $this->getRow($where, array('level', 'min_credit', 'max_credit'));
     } else {
         return false;
     }
 }
コード例 #21
0
 /**
  * 获取房间信息
  *
  * @access  public
  * @paras  int $rid  房间ID
  * 
  * @return  array
  */
 public function get_my_rooms($uid, $skip_rid = 0, $size = 10)
 {
     $this->db = K_Model::getInstanceDb(false);
     if ($uid > 0) {
         $sql = "select * from " . $this->model_name . " where uid = {$uid} and rid > {$skip_rid} order by rid asc limit {$size}";
         $query = $this->db->query($sql);
         return $query->result_array();
     } else {
         return false;
     }
 }
コード例 #22
0
 /**
  * 第三方信息更新
  * @param array $where
  * @param array $field
  * @return boolean
  */
 public function update_oauth($where, $field)
 {
     $this->db = K_Model::getInstanceDb(true);
     return $this->update($where, $field, $this->oauth);
 }