aboutsummaryrefslogtreecommitdiffstats
path: root/git-tools
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-06-19 13:38:03 +0200
committerJoas Schilling <nickvergessen@gmx.de>2013-06-19 13:38:03 +0200
commit1516ae7e7ed77879506a32f00c9787b95106235d (patch)
treeac3bbdf8b796d52a4112f304c898ce0414a1a5b3 /git-tools
parenta7af0134c0cdd5577a094e78ddae258711591b10 (diff)
downloadforums-1516ae7e7ed77879506a32f00c9787b95106235d.tar
forums-1516ae7e7ed77879506a32f00c9787b95106235d.tar.gz
forums-1516ae7e7ed77879506a32f00c9787b95106235d.tar.bz2
forums-1516ae7e7ed77879506a32f00c9787b95106235d.tar.xz
forums-1516ae7e7ed77879506a32f00c9787b95106235d.zip
[ticket/11603] Avoid using cURL
PHPBB3-11603
Diffstat (limited to 'git-tools')
-rwxr-xr-xgit-tools/merge.php17
-rwxr-xr-xgit-tools/setup_github_network.php21
2 files changed, 19 insertions, 19 deletions
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)