diff options
-rw-r--r-- | boot.php | 3 | ||||
-rw-r--r-- | include/delivery.php | 1 | ||||
-rw-r--r-- | include/network.php | 94 | ||||
-rw-r--r-- | include/zot.php | 14 | ||||
-rw-r--r-- | version.inc | 2 |
5 files changed, 110 insertions, 4 deletions
@@ -13,7 +13,8 @@ require_once('library/Mobile_Detect/Mobile_Detect.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica Red'); define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1154 ); +define ( 'ZOT_REVISION', 1 ); +define ( 'DB_UPDATE_VERSION', 1154 ); define ( 'EOL', "<br />\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/delivery.php b/include/delivery.php index 8f4f1fc39..0d84b4626 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -65,6 +65,7 @@ function delivery_run($argv, $argc){ } // It's ours to deliver. Remove it from the queue. + // should probably set to "pending" or some such q("delete from deliverq where cmd = '%s' and item = %d and contact = %d limit 1", dbesc($cmd), diff --git a/include/network.php b/include/network.php index 54e7e023d..8b26713b9 100644 --- a/include/network.php +++ b/include/network.php @@ -182,6 +182,100 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) return($body); }} + + + +if(! function_exists('z_post_url')) { +function z_post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) { + + $ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => ""); + + $ch = curl_init($url); + if(($redirects > 8) || (! $ch)) + return ret; + + curl_setopt($ch, CURLOPT_HEADER, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_POST,1); + curl_setopt($ch, CURLOPT_POSTFIELDS,$params); + curl_setopt($ch, CURLOPT_USERAGENT, "Friendica"); + + 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) { + $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 z_post_url($newurl,$params,$headers,$redirects,$timeout); + } + } + $rc = intval($http_code); + $ret['return_code'] = $rc; + $ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false); + $ret['body'] = substr($s,strlen($header)); + $ret['header'] = $header; + curl_close($ch); + return($ret); +}} + + + + // Generic XML return // Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable // of $st and an optional text <message> of $message and terminates the current process. diff --git a/include/zot.php b/include/zot.php index 82bd8c7f1..cb57c2d84 100644 --- a/include/zot.php +++ b/include/zot.php @@ -10,7 +10,7 @@ function zot_new_uid($entity_id) { $rawstr = z_root() . '/' . $entity_id . '.' . mt_rand(); - return(base64url_encode(hash('whirlpool',$rawstr,true),true)); + return(base64url_encode(hash('whirlpool',$rawstr,true),true) . '.' . mt_rand()); } @@ -53,4 +53,14 @@ function zot_sign(&$item,$identity) { function zot_verify(&$item,$identity) { return rsa_verify($item[signed'],base64url_decode($item['signature']),$identity['pubkey']); -}
\ No newline at end of file +} + + + +function zot_notify($entity,$url) { + $x = z_post_url($url, + array('zot_uid' => $entity_global_id, 'callback' => z_root() . '/zot', 'spec' => ZOT_REVISION)); + return($x); +} + + diff --git a/version.inc b/version.inc index 2488b0fe0..554d35a50 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2012-07-30.31 +2012-07-31.32 |