Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 27th, 2012  |  syntax: PHP  |  size: 1.56 KB  |  views: 61  |  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. <?php
  2.  
  3.     $var = fread_url("http://www.entendu.info");
  4.            
  5.     preg_match_all ("/a[\s]+[^>]*?href[\s]?=[\s\"\']+".
  6.                     "(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/",
  7.                     $var, &$matches);
  8.        
  9.     $matches = $matches[1];
  10.     $list = array();
  11.  
  12.     foreach($matches as $var)
  13.     {    
  14.         print($var."<br>");
  15.     }
  16.  
  17.        
  18.        
  19.        
  20.        
  21.        
  22.  
  23. // The fread_url function allows you to get a complete
  24. // page. If CURL is not installed replace the contents with
  25. // a fopen / fget loop
  26.  
  27.     function fread_url($url,$ref="")
  28.     {
  29.         if(function_exists("curl_init")){
  30.             $ch = curl_init();
  31.             $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; ".
  32.                           "Windows NT 5.0)";
  33.             $ch = curl_init();
  34.             curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  35.             curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
  36.             curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  37.             curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
  38.             curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
  39.             curl_setopt( $ch, CURLOPT_URL, $url );
  40.             curl_setopt( $ch, CURLOPT_REFERER, $ref );
  41.             curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  42.             $html = curl_exec($ch);
  43.             curl_close($ch);
  44.         }
  45.         else{
  46.             $hfile = fopen($url,"r");
  47.             if($hfile){
  48.                 while(!feof($hfile)){
  49.                     $html.=fgets($hfile,1024);
  50.                 }
  51.             }
  52.         }
  53.         return $html;
  54.  
  55.     }
  56.        
  57. ?>