Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. $urls = get_all_content();
  3.  
  4. $uniqueUrls = [];
  5. foreach ($urls as $url){
  6.     #some of the urls are .json files.  we want to skip those
  7.    if (!preg_match("/\.json$/", $url)) {
  8.         echo "$url\n";
  9.         foreach(find_cdn_images($url) as $tmpUrl){
  10.             $uniqueUrls[] = $tmpUrl;
  11.         }
  12.     }
  13. }
  14.  
  15. $fp = fopen('data.txt', 'a');//opens file in append mode.
  16. foreach(array_unique($uniqueUrls) as $tmpUrl){
  17.     fwrite($fp, "$tmpUrl\n");
  18. }
  19.  
  20. fclose($fp);
  21.  
  22. /*
  23. foreach(array_unique($uniqueUrls) as $tmpUrl){
  24.     shell_exec("wget \"$tmpUrl\"");
  25. }
  26. */
  27.  
  28. function get_all_content(){
  29.     $data = json_decode(file_get_contents("https://www.northernquest.com/rebuild-cache.json"), true);
  30.     return array_unique($data);
  31. }
  32.  
  33. function find_cdn_images($url){
  34.     $imageUrls = [];
  35.     $html = file_get_contents($url);
  36.     preg_match_all("/src=\"(https:\/\/78fbf27087a4dfa6b5bd-a5ec6c2236045063e04d541df309bb74.ssl.cf2.rackcdn.com\/[^\"]*)\"/", $html, $matches);
  37.     $imageUrls = array_merge($imageUrls, $matches[1]);
  38.    
  39.     preg_match_all("/background-image: url\(([^\)]*)\)/", $html, $matches);
  40.     $imageUrls = array_merge($imageUrls, $matches[1]);
  41.     return array_unique($imageUrls);
  42. }
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement