-
-
Save avdg/908701 to your computer and use it in GitHub Desktop.
Revisions
-
avdg revised this gist
Apr 7, 2011 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,21 +11,21 @@ function curl_get_contents($url, $timeout = 30, $settings_array = array()) ); // We assume nobody's going to try to overwrite the settings above array_merge($curl_options,$settings_array); if (!$curl_open = curl_init()) { $return = false; } curl_setopt_array($curl_open, $curl_options); $return = curl_exec($curl_open); curl_close($curl_open); // Close CURL } elseif (function_exists("passthru")) { $cmd = "curl -m $timeout -s-url ".$url; // Set up command ob_start(); passthru($cmd, $status); // Run command $return = ob_get_contents(); // Put everything into the variable ob_end_clean(); if ($status > 1) { return false; } } -
avdg revised this gist
Apr 7, 2011 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ <?php function curl_get_contents($url, $timeout = 30, $settings_array = array()) { $return false; if (function_exists("curl_init")) { $curl_options = array( CURLOPT_URL => $url, @@ -27,8 +28,6 @@ function curl_get_contents($url, $timeout = 30, $settings_array = array()) if($status > 1) { return false; } } return $return; } -
avdg revised this gist
Apr 7, 2011 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,17 +17,18 @@ function curl_get_contents($url, $timeout = 30, $settings_array = array()) $return = curl_exec($curl_open); curl_close($curl_open); // Close CURL } elseif(function_exists("passthru")) { $cmd = "curl -m $timeout -s-url ".$url; // Set up command ob_start(); passthru($cmd, $status); // Run command $return = ob_get_contents(); // Put everything into the variable ob_end_clean(); if($status > 1) { return false; } } else { return false; } return $return; } -
avdg revised this gist
Apr 7, 2011 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php function curl_get_contents($url, $timeout = 30, $settings_array = array()) { if (function_exists("curl_init")) { $curl_options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, @@ -23,10 +23,10 @@ function curl_get_contents($url,$timeout=30,$settings_array=array()) $return = ob_get_contents(); // Put everything into the variable ob_end_clean(); if($status > 1) { return false; } } else { return false; } return $return; } -
Ttech revised this gist
Apr 7, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ function curl_get_contents($url,$timeout=30,$settings_array=array()) $cmd = "curl -m $timeout -s-url ".$url.""; // Set up command ob_start(); passthru($cmd, $status); // Run command $return = ob_get_contents(); // Put everything into the variable ob_end_clean(); if($status > 1) { $return = false; -
Ttech revised this gist
Apr 7, 2011 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,10 +11,10 @@ function curl_get_contents($url,$timeout=30,$settings_array=array()) // We assume nobody's going to try to overwrite the settings above array_merge($curl_options,$settings_array); if(!$curl_open = curl_init()){ $return = false; } curl_setopt_array($curl_open, $curl_options); $return = curl_exec($curl_open); curl_close($curl_open); // Close CURL } elseif(function_exists("passthru")) { $cmd = "curl -m $timeout -s-url ".$url.""; // Set up command @@ -23,8 +23,11 @@ function curl_get_contents($url,$timeout=30,$settings_array=array()) return ob_get_contents(); // Put everything into the variable ob_end_clean(); if($status > 1) { $return = false; } } else { $return = false; } return $return; } ?> -
Ttech revised this gist
Apr 7, 2011 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,8 +25,6 @@ function curl_get_contents($url,$timeout=30,$settings_array=array()) if($status > 1) { return false; } } } ?> -
Ttech revised this gist
Apr 7, 2011 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,8 +18,6 @@ function curl_get_contents($url,$timeout=30,$settings_array=array()) curl_close($curl_open); // Close CURL } elseif(function_exists("passthru")) { $cmd = "curl -m $timeout -s-url ".$url.""; // Set up command ob_start(); passthru($cmd, $status); // Run command return ob_get_contents(); // Put everything into the variable -
Ttech revised this gist
Apr 7, 2011 . 3 changed files with 5 additions and 127 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,82 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,38 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,26 +11,24 @@ function curl_get_contents($url,$timeout=30,$settings_array=array()) // We assume nobody's going to try to overwrite the settings above array_merge($curl_options,$settings_array); if(!$curl_open = curl_init()){ return false; } curl_setopt_array($curl_open, $curl_options); return curl_exec($curl_open); curl_close($curl_open); // Close CURL } elseif(function_exists("passthru")) { $cmd = "curl -m $timeout -s-url ".$url.""; // Set up command echo $cmd; /* The only way I could get a correctly formated file into a variable */ ob_start(); passthru($cmd, $status); // Run command return ob_get_contents(); // Put everything into the variable ob_end_clean(); if($status > 1) { return false; } } else { return false; } } ?> -
Ttech revised this gist
Apr 7, 2011 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ <?php function curl_get_contents($url,$timeout=30,$settings_array=array()) { if(function_exists("curl_init")){ $curl_options = array( @@ -9,9 +9,7 @@ function curl_get_contents($url,$timeout=30,$settings_array=false) CURLOPT_HEADER => false ); // We assume nobody's going to try to overwrite the settings above array_merge($curl_options,$settings_array); if(!$curl_open = curl_init()){ $return = false; } -
Ttech revised this gist
Apr 7, 2011 . 1 changed file with 82 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,82 @@ 2,5c2,34 < function curl_get_contents($file, $timeout=30, $settings_array=FAlSE) { < if(function_exists('curl_init')) { < if(!$curl_open = curl_init()) { < trigger_error("Failed to start CURL", E_USER_ERROR); --- > function curl_get_contents($url,$timeout=30,$settings_array=false) > { > if(function_exists("curl_init")){ > $curl_options = array( > CURLOPT_URL => $url, > CURLOPT_RETURNTRANSFER => true, > CURLOPT_TIMEOUT => intval($timeout), > CURLOPT_HEADER => false > ); > // We assume nobody's going to try to overwrite the settings above > if(is_array($settings_array)){ > array_merge($curl_options,$settings_array); > } > if(!$curl_open = curl_init()){ > $return = false; > } > curl_setopt_array($curl_open, $curl_options); > $return = curl_exec($curl_open); > curl_close($curl_open); // Close CURL > } elseif(function_exists("passthru")) { > $cmd = "curl -m $timeout -s-url ".$url.""; // Set up command > echo $cmd; > /* The only way I could get a correctly formated file into a variable */ > ob_start(); > passthru($cmd, $status); // Run command > $return = ob_get_contents(); // Put everything into the variable > ob_end_clean(); > if($status > 1) { > $return = false; > } > } else { > trigger_error("Unable to run cURL", E_USER_ERROR); > $return = false; 7,45c36,37 < < curl_setopt($curl_open, CURLOPT_URL, $file); // Set URL < curl_setopt($curl_open, CURLOPT_RETURNTRANSFER, TRUE); < curl_setopt($curl_open, CURLOPT_TIMEOUT, intval($timeout)); < curl_setopt($curl_open, CURLOPT_HEADER, FALSE); < curl_setopt($curl_open, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); < < /* Let the user set extra options if they want to */ < if($settings_array == TRUE && (is_array($settings_array))) { < $pre_set(CURLOPT_URL, CURLOPT_RETURNTRANSFER, CURLOPT_TIMEOUT, CURLOPT_HEADER, CURLOPT_USERAGENT); < foreach($settings_array as $setting => $value){ < /* Remove any options that were already set */ < if(!isset($pre_set[$setting])) { < if(!curl_setopt($curl_open, $setting, $value)) { < trigger_error("Could not set "$setting"", E_USER_WARNING); // The script may still work, so lets just try < } < } < } < } < $ret = curl_exec($curl_open); // Open the URL and put the contents into $ret < curl_close($curl_open); // Close CURL < } elseif(function_exists('passthru') && (stristr($_SERVER['SERVER_SOFTWARE'], "nix"))) { < < $cmd = "curl -m ".$timeout." -A "".$_SERVER['HTTP_USER_AGENT']."" -url ".$file.""; // Set up command < /* The only way I could get a correctly formated file into a variable */ < ob_start(); < passthru($cmd, $status); // Run command < $ret = ob_get_contents(); // Put everything into the variable < ob_end_clean(); < if(isset($status) && ($status> 1)) { < trigger_error("Bad command line arguments", E_USER_WARNING); // The script may still work, so lets just try < } < } else { < /* If the CURL extention and the command line CURL are not found */ < trigger_error("Could not find or run CURL", E_USER_ERROR); < exit; // If the script is not already stopped, stop the script now since we can't really do anything < } < /* If everything worked correctly return the URL contents */ < return $ret; --- > return $return; // Why??? > } -
Ttech revised this gist
Apr 7, 2011 . 1 changed file with 35 additions and 43 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,46 +1,38 @@ <?php function curl_get_contents($url,$timeout=30,$settings_array=false) { if(function_exists("curl_init")){ $curl_options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => intval($timeout), CURLOPT_HEADER => false ); // We assume nobody's going to try to overwrite the settings above if(is_array($settings_array)){ array_merge($curl_options,$settings_array); } if(!$curl_open = curl_init()){ $return = false; } curl_setopt_array($curl_open, $curl_options); $return = curl_exec($curl_open); curl_close($curl_open); // Close CURL } elseif(function_exists("passthru")) { $cmd = "curl -m $timeout -s-url ".$url.""; // Set up command echo $cmd; /* The only way I could get a correctly formated file into a variable */ ob_start(); passthru($cmd, $status); // Run command $return = ob_get_contents(); // Put everything into the variable ob_end_clean(); if($status > 1) { $return = false; } } else { trigger_error("Unable to run cURL", E_USER_ERROR); $return = false; } return $return; // Why??? } ?> -
Ttech created this gist
Apr 7, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ <?php function curl_get_contents($file, $timeout=30, $settings_array=FAlSE) { if(function_exists('curl_init')) { if(!$curl_open = curl_init()) { trigger_error("Failed to start CURL", E_USER_ERROR); } curl_setopt($curl_open, CURLOPT_URL, $file); // Set URL curl_setopt($curl_open, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl_open, CURLOPT_TIMEOUT, intval($timeout)); curl_setopt($curl_open, CURLOPT_HEADER, FALSE); curl_setopt($curl_open, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); /* Let the user set extra options if they want to */ if($settings_array == TRUE && (is_array($settings_array))) { $pre_set(CURLOPT_URL, CURLOPT_RETURNTRANSFER, CURLOPT_TIMEOUT, CURLOPT_HEADER, CURLOPT_USERAGENT); foreach($settings_array as $setting => $value){ /* Remove any options that were already set */ if(!isset($pre_set[$setting])) { if(!curl_setopt($curl_open, $setting, $value)) { trigger_error("Could not set "$setting"", E_USER_WARNING); // The script may still work, so lets just try } } } } $ret = curl_exec($curl_open); // Open the URL and put the contents into $ret curl_close($curl_open); // Close CURL } elseif(function_exists('passthru') && (stristr($_SERVER['SERVER_SOFTWARE'], "nix"))) { $cmd = "curl -m ".$timeout." -A "".$_SERVER['HTTP_USER_AGENT']."" -url ".$file.""; // Set up command /* The only way I could get a correctly formated file into a variable */ ob_start(); passthru($cmd, $status); // Run command $ret = ob_get_contents(); // Put everything into the variable ob_end_clean(); if(isset($status) && ($status> 1)) { trigger_error("Bad command line arguments", E_USER_WARNING); // The script may still work, so lets just try } } else { /* If the CURL extention and the command line CURL are not found */ trigger_error("Could not find or run CURL", E_USER_ERROR); exit; // If the script is not already stopped, stop the script now since we can't really do anything } /* If everything worked correctly return the URL contents */ return $ret; ?> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ <?php function curl_get_contents($url,$timeout=30,$settings_array=false) { if(function_exists("curl_init")){ $curl_options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => intval($timeout), CURLOPT_HEADER => false ); // We assume nobody's going to try to overwrite the settings above if(is_array($settings_array)){ array_merge($curl_options,$settings_array); } if(!$curl_open = curl_init()){ $return = false; } curl_setopt_array($curl_open, $curl_options); $return = curl_exec($curl_open); curl_close($curl_open); // Close CURL } elseif(function_exists("passthru")) { $cmd = "curl -m $timeout -s-url ".$url.""; // Set up command echo $cmd; /* The only way I could get a correctly formated file into a variable */ ob_start(); passthru($cmd, $status); // Run command $return = ob_get_contents(); // Put everything into the variable ob_end_clean(); if($status > 1) { $return = false; } } else { trigger_error("Unable to run cURL", E_USER_ERROR); $return = false; } return $return; // Why??? } ?>