Browse Source

added spaces + some curly braces + some usage of dbm::is_result()

Signed-off-by: Roland Häder <roland@mxchange.org>
tags/3.5.2
Roland Häder 3 years ago
committed by Roland Haeder
parent
commit
0cd241bcbe
No known key found for this signature in database GPG Key ID: B72F8185C6C7BD78
92 changed files with 1190 additions and 1087 deletions
  1. +1
    -1
      mod/_well_known.php
  2. +2
    -2
      mod/acctlink.php
  3. +5
    -4
      mod/admin.php
  4. +2
    -1
      mod/allfriends.php
  5. +1
    -1
      mod/api.php
  6. +10
    -12
      mod/apps.php
  7. +2
    -2
      mod/attach.php
  8. +2
    -2
      mod/babel.php
  9. +31
    -28
      mod/cal.php
  10. +6
    -5
      mod/common.php
  11. +7
    -6
      mod/community.php
  12. +10
    -9
      mod/contactgroup.php
  13. +30
    -30
      mod/contacts.php
  14. +78
    -77
      mod/content.php
  15. +2
    -2
      mod/crepair.php
  16. +25
    -16
      mod/delegate.php
  17. +47
    -47
      mod/dfrn_confirm.php
  18. +18
    -20
      mod/dfrn_notify.php
  19. +38
    -38
      mod/dfrn_poll.php
  20. +30
    -30
      mod/dfrn_request.php
  21. +18
    -17
      mod/directory.php
  22. +2
    -1
      mod/dirfind.php
  23. +4
    -4
      mod/editpost.php
  24. +33
    -29
      mod/events.php
  25. +2
    -3
      mod/fbrowser.php
  26. +1
    -1
      mod/filer.php
  27. +14
    -12
      mod/friendica.php
  28. +3
    -2
      mod/fsuggest.php
  29. +25
    -23
      mod/group.php
  30. +14
    -7
      mod/help.php
  31. +2
    -2
      mod/home.php
  32. +1
    -1
      mod/hostxrd.php
  33. +7
    -7
      mod/hovercard.php
  34. +5
    -2
      mod/ignored.php
  35. +10
    -10
      mod/install.php
  36. +1
    -1
      mod/invite.php
  37. +98
    -79
      mod/item.php
  38. +12
    -6
      mod/like.php
  39. +10
    -5
      mod/localtime.php
  40. +23
    -15
      mod/lockview.php
  41. +6
    -3
      mod/login.php
  42. +3
    -4
      mod/lostpass.php
  43. +18
    -14
      mod/manage.php
  44. +7
    -7
      mod/match.php
  45. +50
    -47
      mod/message.php
  46. +1
    -1
      mod/modexp.php
  47. +8
    -6
      mod/mood.php
  48. +2
    -2
      mod/msearch.php
  49. +61
    -63
      mod/network.php
  50. +3
    -2
      mod/newmember.php
  51. +3
    -3
      mod/nodeinfo.php
  52. +4
    -3
      mod/noscrape.php
  53. +3
    -2
      mod/notes.php
  54. +14
    -13
      mod/notifications.php
  55. +6
    -6
      mod/openid.php
  56. +2
    -2
      mod/parse_url.php
  57. +12
    -13
      mod/photo.php
  58. +3
    -2
      mod/photos.php
  59. +2
    -2
      mod/ping.php
  60. +21
    -14
      mod/poco.php
  61. +7
    -5
      mod/poke.php
  62. +5
    -4
      mod/post.php
  63. +3
    -4
      mod/pretheme.php
  64. +1
    -1
      mod/probe.php
  65. +14
    -14
      mod/profile.php
  66. +12
    -12
      mod/profile_photo.php
  67. +51
    -52
      mod/profiles.php
  68. +15
    -15
      mod/profperm.php
  69. +8
    -7
      mod/pubsub.php
  70. +2
    -2
      mod/pubsubhubbub.php
  71. +8
    -6
      mod/qsearch.php
  72. +6
    -6
      mod/receive.php
  73. +6
    -6
      mod/redir.php
  74. +21
    -21
      mod/register.php
  75. +3
    -2
      mod/regmod.php
  76. +14
    -14
      mod/salmon.php
  77. +16
    -16
      mod/search.php
  78. +20
    -20
      mod/settings.php
  79. +2
    -2
      mod/share.php
  80. +2
    -3
      mod/smilies.php
  81. +4
    -4
      mod/subthread.php
  82. +15
    -15
      mod/tagger.php
  83. +6
    -6
      mod/uexport.php
  84. +33
    -32
      mod/videos.php
  85. +2
    -1
      mod/view.php
  86. +7
    -6
      mod/viewcontacts.php
  87. +2
    -2
      mod/viewsrc.php
  88. +12
    -12
      mod/wall_attach.php
  89. +16
    -16
      mod/wall_upload.php
  90. +12
    -9
      mod/wallmessage.php
  91. +1
    -1
      mod/webfinger.php
  92. +3
    -2
      mod/xrd.php

+ 1
- 1
mod/_well_known.php View File

@@ -54,7 +54,7 @@ function wk_social_relay(App $a) {
}

