You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
7.1 KiB
212 lines
7.1 KiB
<?php
|
|
/**
|
|
*
|
|
*/
|
|
|
|
include_once(dirname(dirname(__FILE__)) . "/library/publicBase.php");
|
|
|
|
class weibo extends publicBase {
|
|
|
|
public function home() {}
|
|
|
|
public function comments() {}
|
|
|
|
public function comment_detail() {
|
|
$id = $this->get('id') + 0;
|
|
|
|
$obj = new mWeibo();
|
|
$weibo = $obj->getWeiboDetailById($id);
|
|
if (empty($weibo)) $this->show_message('微博不存在', 'goback');
|
|
|
|
$this->view['data'] = $weibo;
|
|
|
|
$cur_page = $this->get('page')+0 > 0 ? $this->get('page')+0 : 1;
|
|
$page_size = $this->get('size')+0 > 0 ? $this->get('size')+0 : 20;
|
|
|
|
$cond = array();
|
|
$is_search = $this->get('search_type') + 0;
|
|
if(isset($_GET['search_type']) && $is_search >= 0) $cond['is_search'] = $is_search;
|
|
|
|
$mobj = new mWeiboComments();
|
|
|
|
$total = $mobj->getCommentCountByWeiboId($id, $cond);
|
|
$this->view['last_page'] = ceil($total / $page_size);
|
|
|
|
$cur_page = $cur_page > $this->view['last_page'] ? $this->view['last_page'] : $cur_page;
|
|
$this->view['total'] = $total;
|
|
$this->view['per_page'] = $page_size;
|
|
$this->view['cur_page'] = $cur_page;
|
|
|
|
$comment_list = $mobj->getCommentByWeiboId($id, $cur_page, $page_size, 'id asc', $cond);
|
|
if(!empty($comment_list)) {
|
|
foreach ($comment_list as $k => $v) {
|
|
$comment_save_path = sprintf(ZHISHIKU_SPIDER_COMMENT_PATH, $weibo['wid'], $v['weibo_data_id']);
|
|
if(!file_exists($comment_save_path)) $this->show_message('评论数据文件不存在', 'goback');
|
|
$cdata = json_decode(file_get_contents($comment_save_path), true);
|
|
$comment_list[$k]['comment_time'] = date('Y-m-d H:i:s', strtotime($cdata['created_at']));
|
|
$comment_list[$k]['source'] = $cdata['source'];
|
|
$comment_list[$k]['screen_name'] = $cdata['user']['screen_name'];
|
|
}
|
|
|
|
$this->view['comment_list'] = $comment_list;
|
|
$this->view['search_status_list'] = $GLOBALS['SPIDER_COMMENT_SEARCH_STATUS_LIST'];
|
|
}
|
|
}
|
|
|
|
public function ajax_weibo_list() {
|
|
$status = $this->post('status') + 0;
|
|
$spider_comment_status = $this->post('spider_comment_status') + 0;
|
|
$cur_page = $this->post('currentPage') ? $this->post('currentPage') : 1;
|
|
$page_size = $this->post('pageSize') ? $this->post('pageSize') : 20;
|
|
|
|
$condition = array();
|
|
if ($spider_comment_status) {
|
|
$condition['spider_comment_status'] = $spider_comment_status;
|
|
$condition['uid'] = WEIBO_USER_ZHANG;
|
|
}else{
|
|
$condition['status'] = $status;
|
|
}
|
|
|
|
$obj = new mWeibo();
|
|
$total = $obj->getWeiboTotal($condition);
|
|
$list = $obj->getWeiboList($condition, $cur_page, $page_size);
|
|
|
|
$rdata = array(
|
|
'total' => $total,
|
|
'per_page' => $page_size,
|
|
'last_page' => ceil($total / $page_size),
|
|
'cur_page' => $cur_page,
|
|
'list' => $list,
|
|
);
|
|
|
|
$this->ajax_json(true, '获取成功', $rdata);
|
|
}
|
|
|
|
public function ajax_weibo_detail() {
|
|
$id = $this->post('id') + 0;
|
|
|
|
$obj = new mWeibo();
|
|
$data = $obj->getWeiboDetailById($id);
|
|
|
|
$this->ajax_json(true, '获取成功', $data);
|
|
}
|
|
|
|
public function ajax_set_weibo_status() {
|
|
$id = $this->post('id') + 0;
|
|
if (!$id) $this->ajax_json(true, '参数错误');
|
|
|
|
$status = $this->post('status') + 0;
|
|
|
|
$obj = new mWeibo();
|
|
$data = $obj->updateWeibo($id, array('status' => $status));
|
|
|
|
$this->ajax_json(true, '设置成功', $data);
|
|
}
|
|
|
|
public function ajax_edit_weibo() {
|
|
$id = trim($this->post('id'));
|
|
$text = trim($this->post('answer'));
|
|
$refer = trim($this->post('desc'));
|
|
$status = $this->post('status') + 0;
|
|
|
|
if ($id) {
|
|
$obj = new mWeibo();
|
|
$res = $obj->updateWeibo($id, array('text' => $text, 'refer' => $refer, 'status' => $status));
|
|
if (!$res) $this->ajax_json(false, '保存失败');
|
|
|
|
$this->ajax_json(true, '保存成功');
|
|
}
|
|
|
|
$data = array(
|
|
'uid' => '1',
|
|
'text' => $text,
|
|
'refer' => $refer,
|
|
'pic_ids' => '',
|
|
'video_url' => '',
|
|
'video_cover' => '',
|
|
'created_at' => date('Y-m-d H:i:s', time()),
|
|
'status' => $status,
|
|
);
|
|
|
|
$obj = new mWeibo();
|
|
$res = $obj->addWeibo($data);
|
|
if (!$res) $this->ajax_json(false, '保存失败');
|
|
|
|
$this->ajax_json(true, '保存成功');
|
|
}
|
|
|
|
public function ajax_get_spider_list() {
|
|
$date = trim($this->post('date'));
|
|
$uid = trim($this->post('uid'));
|
|
$wid = trim($this->post('wid'));
|
|
$cur_page = $this->post('currentPage') ? $this->post('currentPage') : 1;
|
|
$page_size = $this->post('pageSize') ? $this->post('pageSize') : 20;
|
|
|
|
$obj = new mWeiboBehavior();
|
|
$list = $obj->getSpiderBehavior($date, $uid, $wid, $cur_page, $page_size);
|
|
$total = $obj->getSpiderBehaviorTotal($date, $uid, $wid);
|
|
|
|
$rdata = array(
|
|
'total' => $total,
|
|
'per_page' => $page_size,
|
|
'last_page' => ceil($total / $page_size),
|
|
'cur_page' => $cur_page,
|
|
'list' => $list,
|
|
);
|
|
|
|
$this->ajax_json(true, '获取成功', $rdata);
|
|
}
|
|
|
|
public function ajax_hot_list() {
|
|
$type = $this->post('type') + 0;
|
|
$sdate = trim($this->post('sdate'));
|
|
$edate = trim($this->post('edate'));
|
|
$cur_page = $this->post('currentPage') ? $this->post('currentPage') : 1;
|
|
$page_size = $this->post('pageSize') ? $this->post('pageSize') : 20;
|
|
|
|
$obj = new mWeiboBehavior();
|
|
$list = $obj->getHotBehavior($type, $sdate, $edate, $cur_page, $page_size);
|
|
$total = $obj->getHotBehaviorTotal($sdate, $edate);
|
|
|
|
$rdata = array(
|
|
'total' => $total,
|
|
'per_page' => $page_size,
|
|
'last_page' => ceil($total / $page_size),
|
|
'cur_page' => $cur_page,
|
|
'list' => $list,
|
|
);
|
|
|
|
$this->ajax_json(true, '获取成功', $rdata);
|
|
}
|
|
|
|
public function show_detail() {
|
|
$this->view['wid'] = $this->get('wid') + 0;
|
|
}
|
|
|
|
public function ajax_update_cookie() {
|
|
$obj = new mWeiboBehavior();
|
|
|
|
//设置cookie
|
|
$cookie = trim($this->get('cookie'));
|
|
if($cookie){
|
|
$robj = $obj->initRedis();
|
|
$robj->set(_RC_WEIBO_LOGIN_COOKIE, $cookie);
|
|
}
|
|
|
|
//抓取
|
|
$type = $this->get('type') + 0;
|
|
if ($type) {
|
|
shell_exec("nohup /usr/bin/php /data1/www/zhishiku.yizherenxin.cn/queue/crontab/spider_behavior_data.php > /dev/null 2>&1 &");
|
|
$this->ajax_json(true, '111');
|
|
}
|
|
|
|
//统计某日期增量
|
|
$date = trim($this->get('date'));
|
|
if($date){
|
|
shell_exec("nohup /usr/bin/php /data1/www/zhishiku.yizherenxin.cn/queue/crontab/spider_behavior_delta.php {$date} > /dev/null 2>&1 &");
|
|
$this->ajax_json(true, '222');
|
|
}
|
|
|
|
$this->ajax_json(true, '333');
|
|
}
|
|
}
|
|
|