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

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-01-26 15:23:30 +01:00 committed by Roland Haeder
parent 720e7d6034
commit 0cd241bcbe
No known key found for this signature in database
GPG Key ID: B72F8185C6C7BD78
92 changed files with 1190 additions and 1087 deletions

View File

@ -54,7 +54,7 @@ function wk_social_relay(App $a) {
} }
$taglist = array(); $taglist = array();
foreach($tags AS $tag) { foreach ($tags AS $tag) {
$taglist[] = $tag; $taglist[] = $tag;
} }

View File

@ -4,11 +4,11 @@ require_once('include/Scrape.php');
function acctlink_init(App $a) { function acctlink_init(App $a) {
if(x($_GET,'addr')) { if (x($_GET,'addr')) {
$addr = trim($_GET['addr']); $addr = trim($_GET['addr']);
$res = probe_url($addr); $res = probe_url($addr);
//logger('acctlink: ' . print_r($res,true)); //logger('acctlink: ' . print_r($res,true));
if($res['url']) { if ($res['url']) {
goaway($res['url']); goaway($res['url']);
killme(); killme();
} }

View File

@ -861,6 +861,7 @@ function admin_page_site(App $a) {
foreach ($files as $file) { foreach ($files as $file) {
if (intval(file_exists($file.'/unsupported'))) if (intval(file_exists($file.'/unsupported')))
continue; continue;
}
$f = basename($file); $f = basename($file);
@ -1274,7 +1275,7 @@ function admin_page_users(App $a) {
if ($a->argc>2) { if ($a->argc>2) {
$uid = $a->argv[3]; $uid = $a->argv[3];
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid)); $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); notice('User not found'.EOL);
goaway('admin/users'); goaway('admin/users');
return ''; // NOTREACHED return ''; // NOTREACHED
@ -1609,7 +1610,7 @@ function admin_page_plugins(App $a) {
* @param int $result * @param int $result
*/ */
function toggle_theme(&$themes,$th,&$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]['name'] === $th) {
if ($themes[$x]['allowed']) { if ($themes[$x]['allowed']) {
$themes[$x]['allowed'] = 0; $themes[$x]['allowed'] = 0;
@ -1629,7 +1630,7 @@ function toggle_theme(&$themes,$th,&$result) {
* @return int * @return int
*/ */
function theme_status($themes,$th) { 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]['name'] === $th) {
if ($themes[$x]['allowed']) { if ($themes[$x]['allowed']) {
return 1; return 1;
@ -1761,7 +1762,7 @@ function admin_page_themes(App $a) {
$status="off"; $action= t("Enable"); $status="off"; $action= t("Enable");
} }
$readme = Null; $readme = null;
if (is_file("view/theme/$theme/README.md")) { if (is_file("view/theme/$theme/README.md")) {
$readme = file_get_contents("view/theme/$theme/README.md"); $readme = file_get_contents("view/theme/$theme/README.md");
$readme = Markdown($readme); $readme = Markdown($readme);

View File

@ -37,8 +37,9 @@ function allfriends_content(App $a) {
$total = count_all_friends(local_user(), $cid); $total = count_all_friends(local_user(), $cid);
if(count($total)) if (count($total)) {
$a->set_pager_total($total); $a->set_pager_total($total);
}
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);

View File

@ -27,7 +27,7 @@ function api_post(App $a) {
return; 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); notice( t('Permission denied.') . EOL);
return; return;
} }

View File

@ -3,23 +3,21 @@
function apps_content(App $a) { function apps_content(App $a) {
$privateaddons = get_config('config','private_addons'); $privateaddons = get_config('config','private_addons');
if ($privateaddons === "1") { if ($privateaddons === "1") {
if((! (local_user()))) { if ((! (local_user()))) {
info( t("You must be logged in to use addons. ")); info( t("You must be logged in to use addons. "));
return;}; return;
} }
}
$title = t('Applications'); $title = t('Applications');
if(count($a->apps)==0) if (count($a->apps) == 0) {
notice( t('No installed applications.') . EOL); notice( t('No installed applications.') . EOL);
}
$tpl = get_markup_template("apps.tpl"); $tpl = get_markup_template("apps.tpl");
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$title' => $title, '$title' => $title,
'$apps' => $a->apps, '$apps' => $a->apps,
)); ));
} }

View File

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

View File

@ -25,7 +25,7 @@ function babel_content(App $a) {
$o .= '<br /><br />'; $o .= '<br /><br />';
if(x($_REQUEST,'text')) { if (x($_REQUEST,'text')) {
$text = trim($_REQUEST['text']); $text = trim($_REQUEST['text']);
$o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL; $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']); $d2bbtext = trim($_REQUEST['d2bbtext']);
$o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL; $o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;

View File

@ -10,10 +10,10 @@ require_once('include/event.php');
require_once('include/redir.php'); require_once('include/redir.php');
function cal_init(App $a) { function cal_init(App $a) {
if($a->argc > 1) if ($a->argc > 1)
auto_redir($a, $a->argv[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; return;
} }
@ -21,13 +21,13 @@ function cal_init(App $a) {
$o = ''; $o = '';
if($a->argc > 1) { if ($a->argc > 1) {
$nick = $a->argv[1]; $nick = $a->argv[1];
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick) dbesc($nick)
); );
if(! count($user)) if (! count($user))
return; return;
$a->data['user'] = $user[0]; $a->data['user'] = $user[0];
@ -54,7 +54,7 @@ function cal_init(App $a) {
$cal_widget = widget_events(); $cal_widget = widget_events();
if(! x($a->page,'aside')) if (! x($a->page,'aside'))
$a->page['aside'] = ''; $a->page['aside'] = '';
$a->page['aside'] .= $vcard_widget; $a->page['aside'] .= $vcard_widget;
@ -69,6 +69,7 @@ function cal_content(App $a) {
// First day of the week (0 = Sunday) // First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week'); $firstDay = get_pconfig(local_user(),'system','first_day_of_week');
/// @TODO Convert all these to with curly braces
if ($firstDay === false) $firstDay=0; if ($firstDay === false) $firstDay=0;
// get the translation strings for the callendar // get the translation strings for the callendar
@ -94,8 +95,9 @@ function cal_content(App $a) {
$m = 0; $m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
if($a->argc == 4) { /// @TODO Convert to one if() statement
if($a->argv[2] == 'export') { if ($a->argc == 4) {
if ($a->argv[2] == 'export') {
$mode = 'export'; $mode = 'export';
$format = $a->argv[3]; $format = $a->argv[3];
} }
@ -112,15 +114,15 @@ function cal_content(App $a) {
$owner_uid = $a->data['user']['uid']; $owner_uid = $a->data['user']['uid'];
$nick = $a->data['user']['nickname']; $nick = $a->data['user']['nickname'];
if(is_array($_SESSION['remote'])) { if (is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) { foreach ($_SESSION['remote'] as $v) {
if($v['uid'] == $a->profile['profile_uid']) { if ($v['uid'] == $a->profile['profile_uid']) {
$contact_id = $v['cid']; $contact_id = $v['cid'];
break; break;
} }
} }
} }
if($contact_id) { if ($contact_id) {
$groups = init_groups_visitor($contact_id); $groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id), intval($contact_id),
@ -131,15 +133,15 @@ function cal_content(App $a) {
$remote_contact = true; $remote_contact = true;
} }
} }
if(! $remote_contact) { if (! $remote_contact) {
if(local_user()) { if (local_user()) {
$contact_id = $_SESSION['cid']; $contact_id = $_SESSION['cid'];
$contact = $a->contact; $contact = $a->contact;
} }
} }
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false); $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); notice( t('Access to this profile has been restricted.') . EOL);
return; return;
} }
@ -153,33 +155,33 @@ function cal_content(App $a) {
$tabs .= profile_tabs($a,false, $a->data['user']['nickname']); $tabs .= profile_tabs($a,false, $a->data['user']['nickname']);
// The view mode part is similiar to /mod/events.php // 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'); $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
if(! $y) if (! $y)
$y = intval($thisyear); $y = intval($thisyear);
if(! $m) if (! $m)
$m = intval($thismonth); $m = intval($thismonth);
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900. // 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. // 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; $y = 1900;
if($y > 2099) if ($y > 2099)
$y = 2100; $y = 2100;
$nextyear = $y; $nextyear = $y;
$nextmonth = $m + 1; $nextmonth = $m + 1;
if($nextmonth > 12) { if ($nextmonth > 12) {
$nextmonth = 1; $nextmonth = 1;
$nextyear ++; $nextyear ++;
} }
$prevyear = $y; $prevyear = $y;
if($m > 1) if ($m > 1)
$prevmonth = $m - 1; $prevmonth = $m - 1;
else { else {
$prevmonth = 12; $prevmonth = 12;
@ -235,9 +237,10 @@ function cal_content(App $a) {
$events=array(); $events=array();
// transform the event in a usable array // transform the event in a usable array
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
$events = process_events($r); $events = process_events($r);
}
if ($a->argv[2] === 'json'){ if ($a->argv[2] === 'json'){
echo json_encode($events); killme(); 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 // 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(); $event_item = array();
foreach($event['item'] as $k => $v) { foreach ($event['item'] as $k => $v) {
$k = str_replace('-','_',$k); $k = str_replace('-','_',$k);
$event_item[$k] = $v; $event_item[$k] = $v;
} }
@ -287,15 +290,15 @@ function cal_content(App $a) {
return $o; return $o;
} }
if($mode == 'export') { if ($mode == 'export') {
if(! (intval($owner_uid))) { if (! (intval($owner_uid))) {
notice( t('User not found')); notice( t('User not found'));
return; return;
} }
// Test permissions // Test permissions
// Respect the export feature setting for all other /cal pages if it's not the own profile // 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); notice( t('Permission denied.') . EOL);
goaway('cal/' . $nick); goaway('cal/' . $nick);
} }
@ -304,7 +307,7 @@ function cal_content(App $a) {
$evexport = event_export($owner_uid, $format); $evexport = event_export($owner_uid, $format);
if (!$evexport["success"]) { if (!$evexport["success"]) {
if($evexport["content"]) if ($evexport["content"])
notice( t('This calendar format is not supported') ); notice( t('This calendar format is not supported') );
else else
notice( t('No exportable data found')); notice( t('No exportable data found'));

View File

@ -57,23 +57,24 @@ function common_content(App $a) {
return; return;
} }
if(! $cid) { if (! $cid) {
if(get_my_url()) { if (get_my_url()) {
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
dbesc(normalise_link(get_my_url())), dbesc(normalise_link(get_my_url())),
intval($profile_uid) intval($profile_uid)
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$cid = $r[0]['id']; $cid = $r[0]['id'];
else { } else {
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link(get_my_url())) dbesc(normalise_link(get_my_url()))
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$zcid = $r[0]['id']; $zcid = $r[0]['id'];
} }
} }
} }
}
if ($cid == 0 && $zcid == 0) { if ($cid == 0 && $zcid == 0) {
return; return;

View File

@ -18,12 +18,12 @@ function community_content(App $a, $update = 0) {
if ($update) if ($update)
return; 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); notice( t('Public access denied.') . EOL);
return; 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); notice( t('Not available.') . EOL);
return; return;
} }
@ -34,11 +34,11 @@ function community_content(App $a, $update = 0) {
$o .= '<h3>' . t('Community') . '</h3>'; $o .= '<h3>' . t('Community') . '</h3>';
if(! $update) { if (! $update) {
nav_set_selected('community'); nav_set_selected('community');
} }
if(x($a->data,'search')) if (x($a->data,'search'))
$search = notags(trim($a->data['search'])); $search = notags(trim($a->data['search']));
else else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
@ -79,8 +79,9 @@ function community_content(App $a, $update = 0) {
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']); $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)); } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
} else } else {
$s = $r; $s = $r;
}
// we behave the same in message lists as the search module // we behave the same in message lists as the search module

View File

@ -9,16 +9,17 @@ function contactgroup_content(App $a) {
killme(); 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", $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($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$change = intval($a->argv[2]); $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", $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
@ -31,16 +32,16 @@ function contactgroup_content(App $a) {
$group = $r[0]; $group = $r[0];
$members = group_get_members($group['id']); $members = group_get_members($group['id']);
$preselected = array(); $preselected = array();
if(count($members)) { if (count($members)) {
foreach($members as $member) foreach ($members as $member) {
$preselected[] = $member['id']; $preselected[] = $member['id'];
} }
if($change) {
if(in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
} }
else {
if ($change) {
if (in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
} else {
group_add_member(local_user(),$group['name'],$change); group_add_member(local_user(),$group['name'],$change);
} }
} }

View File

@ -14,7 +14,7 @@ function contacts_init(App $a) {
$contact_id = 0; $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]); $contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()), intval(local_user()),
@ -107,7 +107,7 @@ function contacts_batch_actions(App $a) {
); );
$count_actions=0; $count_actions=0;
foreach($orig_records as $orig_record) { foreach ($orig_records as $orig_record) {
$contact_id = $orig_record['id']; $contact_id = $orig_record['id'];
if (x($_POST, 'contacts_batch_update')) { if (x($_POST, 'contacts_batch_update')) {
_contact_update($contact_id); _contact_update($contact_id);
@ -281,7 +281,7 @@ function _contact_update_profile($contact_id) {
$update["subhub"] = true; $update["subhub"] = true;
} }
foreach($updatefields AS $field) foreach ($updatefields AS $field)
if (isset($data[$field]) AND ($data[$field] != "")) if (isset($data[$field]) AND ($data[$field] != ""))
$update[$field] = $data[$field]; $update[$field] = $data[$field];
@ -292,7 +292,7 @@ function _contact_update_profile($contact_id) {
if (isset($data["priority"]) AND ($data["priority"] != 0)) if (isset($data["priority"]) AND ($data["priority"] != 0))
$query = "`priority` = ".intval($data["priority"]); $query = "`priority` = ".intval($data["priority"]);
foreach($update AS $key => $value) { foreach ($update AS $key => $value) {
if ($query != "") if ($query != "")
$query .= ", "; $query .= ", ";
@ -365,10 +365,10 @@ function contacts_content(App $a) {
return; return;
} }
if($a->argc == 3) { if ($a->argc == 3) {
$contact_id = intval($a->argv[1]); $contact_id = intval($a->argv[1]);
if(! $contact_id) if (! $contact_id)
return; return;
$cmd = $a->argv[2]; $cmd = $a->argv[2];
@ -378,25 +378,25 @@ function contacts_content(App $a) {
intval(local_user()) intval(local_user())
); );
if(! count($orig_record)) { if (! count($orig_record)) {
notice( t('Could not access contact record.') . EOL); notice( t('Could not access contact record.') . EOL);
goaway('contacts'); goaway('contacts');
return; // NOTREACHED return; // NOTREACHED
} }
if($cmd === 'update') { if ($cmd === 'update') {
_contact_update($contact_id); _contact_update($contact_id);
goaway('contacts/' . $contact_id); goaway('contacts/' . $contact_id);
// NOTREACHED // NOTREACHED
} }
if($cmd === 'updateprofile') { if ($cmd === 'updateprofile') {
_contact_update_profile($contact_id); _contact_update_profile($contact_id);
goaway('crepair/' . $contact_id); goaway('crepair/' . $contact_id);
// NOTREACHED // NOTREACHED
} }
if($cmd === 'block') { if ($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]); $r = _contact_block($contact_id, $orig_record[0]);
if ($r) { if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1); $blocked = (($orig_record[0]['blocked']) ? 0 : 1);
@ -407,7 +407,7 @@ function contacts_content(App $a) {
return; // NOTREACHED return; // NOTREACHED
} }
if($cmd === 'ignore') { if ($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]); $r = _contact_ignore($contact_id, $orig_record[0]);
if ($r) { if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1); $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]); $r = _contact_archive($contact_id, $orig_record[0]);
if ($r) { if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1); $archived = (($orig_record[0]['archive']) ? 0 : 1);
@ -430,16 +430,16 @@ function contacts_content(App $a) {
return; // NOTREACHED return; // NOTREACHED
} }
if($cmd === 'drop') { if ($cmd === 'drop') {
// Check if we should do HTML-based delete confirmation // Check if we should do HTML-based delete confirmation
if($_REQUEST['confirm']) { if ($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter // <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs // so add any arguments as hidden inputs
$query = explode_querystring($a->query_string); $query = explode_querystring($a->query_string);
$inputs = array(); $inputs = array();
foreach($query['args'] as $arg) { foreach ($query['args'] as $arg) {
if(strpos($arg, 'confirm=') === false) { if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg); $arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); $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; $_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_id = $a->data['contact']['id'];
$contact = $a->data['contact']; $contact = $a->data['contact'];
@ -522,12 +522,12 @@ function contacts_content(App $a) {
break; 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 = "";
$relation_text = sprintf($relation_text,htmlentities($contact['name'])); $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']}"; $url = "redir/{$contact['id']}";
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }
@ -542,7 +542,7 @@ function contacts_content(App $a) {
? t('Never') ? t('Never')
: datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A')); : 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")); $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') : ''); $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
@ -665,23 +665,23 @@ function contacts_content(App $a) {
$ignored = false; $ignored = false;
$all = false; $all = false;
if(($a->argc == 2) && ($a->argv[1] === 'all')) { if (($a->argc == 2) && ($a->argv[1] === 'all')) {
$sql_extra = ''; $sql_extra = '';
$all = true; $all = true;
} }
elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) { elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 "; $sql_extra = " AND `blocked` = 1 ";
$blocked = true; $blocked = true;
} }
elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) { elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) {
$sql_extra = " AND `hidden` = 1 "; $sql_extra = " AND `hidden` = 1 ";
$hidden = true; $hidden = true;
} }
elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) { elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) {
$sql_extra = " AND `readonly` = 1 "; $sql_extra = " AND `readonly` = 1 ";
$ignored = true; $ignored = true;
} }
elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) { elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) {
$sql_extra = " AND `archive` = 1 "; $sql_extra = " AND `archive` = 1 ";
$archived = true; $archived = true;
} }
@ -761,14 +761,14 @@ function contacts_content(App $a) {
$searching = false; $searching = false;
if($search) { if ($search) {
$search_hdr = $search; $search_hdr = $search;
$search_txt = dbesc(protect_sprintf(preg_quote($search))); $search_txt = dbesc(protect_sprintf(preg_quote($search)));
$searching = true; $searching = true;
} }
$sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : ""); $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_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : ''); $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: default:
break; break;
} }
if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) { if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = "redir/{$rr['id']}"; $url = "redir/{$rr['id']}";
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }
@ -971,7 +971,7 @@ function contact_actions($contact) {
$contact_action = array(); $contact_action = array();
// Provide friend suggestion only for Friendica contacts // Provide friend suggestion only for Friendica contacts
if($contact['network'] === NETWORK_DFRN) { if ($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array( $contact_actions['suggest'] = array(
'label' => t('Suggest friends'), 'label' => t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'], 'url' => 'fsuggest/' . $contact['id'],
@ -981,7 +981,7 @@ function contact_actions($contact) {
); );
} }
if($poll_enabled) { if ($poll_enabled) {
$contact_actions['update'] = array( $contact_actions['update'] = array(
'label' => t('Update now'), 'label' => t('Update now'),
'url' => 'contacts/' . $contact['id'] . '/update', 'url' => 'contacts/' . $contact['id'] . '/update',

View File

@ -38,20 +38,18 @@ function content_content(App $a, $update = 0) {
$nouveau = false; $nouveau = false;
if($a->argc > 1) { if ($a->argc > 1) {
for($x = 1; $x < $a->argc; $x ++) { for ($x = 1; $x < $a->argc; $x ++) {
if(is_a_date_arg($a->argv[$x])) { if (is_a_date_arg($a->argv[$x])) {
if($datequery) if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]); $datequery2 = escape_tags($a->argv[$x]);
else { } else {
$datequery = escape_tags($a->argv[$x]); $datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post'; $_GET['order'] = 'post';
} }
} } elseif ($a->argv[$x] === 'new') {
elseif($a->argv[$x] === 'new') {
$nouveau = true; $nouveau = true;
} } elseif (intval($a->argv[$x])) {
elseif(intval($a->argv[$x])) {
$group = intval($a->argv[$x]); $group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>'); $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; $nouveau = true;
if($cid) if ($cid)
$def_acl = array('allow_cid' => '<' . intval($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", $r = q("select id from contact where uid = %d and network = '%s' and self = 0",
intval(local_user()), intval(local_user()),
dbesc($nets) dbesc($nets)
@ -94,9 +92,9 @@ function content_content(App $a, $update = 0) {
$str = ''; $str = '';
if (dbm::is_result($r)) if (dbm::is_result($r))
foreach($r as $rr) foreach ($r as $rr)
$str .= '<' . $rr['id'] . '>'; $str .= '<' . $rr['id'] . '>';
if(strlen($str)) if (strlen($str))
$def_acl = array('allow_cid' => $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 ) "; $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", $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group), intval($group),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
if($update) if ($update)
killme(); killme();
notice( t('No such group') . EOL ); notice( t('No such group') . EOL );
goaway(App::get_baseurl(true) . '/network'); goaway(App::get_baseurl(true) . '/network');
@ -122,7 +120,7 @@ function content_content(App $a, $update = 0) {
} }
$contacts = expand_groups(array($group)); $contacts = expand_groups(array($group));
if((is_array($contacts)) && count($contacts)) { if ((is_array($contacts)) && count($contacts)) {
$contact_str = implode(',',$contacts); $contact_str = implode(',',$contacts);
} }
else { else {
@ -135,7 +133,7 @@ function content_content(App $a, $update = 0) {
'$title' => sprintf( t('Group: %s'), $r[0]['name']) '$title' => sprintf( t('Group: %s'), $r[0]['name'])
)) . $o; )) . $o;
} }
elseif($cid) { elseif ($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d
AND `blocked` = 0 AND `pending` = 0 LIMIT 1", AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
@ -153,10 +151,10 @@ function content_content(App $a, $update = 0) {
$sql_extra3 = ''; $sql_extra3 = '';
if($datequery) { if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$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)))); $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_extra3 = (($nouveau) ? '' : $sql_extra3);
$sql_table = "`item`"; $sql_table = "`item`";
if(x($_GET,'search')) { if (x($_GET,'search')) {
$search = escape_tags($_GET['search']); $search = escape_tags($_GET['search']);
if(strpos($search,'#') === 0) { if (strpos($search,'#') === 0) {
$tag = true; $tag = true;
$search = substr($search,1); $search = substr($search,1);
} }
@ -175,7 +173,7 @@ function content_content(App $a, $update = 0) {
if (get_config('system','only_tag_search')) if (get_config('system','only_tag_search'))
$tag = true; $tag = true;
if($tag) { if ($tag) {
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ", //$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)); // 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` "; //$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)); $sql_extra .= file_tag_file_query('item',unxmlify($file));
} }
if($conv) { if ($conv) {
$myurl = App::get_baseurl() . '/profile/'. $a->user['nickname']; $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = substr($myurl,strpos($myurl,'://')+3);
$myurl = str_replace('www.','',$myurl); $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'])); $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 // "New Item View" - show all items unthreaded in reverse created date order
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
@ -234,7 +232,7 @@ function content_content(App $a, $update = 0) {
// Normal conversation view // Normal conversation view
if($order === 'post') if ($order === 'post')
$ordering = "`created`"; $ordering = "`created`";
else else
$ordering = "`commented`"; $ordering = "`commented`";
@ -260,8 +258,8 @@ function content_content(App $a, $update = 0) {
$parents_str = ''; $parents_str = '';
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr)
if(! in_array($rr['item_id'],$parents_arr)) if (! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr); $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(); $profile_owner = local_user();
$page_writeable = true; $page_writeable = true;
} }
if($mode === 'profile') { if ($mode === 'profile') {
$profile_owner = $a->profile['profile_uid']; $profile_owner = $a->profile['profile_uid'];
$page_writeable = can_write_wall($a,$profile_owner); $page_writeable = can_write_wall($a,$profile_owner);
} }
if($mode === 'notes') { if ($mode === 'notes') {
$profile_owner = local_user(); $profile_owner = local_user();
$page_writeable = true; $page_writeable = true;
} }
if($mode === 'display') { if ($mode === 'display') {
$profile_owner = $a->profile['uid']; $profile_owner = $a->profile['uid'];
$page_writeable = can_write_wall($a,$profile_owner); $page_writeable = can_write_wall($a,$profile_owner);
} }
if($mode === 'community') { if ($mode === 'community') {
$profile_owner = 0; $profile_owner = 0;
$page_writeable = false; $page_writeable = false;
} }
if($update) if ($update)
$return_url = $_SESSION['return_url']; $return_url = $_SESSION['return_url'];
else else
$return_url = $_SESSION['return_url'] = $a->query_string; $return_url = $_SESSION['return_url'] = $a->query_string;
@ -378,9 +376,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$threads = array(); $threads = array();
$threadsid = -1; $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 // "New Item View" on network page or search page results
// - just loop through the items and format them minimally for display // - 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 = get_markup_template('search_item.tpl');
$tpl = 'search_item.tpl'; $tpl = 'search_item.tpl';
foreach($items as $item) { foreach ($items as $item) {
$threadsid++; $threadsid++;
$comment = ''; $comment = '';
@ -397,8 +395,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$owner_name = ''; $owner_name = '';
$sparkle = ''; $sparkle = '';
if($mode === 'search' || $mode === 'community') { if ($mode === 'search' || $mode === 'community') {
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_DISLIKE))
|| activity_match($item['verb'],ACTIVITY_ATTEND) || activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO) || activity_match($item['verb'],ACTIVITY_ATTENDNO)
@ -411,20 +409,20 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$nickname = $a->user['nickname']; $nickname = $a->user['nickname'];
// prevent private email from leaking. // prevent private email from leaking.
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue; continue;
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); $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']; $profile_name = $item['author-link'];
$sp = false; $sp = false;
$profile_link = best_link_url($item,$sp); $profile_link = best_link_url($item,$sp);
if($profile_link === 'mailbox') if ($profile_link === 'mailbox')
$profile_link = ''; $profile_link = '';
if($sp) if ($sp)
$sparkle = ' sparkle'; $sparkle = ' sparkle';
else else
$profile_link = zrl($profile_link); $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)); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
localize_item($item); localize_item($item);
if($mode === 'network-new') if ($mode === 'network-new')
$dropping = true; $dropping = true;
else else
$dropping = false; $dropping = false;
@ -463,7 +461,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$body = prepare_body($item,true); $body = prepare_body($item,true);
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$name_e = template_escape($profile_name); $name_e = template_escape($profile_name);
$title_e = template_escape($item['title']); $title_e = template_escape($item['title']);
$body_e = template_escape($body); $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 // Store the result in the $comments array
$comments = array(); $comments = array();
foreach($items as $item) { foreach ($items as $item) {
if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) { if ((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
if(! x($comments,$item['parent'])) if (! x($comments,$item['parent']))
$comments[$item['parent']] = 1; $comments[$item['parent']] = 1;
else else
$comments[$item['parent']] += 1; $comments[$item['parent']] += 1;
} elseif(! x($comments,$item['parent'])) } elseif (! x($comments,$item['parent']))
$comments[$item['parent']] = 0; // avoid notices later on $comments[$item['parent']] = 0; // avoid notices later on
} }
// map all the like/dislike/attendance activities for each parent item // map all the like/dislike/attendance activities for each parent item
// Store these in the $alike and $dlike arrays // Store these in the $alike and $dlike arrays
foreach($items as $item) { foreach ($items as $item) {
builtin_activity_puller($item, $conv_responses); builtin_activity_puller($item, $conv_responses);
} }
@ -559,7 +557,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$blowhard_count = 0; $blowhard_count = 0;
foreach($items as $item) { foreach ($items as $item) {
$comment = ''; $comment = '';
$template = $tpl; $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 // 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_DISLIKE)
|| activity_match($item['verb'],ACTIVITY_ATTEND) || activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO) || 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 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 there are more than two comments, squash all but the last 2.
if($toplevelpost) { if ($toplevelpost) {
$item_writeable = (($item['writable'] || $item['self']) ? true : false); $item_writeable = (($item['writable'] || $item['self']) ? true : false);
@ -603,7 +601,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
else { else {
// prevent private email reply to public conversation from leaking. // 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; continue;
$comments_seen ++; $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); $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){ if (!$comments_collapsed){
$threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] ); $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; $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; $comment_lastcollapsed = true;
} }
@ -644,9 +642,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$osparkle = ''; $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. // 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. // 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'; $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'])); $owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link']));
$alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$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']); $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) // The author url doesn't match the owner (typically the contact)
// and also doesn't match the contact alias. // and also doesn't match the contact alias.
@ -682,7 +680,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$template = $wallwall; $template = $wallwall;
$commentww = 'ww'; $commentww = 'ww';
// If it is our contact, use a friendly redirect link // 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)) { && ($item['network'] === NETWORK_DFRN)) {
$owner_url = $redirect_url; $owner_url = $redirect_url;
$osparkle = ' sparkle'; $osparkle = ' sparkle';
@ -696,8 +694,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$likebuttons = ''; $likebuttons = '';
$shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false);
if($page_writeable) { if ($page_writeable) {
/* if($toplevelpost) { */ /* if ($toplevelpost) { */
$likebuttons = array( $likebuttons = array(
'like' => array( t("I like this \x28toggle\x29"), t("like")), 'like' => array( t("I like this \x28toggle\x29"), t("like")),
'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")), '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; $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); $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
$qcomment = (($qc) ? explode("\n",$qc) : 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( $comment = replace_macros($cmnt_tpl,array(
'$return_path' => '', '$return_path' => '',
'$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''),
@ -751,7 +749,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$drop = ''; $drop = '';
$dropping = false; $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; $dropping = true;
$drop = array( $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']); $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']; $profile_name = $item['author-link'];
$sp = false; $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 // process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like'); $response_verbs = array('like');
if(feature_enabled($profile_owner,'dislike')) if (feature_enabled($profile_owner,'dislike')) {
$response_verbs[] = 'dislike'; $response_verbs[] = 'dislike';
if($item['object-type'] === ACTIVITY_OBJ_EVENT) { }
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes'; $response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno'; $response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe'; $response_verbs[] = 'attendmaybe';
if($page_writeable) { if ($page_writeable) {
$isevent = true; $isevent = true;
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); $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'); $indent = (($toplevelpost) ? '' : ' comment');
$shiny = ""; $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'; $shiny = 'shiny';
}
// //
localize_item($item); localize_item($item);
$tags=array(); $tags=array();
foreach(explode(',',$item['tag']) as $tag){ foreach (explode(',',$item['tag']) as $tag){
$tag = trim($tag); $tag = trim($tag);
if ($tag!="") $tags[] = bbcode($tag); if ($tag!="") {
$tags[] = bbcode($tag);
}
} }
// Build the HTML // Build the HTML
@ -881,15 +883,14 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$body = prepare_body($item,true); $body = prepare_body($item,true);
//$tmp_item = replace_macros($template, //$tmp_item = replace_macros($template,
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$body_e = template_escape($body); $body_e = template_escape($body);
$text_e = strip_tags(template_escape($body)); $text_e = strip_tags(template_escape($body));
$name_e = template_escape($profile_name); $name_e = template_escape($profile_name);
$title_e = template_escape($item['title']); $title_e = template_escape($item['title']);
$location_e = template_escape($location); $location_e = template_escape($location);
$owner_name_e = template_escape($owner_name); $owner_name_e = template_escape($owner_name);
} } else {
else {
$body_e = $body; $body_e = $body;
$text_e = strip_tags($body); $text_e = strip_tags($body);
$name_e = $profile_name; $name_e = $profile_name;

View File

@ -9,7 +9,7 @@ function crepair_init(App $a) {
$contact_id = 0; $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]); $contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()), intval(local_user()),
@ -109,7 +109,7 @@ function crepair_content(App $a) {
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); $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", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid), intval($cid),
intval(local_user()) intval(local_user())

View File

@ -23,16 +23,16 @@ function delegate_content(App $a) {
$id = $a->argv[2]; $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) intval($id)
); );
if (dbm::is_result($r)) { 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()), intval(local_user()),
dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname'])) dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
); );
if (dbm::is_result($r)) { 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($a->argv[2]),
intval(local_user()) intval(local_user())
); );
@ -64,34 +64,40 @@ function delegate_content(App $a) {
dbesc($a->user['email']), dbesc($a->user['email']),
dbesc($a->user['password']) dbesc($a->user['password'])
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$full_managers = $r; $full_managers = $r;
}
$delegates = array(); $delegates = array();
// find everybody that currently has delegated management to this account/page // 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()) intval(local_user())
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$delegates = $r; $delegates = $r;
}
$uids = array(); $uids = array();
if(count($full_managers)) if (count($full_managers)) {
foreach($full_managers as $rr) foreach ($full_managers as $rr) {
$uids[] = $rr['uid']; $uids[] = $rr['uid'];
}
}
if(count($delegates)) if (count($delegates)) {
foreach($delegates as $rr) foreach ($delegates as $rr) {
$uids[] = $rr['uid']; $uids[] = $rr['uid'];
}
}
// find every contact who might be a candidate for delegation // find every contact who might be a candidate for delegation
$r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%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' ", AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `network` = '%s' ",
dbesc(normalise_link(App::get_baseurl())), dbesc(normalise_link(App::get_baseurl())),
intval(local_user()), intval(local_user()),
dbesc(NETWORK_DFRN) 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 // 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)) if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
if(! in_array($rr['uid'],$uids)) if (! in_array($rr['uid'],$uids)) {
$potentials[] = $rr; $potentials[] = $rr;
}
}
}
require_once("mod/settings.php"); require_once("mod/settings.php");
settings_init($a); settings_init($a);

View File

@ -24,7 +24,7 @@ require_once('include/Probe.php');
function dfrn_confirm_post(App $a, $handsfree = null) { 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. * 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 { else {
if($a->argc > 1) if ($a->argc > 1)
$node = $a->argv[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()); $uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user());
if(! $uid) { if (! $uid) {
notice( t('Permission denied.') . EOL ); notice( t('Permission denied.') . EOL );
return; return;
} }
@ -66,7 +66,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid) intval($uid)
); );
if(! $user) { if (! $user) {
notice( t('Profile not found.') . EOL ); notice( t('Profile not found.') . EOL );
return; 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. // 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'); logger('Confirm in handsfree mode');
$dfrn_id = $handsfree['dfrn_id']; $dfrn_id = $handsfree['dfrn_id'];
$intro_id = $handsfree['intro_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; $cid = 0;
logger('Confirming request for dfrn_id (issued) ' . $dfrn_id); logger('Confirming request for dfrn_id (issued) ' . $dfrn_id);
if($cid) if ($cid)
logger('Confirming follower with contact_id: ' . $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); $network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);
if($contact['network']) if ($contact['network'])
$network = $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); openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']); $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); openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
$params['aes_key'] = bin2hex($params['aes_key']); $params['aes_key'] = bin2hex($params['aes_key']);
$params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key)); $params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));
} }
$params['dfrn_version'] = DFRN_PROTOCOL_VERSION ; $params['dfrn_version'] = DFRN_PROTOCOL_VERSION ;
if($duplex == 1) if ($duplex == 1)
$params['duplex'] = 1; $params['duplex'] = 1;
if($user[0]['page-flags'] == PAGE_COMMUNITY) if ($user[0]['page-flags'] == PAGE_COMMUNITY)
$params['page'] = 1; $params['page'] = 1;
if($user[0]['page-flags'] == PAGE_PRVGROUP) if ($user[0]['page-flags'] == PAGE_PRVGROUP)
$params['page'] = 2; $params['page'] = 2;
logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA); 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')); $leading_junk = substr($res,0,strpos($res,'<?xml'));
$res = substr($res,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. // No XML at all, this exchange is messed up really bad.
// We shouldn't proceed, because the xml parser might choke, // We shouldn't proceed, because the xml parser might choke,
@ -245,7 +245,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
return; 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. // This might be more common. Mixed error text and some XML.
// If we're configured for debugging, show the text. Proceed in either case. // 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 ); 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! // wrong xml! stop here!
notice( t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL ); notice( t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL );
return; return;
@ -265,7 +265,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
switch($status) { switch($status) {
case 0: case 0:
info( t("Confirmation completed successfully.") . EOL); info( t("Confirmation completed successfully.") . EOL);
if(strlen($message)) if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL); notice( t('Remote site reported: ') . $message . EOL);
break; break;
case 1: case 1:
@ -279,19 +279,19 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
case 2: case 2:
notice( t("Temporary failure. Please wait and try again.") . EOL); notice( t("Temporary failure. Please wait and try again.") . EOL);
if(strlen($message)) if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL); notice( t('Remote site reported: ') . $message . EOL);
break; break;
case 3: case 3:
notice( t("Introduction failed or was revoked.") . EOL); notice( t("Introduction failed or was revoked.") . EOL);
if(strlen($message)) if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL); notice( t('Remote site reported: ') . $message . EOL);
break; break;
} }
if(($status == 0) && ($intro_id)) { if (($status == 0) && ($intro_id)) {
// Success. Delete the notification. // Success. Delete the notification.
@ -302,7 +302,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
} }
if($status != 0) if ($status != 0)
return; return;
} }
@ -323,13 +323,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
logger('dfrn_confirm: confirm - imported photos'); logger('dfrn_confirm: confirm - imported photos');
if($network === NETWORK_DFRN) { if ($network === NETWORK_DFRN) {
$new_relation = CONTACT_IS_FOLLOWER; $new_relation = CONTACT_IS_FOLLOWER;
if(($relation == CONTACT_IS_SHARING) || ($duplex)) if (($relation == CONTACT_IS_SHARING) || ($duplex))
$new_relation = CONTACT_IS_FRIEND; $new_relation = CONTACT_IS_FRIEND;
if(($relation == CONTACT_IS_SHARING) && ($duplex)) if (($relation == CONTACT_IS_SHARING) && ($duplex))
$duplex = 0; $duplex = 0;
$r = q("UPDATE `contact` SET `rel` = %d, $r = q("UPDATE `contact` SET `rel` = %d,
@ -349,8 +349,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc(NETWORK_DFRN), dbesc(NETWORK_DFRN),
intval($contact_id) intval($contact_id)
); );
} } else {
else {
// $network !== NETWORK_DFRN // $network !== NETWORK_DFRN
@ -358,13 +357,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$notify = (($contact['notify']) ? $contact['notify'] : ''); $notify = (($contact['notify']) ? $contact['notify'] : '');
$poll = (($contact['poll']) ? $contact['poll'] : ''); $poll = (($contact['poll']) ? $contact['poll'] : '');
if((! $contact['notify']) || (! $contact['poll'])) { if ((! $contact['notify']) || (! $contact['poll'])) {
$arr = Probe::lrdd($contact['url']); $arr = Probe::lrdd($contact['url']);
if(count($arr)) { if (count($arr)) {
foreach($arr as $link) { foreach ($arr as $link) {
if($link['@attributes']['rel'] === 'salmon') if ($link['@attributes']['rel'] === 'salmon')
$notify = $link['@attributes']['href']; $notify = $link['@attributes']['href'];
if($link['@attributes']['rel'] === NAMESPACE_FEED) if ($link['@attributes']['rel'] === NAMESPACE_FEED)
$poll = $link['@attributes']['href']; $poll = $link['@attributes']['href'];
} }
} }
@ -373,13 +372,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$new_relation = $contact['rel']; $new_relation = $contact['rel'];
$writable = $contact['writable']; $writable = $contact['writable'];
if($network === NETWORK_DIASPORA) { if ($network === NETWORK_DIASPORA) {
if($duplex) if ($duplex)
$new_relation = CONTACT_IS_FRIEND; $new_relation = CONTACT_IS_FRIEND;
else else
$new_relation = CONTACT_IS_FOLLOWER; $new_relation = CONTACT_IS_FOLLOWER;
if($new_relation != CONTACT_IS_FOLLOWER) if ($new_relation != CONTACT_IS_FOLLOWER)
$writable = 1; $writable = 1;
} }
@ -444,7 +443,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid) 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'); require_once('include/items.php');
@ -452,7 +451,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid) intval($uid)
); );
if(count($self)) { if (count($self)) {
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32); $arr['guid'] = get_guid(32);
@ -491,14 +490,14 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$arr['deny_gid'] = $user[0]['deny_gid']; $arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr); $i = item_store($arr);
if($i) if ($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
} }
} }
} }
$def_gid = get_default_group($uid, $contact["network"]); $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); group_add_member($uid, '', $contact['id'], $def_gid);
// Let's send our user to the contact editor in case they want to // 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']; $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.'); $message = t('Our site encryption key is apparently messed up.');
xml_status(3,$message); 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); 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.'); $message = t('Empty site URL was provided or URL could not be decrypted by us.');
xml_status(3,$message); xml_status(3,$message);
// NOTREACHED // NOTREACHED
@ -651,7 +650,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
// It's possible that the other person also requested friendship. // It's possible that the other person also requested friendship.
// If it is a duplex relationship, ditch the issued-id if one exists. // 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", $r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d",
intval($dfrn_record) intval($dfrn_record)
); );
@ -723,7 +722,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
if (dbm::is_result($r)) if (dbm::is_result($r))
$combined = $r[0]; $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); $mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array( notification(array(
'type' => NOTIFY_CONFIRM, '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... // 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", $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($local_uid) 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'); require_once('include/items.php');
@ -756,7 +755,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($local_uid) intval($local_uid)
); );
if(count($self)) { if (dbm::is_result($self)) {
$arr = array(); $arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid); $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']; $arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr); $i = item_store($arr);
if($i) if ($i) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
} }
} }

