Some Bugfixes, and variable checks

This commit is contained in:
Tobias Hößl 2012-04-17 11:33:50 +00:00
parent a742199035
commit 720c8324c7
9 changed files with 44 additions and 43 deletions

View File

@ -593,7 +593,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA); logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
$a = get_app(); $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); $feed->set_raw_data($xml);

View File

@ -342,7 +342,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'body' => template_escape($body), 'body' => template_escape($body),
'text' => strip_tags(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'])), 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
'lock' => $lock,
'location' => template_escape($location), 'location' => template_escape($location),
'indent' => '', 'indent' => '',
'owner_name' => template_escape($owner_name), 'owner_name' => template_escape($owner_name),
@ -400,6 +399,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
} }
$comments_collapsed = false; $comments_collapsed = false;
$comments_seen = 0;
$comment_lastcollapsed = false; $comment_lastcollapsed = false;
$comment_firstcollapsed = false; $comment_firstcollapsed = false;
$blowhard = 0; $blowhard = 0;
@ -709,7 +709,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
} }
$page_template = get_markup_template("conversation.tpl"); $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), '$baseurl' => $a->get_baseurl($ssl_state),
'$mode' => $mode, '$mode' => $mode,
'$user' => $a->user, '$user' => $a->user,
@ -1074,7 +1074,6 @@ function find_thread_parent_index($arr,$x) {
} }
function render_location_google($item) { 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>' : ''); $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>' : ''); $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
if($coord) { if($coord) {

View File

@ -107,7 +107,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
if(! strlen($last_update)) if(! strlen($last_update))
$last_update = 'now -30 days'; $last_update = 'now -30 days';
if(x($category)) { if(isset($category)) {
$sql_extra .= file_tag_file_query('item',$category,'category'); $sql_extra .= file_tag_file_query('item',$category,'category');
} }
@ -588,20 +588,21 @@ function get_atom_elements($feed,$item) {
if($rawobj) { if($rawobj) {
$res['object'] = '<object>' . "\n"; $res['object'] = '<object>' . "\n";
if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) { $child = $rawobj[0]['child'];
$res['object-type'] = $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']; if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
$res['object'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n"; $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']) if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['object'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n"; $res['object'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
$res['object'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n"; $res['object'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
$res['object'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n"; $res['object'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
if(! $body) 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 // 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"; $res['object'] .= '<orig>' . xmlify($body) . '</orig>' . "\n";
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
@ -626,20 +627,20 @@ function get_atom_elements($feed,$item) {
if($rawobj) { if($rawobj) {
$res['target'] = '<target>' . "\n"; $res['target'] = '<target>' . "\n";
if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) { $child = $rawobj[0]['child'];
$res['target'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n"; 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']) if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['target'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n"; $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'])
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) $res['target'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
$res['target'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n"; if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) $res['target'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
$res['target'] .= '<title>' . $rawobj[0]['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']) {
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
if(! $body) 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 // 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"; $res['target'] .= '<orig>' . xmlify($body) . '</orig>' . "\n";
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { 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. // 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 ", $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ",
dbesc($parent_uri), dbesc($parent_uri),
@ -3048,7 +3049,7 @@ function item_expire($uid,$days) {
function drop_items($items) { function drop_items($items) {
$uid = 0; $uid = 0;
if((! local_user()) && (! $remote_user())) if(! local_user() && ! remote_user())
return; return;
if(count($items)) { if(count($items)) {

View File

@ -172,7 +172,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
$url_parsed = @parse_url($newurl); $url_parsed = @parse_url($newurl);
if (isset($url_parsed)) { if (isset($url_parsed)) {
$redirects++; $redirects++;
return fetch_url($newurl,$binary,$redirects,$timeout); return fetch_url($newurl,false,$redirects,$timeout);
} }
} }
$a->set_curl_code($http_code); $a->set_curl_code($http_code);
@ -206,6 +206,7 @@ function xml_status($st, $message = '') {
if(! function_exists('http_status_exit')) { if(! function_exists('http_status_exit')) {
function http_status_exit($val) { function http_status_exit($val) {
$err = '';
if($val >= 400) if($val >= 400)
$err = 'Error'; $err = 'Error';
if($val >= 200 && $val < 300) if($val >= 200 && $val < 300)
@ -452,7 +453,7 @@ function lrdd($uri, $debug = false) {
logger('lrdd: parse error: ' . $e); logger('lrdd: parse error: ' . $e);
} }
if($dom) { if(isset($dom) && $dom) {
$items = $dom->getElementsByTagName('link'); $items = $dom->getElementsByTagName('link');
foreach($items as $item) { foreach($items as $item) {
$x = $item->getAttribute('rel'); $x = $item->getAttribute('rel');

View File

@ -49,6 +49,7 @@ function get_language() {
if(isset($preferred)) if(isset($preferred))
return $preferred; return $preferred;
$a = get_app();
return ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en'); return ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
}} }}

View File

@ -2,7 +2,7 @@
function advanced_profile(&$a) { function advanced_profile(&$a) {
$o .= ''; $o = '';
$o .= '<h2>' . t('Profile') . '</h2>'; $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['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $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 '';
} }

View File

@ -339,6 +339,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '',
} }
function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') {
if (!check_form_security_token($typename, $formname)) { 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: user ' . $a->user['guid'] . ' - form element ' . $typename);
logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
header('HTTP/1.1 403 Forbidden'); header('HTTP/1.1 403 Forbidden');

View File

@ -170,7 +170,7 @@ function photo_init(&$a) {
} }
// Writing in cachefile // Writing in cachefile
if ($cachefile != '') if (isset($cachefile) && $cachefile != '')
file_put_contents($cachefile, $data); file_put_contents($cachefile, $data);
if(function_exists('header_remove')) { if(function_exists('header_remove')) {

View File

@ -330,7 +330,6 @@ function photos_post(&$a) {
// Create item container // Create item container
$title = ''; $title = '';
$basename = basename($filename);
$uri = item_new_uri($a->get_hostname(),$page_owner_uid); $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
$arr = array(); $arr = array();