Exemplo n.º 1
0
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}*/
foreach ($manga_pages as $href) {
    $manga = new Manga($href);
    //echo 'Title: ' . 'Sorry, you need to find a way to get this one from $manga->title() or something :p'. '<br />';
    /*echo 'Title: ' . $manga->title(). '<br />';
      echo 'Link: ' . $href . '<br />';
      echo 'Description: ' . $manga->desc() . '<br />';
      echo 'Status: ' . $manga->status() . '<br />';
      echo 'Genre: ' . $manga->genre() . '<br />';
      echo 'Author: ' . $manga->author() . '<br />';
      echo 'Release: ' . $manga->release() . '<br />';
      echo 'Image Link: ' . $manga->image() . '<br />';
      echo '<br /><br />';
      */
    $image = $manga->image();
    $desc = $manga->desc();
    if (!empty($image)) {
        //echo '<b>Image:</b> ' . $mangamerge['Image'] . '<br />';
        $url = explode("?", $manga->image());
        $newurl = file_get_contents($url[0]);
        $img_path = './images/cover/' . preg_replace('/[^\\da-z]/i', "", strtolower($manga->title())) . mt_rand() . '.jpg';
        file_put_contents($img_path, $newurl);
        $image = $img_path;
    }
    if (!empty($desc)) {
        $desc = mysqli_real_escape_string($conn, $manga->desc());
        $sql = "INSERT INTO manga(title, description, status, genre, author, release_date, cover, latest_chapter, url, added_date) VALUES \n      ('" . $manga->title() . "','" . $desc . "','" . $manga->status() . "', '" . $manga->genre() . "', '" . $manga->author() . "', '" . $manga->release() . "', '" . $image . "', '0', '" . $href . "', '" . date("Y-m-d") . "')";
        //mysqli_query($con,$sql);
        //echo $sql;
    } else {