View File

@ -28,12 +28,12 @@ function dfrn_notify_post(App $a) {
$prv = (($page == 2) ? 1 : 0); $prv = (($page == 2) ? 1 : 0);
$writable = (-1); $writable = (-1);
if($dfrn_version >= 2.21) { if ($dfrn_version >= 2.21) {
$writable = (($perm === 'rw') ? 1 : 0); $writable = (($perm === 'rw') ? 1 : 0);
} }
$direction = (-1); $direction = (-1);
if(strpos($dfrn_id,':') == 1) { if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1)); $direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2); $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); 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", q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
intval(($writable == (-1)) ? $importer['writable'] : $writable), intval(($writable == (-1)) ? $importer['writable'] : $writable),
intval($forum), intval($forum),
intval($prv), intval($prv),
intval($importer['id']) intval($importer['id'])
); );
if($writable != (-1)) if ($writable != (-1))
$importer['writable'] = $writable; $importer['writable'] = $writable;
$importer['forum'] = $page; $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: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA); logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
if($dissolve == 1) { if ($dissolve == 1) {
/* /*
* Relationship is dissolved permanently * 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 // 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 // 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 // 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); // xml_status(0);
$rino = get_config('system','rino_encrypt'); $rino = get_config('system','rino_encrypt');
@ -147,7 +147,7 @@ function dfrn_notify_post(App $a) {
logger("Local rino version: ". $rino, LOGGER_DEBUG); 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! // 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 // 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)); logger('rino: md5 raw key: ' . md5($rawkey));
$final_key = ''; $final_key = '';
if($dfrn_version >= 2.1) { if ($dfrn_version >= 2.1) {
if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) { if ((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']); openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']);
} }
else { else {
@ -169,7 +169,7 @@ function dfrn_notify_post(App $a) {
} }
} }
else { 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']); openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']);
} }
else { else {
@ -223,7 +223,7 @@ function dfrn_notify_post(App $a) {
function dfrn_notify_content(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. // initial communication from external contact, $direction is their direction.
// If this is a duplex communication, ours will be the opposite. // 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); logger('dfrn_notify: new notification dfrn_id=' . $dfrn_id);
$direction = (-1); $direction = (-1);
if(strpos($dfrn_id,':') == 1) { if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1)); $direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2); $dfrn_id = substr($dfrn_id,2);
} }
@ -298,16 +298,15 @@ function dfrn_notify_content(App $a) {
$pub_key = trim($r[0]['pubkey']); $pub_key = trim($r[0]['pubkey']);
$dplx = intval($r[0]['duplex']); $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($hash,$challenge,$prv_key);
openssl_private_encrypt($id_str,$encrypted_id,$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($hash,$challenge,$pub_key);
openssl_public_encrypt($id_str,$encrypted_id,$pub_key); openssl_public_encrypt($id_str,$encrypted_id,$pub_key);
} } else {
else
$status = 1; $status = 1;
}
$challenge = bin2hex($challenge); $challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id); $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 requested rino is higher than enabled local rino, reply with local rino
if ($rino_remote < $rino) $rino = $rino_remote; 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'; $perm = 'rw';
} } else {
else {
$perm = 'r'; $perm = 'r';
} }

View File

@ -20,20 +20,20 @@ function dfrn_poll_init(App $a) {
$direction = (-1); $direction = (-1);
if(strpos($dfrn_id,':') == 1) { if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1)); $direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2); $dfrn_id = substr($dfrn_id,2);
} }
$hidewall = false; $hidewall = false;
if(($dfrn_id === '') && (! x($_POST,'dfrn_id'))) { if (($dfrn_id === '') && (! x($_POST,'dfrn_id'))) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
http_status_exit(403); http_status_exit(403);
} }
$user = ''; $user = '';
if($a->argc > 1) { if ($a->argc > 1) {
$r = q("SELECT `hidewall`,`nickname` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1", $r = q("SELECT `hidewall`,`nickname` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1",
dbesc($a->argv[1]) dbesc($a->argv[1])
); );
@ -51,7 +51,7 @@ function dfrn_poll_init(App $a) {
killme(); killme();
} }
if(($type === 'profile') && (! strlen($sec))) { if (($type === 'profile') && (! strlen($sec))) {
$sql_extra = ''; $sql_extra = '';
switch($direction) { switch($direction) {
@ -85,13 +85,13 @@ function dfrn_poll_init(App $a) {
logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA); logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA);
if(strlen($s)) { if (strlen($s)) {
$xml = parse_xml_string($s); $xml = parse_xml_string($s);
if((int) $xml->status == 1) { if ((int) $xml->status == 1) {
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
if(! x($_SESSION,'remote')) if (! x($_SESSION,'remote'))
$_SESSION['remote'] = array(); $_SESSION['remote'] = array();
$_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']); $_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
@ -100,7 +100,7 @@ function dfrn_poll_init(App $a) {
$_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_handle'] = $r[0]['addr']; $_SESSION['visitor_handle'] = $r[0]['addr'];
$_SESSION['visitor_visiting'] = $r[0]['uid']; $_SESSION['visitor_visiting'] = $r[0]['uid'];
if(!$quiet) if (!$quiet)
info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL); info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL);
// Visitors get 1 day session. // Visitors get 1 day session.
$session_id = session_id(); $session_id = session_id();
@ -118,9 +118,9 @@ function dfrn_poll_init(App $a) {
} }
if($type === 'profile-check' && $dfrn_version < 2.2 ) { if ($type === 'profile-check' && $dfrn_version < 2.2 ) {
if((strlen($challenge)) && (strlen($sec))) { if ((strlen($challenge)) && (strlen($sec))) {
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
@ -131,7 +131,7 @@ function dfrn_poll_init(App $a) {
// NOTREACHED // NOTREACHED
} }
$orig_id = $r[0]['dfrn_id']; $orig_id = $r[0]['dfrn_id'];
if(strpos($orig_id, ':')) if (strpos($orig_id, ':'))
$orig_id = substr($orig_id,2); $orig_id = substr($orig_id,2);
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
@ -147,7 +147,7 @@ function dfrn_poll_init(App $a) {
$final_dfrn_id = ''; $final_dfrn_id = '';
if(($contact['duplex']) && strlen($contact['prvkey'])) { if (($contact['duplex']) && strlen($contact['prvkey'])) {
openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']); openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']);
} }
@ -158,10 +158,10 @@ function dfrn_poll_init(App $a) {
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
if(strpos($final_dfrn_id,':') == 1) if (strpos($final_dfrn_id,':') == 1)
$final_dfrn_id = substr($final_dfrn_id,2); $final_dfrn_id = substr($final_dfrn_id,2);
if($final_dfrn_id != $orig_id) { if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site // did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption'); xml_status(3, 'Bad decryption');
@ -213,9 +213,9 @@ function dfrn_poll_post(App $a) {
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0); $dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
$perm = ((x($_POST,'perm')) ? $_POST['perm'] : 'r'); $perm = ((x($_POST,'perm')) ? $_POST['perm'] : 'r');
if($ptype === 'profile-check') { if ($ptype === 'profile-check') {
if((strlen($challenge)) && (strlen($sec))) { if ((strlen($challenge)) && (strlen($sec))) {
logger('dfrn_poll: POST: profile-check'); logger('dfrn_poll: POST: profile-check');
@ -228,7 +228,7 @@ function dfrn_poll_post(App $a) {
// NOTREACHED // NOTREACHED
} }
$orig_id = $r[0]['dfrn_id']; $orig_id = $r[0]['dfrn_id'];
if(strpos($orig_id, ':')) if (strpos($orig_id, ':'))
$orig_id = substr($orig_id,2); $orig_id = substr($orig_id,2);
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
@ -244,7 +244,7 @@ function dfrn_poll_post(App $a) {
$final_dfrn_id = ''; $final_dfrn_id = '';
if(($contact['duplex']) && strlen($contact['prvkey'])) { if (($contact['duplex']) && strlen($contact['prvkey'])) {
openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']); openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']);
} }
@ -255,10 +255,10 @@ function dfrn_poll_post(App $a) {
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
if(strpos($final_dfrn_id,':') == 1) if (strpos($final_dfrn_id,':') == 1)
$final_dfrn_id = substr($final_dfrn_id,2); $final_dfrn_id = substr($final_dfrn_id,2);
if($final_dfrn_id != $orig_id) { if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site // did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption'); xml_status(3, 'Bad decryption');
@ -273,7 +273,7 @@ function dfrn_poll_post(App $a) {
} }
$direction = (-1); $direction = (-1);
if(strpos($dfrn_id,':') == 1) { if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1)); $direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2); $dfrn_id = substr($dfrn_id,2);
} }
@ -329,7 +329,7 @@ function dfrn_poll_post(App $a) {
$contact_id = $r[0]['id']; $contact_id = $r[0]['id'];
if($type === 'reputation' && strlen($url)) { if ($type === 'reputation' && strlen($url)) {
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($url), dbesc($url),
intval($owner_uid) intval($owner_uid)
@ -341,7 +341,7 @@ function dfrn_poll_post(App $a) {
$reputation = $r[0]['rating']; $reputation = $r[0]['rating'];
$text = $r[0]['reason']; $text = $r[0]['reason'];
if($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed if ($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed
$reputation = 0; $reputation = 0;
$text = ''; $text = '';
} }
@ -361,13 +361,13 @@ function dfrn_poll_post(App $a) {
// Update the writable flag if it changed // Update the writable flag if it changed
logger('dfrn_poll: post request feed: ' . print_r($_POST,true),LOGGER_DATA); logger('dfrn_poll: post request feed: ' . print_r($_POST,true),LOGGER_DATA);
if($dfrn_version >= 2.21) { if ($dfrn_version >= 2.21) {
if($perm === 'rw') if ($perm === 'rw')
$writable = 1; $writable = 1;
else else
$writable = 0; $writable = 0;
if($writable != $contact['writable']) { if ($writable != $contact['writable']) {
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d", q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
intval($writable), intval($writable),
intval($contact_id) intval($contact_id)
@ -395,13 +395,13 @@ function dfrn_poll_content(App $a) {
$quiet = ((x($_GET,'quiet')) ? true : false); $quiet = ((x($_GET,'quiet')) ? true : false);
$direction = (-1); $direction = (-1);
if(strpos($dfrn_id,':') == 1) { if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1)); $direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2); $dfrn_id = substr($dfrn_id,2);
} }
if($dfrn_id != '') { if ($dfrn_id != '') {
// initial communication from external contact // initial communication from external contact
$hash = random_string(); $hash = random_string();
@ -409,7 +409,7 @@ function dfrn_poll_content(App $a) {
$r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
if($type !== 'profile') { if ($type !== 'profile') {
$r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` ) $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )
VALUES( '%s', '%s', '%s', '%s', '%s' ) ", VALUES( '%s', '%s', '%s', '%s', '%s' ) ",
dbesc($hash), dbesc($hash),
@ -422,7 +422,7 @@ function dfrn_poll_content(App $a) {
$sql_extra = ''; $sql_extra = '';
switch($direction) { switch($direction) {
case (-1): case (-1):
if($type === 'profile') if ($type === 'profile')
$sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id)); $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id));
else else
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
@ -456,7 +456,7 @@ function dfrn_poll_content(App $a) {
$encrypted_id = ''; $encrypted_id = '';
$id_str = $my_id . '.' . mt_rand(1000,9999); $id_str = $my_id . '.' . mt_rand(1000,9999);
if(($r[0]['duplex'] && strlen($r[0]['pubkey'])) || (! strlen($r[0]['prvkey']))) { if (($r[0]['duplex'] && strlen($r[0]['pubkey'])) || (! strlen($r[0]['prvkey']))) {
openssl_public_encrypt($hash,$challenge,$r[0]['pubkey']); openssl_public_encrypt($hash,$challenge,$r[0]['pubkey']);
openssl_public_encrypt($id_str,$encrypted_id,$r[0]['pubkey']); openssl_public_encrypt($id_str,$encrypted_id,$r[0]['pubkey']);
} }
@ -474,11 +474,11 @@ function dfrn_poll_content(App $a) {
$encrypted_id = ''; $encrypted_id = '';
} }
if(($type === 'profile') && (strlen($sec))) { if (($type === 'profile') && (strlen($sec))) {
// URL reply // URL reply
if($dfrn_version < 2.2) { if ($dfrn_version < 2.2) {
$s = fetch_url($r[0]['poll'] $s = fetch_url($r[0]['poll']
. '?dfrn_id=' . $encrypted_id . '?dfrn_id=' . $encrypted_id
. '&type=profile-check' . '&type=profile-check'
@ -517,7 +517,7 @@ function dfrn_poll_content(App $a) {
logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA);
if(strlen($s) && strstr($s,'<?xml')) { if (strlen($s) && strstr($s,'<?xml')) {
$xml = parse_xml_string($s); $xml = parse_xml_string($s);
@ -527,15 +527,15 @@ function dfrn_poll_content(App $a) {
logger('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec); logger('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec);
if(((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) { if (((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
if(! x($_SESSION,'remote')) if (! x($_SESSION,'remote'))
$_SESSION['remote'] = array(); $_SESSION['remote'] = array();
$_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']); $_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
$_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_id'] = $r[0]['id'];
$_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_visiting'] = $r[0]['uid']; $_SESSION['visitor_visiting'] = $r[0]['uid'];
if(!$quiet) if (!$quiet)
info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL); info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL);
// Visitors get 1 day session. // Visitors get 1 day session.
$session_id = session_id(); $session_id = session_id();

View File

@ -19,7 +19,7 @@ require_once('include/group.php');
function dfrn_request_init(App $a) { function dfrn_request_init(App $a) {
if($a->argc > 1) if ($a->argc > 1)
$which = $a->argv[1]; $which = $a->argv[1];
profile_load($a,$which); profile_load($a,$which);
@ -44,13 +44,13 @@ function dfrn_request_init(App $a) {
*/ */
function dfrn_request_post(App $a) { function dfrn_request_post(App $a) {
if(($a->argc != 2) || (! count($a->profile))) { if (($a->argc != 2) || (! count($a->profile))) {
logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile));
return; return;
} }
if(x($_POST, 'cancel')) { if (x($_POST, 'cancel')) {
goaway(z_root()); goaway(z_root());
} }
@ -63,13 +63,13 @@ function dfrn_request_post(App $a) {
* *
*/ */
if((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) { if ((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
/* /*
* Ensure this is a valid request * Ensure this is a valid request
*/ */
if(local_user() && ($a->user['nickname'] == $a->argv[1]) && (x($_POST,'dfrn_url'))) { if (local_user() && ($a->user['nickname'] == $a->argv[1]) && (x($_POST,'dfrn_url'))) {
$dfrn_url = notags(trim($_POST['dfrn_url'])); $dfrn_url = notags(trim($_POST['dfrn_url']));
@ -80,7 +80,7 @@ function dfrn_request_post(App $a) {
$blocked = 1; $blocked = 1;
$pending = 1; $pending = 1;
if(x($dfrn_url)) { if (x($dfrn_url)) {
/* /*
* Lookup the contact based on their URL (which is the only unique thing we have at the moment) * Lookup the contact based on their URL (which is the only unique thing we have at the moment)
@ -92,7 +92,7 @@ function dfrn_request_post(App $a) {
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
if(strlen($r[0]['dfrn-id'])) { if (strlen($r[0]['dfrn-id'])) {
/* /*
* We don't need to be here. It has already happened. * We don't need to be here. It has already happened.
@ -105,7 +105,7 @@ function dfrn_request_post(App $a) {
$contact_record = $r[0]; $contact_record = $r[0];
} }
if(is_array($contact_record)) { if (is_array($contact_record)) {
$r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d", $r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d",
intval($aes_allow), intval($aes_allow),
intval($hidden), intval($hidden),
@ -187,7 +187,7 @@ function dfrn_request_post(App $a) {
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$def_gid = get_default_group(local_user(), $r[0]["network"]); $def_gid = get_default_group(local_user(), $r[0]["network"]);
if(intval($def_gid)) if (intval($def_gid))
group_add_member(local_user(), '', $r[0]['id'], $def_gid); group_add_member(local_user(), '', $r[0]['id'], $def_gid);
if (isset($photo)) if (isset($photo))
@ -249,7 +249,7 @@ function dfrn_request_post(App $a) {
* *
*/ */
if(! (is_array($a->profile) && count($a->profile))) { if (! (is_array($a->profile) && count($a->profile))) {
notice( t('Profile unavailable.') . EOL); notice( t('Profile unavailable.') . EOL);
return; return;
} }
@ -265,13 +265,13 @@ function dfrn_request_post(App $a) {
$pending = 1; $pending = 1;
if( x($_POST,'dfrn_url')) { if ( x($_POST,'dfrn_url')) {
/* /*
* Block friend request spam * Block friend request spam
*/ */
if($maxreq) { if ($maxreq) {
$r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d", $r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d",
dbesc(datetime_convert('UTC','UTC','now - 24 hours')), dbesc(datetime_convert('UTC','UTC','now - 24 hours')),
intval($uid) intval($uid)
@ -300,7 +300,7 @@ function dfrn_request_post(App $a) {
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
if(! $rr['rel']) { if (! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`", q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`",
intval($rr['cid']) intval($rr['cid'])
); );
@ -325,7 +325,7 @@ function dfrn_request_post(App $a) {
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
if(! $rr['rel']) { if (! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`", q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`",
intval($rr['cid']) intval($rr['cid'])
); );
@ -340,16 +340,16 @@ function dfrn_request_post(App $a) {
$real_name = (x($_POST,'realname') ? notags(trim($_POST['realname'])) : ''); $real_name = (x($_POST,'realname') ? notags(trim($_POST['realname'])) : '');
$url = trim($_POST['dfrn_url']); $url = trim($_POST['dfrn_url']);
if(! strlen($url)) { if (! strlen($url)) {
notice( t("Invalid locator") . EOL ); notice( t("Invalid locator") . EOL );
return; return;
} }
$hcard = ''; $hcard = '';
if($email_follow) { if ($email_follow) {
if(! validate_email($url)) { if (! validate_email($url)) {
notice( t('Invalid email address.') . EOL); notice( t('Invalid email address.') . EOL);
return; return;
} }
@ -365,10 +365,10 @@ function dfrn_request_post(App $a) {
$rel = CONTACT_IS_FOLLOWER; $rel = CONTACT_IS_FOLLOWER;
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(get_config('system','dfrn_only')) if (get_config('system','dfrn_only'))
$mail_disabled = 1; $mail_disabled = 1;
if(! $mail_disabled) { if (! $mail_disabled) {
$failed = false; $failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($uid) intval($uid)
@ -470,18 +470,18 @@ function dfrn_request_post(App $a) {
logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG); logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG);
if($network === NETWORK_DFRN) { if ($network === NETWORK_DFRN) {
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
intval($uid), intval($uid),
dbesc($url) dbesc($url)
); );
if (dbm::is_result($ret)) { if (dbm::is_result($ret)) {
if(strlen($ret[0]['issued-id'])) { if (strlen($ret[0]['issued-id'])) {
notice( t('You have already introduced yourself here.') . EOL ); notice( t('You have already introduced yourself here.') . EOL );
return; return;
} }
elseif($ret[0]['rel'] == CONTACT_IS_FRIEND) { elseif ($ret[0]['rel'] == CONTACT_IS_FRIEND) {
notice( sprintf( t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL); notice( sprintf( t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL);
return; return;
} }
@ -493,7 +493,7 @@ function dfrn_request_post(App $a) {
$issued_id = random_string(); $issued_id = random_string();
if(is_array($contact_record)) { if (is_array($contact_record)) {
// There is a contact record but no issued-id, so this // There is a contact record but no issued-id, so this
// is a reciprocal introduction from a known contact // is a reciprocal introduction from a known contact
$r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d", $r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d",
@ -718,7 +718,7 @@ function dfrn_request_content(App $a) {
return $o; return $o;
} }
elseif((x($_GET,'confirm_key')) && strlen($_GET['confirm_key'])) { elseif ((x($_GET,'confirm_key')) && strlen($_GET['confirm_key'])) {
// we are the requestee and it is now safe to send our user their introduction, // we are the requestee and it is now safe to send our user their introduction,
// We could just unblock it, but first we have to jump through a few hoops to // We could just unblock it, but first we have to jump through a few hoops to
@ -738,10 +738,10 @@ function dfrn_request_content(App $a) {
$auto_confirm = false; $auto_confirm = false;
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
if(($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP)) if (($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP))
$auto_confirm = true; $auto_confirm = true;
if(! $auto_confirm) { if (! $auto_confirm) {
notification(array( notification(array(
'type' => NOTIFY_INTRO, 'type' => NOTIFY_INTRO,
@ -759,7 +759,7 @@ function dfrn_request_content(App $a) {
)); ));
} }
if($auto_confirm) { if ($auto_confirm) {
require_once('mod/dfrn_confirm.php'); require_once('mod/dfrn_confirm.php');
$handsfree = array( $handsfree = array(
'uid' => $r[0]['uid'], 'uid' => $r[0]['uid'],
@ -774,7 +774,7 @@ function dfrn_request_content(App $a) {
} }
if(! $auto_confirm) { if (! $auto_confirm) {
// If we are auto_confirming, this record will have already been nuked // If we are auto_confirming, this record will have already been nuked
// in dfrn_confirm_post() // in dfrn_confirm_post()
@ -794,8 +794,8 @@ function dfrn_request_content(App $a) {
* Normal web request. Display our user's introduction form. * Normal web request. Display our user's introduction form.
*/ */
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
if(! get_config('system','local_block')) { if (! get_config('system','local_block')) {
notice( t('Public access denied.') . EOL); notice( t('Public access denied.') . EOL);
return; return;
} }

View File

@ -3,7 +3,7 @@
function directory_init(App $a) { function directory_init(App $a) {
$a->set_pager_itemspage(60); $a->set_pager_itemspage(60);
if(local_user()) { if (local_user()) {
require_once('include/contact_widgets.php'); require_once('include/contact_widgets.php');
$a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= findpeople_widget();
@ -21,7 +21,7 @@ function directory_init(App $a) {
function directory_post(App $a) { function directory_post(App $a) {
if(x($_POST,'search')) if (x($_POST,'search'))
$a->data['search'] = $_POST['search']; $a->data['search'] = $_POST['search'];
} }
@ -32,7 +32,7 @@ function directory_content(App $a) {
require_once("mod/proxy.php"); require_once("mod/proxy.php");
if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) || if ((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
(get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) { (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL); notice( t('Public access denied.') . EOL);
return; return;
@ -41,18 +41,18 @@ function directory_content(App $a) {
$o = ''; $o = '';
nav_set_selected('directory'); nav_set_selected('directory');
if(x($a->data,'search')) if (x($a->data,'search'))
$search = notags(trim($a->data['search'])); $search = notags(trim($a->data['search']));
else else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$gdirpath = ''; $gdirpath = '';
$dirurl = get_config('system','directory'); $dirurl = get_config('system','directory');
if(strlen($dirurl)) { if (strlen($dirurl)) {
$gdirpath = zrl($dirurl,true); $gdirpath = zrl($dirurl,true);
} }
if($search) { if ($search) {
$search = dbesc($search); $search = dbesc($search);
$sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
@ -110,28 +110,28 @@ function directory_content(App $a) {
$pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : ''); $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
$details = ''; $details = '';
if(strlen($rr['locality'])) if (strlen($rr['locality']))
$details .= $rr['locality']; $details .= $rr['locality'];
if(strlen($rr['region'])) { if (strlen($rr['region'])) {
if(strlen($rr['locality'])) if (strlen($rr['locality']))
$details .= ', '; $details .= ', ';
$details .= $rr['region']; $details .= $rr['region'];
} }
if(strlen($rr['country-name'])) { if (strlen($rr['country-name'])) {
if(strlen($details)) if (strlen($details))
$details .= ', '; $details .= ', ';
$details .= $rr['country-name']; $details .= $rr['country-name'];
} }
// if(strlen($rr['dob'])) { // if (strlen($rr['dob'])) {
// if(($years = age($rr['dob'],$rr['timezone'],'')) != 0) // if (($years = age($rr['dob'],$rr['timezone'],'')) != 0)
// $details .= '<br />' . t('Age: ') . $years ; // $details .= '<br />' . t('Age: ') . $years ;
// } // }
// if(strlen($rr['gender'])) // if (strlen($rr['gender']))
// $details .= '<br />' . t('Gender: ') . $rr['gender']; // $details .= '<br />' . t('Gender: ') . $rr['gender'];
$profile = $rr; $profile = $rr;
if((x($profile,'address') == 1) if ((x($profile,'address') == 1)
|| (x($profile,'locality') == 1) || (x($profile,'locality') == 1)
|| (x($profile,'region') == 1) || (x($profile,'region') == 1)
|| (x($profile,'postal-code') == 1) || (x($profile,'postal-code') == 1)
@ -146,7 +146,7 @@ function directory_content(App $a) {
$about = ((x($profile,'about') == 1) ? t('About:') : False); $about = ((x($profile,'about') == 1) ? t('About:') : False);
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$location_e = template_escape($location); $location_e = template_escape($location);
} }
else { else {
@ -185,8 +185,9 @@ function directory_content(App $a) {
unset($profile); unset($profile);
unset($location); unset($location);
if(! $arr['entry']) if (! $arr['entry']) {
continue; continue;
}
$entries[] = $arr['entry']; $entries[] = $arr['entry'];

View File

@ -166,8 +166,9 @@ function dirfind_content(App $a, $prefix = "") {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
if(strlen(get_config('system','directory'))) if (strlen(get_config('system','directory'))) {
$x = fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search)); $x = fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
}
$j = json_decode($x); $j = json_decode($x);
} }

View File

@ -51,7 +51,7 @@ function editpost_content(App $a) {
$tpl = get_markup_template("jot.tpl"); $tpl = get_markup_template("jot.tpl");
if(($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) if (($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))))
$lockstate = 'lock'; $lockstate = 'lock';
else else
$lockstate = 'unlock'; $lockstate = 'unlock';
@ -64,13 +64,13 @@ function editpost_content(App $a) {
$mail_enabled = false; $mail_enabled = false;
$pubmail_enabled = false; $pubmail_enabled = false;
if(! $mail_disabled) { if (! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user()) intval(local_user())
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$mail_enabled = true; $mail_enabled = true;
if(intval($r[0]['pubmail'])) if (intval($r[0]['pubmail']))
$pubmail_enabled = true; $pubmail_enabled = true;
} }
} }
@ -78,7 +78,7 @@ function editpost_content(App $a) {
// I don't think there's any need for the $jotnets when editing the post, // I don't think there's any need for the $jotnets when editing the post,
// and including them makes it difficult for the JS-free theme, so let's // and including them makes it difficult for the JS-free theme, so let's
// disable them // disable them
/* if($mail_enabled) { /* if ($mail_enabled) {
$selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
$jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> ' $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
. t("Post to Email") . '</div>'; . t("Post to Email") . '</div>';

View File

@ -105,9 +105,9 @@ function events_post(App $a) {
goaway($onerror_url); goaway($onerror_url);
} }
if((! $summary) || (! $start)) { if ((! $summary) || (! $start)) {
notice( t('Event title and start time are required.') . EOL); notice( t('Event title and start time are required.') . EOL);
if(intval($_REQUEST['preview'])) { if (intval($_REQUEST['preview'])) {
echo( t('Event title and start time are required.')); echo( t('Event title and start time are required.'));
killme(); killme();
} }
@ -119,27 +119,27 @@ function events_post(App $a) {
$c = q("select id from contact where uid = %d and self = 1 limit 1", $c = q("select id from contact where uid = %d and self = 1 limit 1",
intval(local_user()) intval(local_user())
); );
if(count($c)) if (count($c))
$self = $c[0]['id']; $self = $c[0]['id'];
else else
$self = 0; $self = 0;
if($share) { if ($share) {
$str_group_allow = perms2str($_POST['group_allow']); $str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']); $str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']); $str_group_deny = perms2str($_POST['group_deny']);
$str_contact_deny = perms2str($_POST['contact_deny']); $str_contact_deny = perms2str($_POST['contact_deny']);
// Undo the pseudo-contact of self, since there are real contacts now // Undo the pseudo-contact of self, since there are real contacts now
if( strpos($str_contact_allow, '<' . $self . '>') !== false ) if ( strpos($str_contact_allow, '<' . $self . '>') !== false )
{ {
$str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow); $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow);
} }
// Make sure to set the `private` field as true. This is necessary to // Make sure to set the `private` field as true. This is necessary to
// have the posts show up correctly in Diaspora if an event is created // have the posts show up correctly in Diaspora if an event is created
// as visible only to self at first, but then edited to display to others. // as visible only to self at first, but then edited to display to others.
if( strlen($str_group_allow) or strlen($str_contact_allow) or strlen($str_group_deny) or strlen($str_contact_deny) ) if ( strlen($str_group_allow) or strlen($str_contact_allow) or strlen($str_group_deny) or strlen($str_contact_deny) )
{ {
$private_event = true; $private_event = true;
} }
@ -173,7 +173,7 @@ function events_post(App $a) {
$datarray['created'] = $created; $datarray['created'] = $created;
$datarray['edited'] = $edited; $datarray['edited'] = $edited;
if(intval($_REQUEST['preview'])) { if (intval($_REQUEST['preview'])) {
$html = format_event_html($datarray); $html = format_event_html($datarray);
echo $html; echo $html;
killme(); killme();
@ -181,7 +181,7 @@ function events_post(App $a) {
$item_id = event_store($datarray); $item_id = event_store($datarray);
if(! $cid) if (! $cid)
proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id); proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id);
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
@ -248,7 +248,7 @@ function events_content(App $a) {
$m = 0; $m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
if($a->argc > 1) { if ($a->argc > 1) {
if ($a->argc > 2 && $a->argv[1] == 'event') { if ($a->argc > 2 && $a->argv[1] == 'event') {
$mode = 'edit'; $mode = 'edit';
$event_id = intval($a->argv[2]); $event_id = intval($a->argv[2]);
@ -289,13 +289,13 @@ function events_content(App $a) {
$nextyear = $y; $nextyear = $y;
$nextmonth = $m + 1; $nextmonth = $m + 1;
if($nextmonth > 12) { if ($nextmonth > 12) {
$nextmonth = 1; $nextmonth = 1;
$nextyear ++; $nextyear ++;
} }
$prevyear = $y; $prevyear = $y;
if($m > 1) if ($m > 1)
$prevmonth = $m - 1; $prevmonth = $m - 1;
else { else {
$prevmonth = 12; $prevmonth = 12;
@ -371,9 +371,9 @@ function events_content(App $a) {
} }
// Get rid of dashes in key names, Smarty3 can't handle them // 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(); $event_item = array();
foreach($event['item'] as $k => $v) { foreach ($event['item'] as $k => $v) {
$k = str_replace('-','_',$k); $k = str_replace('-','_',$k);
$event_item[$k] = $v; $event_item[$k] = $v;
} }
@ -405,7 +405,7 @@ function events_content(App $a) {
} }
if($mode === 'edit' && $event_id) { if ($mode === 'edit' && $event_id) {
$r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($event_id), intval($event_id),
intval(local_user()) intval(local_user())
@ -415,19 +415,19 @@ function events_content(App $a) {
} }
// Passed parameters overrides anything found in the DB // Passed parameters overrides anything found in the DB
if($mode === 'edit' || $mode === 'new') { if ($mode === 'edit' || $mode === 'new') {
if(!x($orig_event)) $orig_event = array(); if (!x($orig_event)) $orig_event = array();
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values // In case of an error the browser is redirected back here, with these parameters filled in with the previous values
if(x($_REQUEST,'nofinish')) $orig_event['nofinish'] = $_REQUEST['nofinish']; if (x($_REQUEST,'nofinish')) $orig_event['nofinish'] = $_REQUEST['nofinish'];
if(x($_REQUEST,'adjust')) $orig_event['adjust'] = $_REQUEST['adjust']; if (x($_REQUEST,'adjust')) $orig_event['adjust'] = $_REQUEST['adjust'];
if(x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary']; if (x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary'];
if(x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description']; if (x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description'];
if(x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location']; if (x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location'];
if(x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start']; if (x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start'];
if(x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish']; if (x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish'];
} }
if($mode === 'edit' || $mode === 'new') { if ($mode === 'edit' || $mode === 'new') {
$n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : ''); $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
$a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : ''); $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : '');
@ -439,21 +439,24 @@ function events_content(App $a) {
$uri = ((x($orig_event)) ? $orig_event['uri'] : ''); $uri = ((x($orig_event)) ? $orig_event['uri'] : '');
if(! x($orig_event)) if (! x($orig_event)) {
$sh_checked = ''; $sh_checked = '';
else } else {
$sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); $sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
}
if($cid OR ($mode !== 'new')) if ($cid OR ($mode !== 'new')) {
$sh_checked .= ' disabled="disabled" '; $sh_checked .= ' disabled="disabled" ';
}
$sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now'); $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
$tz = date_default_timezone_get(); $tz = date_default_timezone_get();
if(x($orig_event)) if (x($orig_event)) {
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC'); $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
}
$syear = datetime_convert('UTC', $tz, $sdt, 'Y'); $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
$smonth = datetime_convert('UTC', $tz, $sdt, 'm'); $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
@ -470,8 +473,9 @@ function events_content(App $a) {
$fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0); $fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0);
$f = get_config('system','event_input_format'); $f = get_config('system','event_input_format');
if(! $f) if (! $f) {
$f = 'ymd'; $f = 'ymd';
}
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');

View File

@ -66,10 +66,9 @@ function fbrowser_content(App $a) {
$types = Photo::supportedTypes(); $types = Photo::supportedTypes();
$ext = $types[$rr['type']]; $ext = $types[$rr['type']];
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']); $filename_e = template_escape($rr['filename']);
} } else {
else {
$filename_e = $rr['filename']; $filename_e = $rr['filename'];
} }

View File

@ -16,7 +16,7 @@ function filer_content(App $a) {
logger('filer: tag ' . $term . ' item ' . $item_id); logger('filer: tag ' . $term . ' item ' . $item_id);
if($item_id && strlen($term)){ if ($item_id && strlen($term)){
// file item // file item
file_tag_save_file(local_user(),$item_id,$term); file_tag_save_file(local_user(),$item_id,$term);
} else { } else {

View File

@ -7,7 +7,7 @@ function friendica_init(App $a) {
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'); $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
$sql_extra = ''; $sql_extra = '';
if(x($a->config,'admin_nickname')) { if (x($a->config,'admin_nickname')) {
$sql_extra = sprintf(" AND nickname = '%s' ",dbesc($a->config['admin_nickname'])); $sql_extra = sprintf(" AND nickname = '%s' ",dbesc($a->config['admin_nickname']));
} }
if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){ if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){
@ -24,18 +24,18 @@ function friendica_init(App $a) {
} }
$visible_plugins = array(); $visible_plugins = array();
if(is_array($a->plugins) && count($a->plugins)) { if (is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0"); $r = q("select * from addon where hidden = 0");
if (dbm::is_result($r)) if (dbm::is_result($r))
foreach($r as $rr) foreach ($r as $rr)
$visible_plugins[] = $rr['name']; $visible_plugins[] = $rr['name'];
} }
Config::load('feature_lock'); Config::load('feature_lock');
$locked_features = array(); $locked_features = array();
if(is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) { if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
foreach($a->config['feature_lock'] as $k => $v) { foreach ($a->config['feature_lock'] as $k => $v) {
if($k === 'config_loaded') if ($k === 'config_loaded')
continue; continue;
$locked_features[$k] = intval($v); $locked_features[$k] = intval($v);
} }
@ -80,22 +80,24 @@ function friendica_content(App $a) {
$o .= '<p></p>'; $o .= '<p></p>';
$visible_plugins = array(); $visible_plugins = array();
if(is_array($a->plugins) && count($a->plugins)) { if (is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0"); $r = q("select * from addon where hidden = 0");
if (dbm::is_result($r)) if (dbm::is_result($r))
foreach($r as $rr) foreach ($r as $rr)
$visible_plugins[] = $rr['name']; $visible_plugins[] = $rr['name'];
} }
if(count($visible_plugins)) { if (count($visible_plugins)) {
$o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>'; $o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
$sorted = $visible_plugins; $sorted = $visible_plugins;
$s = ''; $s = '';
sort($sorted); sort($sorted);
foreach($sorted as $p) { foreach ($sorted as $p) {
if(strlen($p)) { if (strlen($p)) {
if(strlen($s)) $s .= ', '; if (strlen($s)) {
$s .= ', ';
}
$s .= $p; $s .= $p;
} }
} }

View File

@ -29,7 +29,7 @@ function fsuggest_post(App $a) {
$note = escape_tags(trim($_POST['note'])); $note = escape_tags(trim($_POST['note']));
if($new_contact) { if ($new_contact) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($new_contact), intval($new_contact),
intval(local_user()) intval(local_user())
@ -80,8 +80,9 @@ function fsuggest_content(App $a) {
return; return;
} }
if($a->argc != 2) if ($a->argc != 2) {
return; return;
}
$contact_id = intval($a->argv[1]); $contact_id = intval($a->argv[1]);

View File

@ -5,7 +5,7 @@ function validate_members(&$item) {
} }
function group_init(App $a) { function group_init(App $a) {
if(local_user()) { if (local_user()) {
require_once('include/group.php'); require_once('include/group.php');
$a->page['aside'] = group_side('contacts','group','extended',(($a->argc > 1) ? intval($a->argv[1]) : 0)); $a->page['aside'] = group_side('contacts','group','extended',(($a->argc > 1) ? intval($a->argv[1]) : 0));
} }
@ -20,7 +20,7 @@ function group_post(App $a) {
return; return;
} }
if(($a->argc == 2) && ($a->argv[1] === 'new')) { if (($a->argc == 2) && ($a->argv[1] === 'new')) {
check_form_security_token_redirectOnErr('/group/new', 'group_edit'); check_form_security_token_redirectOnErr('/group/new', 'group_edit');
$name = notags(trim($_POST['groupname'])); $name = notags(trim($_POST['groupname']));
@ -80,10 +80,12 @@ function group_content(App $a) {
// Switch to text mode interface if we have more than 'n' contacts or group members // Switch to text mode interface if we have more than 'n' contacts or group members
$switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit'); $switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
if($switchtotext === false) if ($switchtotext === false) {
$switchtotext = get_config('system','groupedit_image_limit'); $switchtotext = get_config('system','groupedit_image_limit');
if($switchtotext === false) }
if ($switchtotext === false) {
$switchtotext = 400; $switchtotext = 400;
}
$tpl = get_markup_template('group_edit.tpl'); $tpl = get_markup_template('group_edit.tpl');
@ -99,8 +101,6 @@ function group_content(App $a) {
'$gid' => 'new', '$gid' => 'new',
'$form_security_token' => get_form_security_token("group_edit"), '$form_security_token' => get_form_security_token("group_edit"),
)); ));
} }
if (($a->argc == 3) && ($a->argv[1] === 'drop')) { if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
@ -135,9 +135,10 @@ function group_content(App $a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$change = intval($a->argv[2]); $change = intval($a->argv[2]);
} }
}
if (($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
@ -153,23 +154,23 @@ function group_content(App $a) {
$group = $r[0]; $group = $r[0];
$members = group_get_members($group['id']); $members = group_get_members($group['id']);
$preselected = array(); $preselected = array();
if(count($members)) { if (count($members)) {
foreach($members as $member) foreach ($members as $member) {
$preselected[] = $member['id']; $preselected[] = $member['id'];
} }
if($change) {
if(in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
} }
else {
if ($change) {
if (in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
} else {
group_add_member(local_user(),$group['name'],$change); group_add_member(local_user(),$group['name'],$change);
} }
$members = group_get_members($group['id']); $members = group_get_members($group['id']);
$preselected = array(); $preselected = array();
if(count($members)) { if (count($members)) {
foreach($members as $member) foreach ($members as $member)
$preselected[] = $member['id']; $preselected[] = $member['id'];
} }
} }
@ -193,8 +194,9 @@ function group_content(App $a) {
} }
if(! isset($group)) if (! isset($group)) {
return; return;
}
$groupeditor = array( $groupeditor = array(
'label_members' => t('Members'), 'label_members' => t('Members'),
@ -206,14 +208,14 @@ function group_content(App $a) {
$sec_token = addslashes(get_form_security_token('group_member_change')); $sec_token = addslashes(get_form_security_token('group_member_change'));
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
foreach($members as $member) { foreach ($members as $member) {
if($member['url']) { if ($member['url']) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;'; $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode); $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
} } else {
else
group_rmv_member(local_user(),$group['name'],$member['id']); group_rmv_member(local_user(),$group['name'],$member['id']);
} }
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC",
intval(local_user()) intval(local_user())
@ -221,8 +223,8 @@ function group_content(App $a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) { foreach ($r as $member) {
if(! in_array($member['id'],$preselected)) { if (! in_array($member['id'],$preselected)) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;'; $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode); $groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode);
} }
@ -232,7 +234,7 @@ function group_content(App $a) {
$context['$groupeditor'] = $groupeditor; $context['$groupeditor'] = $groupeditor;
$context['$desc'] = t('Click on a contact to add or remove.'); $context['$desc'] = t('Click on a contact to add or remove.');
if($change) { if ($change) {
$tpl = get_markup_template('groupeditor.tpl'); $tpl = get_markup_template('groupeditor.tpl');
echo replace_macros($tpl, $context); echo replace_macros($tpl, $context);
killme(); killme();

View File

@ -30,9 +30,10 @@ function help_content(App $a) {
$path = ''; $path = '';
// looping through the argv keys bigger than 0 to build // looping through the argv keys bigger than 0 to build
// a path relative to /help // a path relative to /help
for($x = 1; $x < argc(); $x ++) { for ($x = 1; $x < argc(); $x ++) {
if(strlen($path)) if (strlen($path)) {
$path .= '/'; $path .= '/';
}
$path .= argv($x); $path .= argv($x);
} }
$title = basename($path); $title = basename($path);
@ -65,16 +66,22 @@ function help_content(App $a) {
$toc="<style>aside ul {padding-left: 1em;}aside h1{font-size:2em}</style><h2>TOC</h2><ul id='toc'>"; $toc="<style>aside ul {padding-left: 1em;}aside h1{font-size:2em}</style><h2>TOC</h2><ul id='toc'>";
$lastlevel=1; $lastlevel=1;
$idnum = array(0,0,0,0,0,0,0); $idnum = array(0,0,0,0,0,0,0);
foreach($lines as &$line){ foreach ($lines as &$line){
if (substr($line,0,2)=="<h") { if (substr($line,0,2)=="<h") {
$level = substr($line,2,1); $level = substr($line,2,1);
if ($level!="r") { if ($level!="r") {
$level = intval($level); $level = intval($level);
if ($level<$lastlevel) { if ($level<$lastlevel) {
for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>"; for ($k=$level;$k<$lastlevel; $k++) {
for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0; $toc.="</ul>";
}
for ($k=$level+1;$k<count($idnum);$k++) {
$idnum[$k]=0;
}
}
if ($level>$lastlevel) {
$toc.="<ul>";
} }
if ($level>$lastlevel) $toc.="<ul>";
$idnum[$level]++; $idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level)); $id = implode("_", array_slice($idnum,1,$level));
$href = App::get_baseurl()."/help/{$filename}#{$id}"; $href = App::get_baseurl()."/help/{$filename}#{$id}";
@ -84,7 +91,7 @@ function help_content(App $a) {
} }
} }
} }
for($k=0;$k<$lastlevel; $k++) $toc.="</ul>"; for ($k=0;$k<$lastlevel; $k++) $toc.="</ul>";
$html = implode("\n",$lines); $html = implode("\n",$lines);
$a->page['aside'] = $toc.$a->page['aside']; $a->page['aside'] = $toc.$a->page['aside'];

View File

@ -1,6 +1,6 @@
<?php <?php
if(! function_exists('home_init')) { if (! function_exists('home_init')) {
function home_init(App $a) { function home_init(App $a) {
$ret = array(); $ret = array();
@ -16,7 +16,7 @@ function home_init(App $a) {
}} }}
if(! function_exists('home_content')) { if (! function_exists('home_content')) {
function home_content(App $a) { function home_content(App $a) {
$o = ''; $o = '';

View File

@ -7,7 +7,7 @@ function hostxrd_init(App $a) {
header("Content-type: text/xml"); header("Content-type: text/xml");
$pubkey = get_config('system','site_pubkey'); $pubkey = get_config('system','site_pubkey');
if(! $pubkey) { if (! $pubkey) {
$res = new_keypair(1024); $res = new_keypair(1024);
set_config('system','site_prvkey', $res['prvkey']); set_config('system','site_prvkey', $res['prvkey']);

View File

@ -20,7 +20,7 @@ function hovercard_content() {
$datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json"); $datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json");
// Get out if the system doesn't have public access allowed // Get out if the system doesn't have public access allowed
if(intval(get_config('system','block_public'))) if (intval(get_config('system','block_public')))
http_status_exit(401); http_status_exit(401);
// Return the raw content of the template. We use this to make templates usable for js functions. // Return the raw content of the template. We use this to make templates usable for js functions.
@ -36,7 +36,7 @@ function hovercard_content() {
// If a contact is connected the url is internally changed to "redir/CID". We need the pure url to search for // If a contact is connected the url is internally changed to "redir/CID". We need the pure url to search for
// the contact. So we strip out the contact id from the internal url and look in the contact table for // the contact. So we strip out the contact id from the internal url and look in the contact table for
// the real url (nurl) // the real url (nurl)
if(local_user() && strpos($profileurl, "redir/") === 0) { if (local_user() && strpos($profileurl, "redir/") === 0) {
$cid = intval(substr($profileurl, 6)); $cid = intval(substr($profileurl, 6));
$r = q("SELECT `nurl`, `self` FROM `contact` WHERE `id` = '%d' LIMIT 1", intval($cid)); $r = q("SELECT `nurl`, `self` FROM `contact` WHERE `id` = '%d' LIMIT 1", intval($cid));
$profileurl = ($r[0]["nurl"] ? $r[0]["nurl"] : ""); $profileurl = ($r[0]["nurl"] ? $r[0]["nurl"] : "");
@ -45,16 +45,16 @@ function hovercard_content() {
// if it's the url containing https it should be converted to http // if it's the url containing https it should be converted to http
$nurl = normalise_link(clean_contact_url($profileurl)); $nurl = normalise_link(clean_contact_url($profileurl));
if($nurl) { if ($nurl) {
// Search for contact data // Search for contact data
$contact = get_contact_details_by_url($nurl); $contact = get_contact_details_by_url($nurl);
} }
if(!is_array($contact)) if (!is_array($contact))
return; return;
// Get the photo_menu - the menu if possible contact actions // Get the photo_menu - the menu if possible contact actions
if(local_user()) if (local_user())
$actions = contact_photo_menu($contact); $actions = contact_photo_menu($contact);
@ -80,7 +80,7 @@ function hovercard_content() {
'account_type' => account_type($contact), 'account_type' => account_type($contact),
'actions' => $actions, 'actions' => $actions,
); );
if($datatype == "html") { if ($datatype == "html") {
$t = get_markup_template("hovercard.tpl"); $t = get_markup_template("hovercard.tpl");
$o = replace_macros($t, array( $o = replace_macros($t, array(
@ -110,7 +110,7 @@ function get_template_content($template, $root = "") {
$filename = $t->filename; $filename = $t->filename;
// Get the content of the template file // Get the content of the template file
if(file_exists($filename)) { if (file_exists($filename)) {
$content = file_get_contents($filename); $content = file_get_contents($filename);
return $content; return $content;

View File

@ -37,8 +37,11 @@ function ignored_init(App $a) {
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
if ($return_path) { if ($return_path) {
$rand = '_=' . time(); $rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand"; if (strpos($return_path, '?')) {
else $rand = "?$rand"; $rand = "&$rand";
} else {
$rand = "?$rand";
}
goaway(App::get_baseurl() . "/" . $return_path . $rand); goaway(App::get_baseurl() . "/" . $return_path . $rand);
} }

View File

@ -43,11 +43,11 @@ function install_post(App $a) {
require_once("include/dba.php"); require_once("include/dba.php");
unset($db); unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
/*if(get_db_errno()) { /*if (get_db_errno()) {
unset($db); unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, '', true); $db = new dba($dbhost, $dbuser, $dbpass, '', true);
if(! get_db_errno()) { if (! get_db_errno()) {
$r = q("CREATE DATABASE '%s'", $r = q("CREATE DATABASE '%s'",
dbesc($dbdata) dbesc($dbdata)
); );
@ -164,7 +164,7 @@ function install_content(App $a) {
$db_return_text .= $txt; $db_return_text .= $txt;
} }
if($db && $db->connected) { if ($db && $db->connected) {
$r = q("SELECT COUNT(*) as `total` FROM `user`"); $r = q("SELECT COUNT(*) as `total` FROM `user`");
if (dbm::is_result($r) && $r[0]['total']) { if (dbm::is_result($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl'); $tpl = get_markup_template('install.tpl');
@ -360,13 +360,13 @@ function check_php(&$phpath, &$checks) {
check_add($checks, t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help); check_add($checks, t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);
if($passed) { if ($passed) {
$cmd = "$phpath -v"; $cmd = "$phpath -v";
$result = trim(shell_exec($cmd)); $result = trim(shell_exec($cmd));
$passed2 = ( strpos($result, "(cli)") !== false ); $passed2 = ( strpos($result, "(cli)") !== false );
list($result) = explode("\n", $result); list($result) = explode("\n", $result);
$help = ""; $help = "";
if(!$passed2) { if (!$passed2) {
$help .= t('PHP executable is not the php cli binary (could be cgi-fgci version)'). EOL; $help .= t('PHP executable is not the php cli binary (could be cgi-fgci version)'). EOL;
$help .= t('Found PHP version: ')."<tt>$result</tt>"; $help .= t('Found PHP version: ')."<tt>$result</tt>";
} }
@ -380,7 +380,7 @@ function check_php(&$phpath, &$checks) {
$result = trim(shell_exec($cmd)); $result = trim(shell_exec($cmd));
$passed3 = $result == $str; $passed3 = $result == $str;
$help = ""; $help = "";
if(!$passed3) { if (!$passed3) {
$help .= t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL; $help .= t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL;
$help .= t('This is required for message delivery to work.'); $help .= t('This is required for message delivery to work.');
} }
@ -485,7 +485,7 @@ function check_funcs(&$checks) {
$ck_funcs[6]['help'] = t('Error, XML PHP module required but not installed.'); $ck_funcs[6]['help'] = t('Error, XML PHP module required but not installed.');
} }
/*if((x($_SESSION,'sysmsg')) && is_array($_SESSION['sysmsg']) && count($_SESSION['sysmsg'])) /*if ((x($_SESSION,'sysmsg')) && is_array($_SESSION['sysmsg']) && count($_SESSION['sysmsg']))
notice( t('Please see the file "INSTALL.txt".') . EOL);*/ notice( t('Please see the file "INSTALL.txt".') . EOL);*/
} }
@ -589,10 +589,10 @@ function load_database($db) {
/* $str = file_get_contents('database.sql'); /* $str = file_get_contents('database.sql');
$arr = explode(';',$str); $arr = explode(';',$str);
$errors = false; $errors = false;
foreach($arr as $a) { foreach ($arr as $a) {
if(strlen(trim($a))) { if (strlen(trim($a))) {
$r = @$db->q(trim($a)); $r = @$db->q(trim($a));
if(false === $r) { if (false === $r) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL; $errors .= t('Errors encountered creating database tables.') . $a . EOL;
} }
} }

View File

@ -83,7 +83,7 @@ function invite_post(App $a) {
$total ++; $total ++;
$current_invites ++; $current_invites ++;
set_pconfig(local_user(),'system','sent_invites',$current_invites); set_pconfig(local_user(),'system','sent_invites',$current_invites);
if($current_invites > $max_invites) { if ($current_invites > $max_invites) {
notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL); notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL);
return; return;
} }

View File

@ -29,14 +29,14 @@ require_once('include/Contact.php');
function item_post(App $a) { function item_post(App $a) {
if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter'))) if ((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter')))
return; return;
require_once('include/security.php'); require_once('include/security.php');
$uid = local_user(); $uid = local_user();
if(x($_REQUEST,'dropitems')) { if (x($_REQUEST,'dropitems')) {
$arr_drop = explode(',',$_REQUEST['dropitems']); $arr_drop = explode(',',$_REQUEST['dropitems']);
drop_items($arr_drop); drop_items($arr_drop);
$json = array('success' => 1); $json = array('success' => 1);
@ -125,7 +125,7 @@ function item_post(App $a) {
$parent = $r[0]['id']; $parent = $r[0]['id'];
// multi-level threading - preserve the info but re-parent to our single level threading // multi-level threading - preserve the info but re-parent to our single level threading
//if(($parid) && ($parid != $parent)) //if (($parid) && ($parid != $parent))
$thr_parent = $parent_uri; $thr_parent = $parent_uri;
if ($parent_item['contact-id'] && $uid) { if ($parent_item['contact-id'] && $uid) {
@ -162,7 +162,7 @@ function item_post(App $a) {
} }
} }
if($parent) logger('mod_item: item_post parent=' . $parent); if ($parent) logger('mod_item: item_post parent=' . $parent);
$profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0);
$post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0); $post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0);
@ -189,9 +189,9 @@ function item_post(App $a) {
// First check that the parent exists and it is a wall item. // First check that the parent exists and it is a wall item.
if((x($_REQUEST,'commenter')) && ((! $parent) || (! $parent_item['wall']))) { if ((x($_REQUEST,'commenter')) && ((! $parent) || (! $parent_item['wall']))) {
notice( t('Permission denied.') . EOL) ; notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return')) if (x($_REQUEST,'return'))
goaway($return_path); goaway($return_path);
killme(); killme();
} }
@ -201,9 +201,9 @@ function item_post(App $a) {
if((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) { if ((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
notice( t('Permission denied.') . EOL) ; notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return')) if (x($_REQUEST,'return'))
goaway($return_path); goaway($return_path);
killme(); killme();
} }
@ -213,7 +213,7 @@ function item_post(App $a) {
$orig_post = null; $orig_post = null;
if($post_id) { if ($post_id) {
$i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1", $i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid), intval($profile_uid),
intval($post_id) intval($post_id)
@ -232,7 +232,7 @@ function item_post(App $a) {
if (dbm::is_result($r)) if (dbm::is_result($r))
$user = $r[0]; $user = $r[0];
if($orig_post) { if ($orig_post) {
$str_group_allow = $orig_post['allow_gid']; $str_group_allow = $orig_post['allow_gid'];
$str_contact_allow = $orig_post['allow_cid']; $str_contact_allow = $orig_post['allow_cid'];
$str_group_deny = $orig_post['deny_gid']; $str_group_deny = $orig_post['deny_gid'];
@ -258,7 +258,7 @@ function item_post(App $a) {
// use the user default permissions - as they won't have // use the user default permissions - as they won't have
// been supplied via a form. // been supplied via a form.
if(($api_source) if (($api_source)
&& (! array_key_exists('contact_allow',$_REQUEST)) && (! array_key_exists('contact_allow',$_REQUEST))
&& (! array_key_exists('group_allow',$_REQUEST)) && (! array_key_exists('group_allow',$_REQUEST))
&& (! array_key_exists('contact_deny',$_REQUEST)) && (! array_key_exists('contact_deny',$_REQUEST))
@ -295,12 +295,12 @@ function item_post(App $a) {
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0); $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
if($user['hidewall']) if ($user['hidewall'])
$private = 2; $private = 2;
// If this is a comment, set the permissions from the parent. // If this is a comment, set the permissions from the parent.
if($parent_item) { if ($parent_item) {
// for non native networks use the network of the original post as network of the item // for non native networks use the network of the original post as network of the item
if (($parent_item['network'] != NETWORK_DIASPORA) if (($parent_item['network'] != NETWORK_DIASPORA)
@ -319,9 +319,9 @@ function item_post(App $a) {
// if using the API, we won't see pubmail_enable - figure out if it should be set // if using the API, we won't see pubmail_enable - figure out if it should be set
if($api_source && $profile_uid && $profile_uid == local_user() && (! $private)) { if ($api_source && $profile_uid && $profile_uid == local_user() && (! $private)) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(! $mail_disabled) { if (! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user()) intval(local_user())
); );
@ -330,17 +330,17 @@ function item_post(App $a) {
} }
} }
if(! strlen($body)) { if (! strlen($body)) {
if($preview) if ($preview)
killme(); killme();
info( t('Empty post discarded.') . EOL ); info( t('Empty post discarded.') . EOL );
if(x($_REQUEST,'return')) if (x($_REQUEST,'return'))
goaway($return_path); goaway($return_path);
killme(); killme();
} }
} }
if(strlen($categories)) { if (strlen($categories)) {
// get the "fileas" tags for this post // get the "fileas" tags for this post
$filedas = file_tag_file_to_list($categories, 'file'); $filedas = file_tag_file_to_list($categories, 'file');
} }
@ -348,7 +348,7 @@ function item_post(App $a) {
$categories_old = $categories; $categories_old = $categories;
$categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category'); $categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category');
$categories_new = $categories; $categories_new = $categories;
if(strlen($filedas)) { if (strlen($filedas)) {
// append the fileas stuff to the new categories list // append the fileas stuff to the new categories list
$categories .= file_tag_list_to_file($filedas, 'file'); $categories .= file_tag_list_to_file($filedas, 'file');
} }
@ -359,21 +359,21 @@ function item_post(App $a) {
$self = false; $self = false;
$contact_id = 0; $contact_id = 0;
if((local_user()) && (local_user() == $profile_uid)) { if ((local_user()) && (local_user() == $profile_uid)) {
$self = true; $self = true;
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($_SESSION['uid'])); intval($_SESSION['uid']));
} }
elseif(remote_user()) { elseif (remote_user()) {
if(is_array($_SESSION['remote'])) { if (is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) { foreach ($_SESSION['remote'] as $v) {
if($v['uid'] == $profile_uid) { if ($v['uid'] == $profile_uid) {
$contact_id = $v['cid']; $contact_id = $v['cid'];
break; break;
} }
} }
} }
if($contact_id) { if ($contact_id) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($contact_id) intval($contact_id)
); );
@ -387,7 +387,7 @@ function item_post(App $a) {
// get contact info for owner // get contact info for owner
if($profile_uid == local_user()) { if ($profile_uid == local_user()) {
$contact_record = $author; $contact_record = $author;
} }
else { else {
@ -400,9 +400,9 @@ function item_post(App $a) {
$post_type = notags(trim($_REQUEST['type'])); $post_type = notags(trim($_REQUEST['type']));
if($post_type === 'net-comment') { if ($post_type === 'net-comment') {
if($parent_item !== null) { if ($parent_item !== null) {
if($parent_item['wall'] == 1) if ($parent_item['wall'] == 1)
$post_type = 'wall-comment'; $post_type = 'wall-comment';
else else
$post_type = 'remote-comment'; $post_type = 'remote-comment';
@ -423,9 +423,9 @@ function item_post(App $a) {
$match = null; $match = null;
if((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) { if ((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[2]; $images = $match[2];
if(count($images)) { if (count($images)) {
$objecttype = ACTIVITY_OBJ_IMAGE; $objecttype = ACTIVITY_OBJ_IMAGE;
@ -472,10 +472,10 @@ function item_post(App $a) {
$match = false; $match = false;
if((! $preview) && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) { if ((! $preview) && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
$attaches = $match[1]; $attaches = $match[1];
if(count($attaches)) { if (count($attaches)) {
foreach($attaches as $attach) { foreach ($attaches as $attach) {
$r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1", $r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid), intval($profile_uid),
intval($attach) intval($attach)
@ -572,24 +572,26 @@ function item_post(App $a) {
$private_forum = false; $private_forum = false;
if(count($tags)) { if (count($tags)) {
foreach($tags as $tag) { foreach ($tags as $tag) {
if(strpos($tag,'#') === 0) if (strpos($tag,'#') === 0) {
continue; continue;
}
// If we already tagged 'Robert Johnson', don't try and tag 'Robert'. // If we already tagged 'Robert Johnson', don't try and tag 'Robert'.
// Robert Johnson should be first in the $tags array // Robert Johnson should be first in the $tags array
$fullnametagged = false; $fullnametagged = false;
for($x = 0; $x < count($tagged); $x ++) { for ($x = 0; $x < count($tagged); $x ++) {
if(stristr($tagged[$x],$tag . ' ')) { if (stristr($tagged[$x],$tag . ' ')) {
$fullnametagged = true; $fullnametagged = true;
break; break;
} }
} }
if($fullnametagged) if ($fullnametagged) {
continue; continue;
}
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network); $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
if ($success['replaced']) { if ($success['replaced']) {
@ -722,15 +724,16 @@ function item_post(App $a) {
$datarray['last-child'] = 1; $datarray['last-child'] = 1;
$datarray['visible'] = 1; $datarray['visible'] = 1;
if($orig_post) if ($orig_post) {
$datarray['edit'] = true; $datarray['edit'] = true;
}
// Search for hashtags // Search for hashtags
item_body_set_hashtags($datarray); item_body_set_hashtags($datarray);
// preview mode - prepare the body for display and send it via json // preview mode - prepare the body for display and send it via json
if($preview) { if ($preview) {
require_once('include/conversation.php'); require_once('include/conversation.php');
// We set the datarray ID to -1 because in preview mode the dataray // We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID. // doesn't have an ID.
@ -744,9 +747,9 @@ function item_post(App $a) {
call_hooks('post_local',$datarray); call_hooks('post_local',$datarray);
if(x($datarray,'cancel')) { if (x($datarray,'cancel')) {
logger('mod_item: post cancelled by plugin.'); logger('mod_item: post cancelled by plugin.');
if($return_path) { if ($return_path) {
goaway($return_path); goaway($return_path);
} }
@ -762,7 +765,7 @@ function item_post(App $a) {
// Fill the cache field // Fill the cache field
put_item_in_cache($datarray); put_item_in_cache($datarray);
if($orig_post) { if ($orig_post) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
@ -785,7 +788,7 @@ function item_post(App $a) {
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
proc_run(PRIORITY_HIGH, "include/notifier.php", 'edit_post', $post_id); proc_run(PRIORITY_HIGH, "include/notifier.php", 'edit_post', $post_id);
if((x($_REQUEST,'return')) && strlen($return_path)) { if ((x($_REQUEST,'return')) && strlen($return_path)) {
logger('return: ' . $return_path); logger('return: ' . $return_path);
goaway($return_path); goaway($return_path);
} }
@ -900,7 +903,7 @@ function item_post(App $a) {
// update filetags in pconfig // update filetags in pconfig
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
if($parent) { if ($parent) {
// This item is the last leaf and gets the comment box, clear any ancestors // This item is the last leaf and gets the comment box, clear any ancestors
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d AND `last-child` AND `id` != %d", $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d AND `last-child` AND `id` != %d",
@ -916,7 +919,7 @@ function item_post(App $a) {
intval($parent) intval($parent)
); );
if($contact_record != $author) { if ($contact_record != $author) {
notification(array( notification(array(
'type' => NOTIFY_COMMENT, 'type' => NOTIFY_COMMENT,
'notify_flags' => $user['notify-flags'], 'notify_flags' => $user['notify-flags'],
@ -948,7 +951,7 @@ function item_post(App $a) {
intval($parent), intval($parent),
intval($post_id)); intval($post_id));
if($contact_record != $author) { if ($contact_record != $author) {
notification(array( notification(array(
'type' => NOTIFY_WALL, 'type' => NOTIFY_WALL,
'notify_flags' => $user['notify-flags'], 'notify_flags' => $user['notify-flags'],
@ -969,12 +972,12 @@ function item_post(App $a) {
call_hooks('post_local_end', $datarray); call_hooks('post_local_end', $datarray);
if(strlen($emailcc) && $profile_uid == local_user()) { if (strlen($emailcc) && $profile_uid == local_user()) {
$erecips = explode(',', $emailcc); $erecips = explode(',', $emailcc);
if(count($erecips)) { if (count($erecips)) {
foreach($erecips as $recip) { foreach ($erecips as $recip) {
$addr = trim($recip); $addr = trim($recip);
if(! strlen($addr)) if (! strlen($addr))
continue; continue;
$disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username']) $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '<br />'; . '<br />';
@ -1032,8 +1035,9 @@ function item_post(App $a) {
function item_post_return($baseurl, $api_source, $return_path) { function item_post_return($baseurl, $api_source, $return_path) {
// figure out how to return, depending on from whence we came // figure out how to return, depending on from whence we came
if($api_source) if ($api_source) {
return; return;
}
if ($return_path) { if ($return_path) {
goaway($return_path); goaway($return_path);
@ -1111,19 +1115,24 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0", $r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0",
normalise_link($matches[1])); normalise_link($matches[1]));
if (!$r)
if (!dbm::is_result($r)) {
$r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''", $r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''",
normalise_link($matches[1])); normalise_link($matches[1]));
if ($r)
}
if (dbm::is_result($r)) {
$data = $r[0]; $data = $r[0];
else } else {
$data = probe_url($matches[1]); $data = probe_url($matches[1]);
}
if ($data["alias"] != "") { if ($data["alias"] != "") {
$newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]'; $newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]';
if(!stristr($str_tags,$newtag)) { if (!stristr($str_tags,$newtag)) {
if(strlen($str_tags)) if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
}
$str_tags .= $newtag; $str_tags .= $newtag;
} }
} }
@ -1155,7 +1164,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
); );
// Then check in the contact table for the url // Then check in the contact table for the url
if (!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact` $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact`
WHERE `nurl` = '%s' AND `uid` = %d AND WHERE `nurl` = '%s' AND `uid` = %d AND
(`network` != '%s' OR (`notify` != '' AND `alias` != '')) (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
@ -1164,6 +1173,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
intval($profile_uid), intval($profile_uid),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
}
// Then check in the global contacts for the address // Then check in the global contacts for the address
if (!$r) if (!$r)
@ -1175,15 +1185,16 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
); );
// Then check in the global contacts for the url // Then check in the global contacts for the url
if (!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact` $r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != '')) WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
LIMIT 1", LIMIT 1",
dbesc(normalise_link($name)), dbesc(normalise_link($name)),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
}
if (!$r) { if (!dbm::is_result($r)) {
$probed = probe_url($name); $probed = probe_url($name);
if ($result['network'] != NETWORK_PHANTOM) { if ($result['network'] != NETWORK_PHANTOM) {
update_gcontact($probed); update_gcontact($probed);
@ -1204,55 +1215,61 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
} }
//select someone by attag or nick and the name passed in the current network //select someone by attag or nick and the name passed in the current network
if(!$r AND ($network != "")) if (!dbm::is_result($r) AND ($network != "")) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name), dbesc($name),
dbesc($name), dbesc($name),
dbesc($network), dbesc($network),
intval($profile_uid) intval($profile_uid)
); );
}
//select someone from this user's contacts by name in the current network //select someone from this user's contacts by name in the current network
if (!$r AND ($network != "")) if (!dbm::is_result($r) AND ($network != "")) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name), dbesc($name),
dbesc($network), dbesc($network),
intval($profile_uid) intval($profile_uid)
); );
}
//select someone by attag or nick and the name passed in //select someone by attag or nick and the name passed in
if(!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name), dbesc($name),
dbesc($name), dbesc($name),
intval($profile_uid) intval($profile_uid)
); );
}
//select someone from this user's contacts by name //select someone from this user's contacts by name
if(!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name), dbesc($name),
intval($profile_uid) intval($profile_uid)
); );
} }
}
if ($r) { if (dbm::is_result($r)) {
if(strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) if (strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) {
$inform .= ','; $inform .= ',';
}
if (isset($r[0]["id"])) if (isset($r[0]["id"])) {
$inform .= 'cid:' . $r[0]["id"]; $inform .= 'cid:' . $r[0]["id"];
elseif (isset($r[0]["notify"])) } elseif (isset($r[0]["notify"])) {
$inform .= $r[0]["notify"]; $inform .= $r[0]["notify"];
}
$profile = $r[0]["url"]; $profile = $r[0]["url"];
$alias = $r[0]["alias"]; $alias = $r[0]["alias"];
$newname = $r[0]["nick"]; $newname = $r[0]["nick"];
if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER) if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER)
AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) {
$newname = $r[0]["name"]; $newname = $r[0]["name"];
} }
}
//if there is an url for this persons profile //if there is an url for this persons profile
if (isset($profile) AND ($newname != "")) { if (isset($profile) AND ($newname != "")) {
@ -1263,20 +1280,22 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$newtag = '@[url='.$profile.']'.$newname.'[/url]'; $newtag = '@[url='.$profile.']'.$newname.'[/url]';
$body = str_replace('@'.$name, $newtag, $body); $body = str_replace('@'.$name, $newtag, $body);
//append tag to str_tags //append tag to str_tags
if(! stristr($str_tags,$newtag)) { if (! stristr($str_tags,$newtag)) {
if(strlen($str_tags)) if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
}
$str_tags .= $newtag; $str_tags .= $newtag;
} }
// Status.Net seems to require the numeric ID URL in a mention if the person isn't // Status.Net seems to require the numeric ID URL in a mention if the person isn't
// subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both. // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both.
if(strlen($alias)) { if (strlen($alias)) {
$newtag = '@[url='.$alias.']'.$newname.'[/url]'; $newtag = '@[url='.$alias.']'.$newname.'[/url]';
if(! stristr($str_tags,$newtag)) { if (! stristr($str_tags,$newtag)) {
if(strlen($str_tags)) if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
}
$str_tags .= $newtag; $str_tags .= $newtag;
} }
} }

View File

@ -6,20 +6,23 @@ require_once('include/items.php');
require_once('include/like.php'); require_once('include/like.php');
function like_content(App $a) { function like_content(App $a) {
if(! local_user() && ! remote_user()) { if (! local_user() && ! remote_user()) {
return false; return false;
} }
$verb = notags(trim($_GET['verb'])); $verb = notags(trim($_GET['verb']));
if(! $verb) if (! $verb) {
$verb = 'like'; $verb = 'like';
}
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
$r = do_like($item_id, $verb); $r = do_like($item_id, $verb);
if (!$r) return; if (!$r) {
return;
}
// See if we've been passed a return path to redirect to // See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
@ -35,10 +38,13 @@ function like_content(App $a) {
function like_content_return($baseurl, $return_path) { function like_content_return($baseurl, $return_path) {
if($return_path) { if ($return_path) {
$rand = '_=' . time(); $rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand"; if (strpos($return_path, '?')) {
else $rand = "?$rand"; $rand = "&$rand";
} else {
$rand = "?$rand";
}
goaway($baseurl . "/" . $return_path . $rand); goaway($baseurl . "/" . $return_path . $rand);
} }

View File

@ -6,20 +6,23 @@ require_once('include/datetime.php');
function localtime_post(App $a) { function localtime_post(App $a) {
$t = $_REQUEST['time']; $t = $_REQUEST['time'];
if(! $t) if (! $t) {
$t = 'now'; $t = 'now';
}
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
if($_POST['timezone']) if ($_POST['timezone']) {
$a->data['mod-localtime'] = datetime_convert('UTC',$_POST['timezone'],$t,$bd_format); $a->data['mod-localtime'] = datetime_convert('UTC',$_POST['timezone'],$t,$bd_format);
}
} }
function localtime_content(App $a) { function localtime_content(App $a) {
$t = $_REQUEST['time']; $t = $_REQUEST['time'];
if(! $t) if (! $t) {
$t = 'now'; $t = 'now';
}
$o .= '<h3>' . t('Time Conversion') . '</h3>'; $o .= '<h3>' . t('Time Conversion') . '</h3>';
@ -29,11 +32,13 @@ function localtime_content(App $a) {
$o .= '<p>' . sprintf( t('UTC time: %s'), $t) . '</p>'; $o .= '<p>' . sprintf( t('UTC time: %s'), $t) . '</p>';
if($_REQUEST['timezone']) if ($_REQUEST['timezone']) {
$o .= '<p>' . sprintf( t('Current timezone: %s'), $_REQUEST['timezone']) . '</p>'; $o .= '<p>' . sprintf( t('Current timezone: %s'), $_REQUEST['timezone']) . '</p>';
}
if(x($a->data,'mod-localtime')) if (x($a->data,'mod-localtime')) {
$o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>'; $o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>';
}
$o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >'; $o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';

View File

@ -11,7 +11,7 @@ function lockview_content(App $a) {
$item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0); $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
} }
if(! $item_id) if (! $item_id)
killme(); killme();
if (!in_array($type, array('item','photo','event'))) if (!in_array($type, array('item','photo','event')))
@ -28,13 +28,13 @@ function lockview_content(App $a) {
call_hooks('lockview_content', $item); call_hooks('lockview_content', $item);
if($item['uid'] != local_user()) { if ($item['uid'] != local_user()) {
echo t('Remote privacy information not available.') . '<br />'; echo t('Remote privacy information not available.') . '<br />';
killme(); killme();
} }
if(($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid'])) if (($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
&& (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) { && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
echo t('Remote privacy information not available.') . '<br />'; echo t('Remote privacy information not available.') . '<br />';
@ -49,39 +49,47 @@ function lockview_content(App $a) {
$o = t('Visible to:') . '<br />'; $o = t('Visible to:') . '<br />';
$l = array(); $l = array();
if(count($allowed_groups)) { if (count($allowed_groups)) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $allowed_groups)) dbesc(implode(', ', $allowed_groups))
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$l[] = '<b>' . $rr['name'] . '</b>'; $l[] = '<b>' . $rr['name'] . '</b>';
} }
if(count($allowed_users)) { }
}
if (count($allowed_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$allowed_users)) dbesc(implode(', ',$allowed_users))
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$l[] = $rr['name']; $l[] = $rr['name'];
}
}
} }
if(count($deny_groups)) { if (count($deny_groups)) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $deny_groups)) dbesc(implode(', ', $deny_groups))
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$l[] = '<b><strike>' . $rr['name'] . '</strike></b>'; $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
} }
if(count($deny_users)) { }
}
if (count($deny_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$deny_users)) dbesc(implode(', ',$deny_users))
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$l[] = '<strike>' . $rr['name'] . '</strike>'; $l[] = '<strike>' . $rr['name'] . '</strike>';
}
}
} }

View File

@ -1,13 +1,16 @@
<?php <?php
function login_content(App $a) { function login_content(App $a) {
if(x($_SESSION,'theme')) if (x($_SESSION,'theme')) {
unset($_SESSION['theme']); unset($_SESSION['theme']);
if(x($_SESSION,'mobile-theme')) }
if (x($_SESSION,'mobile-theme')) {
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
}
if(local_user()) if (local_user()) {
goaway(z_root()); goaway(z_root());
}
return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
} }

View File

@ -7,7 +7,7 @@ require_once('include/text.php');
function lostpass_post(App $a) { function lostpass_post(App $a) {
$loginame = notags(trim($_POST['login-name'])); $loginame = notags(trim($_POST['login-name']));
if(! $loginame) if (! $loginame)
goaway(z_root()); goaway(z_root());
$r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `verified` = 1 AND `blocked` = 0 LIMIT 1", $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `verified` = 1 AND `blocked` = 0 LIMIT 1",
@ -31,7 +31,7 @@ function lostpass_post(App $a) {
dbesc($new_password_encoded), dbesc($new_password_encoded),
intval($uid) intval($uid)
); );
if($r) if ($r)
info( t('Password reset request issued. Check your email.') . EOL); info( t('Password reset request issued. Check your email.') . EOL);
@ -79,8 +79,7 @@ function lostpass_post(App $a) {
function lostpass_content(App $a) { function lostpass_content(App $a) {
if (x($_GET,'verify')) {
if(x($_GET,'verify')) {
$verify = $_GET['verify']; $verify = $_GET['verify'];
$hash = hash('whirlpool', $verify); $hash = hash('whirlpool', $verify);

View File

@ -12,8 +12,8 @@ function manage_post(App $a) {
$uid = local_user(); $uid = local_user();
$orig_record = $a->user; $orig_record = $a->user;
if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) { if ((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
$r = q("select * from user where uid = %d limit 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($_SESSION['submanage']) intval($_SESSION['submanage'])
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
@ -22,34 +22,34 @@ function manage_post(App $a) {
} }
} }
$r = q("select * from manage where uid = %d", $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
intval($uid) intval($uid)
); );
$submanage = $r; $submanage = $r;
$identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0); $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
if(! $identity) if (! $identity) {
return; return;
}
$limited_id = 0; $limited_id = 0;
$original_id = $uid; $original_id = $uid;
if(count($submanage)) { if (count($submanage)) {
foreach($submanage as $m) { foreach ($submanage as $m) {
if($identity == $m['mid']) { if ($identity == $m['mid']) {
$limited_id = $m['mid']; $limited_id = $m['mid'];
break; break;
} }
} }
} }
if($limited_id) { if ($limited_id) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($limited_id) intval($limited_id)
); );
} } else {
else {
$r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
intval($identity), intval($identity),
dbesc($orig_record['email']), dbesc($orig_record['email']),
@ -70,18 +70,22 @@ function manage_post(App $a) {
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
unset($_SESSION['page_flags']); unset($_SESSION['page_flags']);
unset($_SESSION['return_url']); unset($_SESSION['return_url']);
if(x($_SESSION,'submanage')) if (x($_SESSION,'submanage')) {
unset($_SESSION['submanage']); unset($_SESSION['submanage']);
if(x($_SESSION,'sysmsg')) }
if (x($_SESSION,'sysmsg')) {
unset($_SESSION['sysmsg']); unset($_SESSION['sysmsg']);
if(x($_SESSION,'sysmsg_info')) }
if (x($_SESSION,'sysmsg_info')) {
unset($_SESSION['sysmsg_info']); unset($_SESSION['sysmsg_info']);
}
require_once('include/security.php'); require_once('include/security.php');
authenticate_success($r[0],true,true); authenticate_success($r[0],true,true);
if($limited_id) if ($limited_id) {
$_SESSION['submanage'] = $original_id; $_SESSION['submanage'] = $original_id;
}
$ret = array(); $ret = array();
call_hooks('home_init',$ret); call_hooks('home_init',$ret);

View File

@ -31,7 +31,7 @@ function match_content(App $a) {
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
return; return;
} }
if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) { if (! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
return; return;
} }
@ -39,28 +39,28 @@ function match_content(App $a) {
$params = array(); $params = array();
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
if($tags) { if ($tags) {
$params['s'] = $tags; $params['s'] = $tags;
if($a->pager['page'] != 1) if ($a->pager['page'] != 1)
$params['p'] = $a->pager['page']; $params['p'] = $a->pager['page'];
if(strlen(get_config('system','directory'))) if (strlen(get_config('system','directory')))
$x = post_url(get_server().'/msearch', $params); $x = post_url(get_server().'/msearch', $params);
else else
$x = post_url(App::get_baseurl() . '/msearch', $params); $x = post_url(App::get_baseurl() . '/msearch', $params);
$j = json_decode($x); $j = json_decode($x);
if($j->total) { if ($j->total) {
$a->set_pager_total($j->total); $a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page); $a->set_pager_itemspage($j->items_page);
} }
if(count($j->results)) { if (count($j->results)) {
$id = 0; $id = 0;
foreach($j->results as $jj) { foreach ($j->results as $jj) {
$match_nurl = normalise_link($jj->url); $match_nurl = normalise_link($jj->url);
$match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
intval(local_user()), intval(local_user()),

View File

@ -75,18 +75,18 @@ function message_post(App $a) {
// fake it to go back to the input form if no recipient listed // fake it to go back to the input form if no recipient listed
if($norecip) { if ($norecip) {
$a->argc = 2; $a->argc = 2;
$a->argv[1] = 'new'; $a->argv[1] = 'new';
} } else {
else
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
}
} }
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images' // Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
// is identical to the code in include/conversation.php // is identical to the code in include/conversation.php
if(! function_exists('item_extract_images')) { if (! function_exists('item_extract_images')) {
function item_extract_images($body) { function item_extract_images($body) {
$saved_image = array(); $saved_image = array();
@ -97,26 +97,27 @@ function item_extract_images($body) {
$img_start = strpos($orig_body, '[img'); $img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
while(($img_st_close !== false) && ($img_end !== false)) { while (($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket $img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start; $img_end += $img_start;
if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) { if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
// This is an embedded image // This is an embedded image
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close)); $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]'; $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
$cnt++; $cnt++;
} } else {
else
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]')); $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
}
$orig_body = substr($orig_body, $img_end + strlen('[/img]')); $orig_body = substr($orig_body, $img_end + strlen('[/img]'));
if($orig_body === false) // in case the body ends on a closing image tag if ($orig_body === false) {// in case the body ends on a closing image tag
$orig_body = ''; $orig_body = '';
}
$img_start = strpos($orig_body, '[img'); $img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
@ -128,13 +129,13 @@ function item_extract_images($body) {
return array('body' => $new_body, 'images' => $saved_image); return array('body' => $new_body, 'images' => $saved_image);
}} }}
if(! function_exists('item_redir_and_replace_images')) { if (! function_exists('item_redir_and_replace_images')) {
function item_redir_and_replace_images($body, $images, $cid) { function item_redir_and_replace_images($body, $images, $cid) {
$origbody = $body; $origbody = $body;
$newbody = ''; $newbody = '';
for($i = 0; $i < count($images); $i++) { for ($i = 0; $i < count($images); $i++) {
$search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is'; $search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is';
$replace = '[url=' . z_path() . '/redir/' . $cid $replace = '[url=' . z_path() . '/redir/' . $cid
. '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ; . '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ;
@ -181,18 +182,18 @@ function message_content(App $a) {
)); ));
if(($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
if(! intval($a->argv[2])) if (! intval($a->argv[2]))
return; return;
// Check if we should do HTML-based delete confirmation // Check if we should do HTML-based delete confirmation
if($_REQUEST['confirm']) { if ($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter // <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs // so add any arguments as hidden inputs
$query = explode_querystring($a->query_string); $query = explode_querystring($a->query_string);
$inputs = array(); $inputs = array();
foreach($query['args'] as $arg) { foreach ($query['args'] as $arg) {
if(strpos($arg, 'confirm=') === false) { if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg); $arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
} }
@ -210,12 +211,12 @@ function message_content(App $a) {
)); ));
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if($_REQUEST['canceled']) { if ($_REQUEST['canceled']) {
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
} }
$cmd = $a->argv[1]; $cmd = $a->argv[1];
if($cmd === 'drop') { if ($cmd === 'drop') {
$r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
@ -245,7 +246,7 @@ function message_content(App $a) {
// as we will never again have the info we need to re-create it. // as we will never again have the info we need to re-create it.
// We'll just have to orphan it. // We'll just have to orphan it.
//if($convid) { //if ($convid) {
// q("delete from conv where id = %d limit 1", // q("delete from conv where id = %d limit 1",
// intval($convid) // intval($convid)
// ); // );
@ -261,7 +262,7 @@ function message_content(App $a) {
} }
if(($a->argc > 1) && ($a->argv[1] === 'new')) { if (($a->argc > 1) && ($a->argv[1] === 'new')) {
$o .= $header; $o .= $header;
@ -284,7 +285,7 @@ function message_content(App $a) {
$prename = $preurl = $preid = ''; $prename = $preurl = $preid = '';
if($preselect) { if ($preselect) {
$r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1", $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval(local_user()), intval(local_user()),
intval($a->argv[2]) intval($a->argv[2])
@ -373,7 +374,7 @@ function message_content(App $a) {
return $o; return $o;
} }
if(($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
$o .= $header; $o .= $header;
@ -388,7 +389,7 @@ function message_content(App $a) {
$convid = $r[0]['convid']; $convid = $r[0]['convid'];
$sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", dbesc($r[0]['parent-uri'])); $sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", dbesc($r[0]['parent-uri']));
if($convid) if ($convid)
$sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ", $sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ",
dbesc($r[0]['parent-uri']), dbesc($r[0]['parent-uri']),
intval($convid) intval($convid)
@ -400,7 +401,7 @@ function message_content(App $a) {
intval(local_user()) intval(local_user())
); );
} }
if(! count($messages)) { if (! count($messages)) {
notice( t('Message not available.') . EOL ); notice( t('Message not available.') . EOL );
return $o; return $o;
} }
@ -430,10 +431,11 @@ function message_content(App $a) {
$seen = 0; $seen = 0;
$unknown = false; $unknown = false;
foreach($messages as $message) { foreach ($messages as $message) {
if($message['unknown']) if ($message['unknown']) {
$unknown = true; $unknown = true;
if($message['from-url'] == $myprofile) { }
if ($message['from-url'] == $myprofile) {
$from_url = $myprofile; $from_url = $myprofile;
$sparkle = ''; $sparkle = '';
} elseif ($message['contact-id'] != 0) { } elseif ($message['contact-id'] != 0) {
@ -446,10 +448,11 @@ function message_content(App $a) {
$extracted = item_extract_images($message['body']); $extracted = item_extract_images($message['body']);
if($extracted['images']) if ($extracted['images']) {
$message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']); $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
}
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$from_name_e = template_escape($message['from-name']); $from_name_e = template_escape($message['from-name']);
$subject_e = template_escape($message['title']); $subject_e = template_escape($message['title']);
$body_e = template_escape(Smilies::replace(bbcode($message['body']))); $body_e = template_escape(Smilies::replace(bbcode($message['body'])));
@ -462,10 +465,11 @@ function message_content(App $a) {
} }
$contact = get_contact_details_by_url($message['from-url']); $contact = get_contact_details_by_url($message['from-url']);
if (isset($contact["thumb"])) if (isset($contact["thumb"])) {
$from_photo = $contact["thumb"]; $from_photo = $contact["thumb"];
else } else {
$from_photo = $message['from-photo']; $from_photo = $message['from-photo'];
}
$mails[] = array( $mails[] = array(
'id' => $message['id'], 'id' => $message['id'],
@ -490,10 +494,9 @@ function message_content(App $a) {
$tpl = get_markup_template('mail_display.tpl'); $tpl = get_markup_template('mail_display.tpl');
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$subjtxt_e = template_escape($message['title']); $subjtxt_e = template_escape($message['title']);
} } else {
else {
$subjtxt_e = $message['title']; $subjtxt_e = $message['title'];
} }
@ -548,16 +551,16 @@ function render_messages(array $msg, $t) {
$myprofile = App::get_baseurl().'/profile/' . $a->user['nickname']; $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname'];
foreach($msg as $rr) { foreach ($msg as $rr) {
if($rr['unknown']) if ($rr['unknown'])
$participants = sprintf( t("Unknown sender - %s"),$rr['from-name']); $participants = sprintf( t("Unknown sender - %s"),$rr['from-name']);
elseif (link_compare($rr['from-url'], $myprofile)) elseif (link_compare($rr['from-url'], $myprofile))
$participants = sprintf( t("You and %s"), $rr['name']); $participants = sprintf( t("You and %s"), $rr['name']);
else else
$participants = sprintf(t("%s and You"), $rr['from-name']); $participants = sprintf(t("%s and You"), $rr['from-name']);
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$subject_e = template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>')); $subject_e = template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'));
$body_e = template_escape($rr['body']); $body_e = template_escape($rr['body']);
$to_name_e = template_escape($rr['name']); $to_name_e = template_escape($rr['name']);

View File

@ -4,7 +4,7 @@ require_once('library/asn1.php');
function modexp_init(App $a) { function modexp_init(App $a) {
if($a->argc != 2) if ($a->argc != 2)
killme(); killme();
$nick = $a->argv[1]; $nick = $a->argv[1];

View File

@ -14,12 +14,12 @@ function mood_init(App $a) {
$uid = local_user(); $uid = local_user();
$verb = notags(trim($_GET['verb'])); $verb = notags(trim($_GET['verb']));
if(! $verb) if (! $verb)
return; return;
$verbs = get_mood_verbs(); $verbs = get_mood_verbs();
if(! in_array($verb,$verbs)) if (! in_array($verb,$verbs))
return; return;
$activity = ACTIVITY_MOOD . '#' . urlencode($verb); $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
@ -30,7 +30,7 @@ function mood_init(App $a) {
logger('mood: verb ' . $verb, LOGGER_DEBUG); logger('mood: verb ' . $verb, LOGGER_DEBUG);
if($parent) { if ($parent) {
$r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
from item where id = %d and parent = %d and uid = %d limit 1", from item where id = %d and parent = %d and uid = %d limit 1",
intval($parent), intval($parent),
@ -90,7 +90,7 @@ function mood_init(App $a) {
$arr['body'] = $action; $arr['body'] = $action;
$item_id = item_store($arr); $item_id = item_store($arr);
if($item_id) { if ($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d", q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
intval($uid), intval($uid),
@ -123,9 +123,11 @@ function mood_content(App $a) {
$verbs = get_mood_verbs(); $verbs = get_mood_verbs();
$shortlist = array(); $shortlist = array();
foreach($verbs as $k => $v) foreach ($verbs as $k => $v) {
if($v !== 'NOTRANSLATION') if ($v !== 'NOTRANSLATION') {
$shortlist[] = array($k,$v); $shortlist[] = array($k,$v);
}
}
$tpl = get_markup_template('mood_content.tpl'); $tpl = get_markup_template('mood_content.tpl');

View File

@ -7,7 +7,7 @@ function msearch_post(App $a) {
$startrec = (($page+1) * $perpage) - $perpage; $startrec = (($page+1) * $perpage) - $perpage;
$search = $_POST['s']; $search = $_POST['s'];
if(! strlen($search)) if (! strlen($search))
killme(); killme();
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ", $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
@ -26,7 +26,7 @@ function msearch_post(App $a) {
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr)
$results[] = array( $results[] = array(
'name' => $rr['name'], 'name' => $rr['name'],
'url' => App::get_baseurl() . '/profile/' . $rr['nickname'], 'url' => App::get_baseurl() . '/profile/' . $rr['nickname'],

View File

@ -43,11 +43,11 @@ function network_init(App $a) {
if ($remember_group) { if ($remember_group) {
$net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection $net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection
} elseif($sel_groups !== false) { } elseif ($sel_groups !== false) {
$net_baseurl .= '/' . $sel_groups; $net_baseurl .= '/' . $sel_groups;
} }
if($remember_tab) { if ($remember_tab) {
// redirect if current selected tab is '/network' and // redirect if current selected tab is '/network' and
// last selected tab is _not_ '/network?f=&order=comment'. // last selected tab is _not_ '/network?f=&order=comment'.
// and this isn't a date query // and this isn't a date query
@ -81,19 +81,19 @@ function network_init(App $a) {
parse_str( $dest_qs, $dest_qa); parse_str( $dest_qs, $dest_qa);
$net_args = array_merge($net_args, $dest_qa); $net_args = array_merge($net_args, $dest_qa);
} }
else if($sel_tabs[4] === 'active') { else if ($sel_tabs[4] === 'active') {
// The '/new' tab is selected // The '/new' tab is selected
$net_baseurl .= '/new'; $net_baseurl .= '/new';
} }
if($remember_net) { if ($remember_net) {
$net_args['nets'] = $last_sel_nets; $net_args['nets'] = $last_sel_nets;
} }
else if($sel_nets!==false) { else if ($sel_nets!==false) {
$net_args['nets'] = $sel_nets; $net_args['nets'] = $sel_nets;
} }
if($remember_tab || $remember_net || $remember_group) { if ($remember_tab || $remember_net || $remember_group) {
$net_args = array_merge($query_array, $net_args); $net_args = array_merge($query_array, $net_args);
$net_queries = build_querystring($net_args); $net_queries = build_querystring($net_args);
@ -103,7 +103,7 @@ function network_init(App $a) {
} }
} }
if(x($_GET['nets']) && $_GET['nets'] === 'all') if (x($_GET['nets']) && $_GET['nets'] === 'all')
unset($_GET['nets']); unset($_GET['nets']);
$group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0); $group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0);
@ -115,12 +115,12 @@ function network_init(App $a) {
require_once('include/items.php'); require_once('include/items.php');
require_once('include/ForumManager.php'); require_once('include/ForumManager.php');
if(! x($a->page,'aside')) if (! x($a->page,'aside'))
$a->page['aside'] = ''; $a->page['aside'] = '';
$search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : ''); $search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : '');
if(x($_GET,'save')) { if (x($_GET,'save')) {
$r = qu("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1", $r = qu("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
@ -132,7 +132,7 @@ function network_init(App $a) {
); );
} }
} }
if(x($_GET,'remove')) { if (x($_GET,'remove')) {
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'", q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'",
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
@ -140,7 +140,7 @@ function network_init(App $a) {
} }
// search terms header // search terms header
if(x($_GET,'search')) { if (x($_GET,'search')) {
$a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array( $a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => sprintf( t('Results for: %s'), $search) '$title' => sprintf( t('Results for: %s'), $search)
)); ));
@ -157,7 +157,7 @@ function network_init(App $a) {
function saved_searches($search) { function saved_searches($search) {
if(! feature_enabled(local_user(),'savedsearch')) if (! feature_enabled(local_user(),'savedsearch'))
return ''; return '';
$a = get_app(); $a = get_app();
@ -232,28 +232,28 @@ function network_query_get_sel_tab(App $a) {
$spam_active = ''; $spam_active = '';
$postord_active = ''; $postord_active = '';
if(($a->argc > 1 && $a->argv[1] === 'new') if (($a->argc > 1 && $a->argv[1] === 'new')
|| ($a->argc > 2 && $a->argv[2] === 'new')) { || ($a->argc > 2 && $a->argv[2] === 'new')) {
$new_active = 'active'; $new_active = 'active';
} }
if(x($_GET,'search')) { if (x($_GET,'search')) {
$search_active = 'active'; $search_active = 'active';
} }
if(x($_GET,'star')) { if (x($_GET,'star')) {
$starred_active = 'active'; $starred_active = 'active';
} }
if(x($_GET,'bmark')) { if (x($_GET,'bmark')) {
$bookmarked_active = 'active'; $bookmarked_active = 'active';
} }
if(x($_GET,'conv')) { if (x($_GET,'conv')) {
$conv_active = 'active'; $conv_active = 'active';
} }
if(x($_GET,'spam')) { if (x($_GET,'spam')) {
$spam_active = 'active'; $spam_active = 'active';
} }
@ -285,7 +285,7 @@ function network_query_get_sel_tab(App $a) {
function network_query_get_sel_net() { function network_query_get_sel_net() {
$network = false; $network = false;
if(x($_GET,'nets')) { if (x($_GET,'nets')) {
$network = $_GET['nets']; $network = $_GET['nets'];
} }
@ -295,7 +295,7 @@ function network_query_get_sel_net() {
function network_query_get_sel_group(App $a) { function network_query_get_sel_group(App $a) {
$group = false; $group = false;
if($a->argc >= 2 && is_numeric($a->argv[1])) { if ($a->argc >= 2 && is_numeric($a->argv[1])) {
$group = $a->argv[1]; $group = $a->argv[1];
} }
@ -326,20 +326,18 @@ function network_content(App $a, $update = 0) {
$nouveau = false; $nouveau = false;
if($a->argc > 1) { if ($a->argc > 1) {
for($x = 1; $x < $a->argc; $x ++) { for ($x = 1; $x < $a->argc; $x ++) {
if(is_a_date_arg($a->argv[$x])) { if (is_a_date_arg($a->argv[$x])) {
if($datequery) if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]); $datequery2 = escape_tags($a->argv[$x]);
else { } else {
$datequery = escape_tags($a->argv[$x]); $datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post'; $_GET['order'] = 'post';
} }
} } elseif ($a->argv[$x] === 'new') {
elseif($a->argv[$x] === 'new') {
$nouveau = true; $nouveau = true;
} } elseif (intval($a->argv[$x])) {
elseif(intval($a->argv[$x])) {
$group = intval($a->argv[$x]); $group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>'); $def_acl = array('allow_gid' => '<' . $group . '>');
} }
@ -368,12 +366,12 @@ function network_content(App $a, $update = 0) {
if(x($_GET,'search') || x($_GET,'file')) if (x($_GET,'search') || x($_GET,'file'))
$nouveau = true; $nouveau = true;
if($cid) if ($cid)
$def_acl = array('allow_cid' => '<' . intval($cid) . '>'); $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
if($nets) { if ($nets) {
$r = qu("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0", $r = qu("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0",
intval(local_user()), intval(local_user()),
dbesc($nets) dbesc($nets)
@ -381,19 +379,19 @@ function network_content(App $a, $update = 0) {
$str = ''; $str = '';
if (dbm::is_result($r)) if (dbm::is_result($r))
foreach($r as $rr) foreach ($r as $rr)
$str .= '<' . $rr['id'] . '>'; $str .= '<' . $rr['id'] . '>';
if(strlen($str)) if (strlen($str))
$def_acl = array('allow_cid' => $str); $def_acl = array('allow_cid' => $str);
} }
set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all')); set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
if(!$update AND !$rawmode) { if (!$update AND !$rawmode) {
$tabs = network_tabs($a); $tabs = network_tabs($a);
$o .= $tabs; $o .= $tabs;
if($group) { if ($group) {
if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { if (($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
notice(sprintf(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.", notice(sprintf(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
"Warning: This group contains %s members from a network that doesn't allow non public messages.", "Warning: This group contains %s members from a network that doesn't allow non public messages.",
$t), $t).EOL); $t), $t).EOL);
@ -457,13 +455,13 @@ function network_content(App $a, $update = 0) {
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : ''); $sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
if($group) { if ($group) {
$r = qu("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = qu("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group), intval($group),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
if($update) if ($update)
killme(); killme();
notice( t('No such group') . EOL ); notice( t('No such group') . EOL );
goaway('network/0'); goaway('network/0');
@ -473,7 +471,7 @@ function network_content(App $a, $update = 0) {
$contacts = expand_groups(array($group)); $contacts = expand_groups(array($group));
$gcontacts = expand_groups(array($group), false, true); $gcontacts = expand_groups(array($group), false, true);
if((is_array($contacts)) && count($contacts)) { if ((is_array($contacts)) && count($contacts)) {
$contact_str_self = ""; $contact_str_self = "";
$gcontact_str_self = ""; $gcontact_str_self = "";
@ -500,7 +498,7 @@ function network_content(App $a, $update = 0) {
)) . $o; )) . $o;
} }
elseif($cid) { elseif ($cid) {
$r = qu("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d $r = qu("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
AND (NOT `blocked` OR `pending`) LIMIT 1", AND (NOT `blocked` OR `pending`) LIMIT 1",
@ -524,7 +522,7 @@ function network_content(App $a, $update = 0) {
'id' => 'network', 'id' => 'network',
)) . $o; )) . $o;
if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { if ($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
notice( t('Private messages to this person are at risk of public disclosure.') . EOL); notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
} }
@ -536,15 +534,15 @@ function network_content(App $a, $update = 0) {
} }
} }
if((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) { if ((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) {
$o .= get_birthdays(); $o .= get_birthdays();
$o .= get_events(); $o .= get_events();
} }
if($datequery) { if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
} }
if($datequery2) { if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
} }
@ -555,10 +553,10 @@ function network_content(App $a, $update = 0) {
$order_mode = "received"; $order_mode = "received";
$tag = false; $tag = false;
if(x($_GET,'search')) { if (x($_GET,'search')) {
$search = escape_tags($_GET['search']); $search = escape_tags($_GET['search']);
if(strpos($search,'#') === 0) { if (strpos($search,'#') === 0) {
$tag = true; $tag = true;
$search = substr($search,1); $search = substr($search,1);
} }
@ -566,7 +564,7 @@ function network_content(App $a, $update = 0) {
if (get_config('system','only_tag_search')) if (get_config('system','only_tag_search'))
$tag = true; $tag = true;
if($tag) { if ($tag) {
$sql_extra = ""; $sql_extra = "";
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
@ -583,17 +581,17 @@ function network_content(App $a, $update = 0) {
$order_mode = "id"; $order_mode = "id";
} }
} }
if(strlen($file)) { if (strlen($file)) {
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user())); dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
$sql_order = "`item`.`id`"; $sql_order = "`item`.`id`";
$order_mode = "id"; $order_mode = "id";
} }
if($conv) if ($conv)
$sql_extra3 .= " AND $sql_table.`mention`"; $sql_extra3 .= " AND $sql_table.`mention`";
if($update) { if ($update) {
// only setup pagination on initial page view // only setup pagination on initial page view
$pager_sql = ''; $pager_sql = '';
@ -611,14 +609,14 @@ function network_content(App $a, $update = 0) {
// now that we have the user settings, see if the theme forces // now that we have the user settings, see if the theme forces
// a maximum item number which is lower then the user choice // a maximum item number which is lower then the user choice
if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
$itemspage_network = $a->force_max_items; $itemspage_network = $a->force_max_items;
$a->set_pager_itemspage($itemspage_network); $a->set_pager_itemspage($itemspage_network);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
} }
if($nouveau) { if ($nouveau) {
$simple_update = (($update) ? " AND `item`.`unseen` " : ''); $simple_update = (($update) ? " AND `item`.`unseen` " : '');
if ($sql_order == "") if ($sql_order == "")
@ -640,7 +638,7 @@ function network_content(App $a, $update = 0) {
// Normal conversation view // Normal conversation view
if($order === 'post') { if ($order === 'post') {
$ordering = "`created`"; $ordering = "`created`";
if ($sql_order == "") if ($sql_order == "")
$order_mode = "created"; $order_mode = "created";
@ -657,7 +655,7 @@ function network_content(App $a, $update = 0) {
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"])); $sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
// Fetch a page full of parent items for this page // Fetch a page full of parent items for this page
if($update) { if ($update) {
if (get_config("system", "like_no_comment")) if (get_config("system", "like_no_comment"))
$sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'"; $sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'";
else else
@ -691,8 +689,8 @@ function network_content(App $a, $update = 0) {
$date_offset = ""; $date_offset = "";
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr)
if(! in_array($rr['item_id'],$parents_arr)) if (! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
$parents_str = implode(", ", $parents_arr); $parents_str = implode(", ", $parents_arr);
@ -730,7 +728,7 @@ function network_content(App $a, $update = 0) {
$a->page_offset = $date_offset; $a->page_offset = $date_offset;
if($parents_str) if ($parents_str)
$update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )'; $update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
} }
@ -824,7 +822,7 @@ function network_tabs(App $a) {
), ),
); );
if(feature_enabled(local_user(),'personal_tab')) { if (feature_enabled(local_user(),'personal_tab')) {
$tabs[] = array( $tabs[] = array(
'label' => t('Personal'), 'label' => t('Personal'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
@ -835,7 +833,7 @@ function network_tabs(App $a) {
); );
} }
if(feature_enabled(local_user(),'new_tab')) { if (feature_enabled(local_user(),'new_tab')) {
$tabs[] = array( $tabs[] = array(
'label' => t('New'), 'label' => t('New'),
'url' => str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''), 'url' => str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
@ -846,7 +844,7 @@ function network_tabs(App $a) {
); );
} }
if(feature_enabled(local_user(),'link_tab')) { if (feature_enabled(local_user(),'link_tab')) {
$tabs[] = array( $tabs[] = array(
'label' => t('Shared Links'), 'label' => t('Shared Links'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
@ -857,7 +855,7 @@ function network_tabs(App $a) {
); );
} }
if(feature_enabled(local_user(),'star_posts')) { if (feature_enabled(local_user(),'star_posts')) {
$tabs[] = array( $tabs[] = array(
'label' => t('Starred'), 'label' => t('Starred'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
@ -869,7 +867,7 @@ function network_tabs(App $a) {
} }
// save selected tab, but only if not in search or file mode // save selected tab, but only if not in search or file mode
if(!x($_GET,'search') && !x($_GET,'file')) { if (!x($_GET,'search') && !x($_GET,'file')) {
set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) ); set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) );
} }

View File

@ -47,8 +47,9 @@ function newmember_content(App $a) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(! $mail_disabled) if (! $mail_disabled) {
$o .= '<li>' . '<a target="newmember" href="settings/connectors">' . t('Importing Emails') . '</a><br />' . t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '</li>' . EOL; $o .= '<li>' . '<a target="newmember" href="settings/connectors">' . t('Importing Emails') . '</a><br />' . t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '</li>' . EOL;
}
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Go to Your Contacts Page') . '</a><br />' . t('Your Contacts page is your gateway to managing friendships and connecting with friends on other networks. Typically you enter their address or site URL in the <em>Add New Contact</em> dialog.') . '</li>' . EOL; $o .= '<li>' . '<a target="newmember" href="contacts">' . t('Go to Your Contacts Page') . '</a><br />' . t('Your Contacts page is your gateway to managing friendships and connecting with friends on other networks. Typically you enter their address or site URL in the <em>Add New Contact</em> dialog.') . '</li>' . EOL;
@ -64,7 +65,7 @@ function newmember_content(App $a) {
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Group Your Contacts') . '</a><br />' . t('Once you have made some friends, organize them into private conversation groups from the sidebar of your Contacts page and then you can interact with each group privately on your Network page.') . '</li>' . EOL; $o .= '<li>' . '<a target="newmember" href="contacts">' . t('Group Your Contacts') . '</a><br />' . t('Once you have made some friends, organize them into private conversation groups from the sidebar of your Contacts page and then you can interact with each group privately on your Network page.') . '</li>' . EOL;
if(get_config('system', 'newuser_private')) { if (get_config('system', 'newuser_private')) {
$o .= '<li>' . '<a target="newmember" href="help/Groups-and-Privacy">' . t("Why Aren't My Posts Public?") . '</a><br />' . t("Friendica respects your privacy. By default, your posts will only show up to people you've added as friends. For more information, see the help section from the link above.") . '</li>' . EOL; $o .= '<li>' . '<a target="newmember" href="help/Groups-and-Privacy">' . t("Why Aren't My Posts Public?") . '</a><br />' . t("Friendica respects your privacy. By default, your posts will only show up to people you've added as friends. For more information, see the help section from the link above.") . '</li>' . EOL;
} }

View File

@ -158,7 +158,7 @@ function nodeinfo_cron() {
$plugins = get_config("system","addon"); $plugins = get_config("system","addon");
$plugins_arr = array(); $plugins_arr = array();
if($plugins) { if ($plugins) {
$plugins_arr = explode(",",str_replace(" ", "",$plugins)); $plugins_arr = explode(",",str_replace(" ", "",$plugins));
$idx = array_search($plugin, $plugins_arr); $idx = array_search($plugin, $plugins_arr);
@ -175,10 +175,10 @@ function nodeinfo_cron() {
$last = get_config('nodeinfo','last_calucation'); $last = get_config('nodeinfo','last_calucation');
if($last) { if ($last) {
// Calculate every 24 hours // Calculate every 24 hours
$next = $last + (24 * 60 * 60); $next = $last + (24 * 60 * 60);
if($next > time()) { if ($next > time()) {
logger("calculation intervall not reached"); logger("calculation intervall not reached");
return; return;
} }

View File

@ -2,13 +2,14 @@
function noscrape_init(App $a) { function noscrape_init(App $a) {
if($a->argc > 1) if ($a->argc > 1) {
$which = $a->argv[1]; $which = $a->argv[1];
else } else {
killme(); killme();
}
$profile = 0; $profile = 0;
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) { if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname']; $which = $a->user['nickname'];
$profile = $a->argv[1]; $profile = $a->argv[1];
} }

View File

@ -43,7 +43,7 @@ function notes_content(App $a, $update = false) {
$o =""; $o ="";
$o .= profile_tabs($a,True); $o .= profile_tabs($a,True);
if(! $update) { if (! $update) {
$o .= '<h3>' . t('Personal Notes') . '</h3>'; $o .= '<h3>' . t('Personal Notes') . '</h3>';
$commpage = false; $commpage = false;
@ -104,8 +104,9 @@ function notes_content(App $a, $update = false) {
$parents_str = ''; $parents_str = '';
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
}
$parents_str = implode(', ', $parents_arr); $parents_str = implode(', ', $parents_arr);
$r = q("SELECT %s FROM `item` %s $r = q("SELECT %s FROM `item` %s

View File

@ -17,10 +17,10 @@ function notifications_post(App $a) {
$request_id = (($a->argc > 1) ? $a->argv[1] : 0); $request_id = (($a->argc > 1) ? $a->argv[1] : 0);
if($request_id === "all") if ($request_id === "all")
return; return;
if($request_id) { if ($request_id) {
$r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($request_id), intval($request_id),
@ -41,11 +41,11 @@ function notifications_post(App $a) {
$fid = $r[0]['fid']; $fid = $r[0]['fid'];
if($_POST['submit'] == t('Discard')) { if ($_POST['submit'] == t('Discard')) {
$r = q("DELETE FROM `intro` WHERE `id` = %d", $r = q("DELETE FROM `intro` WHERE `id` = %d",
intval($intro_id) intval($intro_id)
); );
if(! $fid) { if (! $fid) {
// The check for blocked and pending is in case the friendship was already approved // The check for blocked and pending is in case the friendship was already approved
// and we just want to get rid of the now pointless notification // and we just want to get rid of the now pointless notification
@ -57,7 +57,7 @@ function notifications_post(App $a) {
} }
goaway('notifications/intros'); goaway('notifications/intros');
} }
if($_POST['submit'] == t('Ignore')) { if ($_POST['submit'] == t('Ignore')) {
$r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d", $r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
intval($intro_id)); intval($intro_id));
goaway('notifications/intros'); goaway('notifications/intros');
@ -91,7 +91,7 @@ function notifications_content(App $a) {
$startrec = ($page * $perpage) - $perpage; $startrec = ($page * $perpage) - $perpage;
// Get introductions // Get introductions
if( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) { if ( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
nav_set_selected('introductions'); nav_set_selected('introductions');
$notif_header = t('Notifications'); $notif_header = t('Notifications');
@ -135,13 +135,13 @@ function notifications_content(App $a) {
$notifs['page'] = $a->pager['page']; $notifs['page'] = $a->pager['page'];
// Json output // Json output
if(intval($json) === 1) if (intval($json) === 1)
json_return_and_die($notifs); json_return_and_die($notifs);
$notif_tpl = get_markup_template('notifications.tpl'); $notif_tpl = get_markup_template('notifications.tpl');
// Process the data for template creation // Process the data for template creation
if($notifs['ident'] === 'introductions') { if ($notifs['ident'] === 'introductions') {
$sugg = get_markup_template('suggestions.tpl'); $sugg = get_markup_template('suggestions.tpl');
$tpl = get_markup_template("intros.tpl"); $tpl = get_markup_template("intros.tpl");
@ -190,8 +190,8 @@ function notifications_content(App $a) {
$knowyou = ''; $knowyou = '';
$dfrn_text = ''; $dfrn_text = '';
if($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) { if ($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
if($it['network'] === NETWORK_DFRN) { if ($it['network'] === NETWORK_DFRN) {
$lbl_knowyou = t('Claims to be known to you: '); $lbl_knowyou = t('Claims to be known to you: ');
$knowyou = (($it['knowyou']) ? t('yes') : t('no')); $knowyou = (($it['knowyou']) ? t('yes') : t('no'));
$helptext = t('Shall your connection be bidirectional or not?'); $helptext = t('Shall your connection be bidirectional or not?');
@ -262,7 +262,7 @@ function notifications_content(App $a) {
} }
} }
if($notifs['total'] == 0) if ($notifs['total'] == 0)
info( t('No introductions.') . EOL); info( t('No introductions.') . EOL);
// Normal notifications (no introductions) // Normal notifications (no introductions)
@ -301,7 +301,7 @@ function notifications_content(App $a) {
// It doesn't make sense to show the Show unread / Show all link visible if the user is on the // It doesn't make sense to show the Show unread / Show all link visible if the user is on the
// "Show all" page and there are no notifications. So we will hide it. // "Show all" page and there are no notifications. So we will hide it.
if($show == 0 || intval($show) && $notifs['total'] > 0) { if ($show == 0 || intval($show) && $notifs['total'] > 0) {
$notif_show_lnk = array( $notif_show_lnk = array(
'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ), 'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
'text' => ($show ? t('Show unread') : t('Show all')), 'text' => ($show ? t('Show unread') : t('Show all')),
@ -309,9 +309,10 @@ function notifications_content(App $a) {
} }
// Output if there aren't any notifications available // Output if there aren't any notifications available
if($notifs['total'] == 0) if ($notifs['total'] == 0) {
$notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']); $notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
} }
}
$o .= replace_macros($notif_tpl, array( $o .= replace_macros($notif_tpl, array(
'$notif_header' => $notif_header, '$notif_header' => $notif_header,

View File

@ -7,20 +7,20 @@ require_once('library/openid.php');
function openid_content(App $a) { function openid_content(App $a) {
$noid = get_config('system','no_openid'); $noid = get_config('system','no_openid');
if($noid) if ($noid)
goaway(z_root()); goaway(z_root());
logger('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA); logger('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA);
if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) { if ((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) {
$openid = new LightOpenID; $openid = new LightOpenID;
if($openid->validate()) { if ($openid->validate()) {
$authid = $_REQUEST['openid_identity']; $authid = $_REQUEST['openid_identity'];
if(! strlen($authid)) { if (! strlen($authid)) {
logger( t('OpenID protocol error. No ID returned.') . EOL); logger( t('OpenID protocol error. No ID returned.') . EOL);
goaway(z_root()); goaway(z_root());
} }
@ -69,10 +69,10 @@ function openid_content(App $a) {
if ($k === 'namePerson/friendly') { if ($k === 'namePerson/friendly') {
$nick = notags(trim($v)); $nick = notags(trim($v));
} }
if($k === 'namePerson/first') { if ($k === 'namePerson/first') {
$first = notags(trim($v)); $first = notags(trim($v));
} }
if($k === 'namePerson') { if ($k === 'namePerson') {
$args .= '&username=' . notags(trim($v)); $args .= '&username=' . notags(trim($v));
} }
if ($k === 'contact/email') { if ($k === 'contact/email') {

View File

@ -59,7 +59,7 @@ function parse_url_content(App $a) {
$redirects = 0; $redirects = 0;
// Fetch the header of the URL // Fetch the header of the URL
$result = z_fetch_url($url, false, $redirects, array("novalidate" => true, "nobody" => true)); $result = z_fetch_url($url, false, $redirects, array("novalidate" => true, "nobody" => true));
if($result["success"]) { if ($result["success"]) {
// Convert the header fields into an array // Convert the header fields into an array
$hdrs = array(); $hdrs = array();
$h = explode("\n", $result["header"]); $h = explode("\n", $result["header"]);
@ -71,7 +71,7 @@ function parse_url_content(App $a) {
$type = $hdrs["Content-Type"]; $type = $hdrs["Content-Type"];
} }
if ($type) { if ($type) {
if(stripos($type, "image/") !== false) { if (stripos($type, "image/") !== false) {
echo $br . "[img]" . $url . "[/img]" . $br; echo $br . "[img]" . $url . "[/img]" . $br;
killme(); killme();
} }

View File

@ -36,7 +36,7 @@ function photo_init(App $a) {
header('Etag: '.$_SERVER['HTTP_IF_NONE_MATCH']); header('Etag: '.$_SERVER['HTTP_IF_NONE_MATCH']);
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
header("Cache-Control: max-age=31536000"); header("Cache-Control: max-age=31536000");
if(function_exists('header_remove')) { if (function_exists('header_remove')) {
header_remove('Last-Modified'); header_remove('Last-Modified');
header_remove('Expires'); header_remove('Expires');
header_remove('Cache-Control'); header_remove('Cache-Control');
@ -46,7 +46,7 @@ function photo_init(App $a) {
$default = 'images/person-175.jpg'; $default = 'images/person-175.jpg';
if(isset($type)) { if (isset($type)) {
/** /**
@ -80,23 +80,22 @@ function photo_init(App $a) {
$data = $r[0]['data']; $data = $r[0]['data'];
$mimetype = $r[0]['type']; $mimetype = $r[0]['type'];
} }
if(! isset($data)) { if (! isset($data)) {
$data = file_get_contents($default); $data = file_get_contents($default);
$mimetype = 'image/jpeg'; $mimetype = 'image/jpeg';
} }
} } else {
else {
/** /**
* Other photos * Other photos
*/ */
$resolution = 0; $resolution = 0;
foreach( Photo::supportedTypes() as $m=>$e){ foreach ( Photo::supportedTypes() as $m=>$e){
$photo = str_replace(".$e",'',$photo); $photo = str_replace(".$e",'',$photo);
} }
if(substr($photo,-2,1) == '-') { if (substr($photo,-2,1) == '-') {
$resolution = intval(substr($photo,-1,1)); $resolution = intval(substr($photo,-1,1));
$photo = substr($photo,0,-2); $photo = substr($photo,0,-2);
} }
@ -134,8 +133,8 @@ function photo_init(App $a) {
} }
} }
if(! isset($data)) { if (! isset($data)) {
if(isset($resolution)) { if (isset($resolution)) {
switch($resolution) { switch($resolution) {
case 4: case 4:
@ -161,8 +160,8 @@ function photo_init(App $a) {
// Resize only if its not a GIF // Resize only if its not a GIF
if ($mime != "image/gif") { if ($mime != "image/gif") {
$ph = new Photo($data, $mimetype); $ph = new Photo($data, $mimetype);
if($ph->is_valid()) { if ($ph->is_valid()) {
if(isset($customres) && $customres > 0 && $customres < 500) { if (isset($customres) && $customres > 0 && $customres < 500) {
$ph->scaleImageSquare($customres); $ph->scaleImageSquare($customres);
} }
$data = $ph->imageString(); $data = $ph->imageString();
@ -170,14 +169,14 @@ function photo_init(App $a) {
} }
} }
if(function_exists('header_remove')) { if (function_exists('header_remove')) {
header_remove('Pragma'); header_remove('Pragma');
header_remove('pragma'); header_remove('pragma');
} }
header("Content-type: ".$mimetype); header("Content-type: ".$mimetype);
if($prvcachecontrol) { if ($prvcachecontrol) {
// it is a private photo that they have no permission to view. // it is a private photo that they have no permission to view.
// tell the browser not to cache it, in case they authenticate // tell the browser not to cache it, in case they authenticate

View File

@ -1356,7 +1356,7 @@ function photos_content(App $a) {
intval($owner_uid) intval($owner_uid)
); );
if (count($prvnxt)) { if (dbm::is_result($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) { for($z = 0; $z < count($prvnxt); $z++) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) { if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1; $prv = $z - 1;
@ -1374,8 +1374,9 @@ function photos_content(App $a) {
} }
} }
if (count($ph) == 1) if (count($ph) == 1) {
$hires = $lores = $ph[0]; $hires = $lores = $ph[0];
}
if (count($ph) > 1) { if (count($ph) > 1) {
if ($ph[1]['scale'] == 2) { if ($ph[1]['scale'] == 2) {
// original is 640 or less, we can display it directly // original is 640 or less, we can display it directly

View File

@ -216,7 +216,7 @@ function ping_init(App $a)
if ($all_events) { if ($all_events) {
$str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d'); $str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d');
foreach($ev as $x) { foreach ($ev as $x) {
$bd = false; $bd = false;
if ($x['type'] === 'birthday') { if ($x['type'] === 'birthday') {
$birthdays ++; $birthdays ++;
@ -486,7 +486,7 @@ function ping_get_notifications($uid)
function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen) function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
{ {
$notifications = array(); $notifications = array();
foreach($notifs as $key => $notif) { foreach ($notifs as $key => $notif) {
$notifications[$key . ':note'] = $notif['message']; $notifications[$key . ':note'] = $notif['message'];
$notifications[$key . ':@attributes'] = array( $notifications[$key . ':@attributes'] = array(

View File

@ -157,12 +157,12 @@ function poco_init(App $a) {
if (x($_GET,'updatedSince') AND !$global) { if (x($_GET,'updatedSince') AND !$global) {
$ret['updatedSince'] = false; $ret['updatedSince'] = false;
} }
$ret['startIndex'] = (int) $startIndex; $ret['startIndex'] = (int) $startIndex;
$ret['itemsPerPage'] = (int) $itemsPerPage; $ret['itemsPerPage'] = (int) $itemsPerPage;
$ret['totalResults'] = (int) $totalResults; $ret['totalResults'] = (int) $totalResults;
$ret['entry'] = array(); $ret['entry'] = array();
$fields_ret = array( $fields_ret = array(
'id' => false, 'id' => false,
'displayName' => false, 'displayName' => false,
@ -207,14 +207,17 @@ function poco_init(App $a) {
if (($rr['about'] == "") AND isset($rr['pabout'])) { if (($rr['about'] == "") AND isset($rr['pabout'])) {
$rr['about'] = $rr['pabout']; $rr['about'] = $rr['pabout'];
} }
if ($rr['location'] == "") { if ($rr['location'] == "") {
if (isset($rr['plocation'])) { if (isset($rr['plocation'])) {
$rr['location'] = $rr['plocation']; $rr['location'] = $rr['plocation'];
} }
if (isset($rr['pregion']) AND ($rr['pregion'] != "")) { if (isset($rr['pregion']) AND ($rr['pregion'] != "")) {
if ($rr['location'] != "") { if ($rr['location'] != "") {
$rr['location'] .= ", "; $rr['location'] .= ", ";
} }
$rr['location'] .= $rr['pregion']; $rr['location'] .= $rr['pregion'];
} }
@ -292,6 +295,7 @@ function poco_init(App $a) {
} else { } else {
$entry['updated'] = $rr['updated']; $entry['updated'] = $rr['updated'];
} }
$entry['updated'] = date("c", strtotime($entry['updated'])); $entry['updated'] = date("c", strtotime($entry['updated']));
} }
if ($fields_ret['photos']) { if ($fields_ret['photos']) {
@ -345,6 +349,7 @@ function poco_init(App $a) {
if ($fields_ret['contactType']) { if ($fields_ret['contactType']) {
$entry['contactType'] = intval($rr['contact-type']); $entry['contactType'] = intval($rr['contact-type']);
} }
$ret['entry'][] = $entry; $ret['entry'][] = $entry;
} }
} else { } else {
@ -353,6 +358,7 @@ function poco_init(App $a) {
} else { } else {
http_status_exit(500); http_status_exit(500);
} }
logger("End of poco", LOGGER_DEBUG); logger("End of poco", LOGGER_DEBUG);
if ($format === 'xml') { if ($format === 'xml') {
@ -367,4 +373,5 @@ function poco_init(App $a) {
} else { } else {
http_status_exit(500); http_status_exit(500);
} }
} }

View File

@ -63,7 +63,7 @@ function poke_init(App $a) {
$target = $r[0]; $target = $r[0];
if($parent) { if ($parent) {
$r = q("SELECT `uri`, `private`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` $r = q("SELECT `uri`, `private`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`
FROM `item` WHERE `id` = %d AND `parent` = %d AND `uid` = %d LIMIT 1", FROM `item` WHERE `id` = %d AND `parent` = %d AND `uid` = %d LIMIT 1",
intval($parent), intval($parent),
@ -129,7 +129,7 @@ function poke_init(App $a) {
$arr['object'] .= '</link></object>' . "\n"; $arr['object'] .= '</link></object>' . "\n";
$item_id = item_store($arr); $item_id = item_store($arr);
if($item_id) { if ($item_id) {
//q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d", //q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
// dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), // dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
// intval($uid), // intval($uid),
@ -158,7 +158,7 @@ function poke_content(App $a) {
$name = ''; $name = '';
$id = ''; $id = '';
if(intval($_GET['c'])) { if (intval($_GET['c'])) {
$r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_GET['c']), intval($_GET['c']),
intval(local_user()) intval(local_user())
@ -185,9 +185,11 @@ function poke_content(App $a) {
$verbs = get_poke_verbs(); $verbs = get_poke_verbs();
$shortlist = array(); $shortlist = array();
foreach($verbs as $k => $v) foreach ($verbs as $k => $v) {
if($v[1] !== 'NOTRANSLATION') if ($v[1] !== 'NOTRANSLATION') {
$shortlist[] = array($k,$v[1]); $shortlist[] = array($k,$v[1]);
}
}
$tpl = get_markup_template('poke_content.tpl'); $tpl = get_markup_template('poke_content.tpl');

View File

@ -16,8 +16,7 @@ function post_post(App $a) {
if ($a->argc == 1) { if ($a->argc == 1) {
$bulk_delivery = true; $bulk_delivery = true;
} } else {
else {
$nickname = $a->argv[2]; $nickname = $a->argv[2];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' $r = q("SELECT * FROM `user` WHERE `nickname` = '%s'
AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
@ -34,15 +33,17 @@ function post_post(App $a) {
logger('mod-post: new zot: ' . $xml, LOGGER_DATA); logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
if(! $xml) if (! $xml) {
http_status_exit(500); http_status_exit(500);
}
$msg = zot_decode($importer,$xml); $msg = zot_decode($importer,$xml);
logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA); logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
if(! is_array($msg)) if (! is_array($msg)) {
http_status_exit(500); http_status_exit(500);
}
$ret = 0; $ret = 0;
$ret = zot_incoming($bulk_delivery, $importer,$msg); $ret = zot_incoming($bulk_delivery, $importer,$msg);

View File

@ -2,16 +2,15 @@
function pretheme_init(App $a) { function pretheme_init(App $a) {
if($_REQUEST['theme']) { if ($_REQUEST['theme']) {
$theme = $_REQUEST['theme']; $theme = $_REQUEST['theme'];
$info = get_theme_info($theme); $info = get_theme_info($theme);
if($info) { if ($info) {
// unfortunately there will be no translation for this string // unfortunately there will be no translation for this string
$desc = $info['description']; $desc = $info['description'];
$version = $info['version']; $version = $info['version'];
$credits = $info['credits']; $credits = $info['credits'];
} } else {
else {
$desc = ''; $desc = '';
$version = ''; $version = '';
$credits = ''; $credits = '';

View File

@ -12,7 +12,7 @@ function probe_content(App $a) {
$o .= '<br /><br />'; $o .= '<br /><br />';
if(x($_GET,'addr')) { if (x($_GET,'addr')) {
$addr = trim($_GET['addr']); $addr = trim($_GET['addr']);
$res = probe_url($addr); $res = probe_url($addr);

View File

@ -6,17 +6,17 @@ require_once('include/redir.php');
function profile_init(App $a) { function profile_init(App $a) {
if(! x($a->page,'aside')) if (! x($a->page,'aside')) {
$a->page['aside'] = ''; $a->page['aside'] = '';
}
if($a->argc > 1) if ($a->argc > 1) {
$which = htmlspecialchars($a->argv[1]); $which = htmlspecialchars($a->argv[1]);
else { }else {
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1"); $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']); goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']);
} } else {
else {
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG); logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL ); notice( t('Requested profile is not available.') . EOL );
$a->error = 404; $a->error = 404;
@ -25,11 +25,10 @@ function profile_init(App $a) {
} }
$profile = 0; $profile = 0;
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) { if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname']; $which = $a->user['nickname'];
$profile = htmlspecialchars($a->argv[1]); $profile = htmlspecialchars($a->argv[1]);
} } else {
else {
auto_redir($a, $which); auto_redir($a, $which);
} }
@ -38,7 +37,7 @@ function profile_init(App $a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
$userblock = (($a->profile['hidewall'] && (! local_user()) && (! remote_user())) ? true : false); $userblock = (($a->profile['hidewall'] && (! local_user()) && (! remote_user())) ? true : false);
if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) { if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />'; $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
} }
if (x($a->profile,'openidserver')) { if (x($a->profile,'openidserver')) {
@ -52,7 +51,7 @@ function profile_init(App $a) {
if ((! $blocked) && (! $userblock)) { if ((! $blocked) && (! $userblock)) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords); $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
if(strlen($keywords)) if (strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
} }
@ -262,7 +261,7 @@ function profile_content(App $a, $update = 0) {
} }
// now that we have the user settings, see if the theme forces // now that we have the user settings, see if the theme forces
// a maximum item number which is lower then the user choice // a maximum item number which is lower then the user choice
if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
$itemspage_network = $a->force_max_items; $itemspage_network = $a->force_max_items;
$a->set_pager_itemspage($itemspage_network); $a->set_pager_itemspage($itemspage_network);
@ -289,8 +288,9 @@ function profile_content(App $a, $update = 0) {
$parents_str = ''; $parents_str = '';
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
}
$parents_str = implode(', ', $parents_arr); $parents_str = implode(', ', $parents_arr);
$items = q(item_query()." AND `item`.`uid` = %d $items = q(item_query()." AND `item`.`uid` = %d
@ -305,13 +305,13 @@ function profile_content(App $a, $update = 0) {
$items = array(); $items = array();
} }
if($is_owner && (! $update) && (! get_config('theme','hide_eventlist'))) { if ($is_owner && (! $update) && (! get_config('theme','hide_eventlist'))) {
$o .= get_birthdays(); $o .= get_birthdays();
$o .= get_events(); $o .= get_events();
} }
if($is_owner) { if ($is_owner) {
$r = q("UPDATE `item` SET `unseen` = 0 $r = q("UPDATE `item` SET `unseen` = 0
WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d", WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
intval(local_user()) intval(local_user())

View File

@ -22,12 +22,12 @@ function profile_photo_post(App $a) {
check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo'); check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) { if ((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) {
// unless proven otherwise // unless proven otherwise
$is_default_profile = 1; $is_default_profile = 1;
if($_REQUEST['profile']) { if ($_REQUEST['profile']) {
$r = q("select id, `is-default` from profile where id = %d and uid = %d limit 1", $r = q("select id, `is-default` from profile where id = %d and uid = %d limit 1",
intval($_REQUEST['profile']), intval($_REQUEST['profile']),
intval(local_user()) intval(local_user())
@ -40,14 +40,14 @@ function profile_photo_post(App $a) {
// phase 2 - we have finished cropping // phase 2 - we have finished cropping
if($a->argc != 2) { if ($a->argc != 2) {
notice( t('Image uploaded but image cropping failed.') . EOL ); notice( t('Image uploaded but image cropping failed.') . EOL );
return; return;
} }
$image_id = $a->argv[1]; $image_id = $a->argv[1];
if(substr($image_id,-2,1) == '-') { if (substr($image_id,-2,1) == '-') {
$scale = substr($image_id,-1,1); $scale = substr($image_id,-1,1);
$image_id = substr($image_id,0,-2); $image_id = substr($image_id,0,-2);
} }
@ -68,7 +68,7 @@ function profile_photo_post(App $a) {
$base_image = $r[0]; $base_image = $r[0];
$im = new Photo($base_image['data'], $base_image['type']); $im = new Photo($base_image['data'], $base_image['type']);
if($im->is_valid()) { if ($im->is_valid()) {
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH); $im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile); $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
@ -95,7 +95,7 @@ function profile_photo_post(App $a) {
// If setting for the default profile, unset the profile photo flag from any other photos I own // If setting for the default profile, unset the profile photo flag from any other photos I own
if($is_default_profile) { if ($is_default_profile) {
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d", $r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
dbesc($base_image['resource-id']), dbesc($base_image['resource-id']),
intval(local_user()) intval(local_user())
@ -173,7 +173,7 @@ function profile_photo_post(App $a) {
} }
if(! function_exists('profile_photo_content')) { if (! function_exists('profile_photo_content')) {
function profile_photo_content(App $a) { function profile_photo_content(App $a) {
if (! local_user()) { if (! local_user()) {
@ -183,10 +183,10 @@ function profile_photo_content(App $a) {
$newuser = false; $newuser = false;
if($a->argc == 2 && $a->argv[1] === 'new') if ($a->argc == 2 && $a->argv[1] === 'new')
$newuser = true; $newuser = true;
if( $a->argv[1]=='use'){ if ( $a->argv[1]=='use'){
if ($a->argc<3){ if ($a->argc<3){
notice( t('Permission denied.') . EOL ); notice( t('Permission denied.') . EOL );
return; return;
@ -206,7 +206,7 @@ function profile_photo_content(App $a) {
} }
$havescale = false; $havescale = false;
foreach ($r as $rr) { foreach ($r as $rr) {
if($rr['scale'] == 5) if ($rr['scale'] == 5)
$havescale = true; $havescale = true;
} }
@ -245,7 +245,7 @@ function profile_photo_content(App $a) {
); );
if(! x($a->config,'imagecrop')) { if (! x($a->config,'imagecrop')) {
$tpl = get_markup_template('profile_photo.tpl'); $tpl = get_markup_template('profile_photo.tpl');
@ -283,7 +283,7 @@ function profile_photo_content(App $a) {
}} }}
if(! function_exists('profile_photo_crop_ui_head')) { if (! function_exists('profile_photo_crop_ui_head')) {
function profile_photo_crop_ui_head(App $a, $ph) { function profile_photo_crop_ui_head(App $a, $ph) {
$max_length = get_config('system','max_image_length'); $max_length = get_config('system','max_image_length');
if (! $max_length) { if (! $max_length) {

View File

@ -10,7 +10,7 @@ function profiles_init(App $a) {
return; return;
} }
if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) { if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1", $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
@ -46,7 +46,7 @@ function profiles_init(App $a) {
if(($a->argc > 1) && ($a->argv[1] === 'new')) { if (($a->argc > 1) && ($a->argv[1] === 'new')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't'); check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
@ -74,13 +74,13 @@ function profiles_init(App $a) {
); );
info( t('New profile created.') . EOL); info( t('New profile created.') . EOL);
if(count($r3) == 1) if (count($r3) == 1)
goaway('profiles/'.$r3[0]['id']); goaway('profiles/'.$r3[0]['id']);
goaway('profiles'); goaway('profiles');
} }
if(($a->argc > 2) && ($a->argv[1] === 'clone')) { if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't'); check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
@ -93,7 +93,7 @@ function profiles_init(App $a) {
intval(local_user()), intval(local_user()),
intval($a->argv[2]) intval($a->argv[2])
); );
if(! dbm::is_result($r1)) { if (! dbm::is_result($r1)) {
notice( t('Profile unavailable to clone.') . EOL); notice( t('Profile unavailable to clone.') . EOL);
killme(); killme();
return; return;
@ -126,7 +126,7 @@ function profiles_init(App $a) {
} }
if(($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
@ -172,12 +172,12 @@ function profiles_post(App $a) {
call_hooks('profile_post', $_POST); call_hooks('profile_post', $_POST);
if(($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) { if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
$orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($orig)) { if (! count($orig)) {
notice( t('Profile not found.') . EOL); notice( t('Profile not found.') . EOL);
return; return;
} }
@ -187,7 +187,7 @@ function profiles_post(App $a) {
$is_default = (($orig[0]['is-default']) ? 1 : 0); $is_default = (($orig[0]['is-default']) ? 1 : 0);
$profile_name = notags(trim($_POST['profile_name'])); $profile_name = notags(trim($_POST['profile_name']));
if(! strlen($profile_name)) { if (! strlen($profile_name)) {
notice( t('Profile Name is required.') . EOL); notice( t('Profile Name is required.') . EOL);
return; return;
} }
@ -195,27 +195,27 @@ function profiles_post(App $a) {
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated? $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
$y = substr($dob,0,4); $y = substr($dob,0,4);
if((! ctype_digit($y)) || ($y < 1900)) if ((! ctype_digit($y)) || ($y < 1900))
$ignore_year = true; $ignore_year = true;
else else
$ignore_year = false; $ignore_year = false;
if($dob != '0000-00-00') { if ($dob != '0000-00-00') {
if(strpos($dob,'0000-') === 0) { if (strpos($dob,'0000-') === 0) {
$ignore_year = true; $ignore_year = true;
$dob = substr($dob,5); $dob = substr($dob,5);
} }
$dob = datetime_convert('UTC','UTC',(($ignore_year) ? '1900-' . $dob : $dob),(($ignore_year) ? 'm-d' : 'Y-m-d')); $dob = datetime_convert('UTC','UTC',(($ignore_year) ? '1900-' . $dob : $dob),(($ignore_year) ? 'm-d' : 'Y-m-d'));
if($ignore_year) if ($ignore_year)
$dob = '0000-' . $dob; $dob = '0000-' . $dob;
} }
$name = notags(trim($_POST['name'])); $name = notags(trim($_POST['name']));
if(! strlen($name)) { if (! strlen($name)) {
$name = '[No Name]'; $name = '[No Name]';
} }
if($orig[0]['name'] != $name) if ($orig[0]['name'] != $name)
$namechanged = true; $namechanged = true;
@ -234,7 +234,7 @@ function profiles_post(App $a) {
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : ''); $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
if(! strlen($howlong)) if (! strlen($howlong))
$howlong = '0000-00-00 00:00:00'; $howlong = '0000-00-00 00:00:00';
else else
$howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong); $howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong);
@ -243,20 +243,20 @@ function profiles_post(App $a) {
$withchanged = false; $withchanged = false;
if(strlen($with)) { if (strlen($with)) {
if($with != strip_tags($orig[0]['with'])) { if ($with != strip_tags($orig[0]['with'])) {
$withchanged = true; $withchanged = true;
$prf = ''; $prf = '';
$lookup = $with; $lookup = $with;
if(strpos($lookup,'@') === 0) if (strpos($lookup,'@') === 0)
$lookup = substr($lookup,1); $lookup = substr($lookup,1);
$lookup = str_replace('_',' ', $lookup); $lookup = str_replace('_',' ', $lookup);
if(strpos($lookup,'@') || (strpos($lookup,'http://'))) { if (strpos($lookup,'@') || (strpos($lookup,'http://'))) {
$newname = $lookup; $newname = $lookup;
$links = @Probe::lrdd($lookup); $links = @Probe::lrdd($lookup);
if(count($links)) { if (count($links)) {
foreach($links as $link) { foreach ($links as $link) {
if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') { if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
$prf = $link['@attributes']['href']; $prf = $link['@attributes']['href'];
} }
} }
@ -280,7 +280,7 @@ function profiles_post(App $a) {
dbesc($newname), dbesc($newname),
intval(local_user()) intval(local_user())
); );
if(! $r) { if (! $r) {
$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
dbesc($lookup), dbesc($lookup),
intval(local_user()) intval(local_user())
@ -292,9 +292,9 @@ function profiles_post(App $a) {
} }
} }
if($prf) { if ($prf) {
$with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with); $with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with);
if(strpos($with,'@') === 0) if (strpos($with,'@') === 0)
$with = substr($with,1); $with = substr($with,1);
} }
} }
@ -333,61 +333,61 @@ function profiles_post(App $a) {
$changes = array(); $changes = array();
$value = ''; $value = '';
if($is_default) { if ($is_default) {
if($marital != $orig[0]['marital']) { if ($marital != $orig[0]['marital']) {
$changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Marital Status'); $changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Marital Status');
$value = $marital; $value = $marital;
} }
if($withchanged) { if ($withchanged) {
$changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Romantic Partner'); $changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Romantic Partner');
$value = strip_tags($with); $value = strip_tags($with);
} }
if($likes != $orig[0]['likes']) { if ($likes != $orig[0]['likes']) {
$changes[] = t('Likes'); $changes[] = t('Likes');
$value = $likes; $value = $likes;
} }
if($dislikes != $orig[0]['dislikes']) { if ($dislikes != $orig[0]['dislikes']) {
$changes[] = t('Dislikes'); $changes[] = t('Dislikes');
$value = $dislikes; $value = $dislikes;
} }
if($work != $orig[0]['work']) { if ($work != $orig[0]['work']) {
$changes[] = t('Work/Employment'); $changes[] = t('Work/Employment');
} }
if($religion != $orig[0]['religion']) { if ($religion != $orig[0]['religion']) {
$changes[] = t('Religion'); $changes[] = t('Religion');
$value = $religion; $value = $religion;
} }
if($politic != $orig[0]['politic']) { if ($politic != $orig[0]['politic']) {
$changes[] = t('Political Views'); $changes[] = t('Political Views');
$value = $politic; $value = $politic;
} }
if($gender != $orig[0]['gender']) { if ($gender != $orig[0]['gender']) {
$changes[] = t('Gender'); $changes[] = t('Gender');
$value = $gender; $value = $gender;
} }
if($sexual != $orig[0]['sexual']) { if ($sexual != $orig[0]['sexual']) {
$changes[] = t('Sexual Preference'); $changes[] = t('Sexual Preference');
$value = $sexual; $value = $sexual;
} }
if($xmpp != $orig[0]['xmpp']) { if ($xmpp != $orig[0]['xmpp']) {
$changes[] = t('XMPP'); $changes[] = t('XMPP');
$value = $xmpp; $value = $xmpp;
} }
if($homepage != $orig[0]['homepage']) { if ($homepage != $orig[0]['homepage']) {
$changes[] = t('Homepage'); $changes[] = t('Homepage');
$value = $homepage; $value = $homepage;
} }
if($interest != $orig[0]['interest']) { if ($interest != $orig[0]['interest']) {
$changes[] = t('Interests'); $changes[] = t('Interests');
$value = $interest; $value = $interest;
} }
if($address != $orig[0]['address']) { if ($address != $orig[0]['address']) {
$changes[] = t('Address'); $changes[] = t('Address');
// New address not sent in notifications, potential privacy issues // New address not sent in notifications, potential privacy issues
// in case this leaks to unintended recipients. Yes, it's in the public // in case this leaks to unintended recipients. Yes, it's in the public
// profile but that doesn't mean we have to broadcast it to everybody. // profile but that doesn't mean we have to broadcast it to everybody.
} }
if($locality != $orig[0]['locality'] || $region != $orig[0]['region'] if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
|| $country_name != $orig[0]['country-name']) { || $country_name != $orig[0]['country-name']) {
$changes[] = t('Location'); $changes[] = t('Location');
$comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' '); $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
@ -520,13 +520,13 @@ function profiles_post(App $a) {
function profile_activity($changed, $value) { function profile_activity($changed, $value) {
$a = get_app(); $a = get_app();
if(! local_user() || ! is_array($changed) || ! count($changed)) if (! local_user() || ! is_array($changed) || ! count($changed))
return; return;
if($a->user['hidewall'] || get_config('system','block_public')) if ($a->user['hidewall'] || get_config('system','block_public'))
return; return;
if(! get_pconfig(local_user(),'system','post_profilechange')) if (! get_pconfig(local_user(),'system','post_profilechange'))
return; return;
require_once('include/items.php'); require_once('include/items.php');
@ -535,7 +535,7 @@ function profile_activity($changed, $value) {
intval(local_user()) intval(local_user())
); );
if(! count($self)) if (! count($self))
return; return;
$arr = array(); $arr = array();
@ -560,8 +560,8 @@ function profile_activity($changed, $value) {
$changes = ''; $changes = '';
$t = count($changed); $t = count($changed);
$z = 0; $z = 0;
foreach($changed as $ch) { foreach ($changed as $ch) {
if(strlen($changes)) { if (strlen($changes)) {
if ($z == ($t - 1)) if ($z == ($t - 1))
$changes .= t(' and '); $changes .= t(' and ');
else else
@ -573,7 +573,7 @@ function profile_activity($changed, $value) {
$prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]'; $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';
if($t == 1 && strlen($value)) { if ($t == 1 && strlen($value)) {
$message = sprintf( t('%1$s changed %2$s to &ldquo;%3$s&rdquo;'), $A, $changes, $value); $message = sprintf( t('%1$s changed %2$s to &ldquo;%3$s&rdquo;'), $A, $changes, $value);
$message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof); $message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof);
} }
@ -611,7 +611,7 @@ function profiles_content(App $a) {
$o = ''; $o = '';
if(($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
@ -623,7 +623,6 @@ function profiles_content(App $a) {
require_once('include/profile_selectors.php'); require_once('include/profile_selectors.php');
$a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
'$baseurl' => App::get_baseurl(true), '$baseurl' => App::get_baseurl(true),
)); ));
@ -653,7 +652,7 @@ function profiles_content(App $a) {
$detailled_profile = (get_pconfig(local_user(),'system','detailled_profile') AND $personal_account); $detailled_profile = (get_pconfig(local_user(),'system','detailled_profile') AND $personal_account);
$f = get_config('system','birthday_input_format'); $f = get_config('system','birthday_input_format');
if(! $f) if (! $f)
$f = 'ymd'; $f = 'ymd';
$is_default = (($r[0]['is-default']) ? 1 : 0); $is_default = (($r[0]['is-default']) ? 1 : 0);
@ -755,7 +754,7 @@ function profiles_content(App $a) {
else { else {
//If we don't support multi profiles, don't display this list. //If we don't support multi profiles, don't display this list.
if(!feature_enabled(local_user(),'multi_profiles')){ if (!feature_enabled(local_user(),'multi_profiles')){
$r = q( $r = q(
"SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1", "SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
local_user() local_user()

View File

@ -22,7 +22,7 @@ function profperm_content(App $a) {
} }
if($a->argc < 2) { if ($a->argc < 2) {
notice( t('Invalid profile identifier.') . EOL ); notice( t('Invalid profile identifier.') . EOL );
return; return;
} }
@ -30,13 +30,13 @@ function profperm_content(App $a) {
// Switch to text mod interface if we have more than 'n' contacts or group members // Switch to text mod interface if we have more than 'n' contacts or group members
$switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit'); $switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
if($switchtotext === false) if ($switchtotext === false)
$switchtotext = get_config('system','groupedit_image_limit'); $switchtotext = get_config('system','groupedit_image_limit');
if($switchtotext === false) if ($switchtotext === false)
$switchtotext = 400; $switchtotext = 400;
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 `blocked` = 0 AND `pending` = 0 AND `self` = 0 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1", AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
dbesc(NETWORK_DFRN), dbesc(NETWORK_DFRN),
@ -48,7 +48,7 @@ function profperm_content(App $a) {
} }
if(($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1", $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
@ -66,13 +66,13 @@ function profperm_content(App $a) {
$ingroup = array(); $ingroup = array();
if (dbm::is_result($r)) if (dbm::is_result($r))
foreach($r as $member) foreach ($r as $member)
$ingroup[] = $member['id']; $ingroup[] = $member['id'];
$members = $r; $members = $r;
if($change) { if ($change) {
if(in_array($change,$ingroup)) { if (in_array($change,$ingroup)) {
q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d", q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d",
intval($change), intval($change),
intval(local_user()) intval(local_user())
@ -96,7 +96,7 @@ function profperm_content(App $a) {
$ingroup = array(); $ingroup = array();
if (dbm::is_result($r)) if (dbm::is_result($r))
foreach($r as $member) foreach ($r as $member)
$ingroup[] = $member['id']; $ingroup[] = $member['id'];
} }
@ -109,7 +109,7 @@ function profperm_content(App $a) {
} }
$o .= '<div id="prof-update-wrapper">'; $o .= '<div id="prof-update-wrapper">';
if($change) if ($change)
$o = ''; $o = '';
$o .= '<div id="prof-members-title">'; $o .= '<div id="prof-members-title">';
@ -119,8 +119,8 @@ function profperm_content(App $a) {
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
foreach($members as $member) { foreach ($members as $member) {
if($member['url']) { if ($member['url']) {
$member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;'; $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
$o .= micropro($member,true,'mpprof', $textmode); $o .= micropro($member,true,'mpprof', $textmode);
} }
@ -141,8 +141,8 @@ function profperm_content(App $a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) { foreach ($r as $member) {
if(! in_array($member['id'],$ingroup)) { if (! in_array($member['id'],$ingroup)) {
$member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;'; $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
$o .= micropro($member,true,'mpprof',$textmode); $o .= micropro($member,true,'mpprof',$textmode);
} }
@ -151,7 +151,7 @@ function profperm_content(App $a) {
$o .= '</div><div id="prof-all-contacts-end"></div>'; $o .= '</div><div id="prof-all-contacts-end"></div>';
if($change) { if ($change) {
echo $o; echo $o;
killme(); killme();
} }

View File

@ -2,7 +2,7 @@
function hub_return($valid,$body) { function hub_return($valid,$body) {
if($valid) { if ($valid) {
header($_SERVER["SERVER_PROTOCOL"] . ' 200 ' . 'OK'); header($_SERVER["SERVER_PROTOCOL"] . ' 200 ' . 'OK');
echo $body; echo $body;
killme(); killme();
@ -31,7 +31,7 @@ function pubsub_init(App $a) {
$nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 );
if($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$hub_mode = ((x($_GET,'hub_mode')) ? notags(trim($_GET['hub_mode'])) : ''); $hub_mode = ((x($_GET,'hub_mode')) ? notags(trim($_GET['hub_mode'])) : '');
$hub_topic = ((x($_GET,'hub_topic')) ? notags(trim($_GET['hub_topic'])) : ''); $hub_topic = ((x($_GET,'hub_topic')) ? notags(trim($_GET['hub_topic'])) : '');
@ -68,7 +68,7 @@ function pubsub_init(App $a) {
} }
if ($hub_topic) if ($hub_topic)
if(! link_compare($hub_topic,$r[0]['poll'])) { if (! link_compare($hub_topic,$r[0]['poll'])) {
logger('pubsub: hub topic ' . $hub_topic . ' != ' . $r[0]['poll']); logger('pubsub: hub topic ' . $hub_topic . ' != ' . $r[0]['poll']);
// should abort but let's humour them. // should abort but let's humour them.
} }
@ -78,8 +78,8 @@ function pubsub_init(App $a) {
// We must initiate an unsubscribe request with a verify_token. // We must initiate an unsubscribe request with a verify_token.
// Don't allow outsiders to unsubscribe us. // Don't allow outsiders to unsubscribe us.
if($hub_mode === 'unsubscribe') { if ($hub_mode === 'unsubscribe') {
if(! strlen($hub_verify)) { if (! strlen($hub_verify)) {
logger('pubsub: bogus unsubscribe'); logger('pubsub: bogus unsubscribe');
hub_return(false, ''); hub_return(false, '');
} }
@ -106,7 +106,7 @@ function pubsub_post(App $a) {
logger('pubsub: user-agent: ' . $_SERVER['HTTP_USER_AGENT'] ); logger('pubsub: user-agent: ' . $_SERVER['HTTP_USER_AGENT'] );
logger('pubsub: data: ' . $xml, LOGGER_DATA); logger('pubsub: data: ' . $xml, LOGGER_DATA);
// if(! stristr($xml,'<?xml')) { // if (! stristr($xml,'<?xml')) {
// logger('pubsub_post: bad xml'); // logger('pubsub_post: bad xml');
// hub_post_return(); // hub_post_return();
// } // }
@ -142,8 +142,9 @@ function pubsub_post(App $a) {
// we have no way to match Diaspora guid's with atom post id's and could get duplicates. // we have no way to match Diaspora guid's with atom post id's and could get duplicates.
// we'll assume that direct delivery is robust (and this is a bad assumption, but the duplicates are messy). // we'll assume that direct delivery is robust (and this is a bad assumption, but the duplicates are messy).
if($r[0]['network'] === NETWORK_DIASPORA) if ($r[0]['network'] === NETWORK_DIASPORA) {
hub_post_return(); hub_post_return();
}
$feedhub = ''; $feedhub = '';

View File

@ -21,7 +21,7 @@ function pubsubhubbub_init(App $a) {
// [hub_secret] => af11... // [hub_secret] => af11...
// [hub_topic] => http://friendica.local/dfrn_poll/sazius // [hub_topic] => http://friendica.local/dfrn_poll/sazius
if($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$hub_mode = post_var('hub_mode'); $hub_mode = post_var('hub_mode');
$hub_callback = post_var('hub_callback'); $hub_callback = post_var('hub_callback');
$hub_verify = post_var('hub_verify'); $hub_verify = post_var('hub_verify');
@ -81,7 +81,7 @@ function pubsubhubbub_init(App $a) {
$contact = $r[0]; $contact = $r[0];
// sanity check that topic URLs are the same // sanity check that topic URLs are the same
if(!link_compare($hub_topic, $contact['poll'])) { if (!link_compare($hub_topic, $contact['poll'])) {
logger('pubsubhubbub: hub topic ' . $hub_topic . ' != ' . logger('pubsubhubbub: hub topic ' . $hub_topic . ' != ' .
$contact['poll']); $contact['poll']);
http_status_exit(404); http_status_exit(404);

View File

@ -10,12 +10,14 @@ function qsearch_init(App $a) {
$search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : ''); $search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
if(! strlen($search)) if (! strlen($search)) {
killme(); killme();
}
if($search) if ($search) {
$search = dbesc($search); $search = dbesc($search);
}
$results = array(); $results = array();
@ -25,10 +27,10 @@ function qsearch_init(App $a) {
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) {
foreach($r as $rr)
$results[] = array( 0, (int) $rr['id'], $rr['name'], '', ''); $results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
} }
}
$sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : ""); $sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
@ -40,10 +42,10 @@ function qsearch_init(App $a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) {
foreach($r as $rr)
$results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']); $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
} }
}
echo json_encode((object) $results); echo json_encode((object) $results);
killme(); killme();

View File

@ -14,19 +14,19 @@ function receive_post(App $a) {
$enabled = intval(get_config('system','diaspora_enabled')); $enabled = intval(get_config('system','diaspora_enabled'));
if(! $enabled) { if (! $enabled) {
logger('mod-diaspora: disabled'); logger('mod-diaspora: disabled');
http_status_exit(500); http_status_exit(500);
} }
$public = false; $public = false;
if(($a->argc == 2) && ($a->argv[1] === 'public')) { if (($a->argc == 2) && ($a->argv[1] === 'public')) {
$public = true; $public = true;
} }
else { else {
if($a->argc != 3 || $a->argv[1] !== 'users') if ($a->argc != 3 || $a->argv[1] !== 'users')
http_status_exit(500); http_status_exit(500);
$guid = $a->argv[2]; $guid = $a->argv[2];
@ -49,7 +49,7 @@ function receive_post(App $a) {
logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA); logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
if(! $xml) if (! $xml)
http_status_exit(500); http_status_exit(500);
logger('mod-diaspora: message is okay', LOGGER_DEBUG); logger('mod-diaspora: message is okay', LOGGER_DEBUG);
@ -60,13 +60,13 @@ function receive_post(App $a) {
logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA); logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
if(! is_array($msg)) if (! is_array($msg))
http_status_exit(500); http_status_exit(500);
logger('mod-diaspora: dispatching', LOGGER_DEBUG); logger('mod-diaspora: dispatching', LOGGER_DEBUG);
$ret = 0; $ret = 0;
if($public) { if ($public) {
Diaspora::dispatch_public($msg); Diaspora::dispatch_public($msg);
} else { } else {
$ret = Diaspora::dispatch($importer,$msg); $ret = Diaspora::dispatch($importer,$msg);

View File

@ -8,9 +8,9 @@ function redir_init(App $a) {
// traditional DFRN // traditional DFRN
if( $con_url || (local_user() && $a->argc > 1 && intval($a->argv[1])) ) { if ( $con_url || (local_user() && $a->argc > 1 && intval($a->argv[1])) ) {
if($con_url) { if ($con_url) {
$con_url = str_replace('https', 'http', $con_url); $con_url = str_replace('https', 'http', $con_url);
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
@ -18,7 +18,7 @@ function redir_init(App $a) {
intval(local_user()) intval(local_user())
); );
if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN)) if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
goaway(z_root()); goaway(z_root());
$cid = $r[0]['id']; $cid = $r[0]['id'];
@ -31,17 +31,17 @@ function redir_init(App $a) {
intval(local_user()) intval(local_user())
); );
if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN)) if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
goaway(z_root()); goaway(z_root());
} }
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']); $dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
if($r[0]['duplex'] && $r[0]['issued-id']) { if ($r[0]['duplex'] && $r[0]['issued-id']) {
$orig_id = $r[0]['issued-id']; $orig_id = $r[0]['issued-id'];
$dfrn_id = '1:' . $orig_id; $dfrn_id = '1:' . $orig_id;
} }
if($r[0]['duplex'] && $r[0]['dfrn-id']) { if ($r[0]['duplex'] && $r[0]['dfrn-id']) {
$orig_id = $r[0]['dfrn-id']; $orig_id = $r[0]['dfrn-id'];
$dfrn_id = '0:' . $orig_id; $dfrn_id = '0:' . $orig_id;
} }

View File

@ -4,7 +4,7 @@ require_once('include/enotify.php');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/user.php'); require_once('include/user.php');
if(! function_exists('register_post')) { if (! function_exists('register_post')) {
function register_post(App $a) { function register_post(App $a) {
global $lang; global $lang;
@ -16,9 +16,9 @@ function register_post(App $a) {
call_hooks('register_post', $arr); call_hooks('register_post', $arr);
$max_dailies = intval(get_config('system','max_daily_registrations')); $max_dailies = intval(get_config('system','max_daily_registrations'));
if($max_dailies) { if ($max_dailies) {
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
if($r && $r[0]['total'] >= $max_dailies) { if ($r && $r[0]['total'] >= $max_dailies) {
return; return;
} }
} }
@ -38,7 +38,7 @@ function register_post(App $a) {
default: default:
case REGISTER_CLOSED: case REGISTER_CLOSED:
if((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) { if ((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
notice( t('Permission denied.') . EOL ); notice( t('Permission denied.') . EOL );
return; return;
} }
@ -56,14 +56,14 @@ function register_post(App $a) {
$result = create_user($arr); $result = create_user($arr);
if(! $result['success']) { if (! $result['success']) {
notice($result['message']); notice($result['message']);
return; return;
} }
$user = $result['user']; $user = $result['user'];
if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) { if ($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
$url = App::get_baseurl() . '/profile/' . $user['nickname']; $url = App::get_baseurl() . '/profile/' . $user['nickname'];
proc_run(PRIORITY_LOW, "include/directory.php", $url); proc_run(PRIORITY_LOW, "include/directory.php", $url);
} }
@ -73,9 +73,9 @@ function register_post(App $a) {
$invite_id = ((x($_POST,'invite_id')) ? notags(trim($_POST['invite_id'])) : ''); $invite_id = ((x($_POST,'invite_id')) ? notags(trim($_POST['invite_id'])) : '');
if( $a->config['register_policy'] == REGISTER_OPEN ) { if ( $a->config['register_policy'] == REGISTER_OPEN ) {
if($using_invites && $invite_id) { if ($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id)); q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
set_pconfig($user['uid'],'system','invites_remaining',$num_invites); set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
} }
@ -89,7 +89,7 @@ function register_post(App $a) {
$user['username'], $user['username'],
$result['password']); $result['password']);
if($res) { if ($res) {
info( t('Registration successful. Please check your email for further instructions.') . EOL ) ; info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
goaway(z_root()); goaway(z_root());
} else { } else {
@ -106,8 +106,8 @@ function register_post(App $a) {
goaway(z_root()); goaway(z_root());
} }
} }
elseif($a->config['register_policy'] == REGISTER_APPROVE) { elseif ($a->config['register_policy'] == REGISTER_APPROVE) {
if(! strlen($a->config['admin_email'])) { if (! strlen($a->config['admin_email'])) {
notice( t('Your registration can not be processed.') . EOL); notice( t('Your registration can not be processed.') . EOL);
goaway(z_root()); goaway(z_root());
} }
@ -123,7 +123,7 @@ function register_post(App $a) {
); );
// invite system // invite system
if($using_invites && $invite_id) { if ($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id)); q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
set_pconfig($user['uid'],'system','invites_remaining',$num_invites); set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
} }
@ -171,7 +171,7 @@ function register_post(App $a) {
if(! function_exists('register_content')) { if (! function_exists('register_content')) {
function register_content(App $a) { function register_content(App $a) {
// logged in users can register others (people/pages/groups) // logged in users can register others (people/pages/groups)
@ -180,29 +180,29 @@ function register_content(App $a) {
$block = get_config('system','block_extended_register'); $block = get_config('system','block_extended_register');
if(local_user() && ($block)) { if (local_user() && ($block)) {
notice("Permission denied." . EOL); notice("Permission denied." . EOL);
return; return;
} }
if((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) { if ((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
notice("Permission denied." . EOL); notice("Permission denied." . EOL);
return; return;
} }
$max_dailies = intval(get_config('system','max_daily_registrations')); $max_dailies = intval(get_config('system','max_daily_registrations'));
if($max_dailies) { if ($max_dailies) {
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
if($r && $r[0]['total'] >= $max_dailies) { if ($r && $r[0]['total'] >= $max_dailies) {
logger('max daily registrations exceeded.'); logger('max daily registrations exceeded.');
notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
return; return;
} }
} }
if(x($_SESSION,'theme')) if (x($_SESSION,'theme'))
unset($_SESSION['theme']); unset($_SESSION['theme']);
if(x($_SESSION,'mobile-theme')) if (x($_SESSION,'mobile-theme'))
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
@ -215,7 +215,7 @@ function register_content(App $a) {
$noid = get_config('system','no_openid'); $noid = get_config('system','no_openid');
if($noid) { if ($noid) {
$oidhtml = ''; $oidhtml = '';
$fillwith = ''; $fillwith = '';
$fillext = ''; $fillext = '';
@ -232,7 +232,7 @@ function register_content(App $a) {
$realpeople = ''; // t('Members of this network prefer to communicate with real people who use their real names.'); $realpeople = ''; // t('Members of this network prefer to communicate with real people who use their real names.');
if(get_config('system','publish_all')) { if (get_config('system','publish_all')) {
$profile_publish_reg = '<input type="hidden" name="profile_publish_reg" value="1" />'; $profile_publish_reg = '<input type="hidden" name="profile_publish_reg" value="1" />';
} }
else { else {

View File

@ -54,7 +54,7 @@ function user_allow($hash) {
pop_lang(); pop_lang();
if($res) { if ($res) {
info( t('Account approved.') . EOL ); info( t('Account approved.') . EOL );
return true; return true;
} }
@ -72,8 +72,9 @@ function user_deny($hash) {
dbesc($hash) dbesc($hash)
); );
if(! dbm::is_result($register)) if (! dbm::is_result($register)) {
return false; return false;
}
$user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($register[0]['uid']) intval($register[0]['uid'])

View File

@ -8,9 +8,9 @@ require_once('include/follow.php');
function salmon_return($val) { function salmon_return($val) {
if($val >= 400) if ($val >= 400)
$err = 'Error'; $err = 'Error';
if($val >= 200 && $val < 300) if ($val >= 200 && $val < 300)
$err = 'OK'; $err = 'OK';
logger('mod-salmon returns ' . $val); logger('mod-salmon returns ' . $val);
@ -43,14 +43,14 @@ function salmon_post(App $a) {
// figure out where in the DOM tree our data is hiding // figure out where in the DOM tree our data is hiding
if($dom->provenance->data) if ($dom->provenance->data)
$base = $dom->provenance; $base = $dom->provenance;
elseif($dom->env->data) elseif ($dom->env->data)
$base = $dom->env; $base = $dom->env;
elseif($dom->data) elseif ($dom->data)
$base = $dom; $base = $dom;
if(! $base) { if (! $base) {
logger('mod-salmon: unable to locate salmon data in xml '); logger('mod-salmon: unable to locate salmon data in xml ');
http_status_exit(400); http_status_exit(400);
} }
@ -88,7 +88,7 @@ function salmon_post(App $a) {
$author = ostatus::salmon_author($data,$importer); $author = ostatus::salmon_author($data,$importer);
$author_link = $author["author-link"]; $author_link = $author["author-link"];
if(! $author_link) { if (! $author_link) {
logger('mod-salmon: Could not retrieve author URI.'); logger('mod-salmon: Could not retrieve author URI.');
http_status_exit(400); http_status_exit(400);
} }
@ -99,7 +99,7 @@ function salmon_post(App $a) {
$key = get_salmon_key($author_link,$keyhash); $key = get_salmon_key($author_link,$keyhash);
if(! $key) { if (! $key) {
logger('mod-salmon: Could not retrieve author key.'); logger('mod-salmon: Could not retrieve author key.');
http_status_exit(400); http_status_exit(400);
} }
@ -117,17 +117,17 @@ function salmon_post(App $a) {
$verify = rsa_verify($compliant_format,$signature,$pubkey); $verify = rsa_verify($compliant_format,$signature,$pubkey);
if(! $verify) { if (! $verify) {
logger('mod-salmon: message did not verify using protocol. Trying padding hack.'); logger('mod-salmon: message did not verify using protocol. Trying padding hack.');
$verify = rsa_verify($signed_data,$signature,$pubkey); $verify = rsa_verify($signed_data,$signature,$pubkey);
} }
if(! $verify) { if (! $verify) {
logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.'); logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.');
$verify = rsa_verify($stnet_signed_data,$signature,$pubkey); $verify = rsa_verify($stnet_signed_data,$signature,$pubkey);
} }
if(! $verify) { if (! $verify) {
logger('mod-salmon: Message did not verify. Discarding.'); logger('mod-salmon: Message did not verify. Discarding.');
http_status_exit(400); http_status_exit(400);
} }
@ -153,9 +153,9 @@ function salmon_post(App $a) {
); );
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
logger('mod-salmon: Author unknown to us.'); logger('mod-salmon: Author unknown to us.');
if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) { if (get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
$result = new_contact($importer['uid'],$author_link); $result = new_contact($importer['uid'],$author_link);
if($result['success']) { if ($result['success']) {
$r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s') $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
AND `uid` = %d LIMIT 1", AND `uid` = %d LIMIT 1",
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
@ -170,7 +170,7 @@ function salmon_post(App $a) {
// Have we ignored the person? // Have we ignored the person?
// If so we can not accept this post. // If so we can not accept this post.
//if((dbm::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) { //if ((dbm::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
if (dbm::is_result($r) && $r[0]['blocked']) { if (dbm::is_result($r) && $r[0]['blocked']) {
logger('mod-salmon: Ignoring this author.'); logger('mod-salmon: Ignoring this author.');
http_status_exit(202); http_status_exit(202);

View File

@ -8,7 +8,7 @@ function search_saved_searches() {
$o = ''; $o = '';
if(! feature_enabled(local_user(),'savedsearch')) if (! feature_enabled(local_user(),'savedsearch'))
return $o; return $o;
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d", $r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
@ -47,8 +47,8 @@ function search_init(App $a) {
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
if(local_user()) { if (local_user()) {
if(x($_GET,'save') && $search) { if (x($_GET,'save') && $search) {
$r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1", $r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
@ -60,7 +60,7 @@ function search_init(App $a) {
); );
} }
} }
if(x($_GET,'remove') && $search) { if (x($_GET,'remove') && $search) {
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1", q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
@ -82,19 +82,19 @@ function search_init(App $a) {
function search_post(App $a) { function search_post(App $a) {
if(x($_POST,'search')) if (x($_POST,'search'))
$a->data['search'] = $_POST['search']; $a->data['search'] = $_POST['search'];
} }
function search_content(App $a) { function search_content(App $a) {
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); notice( t('Public access denied.') . EOL);
return; return;
} }
if(get_config('system','local_search') AND !local_user()) { if (get_config('system','local_search') AND !local_user()) {
http_status_exit(403, http_status_exit(403,
array("title" => t("Public access denied."), array("title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a search."))); "description" => t("Only logged in users are permitted to perform a search.")));
@ -132,13 +132,13 @@ function search_content(App $a) {
nav_set_selected('search'); nav_set_selected('search');
if(x($a->data,'search')) if (x($a->data,'search'))
$search = notags(trim($a->data['search'])); $search = notags(trim($a->data['search']));
else else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$tag = false; $tag = false;
if(x($_GET,'tag')) { if (x($_GET,'tag')) {
$tag = true; $tag = true;
$search = ((x($_GET,'tag')) ? notags(trim(rawurldecode($_GET['tag']))) : ''); $search = ((x($_GET,'tag')) ? notags(trim(rawurldecode($_GET['tag']))) : '');
} }
@ -151,18 +151,18 @@ function search_content(App $a) {
'$content' => search($search,'search-box','search',((local_user()) ? true : false), false) '$content' => search($search,'search-box','search',((local_user()) ? true : false), false)
)); ));
if(strpos($search,'#') === 0) { if (strpos($search,'#') === 0) {
$tag = true; $tag = true;
$search = substr($search,1); $search = substr($search,1);
} }
if(strpos($search,'@') === 0) { if (strpos($search,'@') === 0) {
return dirfind_content($a); return dirfind_content($a);
} }
if(strpos($search,'!') === 0) { if (strpos($search,'!') === 0) {
return dirfind_content($a); return dirfind_content($a);
} }
if(x($_GET,'search-option')) if (x($_GET,'search-option'))
switch($_GET['search-option']) { switch($_GET['search-option']) {
case 'fulltext': case 'fulltext':
break; break;
@ -177,7 +177,7 @@ function search_content(App $a) {
break; break;
} }
if(! $search) if (! $search)
return $o; return $o;
if (get_config('system','only_tag_search')) if (get_config('system','only_tag_search'))
@ -188,7 +188,7 @@ function search_content(App $a) {
// OR your own posts if you are a logged in member // OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall. // No items will be shown if the member has a blocked profile wall.
if($tag) { if ($tag) {
logger("Start tag search for '".$search."'", LOGGER_DEBUG); logger("Start tag search for '".$search."'", LOGGER_DEBUG);
$r = q("SELECT %s $r = q("SELECT %s
@ -226,7 +226,7 @@ function search_content(App $a) {
} }
if($tag) if ($tag)
$title = sprintf( t('Items tagged with: %s'), $search); $title = sprintf( t('Items tagged with: %s'), $search);
else else
$title = sprintf( t('Results for: %s'), $search); $title = sprintf( t('Results for: %s'), $search);

View File

@ -47,7 +47,7 @@ function settings_init(App $a) {
), ),
); );
if(get_features()) { if (get_features()) {
$tabs[] = array( $tabs[] = array(
'label' => t('Additional features'), 'label' => t('Additional features'),
'url' => 'settings/features', 'url' => 'settings/features',
@ -189,23 +189,23 @@ function settings_post(App $a) {
return; return;
} }
if(($a->argc > 1) && ($a->argv[1] == 'addon')) { if (($a->argc > 1) && ($a->argv[1] == 'addon')) {
check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon'); check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon');
call_hooks('plugin_settings_post', $_POST); call_hooks('plugin_settings_post', $_POST);
return; return;
} }
if(($a->argc > 1) && ($a->argv[1] == 'connectors')) { if (($a->argc > 1) && ($a->argv[1] == 'connectors')) {
check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors'); check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors');
if(x($_POST, 'general-submit')) { if (x($_POST, 'general-submit')) {
set_pconfig(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening'])); set_pconfig(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening']));
set_pconfig(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow'])); set_pconfig(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow']));
set_pconfig(local_user(), 'ostatus', 'default_group', $_POST['group-selection']); set_pconfig(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
set_pconfig(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); set_pconfig(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif(x($_POST, 'imap-submit')) { } elseif (x($_POST, 'imap-submit')) {
$mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : ''); $mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : '');
$mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : ''); $mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : '');
@ -219,10 +219,10 @@ function settings_post(App $a) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(get_config('system','dfrn_only')) if (get_config('system','dfrn_only'))
$mail_disabled = 1; $mail_disabled = 1;
if(! $mail_disabled) { if (! $mail_disabled) {
$failed = false; $failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user()) intval(local_user())
@ -232,7 +232,7 @@ function settings_post(App $a) {
intval(local_user()) intval(local_user())
); );
} }
if(strlen($mail_pass)) { if (strlen($mail_pass)) {
$pass = ''; $pass = '';
openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']); openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d", q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d",
@ -261,18 +261,18 @@ function settings_post(App $a) {
$eacct = $r[0]; $eacct = $r[0];
require_once('include/email.php'); require_once('include/email.php');
$mb = construct_mailbox_name($eacct); $mb = construct_mailbox_name($eacct);
if(strlen($eacct['server'])) { if (strlen($eacct['server'])) {
$dcrpass = ''; $dcrpass = '';
openssl_private_decrypt(hex2bin($eacct['pass']),$dcrpass,$a->user['prvkey']); openssl_private_decrypt(hex2bin($eacct['pass']),$dcrpass,$a->user['prvkey']);
$mbox = email_connect($mb,$mail_user,$dcrpass); $mbox = email_connect($mb,$mail_user,$dcrpass);
unset($dcrpass); unset($dcrpass);
if(! $mbox) { if (! $mbox) {
$failed = true; $failed = true;
notice( t('Failed to connect with email account using the settings provided.') . EOL); notice( t('Failed to connect with email account using the settings provided.') . EOL);
} }
} }
} }
if(! $failed) if (! $failed)
info( t('Email settings updated.') . EOL); info( t('Email settings updated.') . EOL);
} }
} }
@ -283,8 +283,8 @@ function settings_post(App $a) {
if (($a->argc > 1) && ($a->argv[1] === 'features')) { if (($a->argc > 1) && ($a->argv[1] === 'features')) {
check_form_security_token_redirectOnErr('/settings/features', 'settings_features'); check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
foreach($_POST as $k => $v) { foreach ($_POST as $k => $v) {
if(strpos($k,'feature_') === 0) { if (strpos($k,'feature_') === 0) {
set_pconfig(local_user(),'feature',substr($k,8),((intval($v)) ? 1 : 0)); set_pconfig(local_user(),'feature',substr($k,8),((intval($v)) ? 1 : 0));
} }
} }
@ -320,7 +320,7 @@ function settings_post(App $a) {
$itemspage_mobile_network = 100; $itemspage_mobile_network = 100;
} }
if($mobile_theme !== '') { if ($mobile_theme !== '') {
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme); set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
} }
@ -487,7 +487,7 @@ function settings_post(App $a) {
$name_change = false; $name_change = false;
if($username != $a->user['username']) { if ($username != $a->user['username']) {
$name_change = true; $name_change = true;
if (strlen($username) > 40) { if (strlen($username) > 40) {
$err .= t(' Please use a shorter name.'); $err .= t(' Please use a shorter name.');
@ -511,7 +511,7 @@ function settings_post(App $a) {
$err .= t(' Not valid email.'); $err .= t(' Not valid email.');
} }
// ensure new email is not the admin mail // ensure new email is not the admin mail
//if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) { //if ((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) {
if (x($a->config,'admin_email')) { if (x($a->config,'admin_email')) {
$adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email']))); $adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
if (in_array(strtolower($email), $adminlist)) { if (in_array(strtolower($email), $adminlist)) {
@ -727,7 +727,7 @@ function settings_content(App $a) {
return $o; return $o;
} }
if(($a->argc > 3) && ($a->argv[2] === 'delete')) { if (($a->argc > 3) && ($a->argv[2] === 'delete')) {
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't'); check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
$r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
@ -865,10 +865,10 @@ function settings_content(App $a) {
} }
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(get_config('system','dfrn_only')) if (get_config('system','dfrn_only'))
$mail_disabled = 1; $mail_disabled = 1;
if(! $mail_disabled) { if (! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
local_user() local_user()
); );
@ -1176,7 +1176,7 @@ function settings_content(App $a) {
} }
$opt_tpl = get_markup_template("field_yesno.tpl"); $opt_tpl = get_markup_template("field_yesno.tpl");
if(get_config('system','publish_all')) { if (get_config('system','publish_all')) {
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />'; $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
} else { } else {
$profile_in_dir = replace_macros($opt_tpl,array( $profile_in_dir = replace_macros($opt_tpl,array(

View File

@ -2,7 +2,7 @@
function share_init(App $a) { function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if((! $post_id) || (! local_user())) if ((! $post_id) || (! local_user()))
killme(); killme();
$r = q("SELECT item.*, contact.network FROM `item` $r = q("SELECT item.*, contact.network FROM `item`
@ -12,7 +12,7 @@ function share_init(App $a) {
intval($post_id), intval($post_id),
intval(local_user()) intval(local_user())
); );
if(! dbm::is_result($r) || ($r[0]['private'] == 1)) if (! dbm::is_result($r) || ($r[0]['private'] == 1))
killme(); killme();
if (strpos($r[0]['body'], "[/share]") !== false) { if (strpos($r[0]['body'], "[/share]") !== false) {

View File

@ -10,12 +10,11 @@ function smilies_content(App $a) {
if ($a->argv[1]==="json"){ if ($a->argv[1]==="json"){
$tmp = Smilies::get_list(); $tmp = Smilies::get_list();
$results = array(); $results = array();
for($i = 0; $i < count($tmp['texts']); $i++) { for ($i = 0; $i < count($tmp['texts']); $i++) {
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]); $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
} }
json_return_and_die($results); json_return_and_die($results);
} } else {
else {
return Smilies::replace('',true); return Smilies::replace('',true);
} }
} }

View File

@ -7,7 +7,7 @@ require_once('include/items.php');
function subthread_content(App $a) { function subthread_content(App $a) {
if(! local_user() && ! remote_user()) { if (! local_user() && ! remote_user()) {
return; return;
} }
@ -20,7 +20,7 @@ function subthread_content(App $a) {
dbesc($item_id) dbesc($item_id)
); );
if(! $item_id || (! dbm::is_result($r))) { if (! $item_id || (! dbm::is_result($r))) {
logger('subthread: no item ' . $item_id); logger('subthread: no item ' . $item_id);
return; return;
} }
@ -29,13 +29,13 @@ function subthread_content(App $a) {
$owner_uid = $item['uid']; $owner_uid = $item['uid'];
if(! can_write_wall($a,$owner_uid)) { if (! can_write_wall($a,$owner_uid)) {
return; return;
} }
$remote_owner = null; $remote_owner = null;
if(! $item['wall']) { if (! $item['wall']) {
// The top level post may have been written by somebody on another system // The top level post may have been written by somebody on another system
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($item['contact-id']), intval($item['contact-id']),

View File

@ -7,7 +7,7 @@ require_once('include/items.php');
function tagger_content(App $a) { function tagger_content(App $a) {
if(! local_user() && ! remote_user()) { if (! local_user() && ! remote_user()) {
return; return;
} }
@ -15,7 +15,7 @@ function tagger_content(App $a) {
// no commas allowed // no commas allowed
$term = str_replace(array(',',' '),array('','_'),$term); $term = str_replace(array(',',' '),array('','_'),$term);
if(! $term) if (! $term)
return; return;
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
@ -27,7 +27,7 @@ function tagger_content(App $a) {
dbesc($item_id) dbesc($item_id)
); );
if(! $item_id || (! dbm::is_result($r))) { if (! $item_id || (! dbm::is_result($r))) {
logger('tagger: no item ' . $item_id); logger('tagger: no item ' . $item_id);
return; return;
} }
@ -44,7 +44,7 @@ function tagger_content(App $a) {
$blocktags = $r[0]['blocktags']; $blocktags = $r[0]['blocktags'];
} }
if(local_user() != $owner_uid) if (local_user() != $owner_uid)
return; return;
$r = q("select * from contact where self = 1 and uid = %d limit 1", $r = q("select * from contact where self = 1 and uid = %d limit 1",
@ -146,7 +146,7 @@ EOT;
// ); // );
if(! $item['visible']) { if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']), intval($item['id']),
intval($owner_uid) intval($owner_uid)
@ -158,7 +158,7 @@ EOT;
intval($item['id']), intval($item['id']),
dbesc($term) dbesc($term)
); );
if((! $blocktags) && $t[0]['tcount']==0 ) { if ((! $blocktags) && $t[0]['tcount']==0 ) {
/*q("update item set tag = '%s' where id = %d", /*q("update item set tag = '%s' where id = %d",
dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($item['id']) intval($item['id'])
@ -187,7 +187,7 @@ EOT;
intval($r[0]['id']), intval($r[0]['id']),
dbesc($term) dbesc($term)
); );
if(count($x) && !$x[0]['blocktags'] && $t[0]['tcount']==0){ if (count($x) && !$x[0]['blocktags'] && $t[0]['tcount']==0){
q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)", q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
intval($r[0]['id']), intval($r[0]['id']),
$term_objtype, $term_objtype,
@ -198,7 +198,7 @@ EOT;
); );
} }
/*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) { /*if (count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
q("update item set tag = '%s' where id = %d", q("update item set tag = '%s' where id = %d",
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($r[0]['id']) intval($r[0]['id'])

View File

@ -51,9 +51,9 @@ function _uexport_multirow($query) {
$result = array(); $result = array();
$r = q($query); $r = q($query);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr){ foreach ($r as $rr){
$p = array(); $p = array();
foreach($rr as $k => $v) { foreach ($rr as $k => $v) {
$p[$k] = $v; $p[$k] = $v;
} }
$result[] = $p; $result[] = $p;
@ -66,8 +66,8 @@ function _uexport_row($query) {
$result = array(); $result = array();
$r = q($query); $r = q($query);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
foreach($rr as $k => $v) { foreach ($rr as $k => $v) {
$result[$k] = $v; $result[$k] = $v;
} }
} }
@ -151,8 +151,8 @@ function uexport_all(App $a) {
intval(500) intval(500)
); );
/*if (dbm::is_result($r)) { /*if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr)
foreach($rr as $k => $v) foreach ($rr as $k => $v)
$item[][$k] = $v; $item[][$k] = $v;
}*/ }*/

View File

@ -8,10 +8,10 @@ require_once('include/redir.php');
function videos_init(App $a) { function videos_init(App $a) {
if($a->argc > 1) if ($a->argc > 1)
auto_redir($a, $a->argv[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; return;
} }
@ -19,14 +19,15 @@ function videos_init(App $a) {
$o = ''; $o = '';
if($a->argc > 1) { if ($a->argc > 1) {
$nick = $a->argv[1]; $nick = $a->argv[1];
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick) dbesc($nick)
); );
if(! count($user)) if (!dbm::is_result($user)) {
return; return;
}
$a->data['user'] = $user[0]; $a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid']; $a->profile_uid = $user[0]['uid'];
@ -52,35 +53,35 @@ function videos_init(App $a) {
intval($a->data['user']['uid']) intval($a->data['user']['uid'])
); );
if(count($albums)) { if (count($albums)) {
$a->data['albums'] = $albums; $a->data['albums'] = $albums;
$albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
if($albums_visible) { if ($albums_visible) {
$o .= '<div id="sidebar-photos-albums" class="widget">'; $o .= '<div id="sidebar-photos-albums" class="widget">';
$o .= '<h3>' . '<a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>'; $o .= '<h3>' . '<a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
$o .= '<ul>'; $o .= '<ul>';
foreach($albums as $album) { foreach ($albums as $album) {
// don't show contact photos. We once translated this name, but then you could still access it under // don't show contact photos. We once translated this name, but then you could still access it under
// a different language setting. Now we store the name in English and check in English (and translated for legacy albums). // a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos'))) if ((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
continue; continue;
$o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>'; $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
} }
$o .= '</ul>'; $o .= '</ul>';
} }
if(local_user() && $a->data['user']['uid'] == local_user()) { if (local_user() && $a->data['user']['uid'] == local_user()) {
$o .= '<div id="photo-albums-upload-link"><a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>'; $o .= '<div id="photo-albums-upload-link"><a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
} }
$o .= '</div>'; $o .= '</div>';
}*/ }*/
if(! x($a->page,'aside')) if (! x($a->page,'aside'))
$a->page['aside'] = ''; $a->page['aside'] = '';
$a->page['aside'] .= $vcard_widget; $a->page['aside'] .= $vcard_widget;
@ -194,7 +195,7 @@ function videos_content(App $a) {
// videos/name/video/xxxxx/edit // videos/name/video/xxxxx/edit
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); notice( t('Public access denied.') . EOL);
return; return;
} }
@ -204,7 +205,7 @@ function videos_content(App $a) {
require_once('include/security.php'); require_once('include/security.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
if(! x($a->data,'user')) { if (! x($a->data,'user')) {
notice( t('No videos selected') . EOL ); notice( t('No videos selected') . EOL );
return; return;
} }
@ -217,16 +218,16 @@ function videos_content(App $a) {
// Parse arguments // Parse arguments
// //
if($a->argc > 3) { if ($a->argc > 3) {
$datatype = $a->argv[2]; $datatype = $a->argv[2];
$datum = $a->argv[3]; $datum = $a->argv[3];
} }
elseif(($a->argc > 2) && ($a->argv[2] === 'upload')) elseif (($a->argc > 2) && ($a->argv[2] === 'upload'))
$datatype = 'upload'; $datatype = 'upload';
else else
$datatype = 'summary'; $datatype = 'summary';
if($a->argc > 4) if ($a->argc > 4)
$cmd = $a->argv[4]; $cmd = $a->argv[4];
else else
$cmd = 'view'; $cmd = 'view';
@ -245,19 +246,19 @@ function videos_content(App $a) {
$community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false); $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
if((local_user()) && (local_user() == $owner_uid)) if ((local_user()) && (local_user() == $owner_uid))
$can_post = true; $can_post = true;
else { else {
if($community_page && remote_user()) { if ($community_page && remote_user()) {
if(is_array($_SESSION['remote'])) { if (is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) { foreach ($_SESSION['remote'] as $v) {
if($v['uid'] == $owner_uid) { if ($v['uid'] == $owner_uid) {
$contact_id = $v['cid']; $contact_id = $v['cid'];
break; break;
} }
} }
} }
if($contact_id) { if ($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id), intval($contact_id),
@ -275,17 +276,17 @@ function videos_content(App $a) {
// perhaps they're visiting - but not a community page, so they wouldn't have write access // perhaps they're visiting - but not a community page, so they wouldn't have write access
if(remote_user() && (! $visitor)) { if (remote_user() && (! $visitor)) {
$contact_id = 0; $contact_id = 0;
if(is_array($_SESSION['remote'])) { if (is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) { foreach ($_SESSION['remote'] as $v) {
if($v['uid'] == $owner_uid) { if ($v['uid'] == $owner_uid) {
$contact_id = $v['cid']; $contact_id = $v['cid'];
break; break;
} }
} }
} }
if($contact_id) { if ($contact_id) {
$groups = init_groups_visitor($contact_id); $groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id), intval($contact_id),
@ -298,14 +299,14 @@ function videos_content(App $a) {
} }
} }
if(! $remote_contact) { if (! $remote_contact) {
if(local_user()) { if (local_user()) {
$contact_id = $_SESSION['cid']; $contact_id = $_SESSION['cid'];
$contact = $a->contact; $contact = $a->contact;
} }
} }
if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) { if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
notice( t('Access to this item is restricted.') . EOL); notice( t('Access to this item is restricted.') . EOL);
return; return;
} }
@ -323,13 +324,13 @@ function videos_content(App $a) {
// //
if($datatype === 'upload') { if ($datatype === 'upload') {
return; // no uploading for now return; // no uploading for now
// DELETED -- look at mod/photos.php if you want to implement // DELETED -- look at mod/photos.php if you want to implement
} }
if($datatype === 'album') { if ($datatype === 'album') {
return; // no albums for now return; // no albums for now
@ -337,7 +338,7 @@ function videos_content(App $a) {
} }
if($datatype === 'video') { if ($datatype === 'video') {
return; // no single video view for now return; // no single video view for now

View File

@ -9,9 +9,10 @@ function view_init($a){
if ($a->argc == 4){ if ($a->argc == 4){
$theme = $a->argv[2]; $theme = $a->argv[2];
$THEMEPATH = "view/theme/$theme"; $THEMEPATH = "view/theme/$theme";
if(file_exists("view/theme/$theme/style.php")) if (file_exists("view/theme/$theme/style.php")) {
require_once("view/theme/$theme/style.php"); require_once("view/theme/$theme/style.php");
} }
}
killme(); killme();
} }

View File

@ -4,13 +4,13 @@ require_once('include/contact_selectors.php');
function viewcontacts_init(App $a) { function viewcontacts_init(App $a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return; return;
} }
nav_set_selected('home'); nav_set_selected('home');
if($a->argc > 1) { if ($a->argc > 1) {
$nick = $a->argv[1]; $nick = $a->argv[1];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick) dbesc($nick)
@ -32,7 +32,7 @@ function viewcontacts_init(App $a) {
function viewcontacts_content(App $a) { function viewcontacts_content(App $a) {
require_once("mod/proxy.php"); require_once("mod/proxy.php");
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); notice( t('Public access denied.') . EOL);
return; return;
} }
@ -42,7 +42,7 @@ function viewcontacts_content(App $a) {
// tabs // tabs
$o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']); $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
if(((! count($a->profile)) || ($a->profile['hide-friends']))) { if (((! count($a->profile)) || ($a->profile['hide-friends']))) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return $o; return $o;
} }
@ -90,10 +90,11 @@ function viewcontacts_content(App $a) {
$is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false); $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) if ($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = 'redir/' . $rr['id']; $url = 'redir/' . $rr['id'];
else } else {
$url = zrl($url); $url = zrl($url);
}
$contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr); $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);

View File

@ -10,7 +10,7 @@ function viewsrc_content(App $a) {
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if(! $item_id) { if (! $item_id) {
$a->error = 404; $a->error = 404;
notice( t('Item not found.') . EOL); notice( t('Item not found.') . EOL);
return; return;
@ -25,7 +25,7 @@ function viewsrc_content(App $a) {
); );
if (dbm::is_result($r)) if (dbm::is_result($r))
if(is_ajax()) { if (is_ajax()) {
echo str_replace("\n",'<br />',$r[0]['body']); echo str_replace("\n",'<br />',$r[0]['body']);
killme(); killme();
} else { } else {

View File

@ -7,7 +7,7 @@ function wall_attach_post(App $a) {
$r_json = (x($_GET,'response') && $_GET['response']=='json'); $r_json = (x($_GET,'response') && $_GET['response']=='json');
if($a->argc > 1) { if ($a->argc > 1) {
$nick = $a->argv[1]; $nick = $a->argv[1];
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
dbesc($nick) dbesc($nick)
@ -36,20 +36,20 @@ function wall_attach_post(App $a) {
$page_owner_nick = $r[0]['nickname']; $page_owner_nick = $r[0]['nickname'];
$community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
if((local_user()) && (local_user() == $page_owner_uid)) if ((local_user()) && (local_user() == $page_owner_uid))
$can_post = true; $can_post = true;
else { else {
if($community_page && remote_user()) { if ($community_page && remote_user()) {
$contact_id = 0; $contact_id = 0;
if(is_array($_SESSION['remote'])) { if (is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) { foreach ($_SESSION['remote'] as $v) {
if($v['uid'] == $page_owner_uid) { if ($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid']; $contact_id = $v['cid'];
break; break;
} }
} }
} }
if($contact_id) { if ($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id), intval($contact_id),
@ -62,7 +62,7 @@ function wall_attach_post(App $a) {
} }
} }
} }
if(! $can_post) { if (! $can_post) {
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.'))); echo json_encode(array('error'=>t('Permission denied.')));
killme(); killme();
@ -71,7 +71,7 @@ function wall_attach_post(App $a) {
killme(); killme();
} }
if(! x($_FILES,'userfile')) { if (! x($_FILES,'userfile')) {
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.'))); echo json_encode(array('error'=>t('Invalid request.')));
} }
@ -90,7 +90,7 @@ function wall_attach_post(App $a) {
* Then Filesize gets <= 0. * Then Filesize gets <= 0.
*/ */
if($filesize <=0) { if ($filesize <=0) {
$msg = t('Sorry, maybe your upload is bigger than the PHP configuration allows') . EOL .(t('Or - did you try to upload an empty file?')); $msg = t('Sorry, maybe your upload is bigger than the PHP configuration allows') . EOL .(t('Or - did you try to upload an empty file?'));
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>$msg)); echo json_encode(array('error'=>$msg));
@ -101,7 +101,7 @@ function wall_attach_post(App $a) {
killme(); killme();
} }
if(($maxfilesize) && ($filesize > $maxfilesize)) { if (($maxfilesize) && ($filesize > $maxfilesize)) {
$msg = sprintf(t('File exceeds size limit of %s'), formatBytes($maxfilesize)); $msg = sprintf(t('File exceeds size limit of %s'), formatBytes($maxfilesize));
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>$msg)); echo json_encode(array('error'=>$msg));
@ -154,7 +154,7 @@ function wall_attach_post(App $a) {
@unlink($src); @unlink($src);
if(! $r) { if (! $r) {
$msg = t('File upload failed.'); $msg = t('File upload failed.');
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>$msg)); echo json_encode(array('error'=>$msg));

View File

@ -8,8 +8,8 @@ function wall_upload_post(App $a, $desktopmode = true) {
$r_json = (x($_GET,'response') && $_GET['response']=='json'); $r_json = (x($_GET,'response') && $_GET['response']=='json');
if($a->argc > 1) { if ($a->argc > 1) {
if(! x($_FILES,'media')) { if (! x($_FILES,'media')) {
$nick = $a->argv[1]; $nick = $a->argv[1];
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", $r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
dbesc($nick) dbesc($nick)
@ -44,20 +44,20 @@ function wall_upload_post(App $a, $desktopmode = true) {
$page_owner_nick = $r[0]['nickname']; $page_owner_nick = $r[0]['nickname'];
$community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
if((local_user()) && (local_user() == $page_owner_uid)) if ((local_user()) && (local_user() == $page_owner_uid))
$can_post = true; $can_post = true;
else { else {
if($community_page && remote_user()) { if ($community_page && remote_user()) {
$contact_id = 0; $contact_id = 0;
if(is_array($_SESSION['remote'])) { if (is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) { foreach ($_SESSION['remote'] as $v) {
if($v['uid'] == $page_owner_uid) { if ($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid']; $contact_id = $v['cid'];
break; break;
} }
} }
} }
if($contact_id) { if ($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id), intval($contact_id),
@ -72,7 +72,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
} }
if(! $can_post) { if (! $can_post) {
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.'))); echo json_encode(array('error'=>t('Permission denied.')));
killme(); killme();
@ -81,7 +81,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
killme(); killme();
} }
if(! x($_FILES,'userfile') && ! x($_FILES,'media')){ if (! x($_FILES,'userfile') && ! x($_FILES,'media')){
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.'))); echo json_encode(array('error'=>t('Invalid request.')));
} }
@ -89,13 +89,13 @@ function wall_upload_post(App $a, $desktopmode = true) {
} }
$src = ""; $src = "";
if(x($_FILES,'userfile')) { if (x($_FILES,'userfile')) {
$src = $_FILES['userfile']['tmp_name']; $src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']); $filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']); $filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type']; $filetype = $_FILES['userfile']['type'];
} }
elseif(x($_FILES,'media')) { elseif (x($_FILES,'media')) {
if (is_array($_FILES['media']['tmp_name'])) if (is_array($_FILES['media']['tmp_name']))
$src = $_FILES['media']['tmp_name'][0]; $src = $_FILES['media']['tmp_name'][0];
else else
@ -147,7 +147,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
$maximagesize = get_config('system','maximagesize'); $maximagesize = get_config('system','maximagesize');
if(($maximagesize) && ($filesize > $maximagesize)) { if (($maximagesize) && ($filesize > $maximagesize)) {
$msg = sprintf( t('Image exceeds size limit of %s'), formatBytes($maximagesize)); $msg = sprintf( t('Image exceeds size limit of %s'), formatBytes($maximagesize));
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>$msg)); echo json_encode(array('error'=>$msg));
@ -182,7 +182,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
$imagedata = @file_get_contents($src); $imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype); $ph = new Photo($imagedata, $filetype);
if(! $ph->is_valid()) { if (! $ph->is_valid()) {
$msg = t('Unable to process image.'); $msg = t('Unable to process image.');
if ($r_json) { if ($r_json) {
echo json_encode(array('error'=>$msg)); echo json_encode(array('error'=>$msg));
@ -197,9 +197,9 @@ function wall_upload_post(App $a, $desktopmode = true) {
@unlink($src); @unlink($src);
$max_length = get_config('system','max_image_length'); $max_length = get_config('system','max_image_length');
if(! $max_length) if (! $max_length)
$max_length = MAX_IMAGE_LENGTH; $max_length = MAX_IMAGE_LENGTH;
if($max_length > 0) { if ($max_length > 0) {
$ph->scaleImage($max_length); $ph->scaleImage($max_length);
logger("File upload: Scaling picture to new size ".$max_length, LOGGER_DEBUG); logger("File upload: Scaling picture to new size ".$max_length, LOGGER_DEBUG);
} }

View File

@ -5,7 +5,7 @@ require_once('include/message.php');
function wallmessage_post(App $a) { function wallmessage_post(App $a) {
$replyto = get_my_url(); $replyto = get_my_url();
if(! $replyto) { if (! $replyto) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -14,7 +14,7 @@ function wallmessage_post(App $a) {
$body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
$recipient = (($a->argc > 1) ? notags($a->argv[1]) : ''); $recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
if((! $recipient) || (! $body)) { if ((! $recipient) || (! $body)) {
return; return;
} }
@ -29,7 +29,7 @@ function wallmessage_post(App $a) {
$user = $r[0]; $user = $r[0];
if(! intval($user['unkmail'])) { if (! intval($user['unkmail'])) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -38,7 +38,7 @@ function wallmessage_post(App $a) {
intval($user['uid']) intval($user['uid'])
); );
if($r[0]['total'] > $user['cntunkmail']) { if ($r[0]['total'] > $user['cntunkmail']) {
notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']))); notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return; return;
} }
@ -69,14 +69,14 @@ function wallmessage_post(App $a) {
function wallmessage_content(App $a) { function wallmessage_content(App $a) {
if(! get_my_url()) { if (! get_my_url()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
$recipient = (($a->argc > 1) ? $a->argv[1] : ''); $recipient = (($a->argc > 1) ? $a->argv[1] : '');
if(! $recipient) { if (! $recipient) {
notice( t('No recipient.') . EOL); notice( t('No recipient.') . EOL);
return; return;
} }
@ -93,16 +93,19 @@ function wallmessage_content(App $a) {
$user = $r[0]; $user = $r[0];
if(! intval($user['unkmail'])) { if (! intval($user['unkmail'])) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
$r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1", $r = q("SELECT COUNT(*) AS `total` FROM `mail` WHERE `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 1 DAY AND `unknown` = 1",
intval($user['uid']) intval($user['uid'])
); );
if($r[0]['total'] > $user['cntunkmail']) { if (!dbm::is_result($r)) {
///@TODO Output message to use of failed query
return;
} elseif ($r[0]['total'] > $user['cntunkmail']) {
notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']))); notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return; return;
} }

View File

@ -11,7 +11,7 @@ function webfinger_content(App $a) {
$o .= '<br /><br />'; $o .= '<br /><br />';
if(x($_GET,'addr')) { if (x($_GET,'addr')) {
$addr = trim($_GET['addr']); $addr = trim($_GET['addr']);
$res = Probe::lrdd($addr); $res = Probe::lrdd($addr);
$o .= '<pre>'; $o .= '<pre>';

View File

@ -6,14 +6,15 @@ function xrd_init(App $a) {
$uri = urldecode(notags(trim($_GET['uri']))); $uri = urldecode(notags(trim($_GET['uri'])));
if(substr($uri,0,4) === 'http') { if (substr($uri,0,4) === 'http') {
$acct = false; $acct = false;
$name = basename($uri); $name = basename($uri);
} else { } else {
$acct = true; $acct = true;
$local = str_replace('acct:', '', $uri); $local = str_replace('acct:', '', $uri);
if(substr($local,0,2) == '//') if (substr($local,0,2) == '//') {
$local = substr($local,2); $local = substr($local,2);
}
$name = substr($local,0,strpos($local,'@')); $name = substr($local,0,strpos($local,'@'));
} }