Advertisement
Guest User

Babby's first program

a guest
Dec 26th, 2014
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. parse_str($argv[1]); #get thread, format 'C:\php\php.exe -f 4chan.php -- thread=xxxxxxxx'
  4.  
  5. while($chan = file_get_contents("http://boards.4chan.org/b/thread/".$thread)){ # while not 404'ed
  6.     if(!preg_match_all("/(i\\.4cdn\\.org\\/b\\/[\\d]+\\.[a-z][a-z][a-z][a-z]?)/i", $chan, $linkarray)) { #check for any image links, if while check failed it provides secondary death
  7.         die("Failed or 404");
  8.     }
  9.    
  10.     $dedup = array_unique($linkarray[1]); #there are two links to each file
  11.    
  12.     foreach($dedup as $value) {
  13.         preg_match("/i\\.4cdn\\.org\\/b\\/([\\d]+\\.[a-z][a-z][a-z][a-z]?)/i", $value, $valarray); #Capture 'filename.extention'
  14.         if(file_exists("/b/img/".$valarray[1])) { #if file exists
  15.             continue;
  16.         }else{ #if file does not exist
  17.             file_put_contents("/b/img/".$valarray[1], file_get_contents("http://".$value)); #put file
  18.             echo($valarray[1].": Done.\n");
  19.         }
  20.     }
  21.    
  22.     echo("Looping in 5s to check again.\n");
  23.    
  24.     sleep(5); #wait a bit
  25. }
  26. echo("Done.\n");
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement