Beispiel #1
0
 /**
  * 保存数据进数据库
  * @param $data
  * @author Mr.Cong <*****@*****.**>
  */
 public function saveData($data)
 {
     Forums::where('fid', $this->fid)->delete();
     foreach ($data['items'] as $key => $item) {
         $forums = new Forums();
         $forums->fid = $this->fid;
         $forums->title = $item->get_title();
         $forums->link = $item->get_link();
         $forums->description = html_entity_decode($item->get_description(), ENT_COMPAT);
         $forums->category = $item->get_category()->get_term();
         $forums->author = $item->get_author()->get_email();
         $forums->pubDate = strtotime($item->get_date());
         $forums->save();
         $all_link[$forums->id] = $item->get_link();
     }
     /*
      * 异步采集内容
      */
     $index = 0;
     foreach ($all_link as $kyeId => $link) {
         $index++;
         $threadId = preg_split('/[\\/\\-]/', $link);
         $get_url = sprintf('https://gsee.tuiyue.org/Spider/reptile/%s/%s', $threadId[4], $kyeId);
         sock_get($get_url);
         unset($get_url);
         if ($index == 5) {
             sleep(10);
             $index = 0;
         }
     }
     writeLog('Save data to database.');
 }
Beispiel #2
0
 /**
  * 显示文章列表
  * @param Request $request
  * @return mixed
  * @author Mr.Cong <*****@*****.**>
  */
 public function lists($name = 'news', $tag = null)
 {
     switch ($name) {
         case 'forums':
             //论坛
             if ($tag != false) {
                 $list = Forums::where('fid', $tag)->paginate(15);
             } else {
                 $list = Forums::paginate(15);
             }
             break;
         case 'news':
             //新闻
             if ($tag != false) {
                 $list = News::where('tag', $tag)->paginate(15);
             } else {
                 $list = News::paginate(15);
             }
             break;
         default:
             break;
     }
     return view('index')->with('list', $list)->with('name', $name);
 }
Beispiel #3
0
 /**
  * 显示文章列表
  * @param Request $request
  * @return mixed
  * @author Mr.Cong <*****@*****.**>
  */
 public function lists($name, $tag = null)
 {
     switch ($name) {
         case 'forums':
             //论坛
             if ($tag != false) {
                 $list = Forums::where('fid', $tag)->paginate(15);
             } else {
                 $list = Forums::paginate(15);
             }
             break;
         case 'news':
             //新闻
             if ($tag != false) {
                 $list = News::where('tag', $tag)->paginate(15);
             } else {
                 $list = News::paginate(15);
             }
             break;
         default:
             break;
     }
     return Response::json($list);
 }