Guest User

New mailman WordPress function - Fixed bugs

a guest
Dec 15th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.70 KB | None | 0 0
  1. <?PHP
  2. //open mailman.class.php
  3. /*
  4. find this function below:
  5.  
  6.  function fetch ($url) {^M
  7.     return file_get_contents($url);^M
  8.   }
  9.  
  10. replace with the following functon: */
  11.  
  12.  
  13.   function fetch($url)
  14.   {
  15.     if (function_exists('curl_init') AND $c=curl_init())
  16.     {
  17.       curl_setopt($c, CURLOPT_URL,                $url  );
  18.       curl_setopt($c, CURLOPT_HEADER,             false );
  19.       curl_setopt($c, CURLOPT_RETURNTRANSFER,     true  );
  20.       curl_setopt($c, CURLOPT_CONNECTTIMEOUT,     6     ); //wait 4 seconds, or use CURLOPT_CONNECTTIMEOUT_MS
  21.       curl_setopt($c, CURLOPT_TIMEOUT,            8     ); //maximum execution time for the CURL function
  22.       curl_setopt($c, CURLOPT_FORBID_REUSE,       true  );
  23.       curl_setopt($c, CURLOPT_FRESH_CONNECT,      true  );
  24.  
  25.       curl_setopt($c, CURLOPT_USERAGENT,          filter_input(
  26.                                                     INPUT_SERVER,
  27.                                                     'HTTP_USER_AGENT',
  28.                                                     FILTER_SANITIZE_STRING,
  29.                                                     FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH
  30.                                                   ));
  31.  
  32.       curl_setopt($c, CURLOPT_HTTPHEADER,         array(
  33.                                                     'http_x_forwarded_for: '.
  34.                                                     filter_input(
  35.                                                       INPUT_SERVER,
  36.                                                       'REMOTE_ADDR',
  37.                                                       FILTER_VALIDATE_IP
  38.                                                     )
  39.                                                   ));
  40.  
  41.       curl_setopt($c, CURLOPT_CUSTOMREQUEST,      'GET' );
  42.  
  43.       $data = curl_exec($c);
  44.       curl_close($c);
  45.       if (is_string($data))
  46.         return $data;
  47.       else
  48.         return false;
  49.     }
  50.     elseif
  51.       ( //for security reasons, many people disable url_fopen (some disable complete
  52.         //functions in php.ini via disable_functions = ....).
  53.         function_exists('file_get_contents') AND
  54.         function_exists('ini_get') AND             //some security DICKS disable
  55.                                                    //this function. so annoying..
  56.         ini_get('allow_url_fopen')=='on'           //file_get_contents only works
  57.                                                    //when url_fopen is allowed
  58.       )
  59.     {
  60.       return file_get_contents($url);
  61.     }
  62.     else
  63.     {
  64.       return false;
  65.     }
  66.   }
  67.  
  68.  
  69.  
  70. //below is a test function
  71. //echo fetch('http://www.facebook.com');
  72. /* DONE!!!!!
  73. Now it should be possible to access the MM
  74. */
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment