aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMichael <icarus@dabo.de>2012-02-27 00:03:51 +0100
committerMichael <icarus@dabo.de>2012-02-27 00:03:51 +0100
commit18679111f5aed8f1c5e7ccb9857195e52c57765d (patch)
treebffb4a563ed2fe1ff02a4221e28c608460c866db /include
parentfe3dfbee5638dd2988bd8b126652b3138572f02c (diff)
parent6ddd444afde33337235eab3aa9d6d1fe12bcb7a4 (diff)
downloadvolse-hubzilla-18679111f5aed8f1c5e7ccb9857195e52c57765d.tar.gz
volse-hubzilla-18679111f5aed8f1c5e7ccb9857195e52c57765d.tar.bz2
volse-hubzilla-18679111f5aed8f1c5e7ccb9857195e52c57765d.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'include')
-rwxr-xr-xinclude/Scrape.php17
-rwxr-xr-xinclude/config.php2
-rwxr-xr-xinclude/conversation.php6
-rwxr-xr-xinclude/event.php2
-rwxr-xr-xinclude/items.php6
-rwxr-xr-xinclude/network.php19
-rwxr-xr-xinclude/template_processor.php15
-rwxr-xr-xinclude/text.php2
8 files changed, 41 insertions, 28 deletions
diff --git a/include/Scrape.php b/include/Scrape.php
index e98978f38..4c4ad3cdb 100755
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -230,11 +230,16 @@ function scrape_feed($url) {
$ret = array();
$s = fetch_url($url);
- if(! $s)
+ $headers = $a->get_curl_headers();
+ $code = $a->get_curl_code();
+
+ logger('scrape_feed: returns: ' . $code . ' headers=' . $headers, LOGGER_DEBUG);
+
+ if(! $s) {
+ logger('scrape_feed: no data returned for ' . $url);
return $ret;
+ }
- $headers = $a->get_curl_headers();
- logger('scrape_feed: headers=' . $headers, LOGGER_DEBUG);
$lines = explode("\n",$headers);
if(count($lines)) {
@@ -258,8 +263,10 @@ function scrape_feed($url) {
logger('scrape_feed: parse error: ' . $e);
}
- if(! $dom)
+ if(! $dom) {
+ logger('scrape_feed: failed to parse.');
return $ret;
+ }
$head = $dom->getElementsByTagName('base');
@@ -565,7 +572,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if($check_feed) {
$feedret = scrape_feed(($poll) ? $poll : $url);
- logger('probe_url: scrape_feed returns: ' . print_r($feedret,true), LOGGER_DATA);
+ logger('probe_url: scrape_feed ' . (($poll)? $poll : $url) . ' returns: ' . print_r($feedret,true), LOGGER_DATA);
if(count($feedret) && ($feedret['feed_atom'] || $feedret['feed_rss'])) {
$poll = ((x($feedret,'feed_atom')) ? unamp($feedret['feed_atom']) : unamp($feedret['feed_rss']));
if(! x($vcard))
diff --git a/include/config.php b/include/config.php
index 92694f519..2cddda0b8 100755
--- a/include/config.php
+++ b/include/config.php
@@ -162,7 +162,7 @@ function del_config($family,$key) {
if(x($a->config[$family],$key))
unset($a->config[$family][$key]);
$ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($cat),
+ dbesc($family),
dbesc($key)
);
return $ret;
diff --git a/include/conversation.php b/include/conversation.php
index 3d13a1179..53369cf20 100755
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -232,7 +232,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$alike = array();
$dlike = array();
-
+ $o = "";
// array with html for each thread (parent+comments)
$threads = array();
@@ -436,7 +436,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
else {
// prevent private email from leaking into public conversation
- if((! $toplevelpost) && (! toplevelprivate) && ($item['private']) && ($profile_owner != local_user()))
+ if((! $toplevelpost) && (! $toplevelprivate) && ($item['private']) && ($profile_owner != local_user()))
continue;
$comments_seen ++;
}
@@ -641,7 +641,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$body = prepare_body($item,true);
$tmp_item = replace_macros($template,array(
- '$type' => implode("",array_slice(split("/",$item['verb']),-1)),
+ '$type' => implode("",array_slice(explode("/",$item['verb']),-1)),
'$tags' => $tags,
'$body' => template_escape($body),
'$id' => $item['item_id'],
diff --git a/include/event.php b/include/event.php
index c7669b381..4a9a9a004 100755
--- a/include/event.php
+++ b/include/event.php
@@ -163,7 +163,7 @@ function bbtoevent($s) {
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
$ev['adjust'] = $match[1];
$match = '';
- $ev['nofinish'] = (($ev['start'] && (! $ev['finish'])) ? 1 : 0);
+ $ev['nofinish'] = (($ev['start'] && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0);
return $ev;
}
diff --git a/include/items.php b/include/items.php
index c461b83b4..7d52571c2 100755
--- a/include/items.php
+++ b/include/items.php
@@ -308,7 +308,7 @@ function get_atom_elements($feed,$item) {
if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
$base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
foreach($base as $link) {
- if(! $res['author-avatar']) {
+ if(!x($res, 'author-avatar') || !$res['author-avatar']) {
if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar')
$res['author-avatar'] = unxmlify($link['attribs']['']['href']);
}
@@ -323,7 +323,7 @@ function get_atom_elements($feed,$item) {
foreach($base as $link) {
if($link['attribs']['']['rel'] === 'alternate' && (! $res['author-link']))
$res['author-link'] = unxmlify($link['attribs']['']['href']);
- if(! $res['author-avatar']) {
+ if(!x($res, 'author-avatar') || !$res['author-avatar']) {
if($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo')
$res['author-avatar'] = unxmlify($link['attribs']['']['href']);
}
@@ -503,7 +503,7 @@ function get_atom_elements($feed,$item) {
$base = $rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
foreach($base as $link) {
- if(! $res['owner-avatar']) {
+ if(!x($res, 'owner-avatar') || !$res['owner-avatar']) {
if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar')
$res['owner-avatar'] = unxmlify($link['attribs']['']['href']);
}
diff --git a/include/network.php b/include/network.php
index 531c3ea4c..c72919dd8 100755
--- a/include/network.php
+++ b/include/network.php
@@ -17,7 +17,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
if (!is_null($accept_content)){
curl_setopt($ch,CURLOPT_HTTPHEADER, array (
- "Accept: "+$accept_content
+ "Accept: " . $accept_content
));
}
@@ -60,6 +60,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
$curl_info = @curl_getinfo($ch);
$http_code = $curl_info['http_code'];
+// logger('fetch_url:' . $http_code . ' data: ' . $s);
$header = '';
// Pull out multiple headers, e.g. proxy and continuation headers
@@ -74,11 +75,13 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
- $url = trim(array_pop($matches));
- $url_parsed = @parse_url($url);
+ $newurl = trim(array_pop($matches));
+ if(strpos($newurl,'/') === 0)
+ $newurl = $url . $newurl;
+ $url_parsed = @parse_url($newurl);
if (isset($url_parsed)) {
$redirects++;
- return fetch_url($url,$binary,$redirects,$timeout);
+ return fetch_url($newurl,$binary,$redirects,$timeout);
}
}
@@ -163,11 +166,13 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
if($http_code == 301 || $http_code == 302 || $http_code == 303) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
- $url = trim(array_pop($matches));
- $url_parsed = @parse_url($url);
+ $newurl = trim(array_pop($matches));
+ if(strpos($newurl,'/') === 0)
+ $newurl = $url . $newurl;
+ $url_parsed = @parse_url($newurl);
if (isset($url_parsed)) {
$redirects++;
- return post_url($url,$params,$headers,$redirects,$timeout);
+ return fetch_url($newurl,$binary,$redirects,$timeout);
}
}
$a->set_curl_code($http_code);
diff --git a/include/template_processor.php b/include/template_processor.php
index 0d476f0e6..7f270fb4b 100755
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -32,11 +32,12 @@
if(is_array($r) && count($r)) {
foreach ($r as $k => $v ) {
- if (is_array($v))
+ if (is_array($v)) {
$this->_build_replace($v, "$prefix$k.");
-
- $this->search[] = $prefix . $k;
- $this->replace[] = $v;
+ } else {
+ $this->search[] = $prefix . $k;
+ $this->replace[] = $v;
+ }
}
}
}
@@ -53,7 +54,7 @@
$keys = array_map('trim',explode(".",$name));
$val = $this->r;
foreach($keys as $k) {
- $val = $val[$k];
+ $val = (isset($val[$k]) ? $val[$k] : null);
}
return $val;
}
@@ -79,8 +80,8 @@
} else {
$val = $this->_get_var($args[2]);
}
- list($strue, $sfalse)= preg_split("|{{ *else *}}|", $args[3]);
- return ($val?$strue:$sfalse);
+ $x = preg_split("|{{ *else *}}|", $args[3]);
+ return ( $val ? $x[0] : (isset($x[1]) ? $x[1] : ""));
}
/**
diff --git a/include/text.php b/include/text.php
index 0f7d2f731..1f5d4a3e1 100755
--- a/include/text.php
+++ b/include/text.php
@@ -996,7 +996,7 @@ function lang_selector() {
}
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
- $selected = (($ll === $lang && (x($_SESSION['language']))) ? ' selected="selected" ' : '');
+ $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? ' selected="selected" ' : '');
$o .= '<option value="' . $ll . '"' . $selected . '>' . $ll . '</option>';
}
}