Beispiel #1
0
 function getList($limit)
 {
     $this->db->limit($limit['count'], $limit['page'] * $limit['count']);
     switch ($limit['type']) {
         case 0:
             $info = $this->db->query('SELECT SUM(visitCount) sum,COUNT(*) count FROM weibo')->row_array();
             $this->db->order_by('id desc');
             // 				->where("visitCount>=",floor($info['sum']/($info['count']*3)),FALSE)//平均点击量的1/3
             break;
         case 1:
             $this->db->where("authorId IN (SELECT toId FROM attention WHERE fromId=" . UID . ") OR authorId=" . UID, null, FALSE)->order_by('id desc');
             break;
         case 2:
             $this->load->helper('distance');
             $this->db->where("time >", time() - 1296000, FALSE)->order_by("pow(lat-{$limit['lat']},2)+pow(lng-{$limit['lng']},2)", 'asc');
             break;
         case 3:
             $this->db->where('authorId', $limit['id'])->order_by('id desc');
             break;
         default:
             errInput();
     }
     $data = $this->db->select('*,(SELECT avatar FROM user WHERE id=weibo.authorId) authorAvatar,(SELECT name FROM user WHERE id=weibo.authorId) authorName')->get('weibo')->result_array();
     array_walk($data, [$this, '_dealData']);
     return $data;
 }
Beispiel #2
0
 function feedback()
 {
     $this->load->model('muser');
     $this->muser->check() or noRights();
     $data = $this->input->post('content', TRUE) or errInput();
     $this->db->insert('feedback', ['content' => $data, 'uid' => UID]) ? ajax() : busy();
 }
Beispiel #3
0
 function comment()
 {
     $this->load->model('muser');
     $this->muser->check() or noRights();
     $data = $this->input->post(['bid', 'content'], TRUE) or errInput();
     $bbs = ['time' => time(), 'reply' => 'reply+1'];
     $this->db->where('id', $data['bid'])->set($bbs, '', FALSE)->update('bbs') or ajax(4001, '帖子不存在');
     $data['time'] = $bbs['time'];
     $data['uid'] = UID;
     $this->db->insert('bcomment', $data) ? ajax() : busy();
 }
Beispiel #4
0
 function enrollList()
 {
     $this->load->model('muser');
     $this->muser->check() or noRights();
     $id = (int) $this->input->post('id') or errInput();
     // 		$uid=$this->db->find('yue', $id,'id','uid');
     // 		$uid OR ajax(5001,'此记录不存在');
     // 		$uid==UID OR noRights();
     $res = $this->db->query("SELECT id,avatar,name FROM (SELECT uid FROM yue_people WHERE yid=?) people JOIN user ON uid=id", $id)->result_array();
     ajax(0, '', $res);
 }
Beispiel #5
0
 function getItem()
 {
     $id = $this->input->post('id');
     $id or errInput();
     $data = $this->m->getItem($id);
     if ($data == FALSE) {
         ajax(3001, '没有数据');
     } else {
         ajax(0, '', $data);
     }
 }
Beispiel #6
0
 function unAttend()
 {
     if (!$this->m->check()) {
         noRights();
     }
     $id = $this->input->post('id') or errInput();
     $this->db->where('id', $id)->step('fans', 'user', FALSE);
     $this->db->affected_rows() == 1 or errInput();
     //此用户不存在
     $this->db->where('id', UID)->step('cared', '', FALSE);
     $this->db->where(['fromid' => UID, 'toId' => $this->input->post('id')])->delete('attention');
     ajax();
 }
Beispiel #7
0
 function log($date = '')
 {
     if ($date == '') {
         $time = time() - 86400;
         $date = date('Y-m-d', $time);
     } else {
         if (!preg_match("/^([0-9-])+\$/i", $date)) {
             errInput();
         }
     }
     $date = APPPATH . "logs/{$date}.json";
     if (!file_exists($date)) {
         die('此日志文件不存在!');
     }
     $data = json_decode(file_get_contents($date), TRUE);
     foreach ($data['url'] as $key => $value) {
         echo $key . '模块共访问了' . $value['total'] . '次,具体访问情况如下:<br />';
         unset($value['total']);
         foreach ($value as $key2 => $value2) {
             echo "{$key2} 接口访问了{$value2} 次<br />";
         }
         echo '<br />';
     }
     echo '<br />';
     echo '此日共计有' . count($data['user']) . '人使用。<br />';
     $res = $this->db->select('id,name')->where_in('id', array_keys($data['user']))->get('user')->result_array();
     $user = [];
     foreach ($res as $item) {
         $user[$item['id']] = $item['name'];
     }
     foreach ($data['user'] as $key => $value) {
         echo "ID是{$key} 的用户“" . $user[(string) $key] . "”访问过{$value} 次接口。<br />";
     }
 }
Beispiel #8
0
 function scoreList()
 {
     $id = $this->input->post('id');
     if (!$id) {
         errInput();
     }
     $input = ['id' => $id, 'page' => $this->input->post('page', FALSE, 0), 'count' => $this->input->post('count', FALSE, 20)];
     $this->load->model('mplace', 'm');
     $data = $this->m->scoreList($input);
     ajax(0, '', $data);
 }