1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace Spider\Lib;
- use Dever;
- class Project
- {
- private $config;
- public function __construct($id)
- {
- if (!$id) {
- Dever::alert('id不存在');
- }
- $this->config = Dever::db('spider/project')->one($id);
- $this->check();
- $this->runing();
- }
- public function get()
- {
- return $this->config;
- }
- private function check()
- {
- if (!$this->config) {
- Dever::alert('项目未定义');
- }
- if ($this->config['status'] != 1) {
- //Dever::alert('项目不是待机状态');
- }
- }
- private function runing()
- {
- Dever::db('spider/project')->update(['status' => 2, 'where_id' => $this->config['id']]);
- $this->setting();
- }
- private function setting()
- {
- $this->config['col'] = Dever::db('spider/col')->state(['project_id' => $this->config['id']]);
- $this->config['url'] = explode("\r\n", $this->config['site']);
- $this->config['queue'] = new Queue();
- array_walk($this->config['url'], [$this->config['queue'], 'push']);
- }
- }
|