Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function curl_get( $url )
- {
- if(function_exists('curl_init') && !ini_get("safe_mode") && empty(ini_get("open_basedir")))
- {
- $options = array(
- CURLOPT_RETURNTRANSFER => true, // return web page
- CURLOPT_HEADER => false, // don't return headers
- CURLOPT_FOLLOWLOCATION => true, // follow redirects
- CURLOPT_ENCODING => "", // handle all encodings
- CURLOPT_USERAGENT => "spider", // who am i
- CURLOPT_AUTOREFERER => true, // set referer on redirect
- CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
- CURLOPT_TIMEOUT => 120, // timeout on response
- CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
- );
- $ch = curl_init( $url );
- curl_setopt_array( $ch, $options );
- $content = curl_exec( $ch );
- $err = curl_errno( $ch );
- $errmsg = curl_error( $ch );
- $header = curl_getinfo( $ch );
- curl_close( $ch );
- $header['errno'] = $err;
- $header['errmsg'] = $errmsg;
- $header['content'] = $content;
- return $header;
- } else if(function_exists('fopen') && function_exists('fread') && function_exists('fclose'))
- {
- $x = array();
- $fp = fsockopen("ezirc.org", 80);
- $out = "GET /a/news.php HTTP/1.1\r\n";
- $out .= "Host: www.ezirc.org\r\n";
- $out .= "Connection: Close\r\n\r\n";
- fwrite($fp, $out);
- while(!feof($fp))
- {
- $x['content'] .= fgets($fp, 512);
- }
- fclose($fp);
- return $x;
- } else {
- return array('content' => 'Fetch failed due to no external reading capabilities.');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement