protected function curl_run($comicId, $onlineId)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->comic_url . $onlineId . "/");
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $output = curl_exec($ch);
     $matchArr = [];
     //$output = '<a href="http://8yyls.com/20579">第154話</a>' . '<a href="http://8yyls.com/20375">第004卷</a>';
     preg_match_all("/http:\\/\\/8yyls\\.com\\/[0-9]+[\\/]?\">第[0-9]+(卷|話)/", $output, $matchArr, PREG_OFFSET_CAPTURE);
     $maxNum = last($matchArr[0]);
     $result = [];
     $result = explode('">第', $maxNum[0]);
     $book = \App\Books::where('comics_id', $comicId)->first();
     if ($book === null) {
         $book = new \App\Books();
         $book->comics_id = $comicId;
         $book->link = $result[0];
         $book->chapter = substr($result[1], 0, 3);
         $book->is_read = false;
         $book->save();
     } else {
         if ($book->chapter !== substr($result[1], 0, 3)) {
             $book->link = $result[0];
             $book->chapter = substr($result[1], 0, 3);
             $book->is_read = false;
             $book->save();
         }
     }
     /** finished curl not test */
     curl_close($ch);
 }
Esempio n. 2
0
 public function addBooks(SellBookRequest $request)
 {
     $books = new \App\Books();
     $books->bookname = $request->input('bookname');
     $books->description = $request->input('description');
     $books->author = $request->input('author');
     $books->publishedyear = $request->input('publishedyear');
     $books->publishername = $request->input('publishername');
     $books->price = $request->input('price');
     $books->sellerid = session('user')->userid;
     $books->available = 'y';
     $books->bookcondition = $request->input('bookcondition');
     $books->deliverycharge = $request->input('deliverycharge');
     $books->categoryid = $request->input('categoryid');
     $imagename = rand(1, getrandmax()) . '.' . $request->file('image')->getClientOriginalExtension();
     $request->file('image')->move(base_path() . '/public/images/', $imagename);
     $imageurl = 'images/' . $imagename;
     $books->imageurl = $imageurl;
     $books->save();
     \Session::flash('message', 'Book Added Successfully!');
     \Session::flash('type', 'success');
     return redirect('/dashboard/sell');
 }