aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/network.php104
-rw-r--r--mod/match.php12
2 files changed, 10 insertions, 106 deletions
diff --git a/include/network.php b/include/network.php
index a15b89c67..77ba7b176 100644
--- a/include/network.php
+++ b/include/network.php
@@ -6,108 +6,6 @@ function get_capath() {
return appdirpath() . '/library/cacert.pem';
}
-
-
-// curl wrapper. If binary flag is true, return binary
-// results.
-
-/**
- * fetch_url is deprecated and being replaced by the more capable z_fetch_url
- * please use that function instead.
- * Once all occurrences of fetch_url are removed from the codebase we will
- * remove this function and perhaps rename z_fetch_url back to fetch_url
- */
-
-// post request to $url. $params is an array of post variables.
-
-
-function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) {
- $a = get_app();
- $ch = curl_init($url);
- if(($redirects > 8) || (! $ch))
- return false;
-
- curl_setopt($ch, CURLOPT_HEADER, true);
- @curl_setopt($ch, CURLOPT_CAINFO, get_capath());
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch, CURLOPT_POST,1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
- curl_setopt($ch, CURLOPT_USERAGENT, "Red");
-
- if(intval($timeout)) {
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- }
- else {
- $curl_time = intval(get_config('system','curl_timeout'));
- curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
- }
-
- if(defined('LIGHTTPD')) {
- if(!is_array($headers)) {
- $headers = array('Expect:');
- } else {
- if(!in_array('Expect:', $headers)) {
- array_push($headers, 'Expect:');
- }
- }
- }
- if($headers)
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
-
- $check_cert = get_config('system','verifyssl');
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
- $prx = get_config('system','proxy');
- if(strlen($prx)) {
- curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
- curl_setopt($ch, CURLOPT_PROXY, $prx);
- $prxusr = get_config('system','proxyuser');
- if(strlen($prxusr))
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
- }
-
-
- // don't let curl abort the entire application
- // if it throws any errors.
-
- $s = @curl_exec($ch);
-
- $base = $s;
- $curl_info = curl_getinfo($ch);
- $http_code = $curl_info['http_code'];
-
- $header = '';
-
- // Pull out multiple headers, e.g. proxy and continuation headers
- // allow for HTTP/2.x without fixing code
-
- while(preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) {
- $chunk = substr($base,0,strpos($base,"\r\n\r\n")+4);
- $header .= $chunk;
- $base = substr($base,strlen($chunk));
- }
-
- if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307 || $http_code == 308) {
- $matches = array();
- preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
- $newurl = trim(array_pop($matches));
- if(strpos($newurl,'/') === 0)
- $newurl = $url . $newurl;
- $url_parsed = @parse_url($newurl);
- if (isset($url_parsed)) {
- $redirects++;
- @curl_close($ch);
- return post_url($newurl,$params,$redirects,$timeout);
- }
- }
-
- $body = substr($s,strlen($header));
- curl_close($ch);
- return($body);
-}
-
-
-
-
/**
* @function z_fetch_url
* @param string $url
@@ -251,6 +149,8 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
"Accept: " . $opts['accept_content']
));
}
+ if(x($opts,'headers'))
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
if(x($opts,'timeout') && intval($opts['timeout'])) {
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
diff --git a/mod/match.php b/mod/match.php
index 23eeb9370..5447f755d 100644
--- a/mod/match.php
+++ b/mod/match.php
@@ -1,5 +1,9 @@
<?php
+// FIXME - this has never been properly ported from Friendica
+// It takes keywords from your profile and queries the directory server for
+// matching keywords from other profiles.
+
function match_content(&$a) {
@@ -30,10 +34,10 @@ function match_content(&$a) {
if($a->pager['page'] != 1)
$params['p'] = $a->pager['page'];
- if(strlen(get_config('system','directory_submit_url')))
- $x = post_url('http://dir.friendica.com/msearch', $params);
- else
- $x = post_url($a->get_baseurl() . '/msearch', $params);
+// if(strlen(get_config('system','directory_submit_url')))
+// $x = post_url('http://dir.friendica.com/msearch', $params);
+// else
+// $x = post_url($a->get_baseurl() . '/msearch', $params);
$j = json_decode($x);