aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Scrape.php2
-rw-r--r--include/conversation.php13
-rw-r--r--include/items.php87
-rw-r--r--include/network.php5
-rw-r--r--include/pgettext.php1
-rw-r--r--include/profile_advanced.php15
-rwxr-xr-xinclude/security.php1
7 files changed, 77 insertions, 47 deletions
diff --git a/include/Scrape.php b/include/Scrape.php
index 141c90dcf..b20d7d604 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -593,7 +593,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
$a = get_app();
- logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), $LOGGER_DATA);
+ logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), LOGGER_DATA);
$feed->set_raw_data($xml);
diff --git a/include/conversation.php b/include/conversation.php
index f4a564742..1b869b91e 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -342,7 +342,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'body' => template_escape($body),
'text' => strip_tags(template_escape($body)),
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
- 'lock' => $lock,
'location' => template_escape($location),
'indent' => '',
'owner_name' => template_escape($owner_name),
@@ -400,6 +399,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
$comments_collapsed = false;
+ $comments_seen = 0;
$comment_lastcollapsed = false;
$comment_firstcollapsed = false;
$blowhard = 0;
@@ -559,10 +559,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
}
- $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes'))
- ? array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"))
- : False);
-
+ if(local_user() && link_compare($a->contact['url'],$item['author-link']))
+ $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
+ else
+ $edpost = false;
$drop = '';
$dropping = false;
@@ -709,7 +709,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
$page_template = get_markup_template("conversation.tpl");
- $o .= replace_macros($page_template, array(
+ $o = replace_macros($page_template, array(
'$baseurl' => $a->get_baseurl($ssl_state),
'$mode' => $mode,
'$user' => $a->user,
@@ -1074,7 +1074,6 @@ function find_thread_parent_index($arr,$x) {
}
function render_location_google($item) {
- $location = '';
$location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
$coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
if($coord) {
diff --git a/include/items.php b/include/items.php
index 85df340d3..0a8bc12c0 100644
--- a/include/items.php
+++ b/include/items.php
@@ -107,7 +107,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
if(! strlen($last_update))
$last_update = 'now -30 days';
- if(x($category)) {
+ if(isset($category)) {
$sql_extra .= file_tag_file_query('item',$category,'category');
}
@@ -588,20 +588,21 @@ function get_atom_elements($feed,$item) {
if($rawobj) {
$res['object'] = '<object>' . "\n";
- if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
- $res['object-type'] = $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'];
- $res['object'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
+ $child = $rawobj[0]['child'];
+ if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
+ $res['object-type'] = $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'];
+ $res['object'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
}
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
- $res['object'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
- $res['object'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
- $res['object'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
+ $res['object'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
+ $res['object'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
+ $res['object'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
if(! $body)
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
// preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events
$res['object'] .= '<orig>' . xmlify($body) . '</orig>' . "\n";
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
@@ -626,20 +627,20 @@ function get_atom_elements($feed,$item) {
if($rawobj) {
$res['target'] = '<target>' . "\n";
- if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
- $res['target'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
+ $child = $rawobj[0]['child'];
+ if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
+ $res['target'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
}
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
- $res['target'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
-
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
- $res['target'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
- $res['target'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
+ $res['target'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
+ $res['target'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
+ $res['target'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
if(! $body)
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
// preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events
$res['target'] .= '<orig>' . xmlify($body) . '</orig>' . "\n";
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
@@ -1475,7 +1476,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(! $item['deleted'])
logger('consume_feed: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
- if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTVITY_OBJ_TAGTERM)) {
+ if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
if($xt->type === ACTIVITY_OBJ_NOTE) {
@@ -2091,7 +2092,7 @@ function local_delivery($importer,$data) {
logger('local_delivery: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
- if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTVITY_OBJ_TAGTERM)) {
+ if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
@@ -2229,6 +2230,34 @@ function local_delivery($importer,$data) {
$datarray = get_atom_elements($feed,$item);
+ $r = q("SELECT `id`, `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($item_id),
+ intval($importer['importer_uid'])
+ );
+
+ // Update content if 'updated' changes
+
+ if(count($r)) {
+ $iid = $r[0]['id'];
+ if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
+ logger('received updated comment' , LOGGER_DEBUG);
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($datarray['title']),
+ dbesc($datarray['body']),
+ dbesc($datarray['tag']),
+ dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
+ dbesc($item_id),
+ intval($importer['importer_uid'])
+ );
+
+ proc_run('php',"include/notifier.php","comment-import",$iid);
+
+ }
+
+ continue;
+ }
+
+
// TODO: make this next part work against both delivery threads of a community post
// if((! link_compare($datarray['author-link'],$importer['url'])) && (! $community)) {
@@ -2448,7 +2477,7 @@ function local_delivery($importer,$data) {
// find out if our user is involved in this conversation and wants to be notified.
- if($datarray['type'] != 'activity') {
+ if(!x($datarray['type']) || $datarray['type'] != 'activity') {
$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ",
dbesc($parent_uri),
@@ -3020,7 +3049,7 @@ function item_expire($uid,$days) {
function drop_items($items) {
$uid = 0;
- if((! local_user()) && (! $remote_user()))
+ if(! local_user() && ! remote_user())
return;
if(count($items)) {
diff --git a/include/network.php b/include/network.php
index 8c678a443..4bec4a172 100644
--- a/include/network.php
+++ b/include/network.php
@@ -172,7 +172,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
$url_parsed = @parse_url($newurl);
if (isset($url_parsed)) {
$redirects++;
- return fetch_url($newurl,$binary,$redirects,$timeout);
+ return fetch_url($newurl,false,$redirects,$timeout);
}
}
$a->set_curl_code($http_code);
@@ -206,6 +206,7 @@ function xml_status($st, $message = '') {
if(! function_exists('http_status_exit')) {
function http_status_exit($val) {
+ $err = '';
if($val >= 400)
$err = 'Error';
if($val >= 200 && $val < 300)
@@ -452,7 +453,7 @@ function lrdd($uri, $debug = false) {
logger('lrdd: parse error: ' . $e);
}
- if($dom) {
+ if(isset($dom) && $dom) {
$items = $dom->getElementsByTagName('link');
foreach($items as $item) {
$x = $item->getAttribute('rel');
diff --git a/include/pgettext.php b/include/pgettext.php
index 83e76ba9d..a079a4687 100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
@@ -49,6 +49,7 @@ function get_language() {
if(isset($preferred))
return $preferred;
+ $a = get_app();
return ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
}}
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index 004a58524..bb9850cd0 100644
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
@@ -2,7 +2,7 @@
function advanced_profile(&$a) {
- $o .= '';
+ $o = '';
$o .= '<h2>' . t('Profile') . '</h2>';
@@ -69,13 +69,12 @@ function advanced_profile(&$a) {
if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
- }
-
-
- return replace_macros($tpl, array(
- '$title' => t('Profile'),
- '$profile' => $profile,
- ));
+ return replace_macros($tpl, array(
+ '$title' => t('Profile'),
+ '$profile' => $profile,
+ ));
+ }
+ return '';
}
diff --git a/include/security.php b/include/security.php
index fc816e5d7..a92400b5c 100755
--- a/include/security.php
+++ b/include/security.php
@@ -339,6 +339,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '',
}
function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') {
if (!check_form_security_token($typename, $formname)) {
+ $a = get_app();
logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
header('HTTP/1.1 403 Forbidden');