From 1516ae7e7ed77879506a32f00c9787b95106235d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 19 Jun 2013 13:38:03 +0200 Subject: [ticket/11603] Avoid using cURL PHPBB3-11603 --- git-tools/merge.php | 17 ++++++++++------- git-tools/setup_github_network.php | 21 +++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'git-tools') diff --git a/git-tools/merge.php b/git-tools/merge.php index 5eb48a53f8..08c0ecfbd0 100755 --- a/git-tools/merge.php +++ b/git-tools/merge.php @@ -124,13 +124,16 @@ function get_repository_url($username, $repository, $ssh = false) function api_request($query) { - $c = curl_init(); - curl_setopt($c, CURLOPT_URL, "https://api.github.com/$query"); - curl_setopt($c, CURLOPT_RETURNTRANSFER, true); - curl_setopt($c, CURLOPT_USERAGENT, 'phpBB/1.0'); - curl_setopt($c, CURLOPT_HEADER, true); - $contents = curl_exec($c); - curl_close($c); + return api_url_request("https://api.github.com/$query?per_page=100"); +} + +function api_url_request($url) +{ + $contents = file_get_contents($url, false, stream_context_create(array( + 'http' => array( + 'header' => "User-Agent: phpBB/1.0\r\n", + ), + ))); if ($contents === false) { diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php index c24968c7c2..e5bc89bf91 100755 --- a/git-tools/setup_github_network.php +++ b/git-tools/setup_github_network.php @@ -150,21 +150,18 @@ function api_request($query) function api_url_request($url) { - $c = curl_init(); - curl_setopt($c, CURLOPT_URL, $url); - curl_setopt($c, CURLOPT_RETURNTRANSFER, true); - curl_setopt($c, CURLOPT_USERAGENT, 'phpBB/1.0'); - curl_setopt($c, CURLOPT_HEADER, true); - $contents = curl_exec($c); - curl_close($c); + $contents = file_get_contents($url, false, stream_context_create(array( + 'http' => array( + 'header' => "User-Agent: phpBB/1.0\r\n", + ), + ))); $sub_request_result = array(); // Split possible headers from the body - if ($contents && strpos($contents, "\r\n\r\n") > 0) + if (!empty($http_response_header)) { - list($header, $contents) = explode("\r\n\r\n", $contents); - foreach (explode("\n", $header) as $header_element) - { + foreach ($http_response_header as $header_element) + { // Find Link Header which gives us a link to the next page if (strpos($header_element, 'Link: ') === 0) { @@ -179,7 +176,7 @@ function api_url_request($url) } } } - } + } } if ($contents === false) -- cgit v1.2.1