get($id); if (!$data) { return ''; } $num = Dever::db('spider/data')->total(array('pid' => $id)); $status = Dever::db('spider/project')->config['status']; $table['采集状态'] = $status[$data['status']]; $table['采集次数'] = $data['num']; $table['采集间隔'] = $data['interval'] . '秒'; $table['采集页数'] = $data['cur_page']; $table['采集数据'] = $num . '条'; $table['采集时间'] = $data['sdate'] > 0 ? date('Y-m-d H:i:s', $data['sdate']) : '无'; return Dever::table($table); } public function get($id) { if (!$id) { return false; } $config = Dever::db('spider/project')->one($id); if ($config) { if ($config['project_id'] == -1) { return false; } return $config; } else { return false; } } public function set($config, $status, $page = false) { $test = Dever::input('test'); if ($test == 1) { return false; } $data['status'] = $status; if ($page) { $data['cur_page'] = $page; } $data['where_id'] = $config['id']; if ($status == 3) { $data['num'] = $config['num'] + 1; } if ($status == 2 && $config['interval'] > 0) { # 已结束,设置下次的时间 $data['sdate'] = time() + $config['interval']; } return Dever::db('spider/project')->update($data); } # 获取可以运行的项目 public function getAll() { $where['interval'] = 1; $where['sdate'] = time(); $data = Dever::db('spider/project')->getAll($where); return $data; } }