DraKiNs

[PHP] directDownload

Nov 19th, 2011
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. /*
  2.  * Download direto através do link "DOWNLOAD"
  3.  * Example: directDownload("http://mp3skull.com/mp3/drake_hate_sleeping_alone.html");
  4.  *
  5.  * Criador: Por Bruno da Silva
  6.  * Regex: http://www.the-art-of-web.com/php/parse-links/
  7.  *
  8.  *
  9.  * Equipe de Programadores [iPs]TeaM
  10.  *
  11. */
  12.  
  13. function directDownload($url)
  14. {
  15.     if(preg_match_all("/<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>/siU", @file_get_contents($url), $findLinks, PREG_SET_ORDER))
  16.     {
  17.         foreach($findLinks as $link) if(strpos($link[3], "Download") !== false)
  18.         {
  19.             header('Content-type: mp3');
  20.             header('Content-Disposition: attachment; filename="musica.mp3"');
  21.             readfile($link[2]);
  22.         }
  23.     }
  24.     return true;
  25. }
Add Comment
Please, Sign In to add comment