Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 5th, 2014  |  syntax: PHP  |  size: 1.24 KB  |  views: 163  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <html>
  2. <head>
  3.         <meta charset="UTF-8">
  4.         <title>SDSSKLÖFCJOIF</title>
  5.         <style>
  6.         @font-face {
  7.                 font-family:DOS;
  8.                 src: url(../../DOS.ttf);
  9.         }
  10.         * {
  11.                 background-color: black;
  12.                 color: rgb(192,192,192);
  13.                 font-family: DOS, fixedsys, monospace;
  14.                 font-size: 12pt;
  15.         }
  16.         </style>
  17. </head>
  18. <body>
  19. <pre>
  20. <?php
  21. $tmp = file_get_contents("https://derpiboo.ru/images.json?key=q7VbqRzAz29aRVLFaoD4");
  22. $imgdata = json_decode($tmp);
  23. $imgstored = scandir("/mnt/poni/");
  24. foreach ($imgstored as $key => $value) {
  25.         preg_match("/[0-9]+/", $value, $matches);
  26.         $imgstored[$key] = $matches[0];
  27. }
  28. $imgnew = array();
  29. foreach ($imgdata->images as $img) {
  30.         array_unshift($imgnew, $img->id_number);
  31. }
  32.  
  33. $imgnew = array_diff($imgnew,$imgstored);
  34.  
  35. $start_time = microtime(true);
  36. foreach ($imgdata->images as $img) {
  37.         $filename = $img->id_number." - ".$img->created_at." - ".$img->file_name." - ".$img->tags.".".$img->original_format;
  38.         if(in_array($img->id_number, $imgnew)){
  39.                 file_put_contents("/mnt/poni/".$filename, file_get_contents("http:".$img->image));
  40.                 echo "[WRITE] ".$filename."\n";
  41.         }else{
  42.                 echo "[SKIP] ".$filename."\n";
  43.         }
  44. }
  45. echo "downloaded in ".number_format(microtime(true) - $start_time, 8)." seconds\n";
  46. ?>
  47. </pre>
  48. </body>
  49. </html>