From 720c8324c7572ebf51e4083430e060900cb30750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B6=C3=9Fl?= Date: Tue, 17 Apr 2012 11:33:50 +0000 Subject: [PATCH] Some Bugfixes, and variable checks --- include/Scrape.php | 2 +- include/conversation.php | 5 ++-- include/items.php | 55 ++++++++++++++++++------------------ include/network.php | 5 ++-- include/pgettext.php | 1 + include/profile_advanced.php | 15 +++++----- include/security.php | 1 + mod/photo.php | 2 +- mod/photos.php | 1 - 9 files changed, 44 insertions(+), 43 deletions(-) diff --git a/include/Scrape.php b/include/Scrape.php index 141c90dcfd..b20d7d6046 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 e5549a9c10..1b869b91e4 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; @@ -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']) ? '' . $item['location'] . '' : ''); $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); if($coord) { diff --git a/include/items.php b/include/items.php index e005ffaef7..63450cff5e 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'] = '' . "\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'] .= '' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '' . "\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'] .= '' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '' . "\n"; } - if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) - $res['object'] .= '' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '' . "\n"; - if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) - $res['object'] .= '' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '' . "\n"; - if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) - $res['object'] .= '' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '' . "\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'] .= '' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '' . "\n"; + if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) + $res['object'] .= '' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '' . "\n"; + if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) + $res['object'] .= '' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '' . "\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'] .= '' . xmlify($body) . '' . "\n"; if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { @@ -626,20 +627,20 @@ function get_atom_elements($feed,$item) { if($rawobj) { $res['target'] = '' . "\n"; - if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) { - $res['target'] .= '' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '' . "\n"; + $child = $rawobj[0]['child']; + if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) { + $res['target'] .= '' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '' . "\n"; } - if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) - $res['target'] .= '' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '' . "\n"; - - if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) - $res['target'] .= '' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '' . "\n"; - if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) - $res['target'] .= '' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '' . "\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'] .= '' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '' . "\n"; + if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) + $res['target'] .= '' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '' . "\n"; + if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) + $res['target'] .= '' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '' . "\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'] .= '' . xmlify($body) . '' . "\n"; if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { @@ -2476,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), @@ -3048,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 8c678a443a..4bec4a1727 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 83e76ba9d6..a079a46878 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 004a58524b..bb9850cd02 100644 --- a/include/profile_advanced.php +++ b/include/profile_advanced.php @@ -2,7 +2,7 @@ function advanced_profile(&$a) { - $o .= ''; + $o = ''; $o .= '

' . t('Profile') . '

'; @@ -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 fc816e5d73..a92400b5c4 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'); diff --git a/mod/photo.php b/mod/photo.php index ec53af8996..1d38fe8e45 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -170,7 +170,7 @@ function photo_init(&$a) { } // Writing in cachefile - if ($cachefile != '') + if (isset($cachefile) && $cachefile != '') file_put_contents($cachefile, $data); if(function_exists('header_remove')) { diff --git a/mod/photos.php b/mod/photos.php index 2a808cb41d..8da94841e6 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -330,7 +330,6 @@ function photos_post(&$a) { // Create item container $title = ''; - $basename = basename($filename); $uri = item_new_uri($a->get_hostname(),$page_owner_uid); $arr = array();