$taglist = array();
foreach($tags AS $tag) {
foreach ($tags AS $tag) {
$taglist[] = $tag;
}



+ 2
- 2
mod/acctlink.php View File

@@ -4,11 +4,11 @@ require_once('include/Scrape.php');

function acctlink_init(App $a) {

if(x($_GET,'addr')) {
if (x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = probe_url($addr);
//logger('acctlink: ' . print_r($res,true));
if($res['url']) {
if ($res['url']) {
goaway($res['url']);
killme();
}


+ 5
- 4
mod/admin.php View File

@@ -861,6 +861,7 @@ function admin_page_site(App $a) {
foreach ($files as $file) {
if (intval(file_exists($file.'/unsupported')))
continue;
}

$f = basename($file);

@@ -1274,7 +1275,7 @@ function admin_page_users(App $a) {
if ($a->argc>2) {
$uid = $a->argv[3];
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
if (count($user) == 0) {
if (!dbm::is_result($user)) {
notice('User not found'.EOL);
goaway('admin/users');
return ''; // NOTREACHED
@@ -1609,7 +1610,7 @@ function admin_page_plugins(App $a) {
* @param int $result
*/
function toggle_theme(&$themes,$th,&$result) {
for($x = 0; $x < count($themes); $x ++) {
for ($x = 0; $x < count($themes); $x ++) {
if ($themes[$x]['name'] === $th) {
if ($themes[$x]['allowed']) {
$themes[$x]['allowed'] = 0;
@@ -1629,7 +1630,7 @@ function toggle_theme(&$themes,$th,&$result) {
* @return int
*/
function theme_status($themes,$th) {
for($x = 0; $x < count($themes); $x ++) {
for ($x = 0; $x < count($themes); $x ++) {
if ($themes[$x]['name'] === $th) {
if ($themes[$x]['allowed']) {
return 1;
@@ -1761,7 +1762,7 @@ function admin_page_themes(App $a) {
$status="off"; $action= t("Enable");
}

$readme = Null;
$readme = null;
if (is_file("view/theme/$theme/README.md")) {
$readme = file_get_contents("view/theme/$theme/README.md");
$readme = Markdown($readme);


+ 2
- 1
mod/allfriends.php View File

@@ -37,8 +37,9 @@ function allfriends_content(App $a) {

$total = count_all_friends(local_user(), $cid);

if(count($total))
if (count($total)) {
$a->set_pager_total($total);
}

$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);



+ 1
- 1
mod/api.php View File

@@ -27,7 +27,7 @@ function api_post(App $a) {
return;
}

if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
if (count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
notice( t('Permission denied.') . EOL);
return;
}


+ 10
- 12
mod/apps.php View File

@@ -1,25 +1,23 @@
<?php

function apps_content(App $a) {
$privateaddons = get_config('config','private_addons');
if ($privateaddons === "1") {
if((! (local_user()))) {
info( t("You must be logged in to use addons. "));
return;};
}
$privateaddons = get_config('config','private_addons');
if ($privateaddons === "1") {
if ((! (local_user()))) {
info( t("You must be logged in to use addons. "));
return;
}
}

$title = t('Applications');
$title = t('Applications');

if(count($a->apps)==0)
if (count($a->apps) == 0) {
notice( t('No installed applications.') . EOL);
}

$tpl = get_markup_template("apps.tpl");
return replace_macros($tpl, array(
'$title' => $title,
'$apps' => $a->apps,
));



}

+ 2
- 2
mod/attach.php View File

@@ -4,7 +4,7 @@ require_once('include/security.php');

function attach_init(App $a) {

if($a->argc != 2) {
if ($a->argc != 2) {
notice( t('Item not available.') . EOL);
return;
}
@@ -38,7 +38,7 @@ function attach_init(App $a) {
// error in Chrome for filenames with commas in them
header('Content-type: ' . $r[0]['filetype']);
header('Content-length: ' . $r[0]['filesize']);
if(isset($_GET['attachment']) && $_GET['attachment'] === '0')
if (isset($_GET['attachment']) && $_GET['attachment'] === '0')
header('Content-disposition: filename="' . $r[0]['filename'] . '"');
else
header('Content-disposition: attachment; filename="' . $r[0]['filename'] . '"');


+ 2
- 2
mod/babel.php View File

@@ -25,7 +25,7 @@ function babel_content(App $a) {

$o .= '<br /><br />';

if(x($_REQUEST,'text')) {
if (x($_REQUEST,'text')) {

$text = trim($_REQUEST['text']);
$o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL;
@@ -63,7 +63,7 @@ function babel_content(App $a) {

}

if(x($_REQUEST,'d2bbtext')) {
if (x($_REQUEST,'d2bbtext')) {

$d2bbtext = trim($_REQUEST['d2bbtext']);
$o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;


+ 31
- 28
mod/cal.php View File

@@ -10,10 +10,10 @@ require_once('include/event.php');
require_once('include/redir.php');

function cal_init(App $a) {
if($a->argc > 1)
if ($a->argc > 1)
auto_redir($a, $a->argv[1]);

if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}

@@ -21,13 +21,13 @@ function cal_init(App $a) {

$o = '';

if($a->argc > 1) {
if ($a->argc > 1) {
$nick = $a->argv[1];
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick)
);

if(! count($user))
if (! count($user))
return;

$a->data['user'] = $user[0];
@@ -54,7 +54,7 @@ function cal_init(App $a) {

$cal_widget = widget_events();

if(! x($a->page,'aside'))
if (! x($a->page,'aside'))
$a->page['aside'] = '';

$a->page['aside'] .= $vcard_widget;
@@ -69,6 +69,7 @@ function cal_content(App $a) {

// First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week');
/// @TODO Convert all these to with curly braces
if ($firstDay === false) $firstDay=0;

// get the translation strings for the callendar
@@ -94,8 +95,9 @@ function cal_content(App $a) {
$m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);

if($a->argc == 4) {
if($a->argv[2] == 'export') {
/// @TODO Convert to one if() statement
if ($a->argc == 4) {
if ($a->argv[2] == 'export') {
$mode = 'export';
$format = $a->argv[3];
}
@@ -112,15 +114,15 @@ function cal_content(App $a) {
$owner_uid = $a->data['user']['uid'];
$nick = $a->data['user']['nickname'];

if(is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) {
if($v['uid'] == $a->profile['profile_uid']) {
if (is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $a->profile['profile_uid']) {
$contact_id = $v['cid'];
break;
}
}
}
if($contact_id) {
if ($contact_id) {
$groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
@@ -131,15 +133,15 @@ function cal_content(App $a) {
$remote_contact = true;
}
}
if(! $remote_contact) {
if(local_user()) {
if (! $remote_contact) {
if (local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
}
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);

if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
notice( t('Access to this profile has been restricted.') . EOL);
return;
}
@@ -153,33 +155,33 @@ function cal_content(App $a) {
$tabs .= profile_tabs($a,false, $a->data['user']['nickname']);

// The view mode part is similiar to /mod/events.php
if($mode == 'view') {
if ($mode == 'view') {


$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
if(! $y)
if (! $y)
$y = intval($thisyear);
if(! $m)
if (! $m)
$m = intval($thismonth);

// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.

if($y < 1901)
if ($y < 1901)
$y = 1900;
if($y > 2099)
if ($y > 2099)
$y = 2100;

$nextyear = $y;
$nextmonth = $m + 1;
if($nextmonth > 12) {
if ($nextmonth > 12) {
$nextmonth = 1;
$nextyear ++;
}

$prevyear = $y;
if($m > 1)
if ($m > 1)
$prevmonth = $m - 1;
else {
$prevmonth = 12;
@@ -235,9 +237,10 @@ function cal_content(App $a) {
$events=array();

// transform the event in a usable array
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$r = sort_by_date($r);
$events = process_events($r);
}

if ($a->argv[2] === 'json'){
echo json_encode($events); killme();
@@ -255,9 +258,9 @@ function cal_content(App $a) {
}

// Get rid of dashes in key names, Smarty3 can't handle them
foreach($events as $key => $event) {
foreach ($events as $key => $event) {
$event_item = array();
foreach($event['item'] as $k => $v) {
foreach ($event['item'] as $k => $v) {
$k = str_replace('-','_',$k);
$event_item[$k] = $v;
}
@@ -287,15 +290,15 @@ function cal_content(App $a) {
return $o;
}

if($mode == 'export') {
if(! (intval($owner_uid))) {
if ($mode == 'export') {
if (! (intval($owner_uid))) {
notice( t('User not found'));
return;
}

// Test permissions
// Respect the export feature setting for all other /cal pages if it's not the own profile
if( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) {
if ( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) {
notice( t('Permission denied.') . EOL);
goaway('cal/' . $nick);
}
@@ -304,7 +307,7 @@ function cal_content(App $a) {
$evexport = event_export($owner_uid, $format);

if (!$evexport["success"]) {
if($evexport["content"])
if ($evexport["content"])
notice( t('This calendar format is not supported') );
else
notice( t('No exportable data found'));


+ 6
- 5
mod/common.php View File

@@ -57,20 +57,21 @@ function common_content(App $a) {
return;
}

if(! $cid) {
if(get_my_url()) {
if (! $cid) {
if (get_my_url()) {
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
);
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$cid = $r[0]['id'];
else {
} else {
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link(get_my_url()))
);
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$zcid = $r[0]['id'];
}
}
}
}


+ 7
- 6
mod/community.php View File

@@ -18,12 +18,12 @@ function community_content(App $a, $update = 0) {
if ($update)
return;

if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
}

if(get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
if (get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
notice( t('Not available.') . EOL);
return;
}
@@ -34,11 +34,11 @@ function community_content(App $a, $update = 0) {


$o .= '<h3>' . t('Community') . '</h3>';
if(! $update) {
if (! $update) {
nav_set_selected('community');
}

if(x($a->data,'search'))
if (x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
@@ -79,14 +79,15 @@ function community_content(App $a, $update = 0) {
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);

} while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
} else
} else {
$s = $r;
}

// we behave the same in message lists as the search module

$o .= conversation($a, $s, 'community', $update);

$o .= alt_pager($a, count($r));
$o .= alt_pager($a, count($r));

return $o;
}


+ 10
- 9
mod/contactgroup.php View File

@@ -9,16 +9,17 @@ function contactgroup_content(App $a) {
killme();
}

if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($a->argv[2]),
intval(local_user())
);
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$change = intval($a->argv[2]);
}
}

if(($a->argc > 1) && (intval($a->argv[1]))) {
if (($a->argc > 1) && (intval($a->argv[1]))) {

$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
intval($a->argv[1]),
@@ -31,16 +32,16 @@ function contactgroup_content(App $a) {
$group = $r[0];
$members = group_get_members($group['id']);
$preselected = array();
if(count($members)) {
foreach($members as $member)
if (count($members)) {
foreach ($members as $member) {
$preselected[] = $member['id'];
}
}

if($change) {
if(in_array($change,$preselected)) {
if ($change) {
if (in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
}
else {
} else {
group_add_member(local_user(),$group['name'],$change);
}
}


+ 30
- 30
mod/contacts.php View File

@@ -14,7 +14,7 @@ function contacts_init(App $a) {

$contact_id = 0;

if((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
if ((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
@@ -107,7 +107,7 @@ function contacts_batch_actions(App $a) {
);

$count_actions=0;
foreach($orig_records as $orig_record) {
foreach ($orig_records as $orig_record) {
$contact_id = $orig_record['id'];
if (x($_POST, 'contacts_batch_update')) {
_contact_update($contact_id);
@@ -281,7 +281,7 @@ function _contact_update_profile($contact_id) {
$update["subhub"] = true;
}

foreach($updatefields AS $field)
foreach ($updatefields AS $field)
if (isset($data[$field]) AND ($data[$field] != ""))
$update[$field] = $data[$field];

@@ -292,7 +292,7 @@ function _contact_update_profile($contact_id) {
if (isset($data["priority"]) AND ($data["priority"] != 0))
$query = "`priority` = ".intval($data["priority"]);

foreach($update AS $key => $value) {
foreach ($update AS $key => $value) {
if ($query != "")
$query .= ", ";

@@ -365,10 +365,10 @@ function contacts_content(App $a) {
return;
}

if($a->argc == 3) {
if ($a->argc == 3) {

$contact_id = intval($a->argv[1]);
if(! $contact_id)
if (! $contact_id)
return;

$cmd = $a->argv[2];
@@ -378,25 +378,25 @@ function contacts_content(App $a) {
intval(local_user())
);

if(! count($orig_record)) {
if (! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
}

if($cmd === 'update') {
if ($cmd === 'update') {
_contact_update($contact_id);
goaway('contacts/' . $contact_id);
// NOTREACHED
}

if($cmd === 'updateprofile') {
if ($cmd === 'updateprofile') {
_contact_update_profile($contact_id);
goaway('crepair/' . $contact_id);
// NOTREACHED
}

if($cmd === 'block') {
if ($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]);
if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
@@ -407,7 +407,7 @@ function contacts_content(App $a) {
return; // NOTREACHED
}

if($cmd === 'ignore') {
if ($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]);
if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
@@ -419,7 +419,7 @@ function contacts_content(App $a) {
}


if($cmd === 'archive') {
if ($cmd === 'archive') {
$r = _contact_archive($contact_id, $orig_record[0]);
if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1);
@@ -430,16 +430,16 @@ function contacts_content(App $a) {
return; // NOTREACHED
}

if($cmd === 'drop') {
if ($cmd === 'drop') {

// Check if we should do HTML-based delete confirmation
if($_REQUEST['confirm']) {
if ($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = array();
foreach($query['args'] as $arg) {
if(strpos($arg, 'confirm=') === false) {
foreach ($query['args'] as $arg) {
if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
}
@@ -488,7 +488,7 @@ function contacts_content(App $a) {

$_SESSION['return_url'] = $a->query_string;

if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
if ((x($a->data,'contact')) && (is_array($a->data['contact']))) {

$contact_id = $a->data['contact']['id'];
$contact = $a->data['contact'];
@@ -522,12 +522,12 @@ function contacts_content(App $a) {
break;
}

if(!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
if (!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
$relation_text = "";

$relation_text = sprintf($relation_text,htmlentities($contact['name']));

if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
if (($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
$url = "redir/{$contact['id']}";
$sparkle = ' class="sparkle" ';
}
@@ -542,7 +542,7 @@ function contacts_content(App $a) {
? t('Never')
: datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A'));

if($contact['last-update'] !== '0000-00-00 00:00:00')
if ($contact['last-update'] !== '0000-00-00 00:00:00')
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));

$lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
@@ -665,23 +665,23 @@ function contacts_content(App $a) {
$ignored = false;
$all = false;

if(($a->argc == 2) && ($a->argv[1] === 'all')) {
if (($a->argc == 2) && ($a->argv[1] === 'all')) {
$sql_extra = '';
$all = true;
}
elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
}
elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) {
$sql_extra = " AND `hidden` = 1 ";
$hidden = true;
}
elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) {
$sql_extra = " AND `readonly` = 1 ";
$ignored = true;
}
elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) {
$sql_extra = " AND `archive` = 1 ";
$archived = true;
}
@@ -761,14 +761,14 @@ function contacts_content(App $a) {


$searching = false;
if($search) {
if ($search) {
$search_hdr = $search;
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
$searching = true;
}
$sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : "");

if($nets)
if ($nets)
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));

$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
@@ -929,7 +929,7 @@ function _contact_detail_for_template($rr){
default:
break;
}
if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = "redir/{$rr['id']}";
$sparkle = ' class="sparkle" ';
}
@@ -971,7 +971,7 @@ function contact_actions($contact) {
$contact_action = array();

// Provide friend suggestion only for Friendica contacts
if($contact['network'] === NETWORK_DFRN) {
if ($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array(
'label' => t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'],
@@ -981,7 +981,7 @@ function contact_actions($contact) {
);
}

if($poll_enabled) {
if ($poll_enabled) {
$contact_actions['update'] = array(
'label' => t('Update now'),
'url' => 'contacts/' . $contact['id'] . '/update',


+ 78
- 77
mod/content.php View File

@@ -38,20 +38,18 @@ function content_content(App $a, $update = 0) {

$nouveau = false;

if($a->argc > 1) {
for($x = 1; $x < $a->argc; $x ++) {
if(is_a_date_arg($a->argv[$x])) {
if($datequery)
if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) {
if (is_a_date_arg($a->argv[$x])) {
if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]);
else {
} else {
$datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post';
}
}
elseif($a->argv[$x] === 'new') {
} elseif ($a->argv[$x] === 'new') {
$nouveau = true;
}
elseif(intval($a->argv[$x])) {
} elseif (intval($a->argv[$x])) {
$group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}
@@ -81,12 +79,12 @@ function content_content(App $a, $update = 0) {



if(x($_GET,'search') || x($_GET,'file'))
if (x($_GET,'search') || x($_GET,'file'))
$nouveau = true;
if($cid)
if ($cid)
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');

if($nets) {
if ($nets) {
$r = q("select id from contact where uid = %d and network = '%s' and self = 0",
intval(local_user()),
dbesc($nets)
@@ -94,9 +92,9 @@ function content_content(App $a, $update = 0) {

$str = '';
if (dbm::is_result($r))
foreach($r as $rr)
foreach ($r as $rr)
$str .= '<' . $rr['id'] . '>';
if(strlen($str))
if (strlen($str))
$def_acl = array('allow_cid' => $str);
}

@@ -108,13 +106,13 @@ function content_content(App $a, $update = 0) {

$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";

if($group) {
if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group),
intval($_SESSION['uid'])
);
if (! dbm::is_result($r)) {
if($update)
if ($update)
killme();
notice( t('No such group') . EOL );
goaway(App::get_baseurl(true) . '/network');
@@ -122,7 +120,7 @@ function content_content(App $a, $update = 0) {
}

$contacts = expand_groups(array($group));
if((is_array($contacts)) && count($contacts)) {
if ((is_array($contacts)) && count($contacts)) {
$contact_str = implode(',',$contacts);
}
else {
@@ -135,7 +133,7 @@ function content_content(App $a, $update = 0) {
'$title' => sprintf( t('Group: %s'), $r[0]['name'])
)) . $o;
}
elseif($cid) {
elseif ($cid) {

$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
@@ -153,10 +151,10 @@ function content_content(App $a, $update = 0) {

$sql_extra3 = '';

if($datequery) {
if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
}
if($datequery2) {
if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}

@@ -164,10 +162,10 @@ function content_content(App $a, $update = 0) {
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
$sql_table = "`item`";

if(x($_GET,'search')) {
if (x($_GET,'search')) {
$search = escape_tags($_GET['search']);

if(strpos($search,'#') === 0) {
if (strpos($search,'#') === 0) {
$tag = true;
$search = substr($search,1);
}
@@ -175,7 +173,7 @@ function content_content(App $a, $update = 0) {
if (get_config('system','only_tag_search'))
$tag = true;

if($tag) {
if ($tag) {
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
//$sql_table = "`term` INNER JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
@@ -192,11 +190,11 @@ function content_content(App $a, $update = 0) {
}

}
if(strlen($file)) {
if (strlen($file)) {
$sql_extra .= file_tag_file_query('item',unxmlify($file));
}

if($conv) {
if ($conv) {
$myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3);
$myurl = str_replace('www.','',$myurl);
@@ -211,7 +209,7 @@ function content_content(App $a, $update = 0) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));


if($nouveau) {
if ($nouveau) {
// "New Item View" - show all items unthreaded in reverse created date order

$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
@@ -234,7 +232,7 @@ function content_content(App $a, $update = 0) {
// Normal conversation view


if($order === 'post')
if ($order === 'post')
$ordering = "`created`";
else
$ordering = "`commented`";
@@ -260,8 +258,8 @@ function content_content(App $a, $update = 0) {
$parents_str = '';

if (dbm::is_result($r)) {
foreach($r as $rr)
if(! in_array($rr['item_id'],$parents_arr))
foreach ($r as $rr)
if (! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);

@@ -328,32 +326,32 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
);
}

if($mode === 'network') {
if ($mode === 'network') {
$profile_owner = local_user();
$page_writeable = true;
}

if($mode === 'profile') {
if ($mode === 'profile') {
$profile_owner = $a->profile['profile_uid'];
$page_writeable = can_write_wall($a,$profile_owner);
}

if($mode === 'notes') {
if ($mode === 'notes') {
$profile_owner = local_user();
$page_writeable = true;
}

if($mode === 'display') {
if ($mode === 'display') {
$profile_owner = $a->profile['uid'];
$page_writeable = can_write_wall($a,$profile_owner);
}

if($mode === 'community') {
if ($mode === 'community') {
$profile_owner = 0;
$page_writeable = false;
}

if($update)
if ($update)
$return_url = $_SESSION['return_url'];
else
$return_url = $_SESSION['return_url'] = $a->query_string;
@@ -378,9 +376,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$threads = array();
$threadsid = -1;

if($items && count($items)) {
if ($items && count($items)) {

if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {

// "New Item View" on network page or search page results
// - just loop through the items and format them minimally for display
@@ -388,7 +386,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
//$tpl = get_markup_template('search_item.tpl');
$tpl = 'search_item.tpl';

foreach($items as $item) {
foreach ($items as $item) {
$threadsid++;

$comment = '';
@@ -397,8 +395,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$owner_name = '';
$sparkle = '';

if($mode === 'search' || $mode === 'community') {
if(((activity_match($item['verb'],ACTIVITY_LIKE))
if ($mode === 'search' || $mode === 'community') {
if (((activity_match($item['verb'],ACTIVITY_LIKE))
|| (activity_match($item['verb'],ACTIVITY_DISLIKE))
|| activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO)
@@ -411,20 +409,20 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$nickname = $a->user['nickname'];

// prevent private email from leaking.
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue;

$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
if($item['author-link'] && (! $item['author-name']))
if ($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];



$sp = false;
$profile_link = best_link_url($item,$sp);
if($profile_link === 'mailbox')
if ($profile_link === 'mailbox')
$profile_link = '';
if($sp)
if ($sp)
$sparkle = ' sparkle';
else
$profile_link = zrl($profile_link);
@@ -442,7 +440,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));

localize_item($item);
if($mode === 'network-new')
if ($mode === 'network-new')
$dropping = true;
else
$dropping = false;
@@ -463,7 +461,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {

$body = prepare_body($item,true);

if($a->theme['template_engine'] === 'internal') {
if ($a->theme['template_engine'] === 'internal') {
$name_e = template_escape($profile_name);
$title_e = template_escape($item['title']);
$body_e = template_escape($body);
@@ -534,20 +532,20 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
// Store the result in the $comments array

$comments = array();
foreach($items as $item) {
if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
if(! x($comments,$item['parent']))
foreach ($items as $item) {
if ((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
if (! x($comments,$item['parent']))
$comments[$item['parent']] = 1;
else
$comments[$item['parent']] += 1;
} elseif(! x($comments,$item['parent']))
} elseif (! x($comments,$item['parent']))
$comments[$item['parent']] = 0; // avoid notices later on
}

// map all the like/dislike/attendance activities for each parent item
// Store these in the $alike and $dlike arrays

foreach($items as $item) {
foreach ($items as $item) {
builtin_activity_puller($item, $conv_responses);
}

@@ -559,7 +557,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$blowhard_count = 0;


foreach($items as $item) {
foreach ($items as $item) {

$comment = '';
$template = $tpl;
@@ -569,7 +567,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {

// We've already parsed out like/dislike for special treatment. We can ignore them now

if(((activity_match($item['verb'],ACTIVITY_LIKE))
if (((activity_match($item['verb'],ACTIVITY_LIKE))
|| (activity_match($item['verb'],ACTIVITY_DISLIKE)
|| activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO)
@@ -585,7 +583,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
// If a single author has more than 3 consecutive top-level posts, squash the remaining ones.
// If there are more than two comments, squash all but the last 2.

if($toplevelpost) {
if ($toplevelpost) {

$item_writeable = (($item['writable'] || $item['self']) ? true : false);

@@ -603,7 +601,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
else {

// prevent private email reply to public conversation from leaking.
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue;

$comments_seen ++;
@@ -615,7 +613,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);


if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
if (($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {

if (!$comments_collapsed){
$threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] );
@@ -626,7 +624,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$comment_firstcollapsed = true;
}
}
if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
if (($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {

$comment_lastcollapsed = true;
}
@@ -644,9 +642,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {

$osparkle = '';

if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
if (($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {

if($item['wall']) {
if ($item['wall']) {

// On the network page, I am the owner. On the display page it will be the profile owner.
// This will have been stored in $a->page_contact by our calling page.
@@ -659,12 +657,12 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$commentww = 'ww';
}

if((! $item['wall']) && $item['owner-link']) {
if ((! $item['wall']) && $item['owner-link']) {

$owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link']));
$alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$item['author-link']));
$owner_namematch = (($item['owner-name']) && $item['owner-name'] == $item['author-name']);
if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {

// The author url doesn't match the owner (typically the contact)
// and also doesn't match the contact alias.
@@ -682,7 +680,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$template = $wallwall;
$commentww = 'ww';
// If it is our contact, use a friendly redirect link
if((link_compare($item['owner-link'],$item['url']))
if ((link_compare($item['owner-link'],$item['url']))
&& ($item['network'] === NETWORK_DFRN)) {
$owner_url = $redirect_url;
$osparkle = ' sparkle';
@@ -696,8 +694,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$likebuttons = '';
$shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false);

if($page_writeable) {
/* if($toplevelpost) { */
if ($page_writeable) {
/* if ($toplevelpost) { */
$likebuttons = array(
'like' => array( t("I like this \x28toggle\x29"), t("like")),
'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")),
@@ -707,12 +705,12 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {

$qc = $qcomment = null;

if(in_array('qcomment',$a->plugins)) {
if (in_array('qcomment',$a->plugins)) {
$qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
$qcomment = (($qc) ? explode("\n",$qc) : null);
}

if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
if (($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
$comment = replace_macros($cmnt_tpl,array(
'$return_path' => '',
'$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''),
@@ -751,7 +749,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$drop = '';
$dropping = false;

if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
if ((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
$dropping = true;

$drop = array(
@@ -815,7 +813,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {

$profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);

if($item['author-link'] && (! $item['author-name']))
if ($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];

$sp = false;
@@ -842,13 +840,14 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {

// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
if(feature_enabled($profile_owner,'dislike'))
if (feature_enabled($profile_owner,'dislike')) {
$response_verbs[] = 'dislike';
if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
}
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe';
if($page_writeable) {
if ($page_writeable) {
$isevent = true;
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
}
@@ -863,17 +862,20 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$indent = (($toplevelpost) ? '' : ' comment');

$shiny = "";
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) {
$shiny = 'shiny';
}

//
localize_item($item);


$tags=array();
foreach(explode(',',$item['tag']) as $tag){
foreach (explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") $tags[] = bbcode($tag);
if ($tag!="") {
$tags[] = bbcode($tag);
}
}

// Build the HTML
@@ -881,15 +883,14 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$body = prepare_body($item,true);
//$tmp_item = replace_macros($template,

if($a->theme['template_engine'] === 'internal') {
if ($a->theme['template_engine'] === 'internal') {
$body_e = template_escape($body);
$text_e = strip_tags(template_escape($body));
$name_e = template_escape($profile_name);
$title_e = template_escape($item['title']);
$location_e = template_escape($location);
$owner_name_e = template_escape($owner_name);
}
else {
} else {
$body_e = $body;
$text_e = strip_tags($body);
$name_e = $profile_name;


+ 2
- 2
mod/crepair.php View File

@@ -9,7 +9,7 @@ function crepair_init(App $a) {

$contact_id = 0;

if(($a->argc == 2) && intval($a->argv[1])) {
if (($a->argc == 2) && intval($a->argv[1])) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
@@ -109,7 +109,7 @@ function crepair_content(App $a) {

$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);

if($cid) {
if ($cid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval(local_user())


+ 25
- 16
mod/delegate.php View File

@@ -23,16 +23,16 @@ function delegate_content(App $a) {

$id = $a->argv[2];

$r = q("select `nickname` from user where uid = %d limit 1",
$r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($id)
);
if (dbm::is_result($r)) {
$r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
intval(local_user()),
dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
);
if (dbm::is_result($r)) {
q("insert into manage ( uid, mid ) values ( %d , %d ) ",
q("INSERT INTO `manage` ( `uid`, `mid` ) VALUES ( %d , %d ) ",
intval($a->argv[2]),
intval(local_user())
);
@@ -64,34 +64,40 @@ function delegate_content(App $a) {
dbesc($a->user['email']),
dbesc($a->user['password'])
);
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$full_managers = $r;
}

$delegates = array();

// find everybody that currently has delegated management to this account/page

$r = q("select * from user where uid in ( select uid from manage where mid = %d ) ",
$r = q("SELECT * FROM `user` WHERE `uid` IN ( SELECT `uid` FROM `manage` WHERE `mid` = %d ) ",
intval(local_user())
);

if (dbm::is_result($r))
if (dbm::is_result($r)) {
$delegates = $r;
}

$uids = array();

if(count($full_managers))
foreach($full_managers as $rr)
if (count($full_managers)) {
foreach ($full_managers as $rr) {
$uids[] = $rr['uid'];
}
}

if(count($delegates))
foreach($delegates as $rr)
if (count($delegates)) {
foreach ($delegates as $rr) {
$uids[] = $rr['uid'];
}
}

// find every contact who might be a candidate for delegation

$r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s'
and contact.uid = %d and contact.self = 0 and network = '%s' ",
$r = q("SELECT `nurl` FROM `contact` WHERE SUBSTRING_INDEX(`contact`.`nurl`,'/',3) = '%s'
AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `network` = '%s' ",
dbesc(normalise_link(App::get_baseurl())),
intval(local_user()),
dbesc(NETWORK_DFRN)
@@ -116,12 +122,15 @@ function delegate_content(App $a) {

// get user records for all potential page delegates who are not already delegates or managers

$r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )");
$r = q("SELECT `uid`, `username`, `nickname` FROM `user` WHERE `nickname` IN ( $nicks )");

if (dbm::is_result($r))
foreach($r as $rr)
if(! in_array($rr['uid'],$uids))
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if (! in_array($rr['uid'],$uids)) {
$potentials[] = $rr;
}
}
}

require_once("mod/settings.php");
settings_init($a);


+ 47
- 47
mod/dfrn_confirm.php View File

@@ -24,7 +24,7 @@ require_once('include/Probe.php');

function dfrn_confirm_post(App $a, $handsfree = null) {

if(is_array($handsfree)) {
if (is_array($handsfree)) {

/*
* We were called directly from dfrn_request due to automatic friend acceptance.
@@ -37,7 +37,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {

}
else {
if($a->argc > 1)
if ($a->argc > 1)
$node = $a->argv[1];
}

@@ -53,11 +53,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
*
*/

if(! x($_POST,'source_url')) {
if (! x($_POST,'source_url')) {

$uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user());

if(! $uid) {
if (! $uid) {
notice( t('Permission denied.') . EOL );
return;
}
@@ -66,7 +66,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid)
);

if(! $user) {
if (! $user) {
notice( t('Profile not found.') . EOL );
return;
}
@@ -74,7 +74,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {

// These data elements may come from either the friend request notification form or $handsfree array.

if(is_array($handsfree)) {
if (is_array($handsfree)) {
logger('Confirm in handsfree mode');
$dfrn_id = $handsfree['dfrn_id'];
$intro_id = $handsfree['intro_id'];
@@ -99,11 +99,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
*
*/

if(strlen($dfrn_id))
if (strlen($dfrn_id))
$cid = 0;

logger('Confirming request for dfrn_id (issued) ' . $dfrn_id);
if($cid)
if ($cid)
logger('Confirming follower with contact_id: ' . $cid);


@@ -138,10 +138,10 @@ function dfrn_confirm_post(App $a, $handsfree = null) {

$network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);

if($contact['network'])
if ($contact['network'])
$network = $contact['network'];

if($network === NETWORK_DFRN) {
if ($network === NETWORK_DFRN) {

/*
*
@@ -199,19 +199,19 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']);

if($aes_allow && function_exists('openssl_encrypt')) {
if ($aes_allow && function_exists('openssl_encrypt')) {
openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
$params['aes_key'] = bin2hex($params['aes_key']);
$params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));
}

$params['dfrn_version'] = DFRN_PROTOCOL_VERSION ;
if($duplex == 1)
if ($duplex == 1)
$params['duplex'] = 1;

if($user[0]['page-flags'] == PAGE_COMMUNITY)
if ($user[0]['page-flags'] == PAGE_COMMUNITY)
$params['page'] = 1;
if($user[0]['page-flags'] == PAGE_PRVGROUP)
if ($user[0]['page-flags'] == PAGE_PRVGROUP)
$params['page'] = 2;

logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA);
@@ -234,7 +234,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$leading_junk = substr($res,0,strpos($res,'<?xml'));

$res = substr($res,strpos($res,'<?xml'));
if(! strlen($res)) {
if (! strlen($res)) {

// No XML at all, this exchange is messed up really bad.
// We shouldn't proceed, because the xml parser might choke,
@@ -245,7 +245,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
return;
}

if(strlen($leading_junk) && get_config('system','debugging')) {
if (strlen($leading_junk) && get_config('system','debugging')) {

// This might be more common. Mixed error text and some XML.
// If we're configured for debugging, show the text. Proceed in either case.
@@ -253,7 +253,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
notice( t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL );
}

if(stristr($res, "<status")===false) {
if (stristr($res, "<status")===false) {
// wrong xml! stop here!
notice( t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL );
return;
@@ -265,7 +265,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
switch($status) {
case 0:
info( t("Confirmation completed successfully.") . EOL);
if(strlen($message))
if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
case 1:
@@ -279,19 +279,19 @@ function dfrn_confirm_post(App $a, $handsfree = null) {

case 2:
notice( t("Temporary failure. Please wait and try again.") . EOL);
if(strlen($message))
if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;


case 3:
notice( t("Introduction failed or was revoked.") . EOL);
if(strlen($message))
if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
}

if(($status == 0) && ($intro_id)) {
if (($status == 0) && ($intro_id)) {

// Success. Delete the notification.

@@ -302,7 +302,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {

}

if($status != 0)
if ($status != 0)
return;
}

@@ -323,13 +323,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {

logger('dfrn_confirm: confirm - imported photos');

if($network === NETWORK_DFRN) {
if ($network === NETWORK_DFRN) {

$new_relation = CONTACT_IS_FOLLOWER;
if(($relation == CONTACT_IS_SHARING) || ($duplex))
if (($relation == CONTACT_IS_SHARING) || ($duplex))
$new_relation = CONTACT_IS_FRIEND;

if(($relation == CONTACT_IS_SHARING) && ($duplex))
if (($relation == CONTACT_IS_SHARING) && ($duplex))
$duplex = 0;

$r = q("UPDATE `contact` SET `rel` = %d,
@@ -349,8 +349,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc(NETWORK_DFRN),
intval($contact_id)
);
}
else {
} else {

// $network !== NETWORK_DFRN

@@ -358,13 +357,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$notify = (($contact['notify']) ? $contact['notify'] : '');
$poll = (($contact['poll']) ? $contact['poll'] : '');

if((! $contact['notify']) || (! $contact['poll'])) {
if ((! $contact['notify']) || (! $contact['poll'])) {
$arr = Probe::lrdd($contact['url']);
if(count($arr)) {
foreach($arr as $link) {
if($link['@attributes']['rel'] === 'salmon')
if (count($arr)) {
foreach ($arr as $link) {
if ($link['@attributes']['rel'] === 'salmon')
$notify = $link['@attributes']['href'];
if($link['@attributes']['rel'] === NAMESPACE_FEED)
if ($link['@attributes']['rel'] === NAMESPACE_FEED)
$poll = $link['@attributes']['href'];
}
}
@@ -373,13 +372,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$new_relation = $contact['rel'];
$writable = $contact['writable'];

if($network === NETWORK_DIASPORA) {
if($duplex)
if ($network === NETWORK_DIASPORA) {
if ($duplex)
$new_relation = CONTACT_IS_FRIEND;
else
$new_relation = CONTACT_IS_FOLLOWER;

if($new_relation != CONTACT_IS_FOLLOWER)
if ($new_relation != CONTACT_IS_FOLLOWER)
$writable = 1;
}

@@ -444,7 +443,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid)
);

if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {

require_once('include/items.php');

@@ -452,7 +451,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid)
);

if(count($self)) {
if (count($self)) {

$arr = array();
$arr['guid'] = get_guid(32);
@@ -491,14 +490,14 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$arr['deny_gid'] = $user[0]['deny_gid'];

$i = item_store($arr);
if($i)
if ($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
}
}

$def_gid = get_default_group($uid, $contact["network"]);
if($contact && intval($def_gid))
if ($contact && intval($def_gid))
group_add_member($uid, '', $contact['id'], $def_gid);

// Let's send our user to the contact editor in case they want to
@@ -565,7 +564,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$local_uid = $r[0]['uid'];


if(! strstr($my_prvkey,'PRIVATE KEY')) {
if (! strstr($my_prvkey,'PRIVATE KEY')) {
$message = t('Our site encryption key is apparently messed up.');
xml_status(3,$message);
}
@@ -576,7 +575,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
openssl_private_decrypt($source_url,$decrypted_source_url,$my_prvkey);


if(! strlen($decrypted_source_url)) {
if (! strlen($decrypted_source_url)) {
$message = t('Empty site URL was provided or URL could not be decrypted by us.');
xml_status(3,$message);
// NOTREACHED
@@ -651,7 +650,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
// It's possible that the other person also requested friendship.
// If it is a duplex relationship, ditch the issued-id if one exists.

if($duplex) {
if ($duplex) {
$r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d",
intval($dfrn_record)
);
@@ -723,7 +722,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
if (dbm::is_result($r))
$combined = $r[0];

if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
if ((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
$mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array(
'type' => NOTIFY_CONFIRM,
@@ -743,12 +742,12 @@ function dfrn_confirm_post(App $a, $handsfree = null) {

// Send a new friend post if we are allowed to...

if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) {
if ($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) {
$r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($local_uid)
);

if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {

require_once('include/items.php');

@@ -756,7 +755,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($local_uid)
);

if(count($self)) {
if (dbm::is_result($self)) {

$arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
@@ -793,8 +792,9 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$arr['deny_gid'] = $user[0]['deny_gid'];

$i = item_store($arr);
if($i)
if ($i) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}

}
}


+ 18
- 20
mod/dfrn_notify.php View File

@@ -28,12 +28,12 @@ function dfrn_notify_post(App $a) {
$prv = (($page == 2) ? 1 : 0);

$writable = (-1);
if($dfrn_version >= 2.21) {
if ($dfrn_version >= 2.21) {
$writable = (($perm === 'rw') ? 1 : 0);
}

$direction = (-1);
if(strpos($dfrn_id,':') == 1) {
if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
@@ -100,14 +100,14 @@ function dfrn_notify_post(App $a) {

logger("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DEBUG);

if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
if ((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
intval(($writable == (-1)) ? $importer['writable'] : $writable),
intval($forum),
intval($prv),
intval($importer['id'])
);
if($writable != (-1))
if ($writable != (-1))
$importer['writable'] = $writable;
$importer['forum'] = $page;
}
@@ -120,7 +120,7 @@ function dfrn_notify_post(App $a) {
logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA);

if($dissolve == 1) {
if ($dissolve == 1) {

/*
* Relationship is dissolved permanently
@@ -137,7 +137,7 @@ function dfrn_notify_post(App $a) {
// If we are setup as a soapbox we aren't accepting input from this person
// This behaviour is deactivated since it really doesn't make sense to even disallow comments
// The check if someone is a friend or simply a follower is done in a later place so it needn't to be done here
//if($importer['page-flags'] == PAGE_SOAPBOX)
//if ($importer['page-flags'] == PAGE_SOAPBOX)
// xml_status(0);

$rino = get_config('system','rino_encrypt');
@@ -147,7 +147,7 @@ function dfrn_notify_post(App $a) {

logger("Local rino version: ". $rino, LOGGER_DEBUG);

if(strlen($key)) {
if (strlen($key)) {

// if local rino is lower than remote rino, abort: should not happen!
// but only for $remote_rino > 1, because old code did't send rino version
@@ -160,8 +160,8 @@ function dfrn_notify_post(App $a) {
logger('rino: md5 raw key: ' . md5($rawkey));
$final_key = '';

if($dfrn_version >= 2.1) {
if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
if ($dfrn_version >= 2.1) {
if ((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']);
}
else {
@@ -169,7 +169,7 @@ function dfrn_notify_post(App $a) {
}
}
else {
if((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
if ((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']);
}
else {
@@ -223,7 +223,7 @@ function dfrn_notify_post(App $a) {

function dfrn_notify_content(App $a) {

if(x($_GET,'dfrn_id')) {
if (x($_GET,'dfrn_id')) {

// initial communication from external contact, $direction is their direction.
// If this is a duplex communication, ours will be the opposite.
@@ -237,7 +237,7 @@ function dfrn_notify_content(App $a) {
logger('dfrn_notify: new notification dfrn_id=' . $dfrn_id);

$direction = (-1);
if(strpos($dfrn_id,':') == 1) {
if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
@@ -298,16 +298,15 @@ function dfrn_notify_content(App $a) {
$pub_key = trim($r[0]['pubkey']);
$dplx = intval($r[0]['duplex']);

if((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
if ((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
openssl_private_encrypt($hash,$challenge,$prv_key);
openssl_private_encrypt($id_str,$encrypted_id,$prv_key);
}
elseif(strlen($pub_key)) {
} elseif (strlen($pub_key)) {
openssl_public_encrypt($hash,$challenge,$pub_key);
openssl_public_encrypt($id_str,$encrypted_id,$pub_key);
}
else
} else {
$status = 1;
}

$challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id);
@@ -324,10 +323,9 @@ function dfrn_notify_content(App $a) {
// if requested rino is higher than enabled local rino, reply with local rino
if ($rino_remote < $rino) $rino = $rino_remote;

if((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
if ((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
$perm = 'rw';
}
else {
} else {
$perm = 'r';
}