aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormarijus <mario@localhost.localdomain>2013-12-02 11:30:02 +0100
committermarijus <mario@localhost.localdomain>2013-12-02 11:30:02 +0100
commitfc8c34826ea361a49c29742f15b98b573e6c7c86 (patch)
tree082c5d1c39a358cc19bcbb9465ccf831f134b751 /include
parent51cad9cafef228090cc1641a425ba272b1a3b470 (diff)
parentf22302cbb649013087e27ba5d6679dcefb3953f1 (diff)
downloadvolse-hubzilla-fc8c34826ea361a49c29742f15b98b573e6c7c86.tar.gz
volse-hubzilla-fc8c34826ea361a49c29742f15b98b573e6c7c86.tar.bz2
volse-hubzilla-fc8c34826ea361a49c29742f15b98b573e6c7c86.zip
Merge branch 'master' of https://github.com/friendica/red
Diffstat (limited to 'include')
-rw-r--r--include/network.php207
-rwxr-xr-xinclude/plugin.php2
2 files changed, 3 insertions, 206 deletions
diff --git a/include/network.php b/include/network.php
index a15b89c67..dac039230 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']);
@@ -676,63 +576,6 @@ function parse_xml_string($s,$strict = true) {
return $x;
}
-function add_fcontact($arr,$update = false) {
-
- if($update) {
- $r = q("UPDATE `fcontact` SET
- `name` = '%s',
- `photo` = '%s',
- `request` = '%s',
- `nick` = '%s',
- `addr` = '%s',
- `batch` = '%s',
- `notify` = '%s',
- `poll` = '%s',
- `confirm` = '%s',
- `alias` = '%s',
- `pubkey` = '%s',
- `updated` = '%s'
- WHERE `url` = '%s' AND `network` = '%s' LIMIT 1",
- dbesc($arr['name']),
- dbesc($arr['photo']),
- dbesc($arr['request']),
- dbesc($arr['nick']),
- dbesc($arr['addr']),
- dbesc($arr['batch']),
- dbesc($arr['notify']),
- dbesc($arr['poll']),
- dbesc($arr['confirm']),
- dbesc($arr['alias']),
- dbesc($arr['pubkey']),
- dbesc(datetime_convert()),
- dbesc($arr['url']),
- dbesc($arr['network'])
- );
- }
- else {
- $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`,
- `batch`, `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` )
- values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
- dbesc($arr['url']),
- dbesc($arr['name']),
- dbesc($arr['photo']),
- dbesc($arr['request']),
- dbesc($arr['nick']),
- dbesc($arr['addr']),
- dbesc($arr['batch']),
- dbesc($arr['notify']),
- dbesc($arr['poll']),
- dbesc($arr['confirm']),
- dbesc($arr['network']),
- dbesc($arr['alias']),
- dbesc($arr['pubkey']),
- dbesc(datetime_convert())
- );
- }
-
- return $r;
-}
-
function scale_external_images($s, $include_link = true, $scale_replace = false) {
@@ -810,52 +653,6 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
return $s;
}
-
-function fix_contact_ssl_policy(&$contact,$new_policy) {
-
- $ssl_changed = false;
- if((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'],'https:')) {
- $ssl_changed = true;
- $contact['url'] = str_replace('https:','http:',$contact['url']);
- $contact['request'] = str_replace('https:','http:',$contact['request']);
- $contact['notify'] = str_replace('https:','http:',$contact['notify']);
- $contact['poll'] = str_replace('https:','http:',$contact['poll']);
- $contact['confirm'] = str_replace('https:','http:',$contact['confirm']);
- $contact['poco'] = str_replace('https:','http:',$contact['poco']);
- }
-
- if((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'],'http:')) {
- $ssl_changed = true;
- $contact['url'] = str_replace('http:','https:',$contact['url']);
- $contact['request'] = str_replace('http:','https:',$contact['request']);
- $contact['notify'] = str_replace('http:','https:',$contact['notify']);
- $contact['poll'] = str_replace('http:','https:',$contact['poll']);
- $contact['confirm'] = str_replace('http:','https:',$contact['confirm']);
- $contact['poco'] = str_replace('http:','https:',$contact['poco']);
- }
-
- if($ssl_changed) {
- q("update contact set
- url = '%s',
- request = '%s',
- notify = '%s',
- poll = '%s',
- confirm = '%s',
- poco = '%s'
- where id = %d limit 1",
- dbesc($contact['url']),
- dbesc($contact['request']),
- dbesc($contact['notify']),
- dbesc($contact['poll']),
- dbesc($contact['confirm']),
- dbesc($contact['poco']),
- intval($contact['id'])
- );
- }
-}
-
-
-
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
diff --git a/include/plugin.php b/include/plugin.php
index 4d28909d2..5ed2a1736 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -197,7 +197,7 @@ function load_hooks() {
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
}
}
-logger('hooks: ' . print_r($a->hooks,true));
+//logger('hooks: ' . print_r($a->hooks,true));
}