Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. $con=mysqli_connect("localhost","rub3x_testbed","GF~Zm}eM(lpp","rub3x_testbed");
  4. if (mysqli_connect_errno()) {
  5.   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  6. }
  7. $new = True;
  8. $handle = @fopen("movielist.txt", "r");
  9. if ($handle) {
  10.     $total = array();
  11.     $i = 0;
  12.     $x = 0;
  13.     while (($buffer = fgets($handle, 4096)) !== false)
  14.     {
  15.         if($x == 0)
  16.         {
  17.             $total[$i][0] = $buffer;
  18.             $mseries = $buffer;
  19.             $x++;
  20.             $new = True;
  21.         } elseif($x == 3) {
  22.             $x = 0;
  23.             $total[$i][3] = $buffer;
  24.             $i++;
  25.             $new = False;
  26.         } else {
  27.             $total[$i][$x] = $buffer;
  28.             $x++;
  29.             $new = False;
  30.         }
  31.         //loop broke you need a true/false to make below work
  32.  
  33.         if($new == False)
  34.         {
  35.             $mdate = substr(strrchr($buffer, " ("), 1);
  36.             $mdate = str_replace('(', '', $mdate);
  37.             $mdate = str_replace(')', '', $mdate);
  38.             $mname = substr($buffer, 0,strrpos($buffer, ' ('));
  39.             $mname = str_replace(' ', '%20', $mname);
  40.             //$url = "http://www.omdbapi.com/?t=$mname&y=$udate";
  41.             //$json = file_get_contents($url);
  42.             //$obj = json_decode($json);
  43.             //$mimage = $obj->Poster;
  44.             //echo $i . "<br />";
  45.             //usleep(75000);
  46.             //$mrating = $obj->imdbRating;
  47.             //$mgenre = $obj->Genre;
  48.             //$mactors = $obj->Actors;
  49.             //$dbname = $obj->Title;
  50.             //mysqli_query($con,"INSERT INTO `rub3x_testbed`.`movies` (`series`, `movie`, `date`, `image`, `rating`, `genre`, `actors`) VALUES ('$mseries', '$dbname', '$mdate', '$mimage', '$mrating', '$mgenre', '$mactors');");
  51.             echo '"' . $mname . '"<br />';
  52.         } else {
  53.             echo 'Series: "' . $mseries . '"<br />';
  54.         }
  55.     }
  56.  
  57.     if (!feof($handle))
  58.     {
  59.         echo "Error: unexpected fgets() fail\n";
  60.     }
  61.     fclose($handle);
  62.    
  63. }
  64.  
  65.  
  66. mysqli_close($con);
  67.  
  68.  
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement