Project.php 695 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Spider\Lib;
  3. use Dever;
  4. class Project
  5. {
  6. private $config;
  7. public function __construct($id)
  8. {
  9. if (!$id) {
  10. Dever::alert('id不存在');
  11. }
  12. $this->config = Dever::db('spider/project')->one($id);
  13. $this->check();
  14. }
  15. public function get()
  16. {
  17. $this->setting();
  18. return $this->config;
  19. }
  20. private function check()
  21. {
  22. if (!$this->config) {
  23. Dever::alert('项目未定义');
  24. }
  25. if ($this->config['status'] != 1) {
  26. //Dever::alert('项目不是待机状态');
  27. }
  28. }
  29. private function setting()
  30. {
  31. Dever::db('spider/project')->update(['status' => 2, 'where_id' => $this->config['id']]);
  32. $this->config['url'] = explode("\r\n", $this->config['site']);
  33. }
  34. }