}
$taglist = array();
- foreach($tags AS $tag) {
+ foreach ($tags AS $tag) {
$taglist[] = $tag;
}
function acctlink_init(App $a) {
- if(x($_GET,'addr')) {
+ if (x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = probe_url($addr);
//logger('acctlink: ' . print_r($res,true));
- if($res['url']) {
+ if ($res['url']) {
goaway($res['url']);
killme();
}
foreach ($files as $file) {
if (intval(file_exists($file.'/unsupported')))
continue;
+ }
$f = basename($file);
if ($a->argc>2) {
$uid = $a->argv[3];
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
- if (count($user) == 0) {
+ if (!dbm::is_result($user)) {
notice('User not found'.EOL);
goaway('admin/users');
return ''; // NOTREACHED
* @param int $result
*/
function toggle_theme(&$themes,$th,&$result) {
- for($x = 0; $x < count($themes); $x ++) {
+ for ($x = 0; $x < count($themes); $x ++) {
if ($themes[$x]['name'] === $th) {
if ($themes[$x]['allowed']) {
$themes[$x]['allowed'] = 0;
* @return int
*/
function theme_status($themes,$th) {
- for($x = 0; $x < count($themes); $x ++) {
+ for ($x = 0; $x < count($themes); $x ++) {
if ($themes[$x]['name'] === $th) {
if ($themes[$x]['allowed']) {
return 1;
$status="off"; $action= t("Enable");
}
- $readme = Null;
+ $readme = null;
if (is_file("view/theme/$theme/README.md")) {
$readme = file_get_contents("view/theme/$theme/README.md");
$readme = Markdown($readme);
$total = count_all_friends(local_user(), $cid);
- if(count($total))
+ if (count($total)) {
$a->set_pager_total($total);
+ }
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
return;
}
- if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
+ if (count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
<?php
function apps_content(App $a) {
- $privateaddons = get_config('config','private_addons');
- if ($privateaddons === "1") {
- if((! (local_user()))) {
- info( t("You must be logged in to use addons. "));
- return;};
-}
+ $privateaddons = get_config('config','private_addons');
+ if ($privateaddons === "1") {
+ if ((! (local_user()))) {
+ info( t("You must be logged in to use addons. "));
+ return;
+ }
+ }
- $title = t('Applications');
+ $title = t('Applications');
- if(count($a->apps)==0)
+ if (count($a->apps) == 0) {
notice( t('No installed applications.') . EOL);
-
+ }
$tpl = get_markup_template("apps.tpl");
return replace_macros($tpl, array(
'$title' => $title,
'$apps' => $a->apps,
));
-
-
-
}
function attach_init(App $a) {
- if($a->argc != 2) {
+ if ($a->argc != 2) {
notice( t('Item not available.') . EOL);
return;
}
// error in Chrome for filenames with commas in them
header('Content-type: ' . $r[0]['filetype']);
header('Content-length: ' . $r[0]['filesize']);
- if(isset($_GET['attachment']) && $_GET['attachment'] === '0')
+ if (isset($_GET['attachment']) && $_GET['attachment'] === '0')
header('Content-disposition: filename="' . $r[0]['filename'] . '"');
else
header('Content-disposition: attachment; filename="' . $r[0]['filename'] . '"');
$o .= '<br /><br />';
- if(x($_REQUEST,'text')) {
+ if (x($_REQUEST,'text')) {
$text = trim($_REQUEST['text']);
$o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL;
}
- if(x($_REQUEST,'d2bbtext')) {
+ if (x($_REQUEST,'d2bbtext')) {
$d2bbtext = trim($_REQUEST['d2bbtext']);
$o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;
require_once('include/redir.php');
function cal_init(App $a) {
- if($a->argc > 1)
+ if ($a->argc > 1)
auto_redir($a, $a->argv[1]);
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
$o = '';
- if($a->argc > 1) {
+ if ($a->argc > 1) {
$nick = $a->argv[1];
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick)
);
- if(! count($user))
+ if (! count($user))
return;
$a->data['user'] = $user[0];
$cal_widget = widget_events();
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $vcard_widget;
// First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week');
+ /// @TODO Convert all these to with curly braces
if ($firstDay === false) $firstDay=0;
// get the translation strings for the callendar
$m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
- if($a->argc == 4) {
- if($a->argv[2] == 'export') {
+ /// @TODO Convert to one if() statement
+ if ($a->argc == 4) {
+ if ($a->argv[2] == 'export') {
$mode = 'export';
$format = $a->argv[3];
}
$owner_uid = $a->data['user']['uid'];
$nick = $a->data['user']['nickname'];
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $v) {
- if($v['uid'] == $a->profile['profile_uid']) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $v) {
+ if ($v['uid'] == $a->profile['profile_uid']) {
$contact_id = $v['cid'];
break;
}
}
}
- if($contact_id) {
+ if ($contact_id) {
$groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
$remote_contact = true;
}
}
- if(! $remote_contact) {
- if(local_user()) {
+ if (! $remote_contact) {
+ if (local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
}
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
- if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
+ if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
notice( t('Access to this profile has been restricted.') . EOL);
return;
}
$tabs .= profile_tabs($a,false, $a->data['user']['nickname']);
// The view mode part is similiar to /mod/events.php
- if($mode == 'view') {
+ if ($mode == 'view') {
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
- if(! $y)
+ if (! $y)
$y = intval($thisyear);
- if(! $m)
+ if (! $m)
$m = intval($thismonth);
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
- if($y < 1901)
+ if ($y < 1901)
$y = 1900;
- if($y > 2099)
+ if ($y > 2099)
$y = 2100;
$nextyear = $y;
$nextmonth = $m + 1;
- if($nextmonth > 12) {
+ if ($nextmonth > 12) {
$nextmonth = 1;
$nextyear ++;
}
$prevyear = $y;
- if($m > 1)
+ if ($m > 1)
$prevmonth = $m - 1;
else {
$prevmonth = 12;
$events=array();
// transform the event in a usable array
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$r = sort_by_date($r);
$events = process_events($r);
+ }
if ($a->argv[2] === 'json'){
echo json_encode($events); killme();
}
// Get rid of dashes in key names, Smarty3 can't handle them
- foreach($events as $key => $event) {
+ foreach ($events as $key => $event) {
$event_item = array();
- foreach($event['item'] as $k => $v) {
+ foreach ($event['item'] as $k => $v) {
$k = str_replace('-','_',$k);
$event_item[$k] = $v;
}
return $o;
}
- if($mode == 'export') {
- if(! (intval($owner_uid))) {
+ if ($mode == 'export') {
+ if (! (intval($owner_uid))) {
notice( t('User not found'));
return;
}
// Test permissions
// Respect the export feature setting for all other /cal pages if it's not the own profile
- if( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) {
+ if ( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) {
notice( t('Permission denied.') . EOL);
goaway('cal/' . $nick);
}
$evexport = event_export($owner_uid, $format);
if (!$evexport["success"]) {
- if($evexport["content"])
+ if ($evexport["content"])
notice( t('This calendar format is not supported') );
else
notice( t('No exportable data found'));
return;
}
- if(! $cid) {
- if(get_my_url()) {
+ if (! $cid) {
+ if (get_my_url()) {
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$cid = $r[0]['id'];
- else {
+ } else {
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link(get_my_url()))
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$zcid = $r[0]['id'];
+ }
}
}
}
if ($update)
return;
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
}
- if(get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
+ if (get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
notice( t('Not available.') . EOL);
return;
}
$o .= '<h3>' . t('Community') . '</h3>';
- if(! $update) {
+ if (! $update) {
nav_set_selected('community');
}
- if(x($a->data,'search'))
+ if (x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
} while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
- } else
+ } else {
$s = $r;
+ }
// we behave the same in message lists as the search module
$o .= conversation($a, $s, 'community', $update);
- $o .= alt_pager($a, count($r));
+ $o .= alt_pager($a, count($r));
return $o;
}
killme();
}
- if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
+ if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($a->argv[2]),
intval(local_user())
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$change = intval($a->argv[2]);
+ }
}
- if(($a->argc > 1) && (intval($a->argv[1]))) {
+ if (($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
intval($a->argv[1]),
$group = $r[0];
$members = group_get_members($group['id']);
$preselected = array();
- if(count($members)) {
- foreach($members as $member)
+ if (count($members)) {
+ foreach ($members as $member) {
$preselected[] = $member['id'];
+ }
}
- if($change) {
- if(in_array($change,$preselected)) {
+ if ($change) {
+ if (in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
- }
- else {
+ } else {
group_add_member(local_user(),$group['name'],$change);
}
}
$contact_id = 0;
- if((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
+ if ((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
);
$count_actions=0;
- foreach($orig_records as $orig_record) {
+ foreach ($orig_records as $orig_record) {
$contact_id = $orig_record['id'];
if (x($_POST, 'contacts_batch_update')) {
_contact_update($contact_id);
$update["subhub"] = true;
}
- foreach($updatefields AS $field)
+ foreach ($updatefields AS $field)
if (isset($data[$field]) AND ($data[$field] != ""))
$update[$field] = $data[$field];
if (isset($data["priority"]) AND ($data["priority"] != 0))
$query = "`priority` = ".intval($data["priority"]);
- foreach($update AS $key => $value) {
+ foreach ($update AS $key => $value) {
if ($query != "")
$query .= ", ";
return;
}
- if($a->argc == 3) {
+ if ($a->argc == 3) {
$contact_id = intval($a->argv[1]);
- if(! $contact_id)
+ if (! $contact_id)
return;
$cmd = $a->argv[2];
intval(local_user())
);
- if(! count($orig_record)) {
+ if (! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
}
- if($cmd === 'update') {
+ if ($cmd === 'update') {
_contact_update($contact_id);
goaway('contacts/' . $contact_id);
// NOTREACHED
}
- if($cmd === 'updateprofile') {
+ if ($cmd === 'updateprofile') {
_contact_update_profile($contact_id);
goaway('crepair/' . $contact_id);
// NOTREACHED
}
- if($cmd === 'block') {
+ if ($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]);
if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
return; // NOTREACHED
}
- if($cmd === 'ignore') {
+ if ($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]);
if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
}
- if($cmd === 'archive') {
+ if ($cmd === 'archive') {
$r = _contact_archive($contact_id, $orig_record[0]);
if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1);
return; // NOTREACHED
}
- if($cmd === 'drop') {
+ if ($cmd === 'drop') {
// Check if we should do HTML-based delete confirmation
- if($_REQUEST['confirm']) {
+ if ($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = array();
- foreach($query['args'] as $arg) {
- if(strpos($arg, 'confirm=') === false) {
+ foreach ($query['args'] as $arg) {
+ if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
}
$_SESSION['return_url'] = $a->query_string;
- if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
+ if ((x($a->data,'contact')) && (is_array($a->data['contact']))) {
$contact_id = $a->data['contact']['id'];
$contact = $a->data['contact'];
break;
}
- if(!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
+ if (!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
$relation_text = "";
$relation_text = sprintf($relation_text,htmlentities($contact['name']));
- if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
+ if (($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
$url = "redir/{$contact['id']}";
$sparkle = ' class="sparkle" ';
}
? t('Never')
: datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A'));
- if($contact['last-update'] !== '0000-00-00 00:00:00')
+ if ($contact['last-update'] !== '0000-00-00 00:00:00')
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
$lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
$ignored = false;
$all = false;
- if(($a->argc == 2) && ($a->argv[1] === 'all')) {
+ if (($a->argc == 2) && ($a->argv[1] === 'all')) {
$sql_extra = '';
$all = true;
}
- elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
+ elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
}
- elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
+ elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) {
$sql_extra = " AND `hidden` = 1 ";
$hidden = true;
}
- elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
+ elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) {
$sql_extra = " AND `readonly` = 1 ";
$ignored = true;
}
- elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
+ elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) {
$sql_extra = " AND `archive` = 1 ";
$archived = true;
}
$searching = false;
- if($search) {
+ if ($search) {
$search_hdr = $search;
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
$searching = true;
}
$sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : "");
- if($nets)
+ if ($nets)
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
default:
break;
}
- if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
+ if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = "redir/{$rr['id']}";
$sparkle = ' class="sparkle" ';
}
$contact_action = array();
// Provide friend suggestion only for Friendica contacts
- if($contact['network'] === NETWORK_DFRN) {
+ if ($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array(
'label' => t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'],
);
}
- if($poll_enabled) {
+ if ($poll_enabled) {
$contact_actions['update'] = array(
'label' => t('Update now'),
'url' => 'contacts/' . $contact['id'] . '/update',
$nouveau = false;
- if($a->argc > 1) {
- for($x = 1; $x < $a->argc; $x ++) {
- if(is_a_date_arg($a->argv[$x])) {
- if($datequery)
+ if ($a->argc > 1) {
+ for ($x = 1; $x < $a->argc; $x ++) {
+ if (is_a_date_arg($a->argv[$x])) {
+ if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]);
- else {
+ } else {
$datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post';
}
- }
- elseif($a->argv[$x] === 'new') {
+ } elseif ($a->argv[$x] === 'new') {
$nouveau = true;
- }
- elseif(intval($a->argv[$x])) {
+ } elseif (intval($a->argv[$x])) {
$group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}
- if(x($_GET,'search') || x($_GET,'file'))
+ if (x($_GET,'search') || x($_GET,'file'))
$nouveau = true;
- if($cid)
+ if ($cid)
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
- if($nets) {
+ if ($nets) {
$r = q("select id from contact where uid = %d and network = '%s' and self = 0",
intval(local_user()),
dbesc($nets)
$str = '';
if (dbm::is_result($r))
- foreach($r as $rr)
+ foreach ($r as $rr)
$str .= '<' . $rr['id'] . '>';
- if(strlen($str))
+ if (strlen($str))
$def_acl = array('allow_cid' => $str);
}
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
- if($group) {
+ if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group),
intval($_SESSION['uid'])
);
if (! dbm::is_result($r)) {
- if($update)
+ if ($update)
killme();
notice( t('No such group') . EOL );
goaway(App::get_baseurl(true) . '/network');
}
$contacts = expand_groups(array($group));
- if((is_array($contacts)) && count($contacts)) {
+ if ((is_array($contacts)) && count($contacts)) {
$contact_str = implode(',',$contacts);
}
else {
'$title' => sprintf( t('Group: %s'), $r[0]['name'])
)) . $o;
}
- elseif($cid) {
+ elseif ($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
$sql_extra3 = '';
- if($datequery) {
+ if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
}
- if($datequery2) {
+ if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
$sql_table = "`item`";
- if(x($_GET,'search')) {
+ if (x($_GET,'search')) {
$search = escape_tags($_GET['search']);
- if(strpos($search,'#') === 0) {
+ if (strpos($search,'#') === 0) {
$tag = true;
$search = substr($search,1);
}
if (get_config('system','only_tag_search'))
$tag = true;
- if($tag) {
+ if ($tag) {
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
//$sql_table = "`term` INNER JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
}
}
- if(strlen($file)) {
+ if (strlen($file)) {
$sql_extra .= file_tag_file_query('item',unxmlify($file));
}
- if($conv) {
+ if ($conv) {
$myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3);
$myurl = str_replace('www.','',$myurl);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
- if($nouveau) {
+ if ($nouveau) {
// "New Item View" - show all items unthreaded in reverse created date order
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
// Normal conversation view
- if($order === 'post')
+ if ($order === 'post')
$ordering = "`created`";
else
$ordering = "`commented`";
$parents_str = '';
if (dbm::is_result($r)) {
- foreach($r as $rr)
- if(! in_array($rr['item_id'],$parents_arr))
+ foreach ($r as $rr)
+ if (! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
);
}
- if($mode === 'network') {
+ if ($mode === 'network') {
$profile_owner = local_user();
$page_writeable = true;
}
- if($mode === 'profile') {
+ if ($mode === 'profile') {
$profile_owner = $a->profile['profile_uid'];
$page_writeable = can_write_wall($a,$profile_owner);
}
- if($mode === 'notes') {
+ if ($mode === 'notes') {
$profile_owner = local_user();
$page_writeable = true;
}
- if($mode === 'display') {
+ if ($mode === 'display') {
$profile_owner = $a->profile['uid'];
$page_writeable = can_write_wall($a,$profile_owner);
}
- if($mode === 'community') {
+ if ($mode === 'community') {
$profile_owner = 0;
$page_writeable = false;
}
- if($update)
+ if ($update)
$return_url = $_SESSION['return_url'];
else
$return_url = $_SESSION['return_url'] = $a->query_string;
$threads = array();
$threadsid = -1;
- if($items && count($items)) {
+ if ($items && count($items)) {
- if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
+ if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
// "New Item View" on network page or search page results
// - just loop through the items and format them minimally for display
//$tpl = get_markup_template('search_item.tpl');
$tpl = 'search_item.tpl';
- foreach($items as $item) {
+ foreach ($items as $item) {
$threadsid++;
$comment = '';
$owner_name = '';
$sparkle = '';
- if($mode === 'search' || $mode === 'community') {
- if(((activity_match($item['verb'],ACTIVITY_LIKE))
+ if ($mode === 'search' || $mode === 'community') {
+ if (((activity_match($item['verb'],ACTIVITY_LIKE))
|| (activity_match($item['verb'],ACTIVITY_DISLIKE))
|| activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO)
$nickname = $a->user['nickname'];
// prevent private email from leaking.
- if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+ if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue;
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
- if($item['author-link'] && (! $item['author-name']))
+ if ($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];
$sp = false;
$profile_link = best_link_url($item,$sp);
- if($profile_link === 'mailbox')
+ if ($profile_link === 'mailbox')
$profile_link = '';
- if($sp)
+ if ($sp)
$sparkle = ' sparkle';
else
$profile_link = zrl($profile_link);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
localize_item($item);
- if($mode === 'network-new')
+ if ($mode === 'network-new')
$dropping = true;
else
$dropping = false;
$body = prepare_body($item,true);
- if($a->theme['template_engine'] === 'internal') {
+ if ($a->theme['template_engine'] === 'internal') {
$name_e = template_escape($profile_name);
$title_e = template_escape($item['title']);
$body_e = template_escape($body);
// Store the result in the $comments array
$comments = array();
- foreach($items as $item) {
- if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
- if(! x($comments,$item['parent']))
+ foreach ($items as $item) {
+ if ((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
+ if (! x($comments,$item['parent']))
$comments[$item['parent']] = 1;
else
$comments[$item['parent']] += 1;
- } elseif(! x($comments,$item['parent']))
+ } elseif (! x($comments,$item['parent']))
$comments[$item['parent']] = 0; // avoid notices later on
}
// map all the like/dislike/attendance activities for each parent item
// Store these in the $alike and $dlike arrays
- foreach($items as $item) {
+ foreach ($items as $item) {
builtin_activity_puller($item, $conv_responses);
}
$blowhard_count = 0;
- foreach($items as $item) {
+ foreach ($items as $item) {
$comment = '';
$template = $tpl;
// We've already parsed out like/dislike for special treatment. We can ignore them now
- if(((activity_match($item['verb'],ACTIVITY_LIKE))
+ if (((activity_match($item['verb'],ACTIVITY_LIKE))
|| (activity_match($item['verb'],ACTIVITY_DISLIKE)
|| activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO)
// If a single author has more than 3 consecutive top-level posts, squash the remaining ones.
// If there are more than two comments, squash all but the last 2.
- if($toplevelpost) {
+ if ($toplevelpost) {
$item_writeable = (($item['writable'] || $item['self']) ? true : false);
else {
// prevent private email reply to public conversation from leaking.
- if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+ if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue;
$comments_seen ++;
$show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);
- if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
+ if (($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
if (!$comments_collapsed){
$threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] );
$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;
}
$osparkle = '';
- if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
+ if (($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
- if($item['wall']) {
+ if ($item['wall']) {
// On the network page, I am the owner. On the display page it will be the profile owner.
// This will have been stored in $a->page_contact by our calling page.
$commentww = 'ww';
}
- if((! $item['wall']) && $item['owner-link']) {
+ if ((! $item['wall']) && $item['owner-link']) {
$owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link']));
$alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$item['author-link']));
$owner_namematch = (($item['owner-name']) && $item['owner-name'] == $item['author-name']);
- if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
+ if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
// The author url doesn't match the owner (typically the contact)
// and also doesn't match the contact alias.
$template = $wallwall;
$commentww = 'ww';
// If it is our contact, use a friendly redirect link
- if((link_compare($item['owner-link'],$item['url']))
+ if ((link_compare($item['owner-link'],$item['url']))
&& ($item['network'] === NETWORK_DFRN)) {
$owner_url = $redirect_url;
$osparkle = ' sparkle';
$likebuttons = '';
$shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false);
- if($page_writeable) {
-/* if($toplevelpost) { */
+ if ($page_writeable) {
+/* if ($toplevelpost) { */
$likebuttons = array(
'like' => array( t("I like this \x28toggle\x29"), t("like")),
'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")),
$qc = $qcomment = null;
- if(in_array('qcomment',$a->plugins)) {
+ if (in_array('qcomment',$a->plugins)) {
$qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
$qcomment = (($qc) ? explode("\n",$qc) : null);
}
- if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
+ if (($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
$comment = replace_macros($cmnt_tpl,array(
'$return_path' => '',
'$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''),
$drop = '';
$dropping = false;
- if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
+ if ((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
$dropping = true;
$drop = array(
$profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
- if($item['author-link'] && (! $item['author-name']))
+ if ($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];
$sp = false;
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
- if(feature_enabled($profile_owner,'dislike'))
+ if (feature_enabled($profile_owner,'dislike')) {
$response_verbs[] = 'dislike';
- if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+ }
+ if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe';
- if($page_writeable) {
+ if ($page_writeable) {
$isevent = true;
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
}
$indent = (($toplevelpost) ? '' : ' comment');
$shiny = "";
- if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
+ if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) {
$shiny = 'shiny';
+ }
//
localize_item($item);
$tags=array();
- foreach(explode(',',$item['tag']) as $tag){
+ foreach (explode(',',$item['tag']) as $tag){
$tag = trim($tag);
- if ($tag!="") $tags[] = bbcode($tag);
+ if ($tag!="") {
+ $tags[] = bbcode($tag);
+ }
}
// Build the HTML
$body = prepare_body($item,true);
//$tmp_item = replace_macros($template,
- if($a->theme['template_engine'] === 'internal') {
+ if ($a->theme['template_engine'] === 'internal') {
$body_e = template_escape($body);
$text_e = strip_tags(template_escape($body));
$name_e = template_escape($profile_name);
$title_e = template_escape($item['title']);
$location_e = template_escape($location);
$owner_name_e = template_escape($owner_name);
- }
- else {
+ } else {
$body_e = $body;
$text_e = strip_tags($body);
$name_e = $profile_name;
$contact_id = 0;
- if(($a->argc == 2) && intval($a->argv[1])) {
+ if (($a->argc == 2) && intval($a->argv[1])) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if($cid) {
+ if ($cid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval(local_user())
$id = $a->argv[2];
- $r = q("select `nickname` from user where uid = %d limit 1",
+ $r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($id)
);
if (dbm::is_result($r)) {
- $r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
+ $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
intval(local_user()),
dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
);
if (dbm::is_result($r)) {
- q("insert into manage ( uid, mid ) values ( %d , %d ) ",
+ q("INSERT INTO `manage` ( `uid`, `mid` ) VALUES ( %d , %d ) ",
intval($a->argv[2]),
intval(local_user())
);
dbesc($a->user['email']),
dbesc($a->user['password'])
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$full_managers = $r;
+ }
$delegates = array();
// find everybody that currently has delegated management to this account/page
- $r = q("select * from user where uid in ( select uid from manage where mid = %d ) ",
+ $r = q("SELECT * FROM `user` WHERE `uid` IN ( SELECT `uid` FROM `manage` WHERE `mid` = %d ) ",
intval(local_user())
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$delegates = $r;
+ }
$uids = array();
- if(count($full_managers))
- foreach($full_managers as $rr)
+ if (count($full_managers)) {
+ foreach ($full_managers as $rr) {
$uids[] = $rr['uid'];
+ }
+ }
- if(count($delegates))
- foreach($delegates as $rr)
+ if (count($delegates)) {
+ foreach ($delegates as $rr) {
$uids[] = $rr['uid'];
+ }
+ }
// find every contact who might be a candidate for delegation
- $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s'
- and contact.uid = %d and contact.self = 0 and network = '%s' ",
+ $r = q("SELECT `nurl` FROM `contact` WHERE SUBSTRING_INDEX(`contact`.`nurl`,'/',3) = '%s'
+ AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `network` = '%s' ",
dbesc(normalise_link(App::get_baseurl())),
intval(local_user()),
dbesc(NETWORK_DFRN)
// get user records for all potential page delegates who are not already delegates or managers
- $r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )");
+ $r = q("SELECT `uid`, `username`, `nickname` FROM `user` WHERE `nickname` IN ( $nicks )");
- if (dbm::is_result($r))
- foreach($r as $rr)
- if(! in_array($rr['uid'],$uids))
+ if (dbm::is_result($r)) {
+ foreach ($r as $rr) {
+ if (! in_array($rr['uid'],$uids)) {
$potentials[] = $rr;
+ }
+ }
+ }
require_once("mod/settings.php");
settings_init($a);
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.
}
else {
- if($a->argc > 1)
+ if ($a->argc > 1)
$node = $a->argv[1];
}
*
*/
- if(! x($_POST,'source_url')) {
+ if (! x($_POST,'source_url')) {
$uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user());
- if(! $uid) {
+ if (! $uid) {
notice( t('Permission denied.') . EOL );
return;
}
intval($uid)
);
- if(! $user) {
+ if (! $user) {
notice( t('Profile not found.') . EOL );
return;
}
// These data elements may come from either the friend request notification form or $handsfree array.
- if(is_array($handsfree)) {
+ if (is_array($handsfree)) {
logger('Confirm in handsfree mode');
$dfrn_id = $handsfree['dfrn_id'];
$intro_id = $handsfree['intro_id'];
*
*/
- if(strlen($dfrn_id))
+ if (strlen($dfrn_id))
$cid = 0;
logger('Confirming request for dfrn_id (issued) ' . $dfrn_id);
- if($cid)
+ if ($cid)
logger('Confirming follower with contact_id: ' . $cid);
$network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);
- if($contact['network'])
+ if ($contact['network'])
$network = $contact['network'];
- if($network === NETWORK_DFRN) {
+ if ($network === NETWORK_DFRN) {
/*
*
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']);
- if($aes_allow && function_exists('openssl_encrypt')) {
+ if ($aes_allow && function_exists('openssl_encrypt')) {
openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
$params['aes_key'] = bin2hex($params['aes_key']);
$params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));
}
$params['dfrn_version'] = DFRN_PROTOCOL_VERSION ;
- if($duplex == 1)
+ if ($duplex == 1)
$params['duplex'] = 1;
- if($user[0]['page-flags'] == PAGE_COMMUNITY)
+ if ($user[0]['page-flags'] == PAGE_COMMUNITY)
$params['page'] = 1;
- if($user[0]['page-flags'] == PAGE_PRVGROUP)
+ if ($user[0]['page-flags'] == PAGE_PRVGROUP)
$params['page'] = 2;
logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA);
$leading_junk = substr($res,0,strpos($res,'<?xml'));
$res = substr($res,strpos($res,'<?xml'));
- if(! strlen($res)) {
+ if (! strlen($res)) {
// No XML at all, this exchange is messed up really bad.
// We shouldn't proceed, because the xml parser might choke,
return;
}
- if(strlen($leading_junk) && get_config('system','debugging')) {
+ if (strlen($leading_junk) && get_config('system','debugging')) {
// This might be more common. Mixed error text and some XML.
// If we're configured for debugging, show the text. Proceed in either case.
notice( t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL );
}
- if(stristr($res, "<status")===false) {
+ if (stristr($res, "<status")===false) {
// wrong xml! stop here!
notice( t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL );
return;
switch($status) {
case 0:
info( t("Confirmation completed successfully.") . EOL);
- if(strlen($message))
+ if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
case 1:
case 2:
notice( t("Temporary failure. Please wait and try again.") . EOL);
- if(strlen($message))
+ if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
case 3:
notice( t("Introduction failed or was revoked.") . EOL);
- if(strlen($message))
+ if (strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
}
- if(($status == 0) && ($intro_id)) {
+ if (($status == 0) && ($intro_id)) {
// Success. Delete the notification.
}
- if($status != 0)
+ if ($status != 0)
return;
}
logger('dfrn_confirm: confirm - imported photos');
- if($network === NETWORK_DFRN) {
+ if ($network === NETWORK_DFRN) {
$new_relation = CONTACT_IS_FOLLOWER;
- if(($relation == CONTACT_IS_SHARING) || ($duplex))
+ if (($relation == CONTACT_IS_SHARING) || ($duplex))
$new_relation = CONTACT_IS_FRIEND;
- if(($relation == CONTACT_IS_SHARING) && ($duplex))
+ if (($relation == CONTACT_IS_SHARING) && ($duplex))
$duplex = 0;
$r = q("UPDATE `contact` SET `rel` = %d,
dbesc(NETWORK_DFRN),
intval($contact_id)
);
- }
- else {
+ } else {
// $network !== NETWORK_DFRN
$notify = (($contact['notify']) ? $contact['notify'] : '');
$poll = (($contact['poll']) ? $contact['poll'] : '');
- if((! $contact['notify']) || (! $contact['poll'])) {
+ if ((! $contact['notify']) || (! $contact['poll'])) {
$arr = Probe::lrdd($contact['url']);
- if(count($arr)) {
- foreach($arr as $link) {
- if($link['@attributes']['rel'] === 'salmon')
+ if (count($arr)) {
+ foreach ($arr as $link) {
+ if ($link['@attributes']['rel'] === 'salmon')
$notify = $link['@attributes']['href'];
- if($link['@attributes']['rel'] === NAMESPACE_FEED)
+ if ($link['@attributes']['rel'] === NAMESPACE_FEED)
$poll = $link['@attributes']['href'];
}
}
$new_relation = $contact['rel'];
$writable = $contact['writable'];
- if($network === NETWORK_DIASPORA) {
- if($duplex)
+ if ($network === NETWORK_DIASPORA) {
+ if ($duplex)
$new_relation = CONTACT_IS_FRIEND;
else
$new_relation = CONTACT_IS_FOLLOWER;
- if($new_relation != CONTACT_IS_FOLLOWER)
+ if ($new_relation != CONTACT_IS_FOLLOWER)
$writable = 1;
}
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');
intval($uid)
);
- if(count($self)) {
+ if (count($self)) {
$arr = array();
$arr['guid'] = get_guid(32);
$arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr);
- if($i)
+ if ($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
}
}
$def_gid = get_default_group($uid, $contact["network"]);
- if($contact && intval($def_gid))
+ if ($contact && intval($def_gid))
group_add_member($uid, '', $contact['id'], $def_gid);
// Let's send our user to the contact editor in case they want to
$local_uid = $r[0]['uid'];
- if(! strstr($my_prvkey,'PRIVATE KEY')) {
+ if (! strstr($my_prvkey,'PRIVATE KEY')) {
$message = t('Our site encryption key is apparently messed up.');
xml_status(3,$message);
}
openssl_private_decrypt($source_url,$decrypted_source_url,$my_prvkey);
- if(! strlen($decrypted_source_url)) {
+ if (! strlen($decrypted_source_url)) {
$message = t('Empty site URL was provided or URL could not be decrypted by us.');
xml_status(3,$message);
// NOTREACHED
// It's possible that the other person also requested friendship.
// If it is a duplex relationship, ditch the issued-id if one exists.
- if($duplex) {
+ if ($duplex) {
$r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d",
intval($dfrn_record)
);
if (dbm::is_result($r))
$combined = $r[0];
- if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
+ if ((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
$mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array(
'type' => NOTIFY_CONFIRM,
// Send a new friend post if we are allowed to...
- if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) {
+ if ($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) {
$r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($local_uid)
);
- if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
+ if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
require_once('include/items.php');
intval($local_uid)
);
- if(count($self)) {
+ if (dbm::is_result($self)) {
$arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
$arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr);
- if($i)
+ if ($i) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
+ }
}
}
$prv = (($page == 2) ? 1 : 0);
$writable = (-1);
- if($dfrn_version >= 2.21) {
+ if ($dfrn_version >= 2.21) {
$writable = (($perm === 'rw') ? 1 : 0);
}
$direction = (-1);
- if(strpos($dfrn_id,':') == 1) {
+ if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
logger("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DEBUG);
- if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
+ if ((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
intval(($writable == (-1)) ? $importer['writable'] : $writable),
intval($forum),
intval($prv),
intval($importer['id'])
);
- if($writable != (-1))
+ if ($writable != (-1))
$importer['writable'] = $writable;
$importer['forum'] = $page;
}
logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
- if($dissolve == 1) {
+ if ($dissolve == 1) {
/*
* Relationship is dissolved permanently
// If we are setup as a soapbox we aren't accepting input from this person
// This behaviour is deactivated since it really doesn't make sense to even disallow comments
// The check if someone is a friend or simply a follower is done in a later place so it needn't to be done here
- //if($importer['page-flags'] == PAGE_SOAPBOX)
+ //if ($importer['page-flags'] == PAGE_SOAPBOX)
// xml_status(0);
$rino = get_config('system','rino_encrypt');
logger("Local rino version: ". $rino, LOGGER_DEBUG);
- if(strlen($key)) {
+ if (strlen($key)) {
// if local rino is lower than remote rino, abort: should not happen!
// but only for $remote_rino > 1, because old code did't send rino version
logger('rino: md5 raw key: ' . md5($rawkey));
$final_key = '';
- if($dfrn_version >= 2.1) {
- if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
+ if ($dfrn_version >= 2.1) {
+ if ((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']);
}
else {
}
}
else {
- if((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
+ if ((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']);
}
else {
function dfrn_notify_content(App $a) {
- if(x($_GET,'dfrn_id')) {
+ if (x($_GET,'dfrn_id')) {
// initial communication from external contact, $direction is their direction.
// If this is a duplex communication, ours will be the opposite.
logger('dfrn_notify: new notification dfrn_id=' . $dfrn_id);
$direction = (-1);
- if(strpos($dfrn_id,':') == 1) {
+ if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
$pub_key = trim($r[0]['pubkey']);
$dplx = intval($r[0]['duplex']);
- if((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
+ if ((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
openssl_private_encrypt($hash,$challenge,$prv_key);
openssl_private_encrypt($id_str,$encrypted_id,$prv_key);
- }
- elseif(strlen($pub_key)) {
+ } elseif (strlen($pub_key)) {
openssl_public_encrypt($hash,$challenge,$pub_key);
openssl_public_encrypt($id_str,$encrypted_id,$pub_key);
- }
- else
+ } else {
$status = 1;
+ }
$challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id);
// if requested rino is higher than enabled local rino, reply with local rino
if ($rino_remote < $rino) $rino = $rino_remote;
- if((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
+ if ((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
$perm = 'rw';
- }
- else {
+ } else {
$perm = 'r';
}
$direction = (-1);
- if(strpos($dfrn_id,':') == 1) {
+ if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
$hidewall = false;
- if(($dfrn_id === '') && (! x($_POST,'dfrn_id'))) {
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if (($dfrn_id === '') && (! x($_POST,'dfrn_id'))) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
http_status_exit(403);
}
$user = '';
- if($a->argc > 1) {
+ if ($a->argc > 1) {
$r = q("SELECT `hidewall`,`nickname` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1",
dbesc($a->argv[1])
);
killme();
}
- if(($type === 'profile') && (! strlen($sec))) {
+ if (($type === 'profile') && (! strlen($sec))) {
$sql_extra = '';
switch($direction) {
logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA);
- if(strlen($s)) {
+ if (strlen($s)) {
$xml = parse_xml_string($s);
- if((int) $xml->status == 1) {
+ if ((int) $xml->status == 1) {
$_SESSION['authenticated'] = 1;
- if(! x($_SESSION,'remote'))
+ if (! x($_SESSION,'remote'))
$_SESSION['remote'] = array();
$_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
$_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_handle'] = $r[0]['addr'];
$_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);
// Visitors get 1 day session.
$session_id = session_id();
}
- 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()));
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
// NOTREACHED
}
$orig_id = $r[0]['dfrn_id'];
- if(strpos($orig_id, ':'))
+ if (strpos($orig_id, ':'))
$orig_id = substr($orig_id,2);
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
$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($challenge,$decoded_challenge,$contact['prvkey']);
}
$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);
- if($final_dfrn_id != $orig_id) {
+ if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
$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');
// NOTREACHED
}
$orig_id = $r[0]['dfrn_id'];
- if(strpos($orig_id, ':'))
+ if (strpos($orig_id, ':'))
$orig_id = substr($orig_id,2);
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
$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($challenge,$decoded_challenge,$contact['prvkey']);
}
$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);
- if($final_dfrn_id != $orig_id) {
+ if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
}
$direction = (-1);
- if(strpos($dfrn_id,':') == 1) {
+ if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
$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",
dbesc($url),
intval($owner_uid)
$reputation = $r[0]['rating'];
$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;
$text = '';
}
// Update the writable flag if it changed
logger('dfrn_poll: post request feed: ' . print_r($_POST,true),LOGGER_DATA);
- if($dfrn_version >= 2.21) {
- if($perm === 'rw')
+ if ($dfrn_version >= 2.21) {
+ if ($perm === 'rw')
$writable = 1;
else
$writable = 0;
- if($writable != $contact['writable']) {
+ if ($writable != $contact['writable']) {
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
intval($writable),
intval($contact_id)
$quiet = ((x($_GET,'quiet')) ? true : false);
$direction = (-1);
- if(strpos($dfrn_id,':') == 1) {
+ if (strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
- if($dfrn_id != '') {
+ if ($dfrn_id != '') {
// initial communication from external contact
$hash = random_string();
$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` )
VALUES( '%s', '%s', '%s', '%s', '%s' ) ",
dbesc($hash),
$sql_extra = '';
switch($direction) {
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));
else
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
$encrypted_id = '';
$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($id_str,$encrypted_id,$r[0]['pubkey']);
}
$encrypted_id = '';
}
- if(($type === 'profile') && (strlen($sec))) {
+ if (($type === 'profile') && (strlen($sec))) {
// URL reply
- if($dfrn_version < 2.2) {
+ if ($dfrn_version < 2.2) {
$s = fetch_url($r[0]['poll']
. '?dfrn_id=' . $encrypted_id
. '&type=profile-check'
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);
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;
- if(! x($_SESSION,'remote'))
+ if (! x($_SESSION,'remote'))
$_SESSION['remote'] = array();
$_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
$_SESSION['visitor_id'] = $r[0]['id'];
$_SESSION['visitor_home'] = $r[0]['url'];
$_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);
// Visitors get 1 day session.
$session_id = session_id();
function dfrn_request_init(App $a) {
- if($a->argc > 1)
+ if ($a->argc > 1)
$which = $a->argv[1];
profile_load($a,$which);
*/
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));
return;
}
- if(x($_POST, 'cancel')) {
+ if (x($_POST, 'cancel')) {
goaway(z_root());
}
*
*/
- if((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
+ if ((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
/*
* 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']));
$blocked = 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)
);
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.
$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",
intval($aes_allow),
intval($hidden),
);
if (dbm::is_result($r)) {
$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);
if (isset($photo))
*
*/
- if(! (is_array($a->profile) && count($a->profile))) {
+ if (! (is_array($a->profile) && count($a->profile))) {
notice( t('Profile unavailable.') . EOL);
return;
}
$pending = 1;
- if( x($_POST,'dfrn_url')) {
+ if ( x($_POST,'dfrn_url')) {
/*
* Block friend request spam
*/
- if($maxreq) {
+ if ($maxreq) {
$r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d",
dbesc(datetime_convert('UTC','UTC','now - 24 hours')),
intval($uid)
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
- if(! $rr['rel']) {
+ if (! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`",
intval($rr['cid'])
);
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
- if(! $rr['rel']) {
+ if (! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`",
intval($rr['cid'])
);
$real_name = (x($_POST,'realname') ? notags(trim($_POST['realname'])) : '');
$url = trim($_POST['dfrn_url']);
- if(! strlen($url)) {
+ if (! strlen($url)) {
notice( t("Invalid locator") . EOL );
return;
}
$hcard = '';
- if($email_follow) {
+ if ($email_follow) {
- if(! validate_email($url)) {
+ if (! validate_email($url)) {
notice( t('Invalid email address.') . EOL);
return;
}
$rel = CONTACT_IS_FOLLOWER;
$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;
- if(! $mail_disabled) {
+ if (! $mail_disabled) {
$failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($uid)
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",
intval($uid),
dbesc($url)
);
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 );
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);
return;
}
$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
// is a reciprocal introduction from a known contact
$r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d",
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 could just unblock it, but first we have to jump through a few hoops to
$auto_confirm = false;
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;
- if(! $auto_confirm) {
+ if (! $auto_confirm) {
notification(array(
'type' => NOTIFY_INTRO,
));
}
- if($auto_confirm) {
+ if ($auto_confirm) {
require_once('mod/dfrn_confirm.php');
$handsfree = array(
'uid' => $r[0]['uid'],
}
- if(! $auto_confirm) {
+ if (! $auto_confirm) {
// If we are auto_confirming, this record will have already been nuked
// in dfrn_confirm_post()
* Normal web request. Display our user's introduction form.
*/
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
- if(! get_config('system','local_block')) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if (! get_config('system','local_block')) {
notice( t('Public access denied.') . EOL);
return;
}
function directory_init(App $a) {
$a->set_pager_itemspage(60);
- if(local_user()) {
+ if (local_user()) {
require_once('include/contact_widgets.php');
$a->page['aside'] .= findpeople_widget();
function directory_post(App $a) {
- if(x($_POST,'search'))
+ if (x($_POST,'search'))
$a->data['search'] = $_POST['search'];
}
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())) {
notice( t('Public access denied.') . EOL);
return;
$o = '';
nav_set_selected('directory');
- if(x($a->data,'search'))
+ if (x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$gdirpath = '';
$dirurl = get_config('system','directory');
- if(strlen($dirurl)) {
+ if (strlen($dirurl)) {
$gdirpath = zrl($dirurl,true);
}
- if($search) {
+ if ($search) {
$search = dbesc($search);
$sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
$pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
$details = '';
- if(strlen($rr['locality']))
+ if (strlen($rr['locality']))
$details .= $rr['locality'];
- if(strlen($rr['region'])) {
- if(strlen($rr['locality']))
+ if (strlen($rr['region'])) {
+ if (strlen($rr['locality']))
$details .= ', ';
$details .= $rr['region'];
}
- if(strlen($rr['country-name'])) {
- if(strlen($details))
+ if (strlen($rr['country-name'])) {
+ if (strlen($details))
$details .= ', ';
$details .= $rr['country-name'];
}
-// if(strlen($rr['dob'])) {
-// if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
+// if (strlen($rr['dob'])) {
+// if (($years = age($rr['dob'],$rr['timezone'],'')) != 0)
// $details .= '<br />' . t('Age: ') . $years ;
// }
-// if(strlen($rr['gender']))
+// if (strlen($rr['gender']))
// $details .= '<br />' . t('Gender: ') . $rr['gender'];
$profile = $rr;
- if((x($profile,'address') == 1)
+ if ((x($profile,'address') == 1)
|| (x($profile,'locality') == 1)
|| (x($profile,'region') == 1)
|| (x($profile,'postal-code') == 1)
$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);
}
else {
unset($profile);
unset($location);
- if(! $arr['entry'])
+ if (! $arr['entry']) {
continue;
+ }
$entries[] = $arr['entry'];
$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));
+ }
$j = json_decode($x);
}
$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';
else
$lockstate = 'unlock';
$mail_enabled = false;
$pubmail_enabled = false;
- if(! $mail_disabled) {
+ if (! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
if (dbm::is_result($r)) {
$mail_enabled = true;
- if(intval($r[0]['pubmail']))
+ if (intval($r[0]['pubmail']))
$pubmail_enabled = true;
}
}
// 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
// disable them
-/* if($mail_enabled) {
+/* if ($mail_enabled) {
$selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
$jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
. t("Post to Email") . '</div>';
goaway($onerror_url);
}
- if((! $summary) || (! $start)) {
+ if ((! $summary) || (! $start)) {
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.'));
killme();
}
$c = q("select id from contact where uid = %d and self = 1 limit 1",
intval(local_user())
);
- if(count($c))
+ if (count($c))
$self = $c[0]['id'];
else
$self = 0;
- if($share) {
+ if ($share) {
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
$str_contact_deny = perms2str($_POST['contact_deny']);
// 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);
}
// 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
// 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;
}
$datarray['created'] = $created;
$datarray['edited'] = $edited;
- if(intval($_REQUEST['preview'])) {
+ if (intval($_REQUEST['preview'])) {
$html = format_event_html($datarray);
echo $html;
killme();
$item_id = event_store($datarray);
- if(! $cid)
+ if (! $cid)
proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id);
goaway($_SESSION['return_url']);
$m = 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') {
$mode = 'edit';
$event_id = intval($a->argv[2]);
$nextyear = $y;
$nextmonth = $m + 1;
- if($nextmonth > 12) {
+ if ($nextmonth > 12) {
$nextmonth = 1;
$nextyear ++;
}
$prevyear = $y;
- if($m > 1)
+ if ($m > 1)
$prevmonth = $m - 1;
else {
$prevmonth = 12;
}
// Get rid of dashes in key names, Smarty3 can't handle them
- foreach($events as $key => $event) {
+ foreach ($events as $key => $event) {
$event_item = array();
- foreach($event['item'] as $k => $v) {
+ foreach ($event['item'] as $k => $v) {
$k = str_replace('-','_',$k);
$event_item[$k] = $v;
}
}
- if($mode === 'edit' && $event_id) {
+ if ($mode === 'edit' && $event_id) {
$r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($event_id),
intval(local_user())
}
// Passed parameters overrides anything found in the DB
- if($mode === 'edit' || $mode === 'new') {
- if(!x($orig_event)) $orig_event = array();
+ if ($mode === 'edit' || $mode === 'new') {
+ 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
- if(x($_REQUEST,'nofinish')) $orig_event['nofinish'] = $_REQUEST['nofinish'];
- if(x($_REQUEST,'adjust')) $orig_event['adjust'] = $_REQUEST['adjust'];
- if(x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary'];
- if(x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description'];
- if(x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location'];
- if(x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start'];
- if(x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish'];
+ if (x($_REQUEST,'nofinish')) $orig_event['nofinish'] = $_REQUEST['nofinish'];
+ if (x($_REQUEST,'adjust')) $orig_event['adjust'] = $_REQUEST['adjust'];
+ if (x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary'];
+ if (x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description'];
+ if (x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location'];
+ if (x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start'];
+ 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" ' : '');
$a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : '');
$uri = ((x($orig_event)) ? $orig_event['uri'] : '');
- if(! x($orig_event))
+ if (! x($orig_event)) {
$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" ' );
+ }
- if($cid OR ($mode !== 'new'))
+ if ($cid OR ($mode !== 'new')) {
$sh_checked .= ' disabled="disabled" ';
+ }
$sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
$tz = date_default_timezone_get();
- if(x($orig_event))
+ if (x($orig_event)) {
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
+ }
$syear = datetime_convert('UTC', $tz, $sdt, 'Y');
$smonth = datetime_convert('UTC', $tz, $sdt, 'm');
$fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0);
$f = get_config('system','event_input_format');
- if(! $f)
+ if (! $f) {
$f = 'ymd';
+ }
require_once('include/acl_selectors.php');
$types = Photo::supportedTypes();
$ext = $types[$rr['type']];
- if($a->theme['template_engine'] === 'internal') {
+ if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']);
- }
- else {
+ } else {
$filename_e = $rr['filename'];
}
logger('filer: tag ' . $term . ' item ' . $item_id);
- if($item_id && strlen($term)){
+ if ($item_id && strlen($term)){
// file item
file_tag_save_file(local_user(),$item_id,$term);
} else {
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
$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']));
}
if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){
}
$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");
if (dbm::is_result($r))
- foreach($r as $rr)
+ foreach ($r as $rr)
$visible_plugins[] = $rr['name'];
}
Config::load('feature_lock');
$locked_features = array();
- if(is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
- foreach($a->config['feature_lock'] as $k => $v) {
- if($k === 'config_loaded')
+ if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
+ foreach ($a->config['feature_lock'] as $k => $v) {
+ if ($k === 'config_loaded')
continue;
$locked_features[$k] = intval($v);
}
$o .= '<p></p>';
$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");
if (dbm::is_result($r))
- foreach($r as $rr)
+ foreach ($r as $rr)
$visible_plugins[] = $rr['name'];
}
- if(count($visible_plugins)) {
+ if (count($visible_plugins)) {
$o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
$sorted = $visible_plugins;
$s = '';
sort($sorted);
- foreach($sorted as $p) {
- if(strlen($p)) {
- if(strlen($s)) $s .= ', ';
+ foreach ($sorted as $p) {
+ if (strlen($p)) {
+ if (strlen($s)) {
+ $s .= ', ';
+ }
$s .= $p;
}
}
$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",
intval($new_contact),
intval(local_user())
return;
}
- if($a->argc != 2)
+ if ($a->argc != 2) {
return;
+ }
$contact_id = intval($a->argv[1]);
}
function group_init(App $a) {
- if(local_user()) {
+ if (local_user()) {
require_once('include/group.php');
$a->page['aside'] = group_side('contacts','group','extended',(($a->argc > 1) ? intval($a->argv[1]) : 0));
}
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');
$name = notags(trim($_POST['groupname']));
// Switch to text mode interface if we have more than 'n' contacts or group members
$switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
- if($switchtotext === false)
+ if ($switchtotext === false) {
$switchtotext = get_config('system','groupedit_image_limit');
- if($switchtotext === false)
+ }
+ if ($switchtotext === false) {
$switchtotext = 400;
+ }
$tpl = get_markup_template('group_edit.tpl');
'$gid' => 'new',
'$form_security_token' => get_form_security_token("group_edit"),
));
-
-
}
if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
intval($a->argv[2]),
intval(local_user())
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$change = intval($a->argv[2]);
+ }
}
if (($a->argc > 1) && (intval($a->argv[1]))) {
$group = $r[0];
$members = group_get_members($group['id']);
$preselected = array();
- if(count($members)) {
- foreach($members as $member)
+ if (count($members)) {
+ foreach ($members as $member) {
$preselected[] = $member['id'];
+ }
}
- if($change) {
- if(in_array($change,$preselected)) {
+ if ($change) {
+ if (in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
- }
- else {
+ } else {
group_add_member(local_user(),$group['name'],$change);
}
$members = group_get_members($group['id']);
$preselected = array();
- if(count($members)) {
- foreach($members as $member)
+ if (count($members)) {
+ foreach ($members as $member)
$preselected[] = $member['id'];
}
}
}
- if(! isset($group))
+ if (! isset($group)) {
return;
+ }
$groupeditor = array(
'label_members' => t('Members'),
$sec_token = addslashes(get_form_security_token('group_member_change'));
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
- foreach($members as $member) {
- if($member['url']) {
+ foreach ($members as $member) {
+ if ($member['url']) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
- }
- else
+ } else {
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",
if (dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
- foreach($r as $member) {
- if(! in_array($member['id'],$preselected)) {
+ foreach ($r as $member) {
+ if (! in_array($member['id'],$preselected)) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode);
}
$context['$groupeditor'] = $groupeditor;
$context['$desc'] = t('Click on a contact to add or remove.');
- if($change) {
+ if ($change) {
$tpl = get_markup_template('groupeditor.tpl');
echo replace_macros($tpl, $context);
killme();
$path = '';
// looping through the argv keys bigger than 0 to build
// a path relative to /help
- for($x = 1; $x < argc(); $x ++) {
- if(strlen($path))
+ for ($x = 1; $x < argc(); $x ++) {
+ if (strlen($path)) {
$path .= '/';
+ }
$path .= argv($x);
}
$title = basename($path);
$toc="<style>aside ul {padding-left: 1em;}aside h1{font-size:2em}</style><h2>TOC</h2><ul id='toc'>";
$lastlevel=1;
$idnum = array(0,0,0,0,0,0,0);
- foreach($lines as &$line){
+ foreach ($lines as &$line){
if (substr($line,0,2)=="<h") {
$level = substr($line,2,1);
if ($level!="r") {
$level = intval($level);
if ($level<$lastlevel) {
- for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>";
- for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0;
+ for ($k=$level;$k<$lastlevel; $k++) {
+ $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]++;
$id = implode("_", array_slice($idnum,1,$level));
$href = App::get_baseurl()."/help/{$filename}#{$id}";
}
}
}
- for($k=0;$k<$lastlevel; $k++) $toc.="</ul>";
+ for ($k=0;$k<$lastlevel; $k++) $toc.="</ul>";
$html = implode("\n",$lines);
$a->page['aside'] = $toc.$a->page['aside'];
<?php
-if(! function_exists('home_init')) {
+if (! function_exists('home_init')) {
function home_init(App $a) {
$ret = array();
}}
-if(! function_exists('home_content')) {
+if (! function_exists('home_content')) {
function home_content(App $a) {
$o = '';
header("Content-type: text/xml");
$pubkey = get_config('system','site_pubkey');
- if(! $pubkey) {
+ if (! $pubkey) {
$res = new_keypair(1024);
set_config('system','site_prvkey', $res['prvkey']);
$datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json");
// 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);
// Return the raw content of the template. We use this to make templates usable for js functions.
// 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 real url (nurl)
- if(local_user() && strpos($profileurl, "redir/") === 0) {
+ if (local_user() && strpos($profileurl, "redir/") === 0) {
$cid = intval(substr($profileurl, 6));
$r = q("SELECT `nurl`, `self` FROM `contact` WHERE `id` = '%d' LIMIT 1", intval($cid));
$profileurl = ($r[0]["nurl"] ? $r[0]["nurl"] : "");
// if it's the url containing https it should be converted to http
$nurl = normalise_link(clean_contact_url($profileurl));
- if($nurl) {
+ if ($nurl) {
// Search for contact data
$contact = get_contact_details_by_url($nurl);
}
- if(!is_array($contact))
+ if (!is_array($contact))
return;
// Get the photo_menu - the menu if possible contact actions
- if(local_user())
+ if (local_user())
$actions = contact_photo_menu($contact);
'account_type' => account_type($contact),
'actions' => $actions,
);
- if($datatype == "html") {
+ if ($datatype == "html") {
$t = get_markup_template("hovercard.tpl");
$o = replace_macros($t, array(
$filename = $t->filename;
// Get the content of the template file
- if(file_exists($filename)) {
+ if (file_exists($filename)) {
$content = file_get_contents($filename);
return $content;
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
if ($return_path) {
$rand = '_=' . time();
- if(strpos($return_path, '?')) $rand = "&$rand";
- else $rand = "?$rand";
+ if (strpos($return_path, '?')) {
+ $rand = "&$rand";
+ } else {
+ $rand = "?$rand";
+ }
goaway(App::get_baseurl() . "/" . $return_path . $rand);
}
require_once("include/dba.php");
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
- /*if(get_db_errno()) {
+ /*if (get_db_errno()) {
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, '', true);
- if(! get_db_errno()) {
+ if (! get_db_errno()) {
$r = q("CREATE DATABASE '%s'",
dbesc($dbdata)
);
$db_return_text .= $txt;
}
- if($db && $db->connected) {
+ if ($db && $db->connected) {
$r = q("SELECT COUNT(*) as `total` FROM `user`");
if (dbm::is_result($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl');
check_add($checks, t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);
- if($passed) {
+ if ($passed) {
$cmd = "$phpath -v";
$result = trim(shell_exec($cmd));
$passed2 = ( strpos($result, "(cli)") !== false );
list($result) = explode("\n", $result);
$help = "";
- if(!$passed2) {
+ if (!$passed2) {
$help .= t('PHP executable is not the php cli binary (could be cgi-fgci version)'). EOL;
$help .= t('Found PHP version: ')."<tt>$result</tt>";
}
$result = trim(shell_exec($cmd));
$passed3 = $result == $str;
$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('This is required for message delivery to work.');
}
$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);*/
}
/* $str = file_get_contents('database.sql');
$arr = explode(';',$str);
$errors = false;
- foreach($arr as $a) {
- if(strlen(trim($a))) {
+ foreach ($arr as $a) {
+ if (strlen(trim($a))) {
$r = @$db->q(trim($a));
- if(false === $r) {
+ if (false === $r) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL;
}
}
$total ++;
$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);
return;
}
function item_post(App $a) {
- if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter')))
+ if ((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter')))
return;
require_once('include/security.php');
$uid = local_user();
- if(x($_REQUEST,'dropitems')) {
+ if (x($_REQUEST,'dropitems')) {
$arr_drop = explode(',',$_REQUEST['dropitems']);
drop_items($arr_drop);
$json = array('success' => 1);
$parent = $r[0]['id'];
// 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;
if ($parent_item['contact-id'] && $uid) {
}
}
- 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);
$post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0);
// 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) ;
- if(x($_REQUEST,'return'))
+ if (x($_REQUEST,'return'))
goaway($return_path);
killme();
}
- if((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
+ if ((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
notice( t('Permission denied.') . EOL) ;
- if(x($_REQUEST,'return'))
+ if (x($_REQUEST,'return'))
goaway($return_path);
killme();
}
$orig_post = null;
- if($post_id) {
+ if ($post_id) {
$i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid),
intval($post_id)
if (dbm::is_result($r))
$user = $r[0];
- if($orig_post) {
+ if ($orig_post) {
$str_group_allow = $orig_post['allow_gid'];
$str_contact_allow = $orig_post['allow_cid'];
$str_group_deny = $orig_post['deny_gid'];
// use the user default permissions - as they won't have
// been supplied via a form.
- if(($api_source)
+ if (($api_source)
&& (! array_key_exists('contact_allow',$_REQUEST))
&& (! array_key_exists('group_allow',$_REQUEST))
&& (! array_key_exists('contact_deny',$_REQUEST))
$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;
// 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
if (($parent_item['network'] != NETWORK_DIASPORA)
// 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);
- if(! $mail_disabled) {
+ if (! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
}
}
- if(! strlen($body)) {
- if($preview)
+ if (! strlen($body)) {
+ if ($preview)
killme();
info( t('Empty post discarded.') . EOL );
- if(x($_REQUEST,'return'))
+ if (x($_REQUEST,'return'))
goaway($return_path);
killme();
}
}
- if(strlen($categories)) {
+ if (strlen($categories)) {
// get the "fileas" tags for this post
$filedas = file_tag_file_to_list($categories, 'file');
}
$categories_old = $categories;
$categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category');
$categories_new = $categories;
- if(strlen($filedas)) {
+ if (strlen($filedas)) {
// append the fileas stuff to the new categories list
$categories .= file_tag_list_to_file($filedas, 'file');
}
$self = false;
$contact_id = 0;
- if((local_user()) && (local_user() == $profile_uid)) {
+ if ((local_user()) && (local_user() == $profile_uid)) {
$self = true;
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($_SESSION['uid']));
}
- elseif(remote_user()) {
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $v) {
- if($v['uid'] == $profile_uid) {
+ elseif (remote_user()) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $v) {
+ if ($v['uid'] == $profile_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if($contact_id) {
+ if ($contact_id) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($contact_id)
);
// get contact info for owner
- if($profile_uid == local_user()) {
+ if ($profile_uid == local_user()) {
$contact_record = $author;
}
else {
$post_type = notags(trim($_REQUEST['type']));
- if($post_type === 'net-comment') {
- if($parent_item !== null) {
- if($parent_item['wall'] == 1)
+ if ($post_type === 'net-comment') {
+ if ($parent_item !== null) {
+ if ($parent_item['wall'] == 1)
$post_type = 'wall-comment';
else
$post_type = 'remote-comment';
$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];
- if(count($images)) {
+ if (count($images)) {
$objecttype = ACTIVITY_OBJ_IMAGE;
$match = false;
- if((! $preview) && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
+ if ((! $preview) && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
$attaches = $match[1];
- if(count($attaches)) {
- foreach($attaches as $attach) {
+ if (count($attaches)) {
+ foreach ($attaches as $attach) {
$r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid),
intval($attach)
$private_forum = false;
- if(count($tags)) {
- foreach($tags as $tag) {
+ if (count($tags)) {
+ foreach ($tags as $tag) {
- if(strpos($tag,'#') === 0)
+ if (strpos($tag,'#') === 0) {
continue;
+ }
// If we already tagged 'Robert Johnson', don't try and tag 'Robert'.
// Robert Johnson should be first in the $tags array
$fullnametagged = false;
- for($x = 0; $x < count($tagged); $x ++) {
- if(stristr($tagged[$x],$tag . ' ')) {
+ for ($x = 0; $x < count($tagged); $x ++) {
+ if (stristr($tagged[$x],$tag . ' ')) {
$fullnametagged = true;
break;
}
}
- if($fullnametagged)
+ if ($fullnametagged) {
continue;
+ }
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
if ($success['replaced']) {
$datarray['last-child'] = 1;
$datarray['visible'] = 1;
- if($orig_post)
+ if ($orig_post) {
$datarray['edit'] = true;
+ }
// Search for hashtags
item_body_set_hashtags($datarray);
// preview mode - prepare the body for display and send it via json
- if($preview) {
+ if ($preview) {
require_once('include/conversation.php');
// We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID.
call_hooks('post_local',$datarray);
- if(x($datarray,'cancel')) {
+ if (x($datarray,'cancel')) {
logger('mod_item: post cancelled by plugin.');
- if($return_path) {
+ if ($return_path) {
goaway($return_path);
}
// Fill the cache field
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",
dbesc($datarray['title']),
dbesc($datarray['body']),
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
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);
goaway($return_path);
}
// update filetags in pconfig
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
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d AND `last-child` AND `id` != %d",
intval($parent)
);
- if($contact_record != $author) {
+ if ($contact_record != $author) {
notification(array(
'type' => NOTIFY_COMMENT,
'notify_flags' => $user['notify-flags'],
intval($parent),
intval($post_id));
- if($contact_record != $author) {
+ if ($contact_record != $author) {
notification(array(
'type' => NOTIFY_WALL,
'notify_flags' => $user['notify-flags'],
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
+ 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
call_hooks('post_local_end', $datarray);
- if(strlen($emailcc) && $profile_uid == local_user()) {
+ if (strlen($emailcc) && $profile_uid == local_user()) {
$erecips = explode(',', $emailcc);
- if(count($erecips)) {
- foreach($erecips as $recip) {
+ if (count($erecips)) {
+ foreach ($erecips as $recip) {
$addr = trim($recip);
- if(! strlen($addr))
+ if (! strlen($addr))
continue;
$disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '<br />';
function item_post_return($baseurl, $api_source, $return_path) {
// figure out how to return, depending on from whence we came
- if($api_source)
+ if ($api_source) {
return;
+ }
if ($return_path) {
goaway($return_path);
$r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0",
normalise_link($matches[1]));
- if (!$r)
+
+ if (!dbm::is_result($r)) {
$r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''",
normalise_link($matches[1]));
- if ($r)
+
+ }
+ if (dbm::is_result($r)) {
$data = $r[0];
- else
+ } else {
$data = probe_url($matches[1]);
+ }
if ($data["alias"] != "") {
$newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]';
- if(!stristr($str_tags,$newtag)) {
- if(strlen($str_tags))
+ if (!stristr($str_tags,$newtag)) {
+ if (strlen($str_tags)) {
$str_tags .= ',';
+ }
$str_tags .= $newtag;
}
}
);
// 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`
WHERE `nurl` = '%s' AND `uid` = %d AND
(`network` != '%s' OR (`notify` != '' AND `alias` != ''))
intval($profile_uid),
dbesc(NETWORK_OSTATUS)
);
+ }
// Then check in the global contacts for the address
if (!$r)
);
// 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`
WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
LIMIT 1",
dbesc(normalise_link($name)),
dbesc(NETWORK_OSTATUS)
);
+ }
- if (!$r) {
+ if (!dbm::is_result($r)) {
$probed = probe_url($name);
if ($result['network'] != NETWORK_PHANTOM) {
update_gcontact($probed);
}
//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",
dbesc($name),
dbesc($name),
dbesc($network),
intval($profile_uid)
);
+ }
//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",
dbesc($name),
dbesc($network),
intval($profile_uid)
);
+ }
//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",
dbesc($name),
dbesc($name),
intval($profile_uid)
);
-
+ }
//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",
dbesc($name),
intval($profile_uid)
);
+ }
}
- if ($r) {
- if(strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"])))
+ if (dbm::is_result($r)) {
+ if (strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) {
$inform .= ',';
+ }
- if (isset($r[0]["id"]))
+ if (isset($r[0]["id"])) {
$inform .= 'cid:' . $r[0]["id"];
- elseif (isset($r[0]["notify"]))
+ } elseif (isset($r[0]["notify"])) {
$inform .= $r[0]["notify"];
+ }
$profile = $r[0]["url"];
$alias = $r[0]["alias"];
$newname = $r[0]["nick"];
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"];
+ }
}
//if there is an url for this persons profile
$newtag = '@[url='.$profile.']'.$newname.'[/url]';
$body = str_replace('@'.$name, $newtag, $body);
//append tag to str_tags
- if(! stristr($str_tags,$newtag)) {
- if(strlen($str_tags))
+ if (! stristr($str_tags,$newtag)) {
+ if (strlen($str_tags)) {
$str_tags .= ',';
+ }
$str_tags .= $newtag;
}
// 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.
- if(strlen($alias)) {
+ if (strlen($alias)) {
$newtag = '@[url='.$alias.']'.$newname.'[/url]';
- if(! stristr($str_tags,$newtag)) {
- if(strlen($str_tags))
+ if (! stristr($str_tags,$newtag)) {
+ if (strlen($str_tags)) {
$str_tags .= ',';
+ }
$str_tags .= $newtag;
}
}
require_once('include/like.php');
function like_content(App $a) {
- if(! local_user() && ! remote_user()) {
+ if (! local_user() && ! remote_user()) {
return false;
}
$verb = notags(trim($_GET['verb']));
- if(! $verb)
+ if (! $verb) {
$verb = 'like';
+ }
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
$r = do_like($item_id, $verb);
- if (!$r) return;
+ if (!$r) {
+ return;
+ }
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
function like_content_return($baseurl, $return_path) {
- if($return_path) {
+ if ($return_path) {
$rand = '_=' . time();
- if(strpos($return_path, '?')) $rand = "&$rand";
- else $rand = "?$rand";
+ if (strpos($return_path, '?')) {
+ $rand = "&$rand";
+ } else {
+ $rand = "?$rand";
+ }
goaway($baseurl . "/" . $return_path . $rand);
}
function localtime_post(App $a) {
$t = $_REQUEST['time'];
- if(! $t)
+ if (! $t) {
$t = 'now';
+ }
$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);
+ }
}
function localtime_content(App $a) {
$t = $_REQUEST['time'];
- if(! $t)
+ if (! $t) {
$t = 'now';
+ }
$o .= '<h3>' . t('Time Conversion') . '</h3>';
$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>';
+ }
- 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 .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';
$item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
}
- if(! $item_id)
+ if (! $item_id)
killme();
if (!in_array($type, array('item','photo','event')))
call_hooks('lockview_content', $item);
- if($item['uid'] != local_user()) {
+ if ($item['uid'] != local_user()) {
echo t('Remote privacy information not available.') . '<br />';
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']))) {
echo t('Remote privacy information not available.') . '<br />';
$o = t('Visible to:') . '<br />';
$l = array();
- if(count($allowed_groups)) {
+ if (count($allowed_groups)) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $allowed_groups))
);
- if (dbm::is_result($r))
- foreach($r as $rr)
+ if (dbm::is_result($r)) {
+ foreach ($r as $rr) {
$l[] = '<b>' . $rr['name'] . '</b>';
+ }
+ }
}
- if(count($allowed_users)) {
+ if (count($allowed_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$allowed_users))
);
- if (dbm::is_result($r))
- foreach($r as $rr)
+ if (dbm::is_result($r)) {
+ foreach ($r as $rr) {
$l[] = $rr['name'];
+ }
+ }
}
- if(count($deny_groups)) {
+ if (count($deny_groups)) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $deny_groups))
);
- if (dbm::is_result($r))
- foreach($r as $rr)
+ if (dbm::is_result($r)) {
+ foreach ($r as $rr) {
$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 )",
dbesc(implode(', ',$deny_users))
);
- if (dbm::is_result($r))
- foreach($r as $rr)
+ if (dbm::is_result($r)) {
+ foreach ($r as $rr) {
$l[] = '<strike>' . $rr['name'] . '</strike>';
+ }
+ }
}
<?php
function login_content(App $a) {
- if(x($_SESSION,'theme'))
+ if (x($_SESSION,'theme')) {
unset($_SESSION['theme']);
- if(x($_SESSION,'mobile-theme'))
+ }
+ if (x($_SESSION,'mobile-theme')) {
unset($_SESSION['mobile-theme']);
+ }
- if(local_user())
+ if (local_user()) {
goaway(z_root());
+ }
return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
}
function lostpass_post(App $a) {
$loginame = notags(trim($_POST['login-name']));
- if(! $loginame)
+ if (! $loginame)
goaway(z_root());
$r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `verified` = 1 AND `blocked` = 0 LIMIT 1",
dbesc($new_password_encoded),
intval($uid)
);
- if($r)
+ if ($r)
info( t('Password reset request issued. Check your email.') . EOL);
function lostpass_content(App $a) {
-
- if(x($_GET,'verify')) {
+ if (x($_GET,'verify')) {
$verify = $_GET['verify'];
$hash = hash('whirlpool', $verify);
$uid = local_user();
$orig_record = $a->user;
- if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
- $r = q("select * from user where uid = %d limit 1",
+ if ((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
+ $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($_SESSION['submanage'])
);
if (dbm::is_result($r)) {
}
}
- $r = q("select * from manage where uid = %d",
+ $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
intval($uid)
);
$submanage = $r;
$identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
- if(! $identity)
+ if (! $identity) {
return;
+ }
$limited_id = 0;
$original_id = $uid;
- if(count($submanage)) {
- foreach($submanage as $m) {
- if($identity == $m['mid']) {
+ if (count($submanage)) {
+ foreach ($submanage as $m) {
+ if ($identity == $m['mid']) {
$limited_id = $m['mid'];
break;
}
}
}
- if($limited_id) {
+ if ($limited_id) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($limited_id)
);
- }
- else {
+ } else {
$r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
intval($identity),
dbesc($orig_record['email']),
unset($_SESSION['mobile-theme']);
unset($_SESSION['page_flags']);
unset($_SESSION['return_url']);
- if(x($_SESSION,'submanage'))
+ if (x($_SESSION,'submanage')) {
unset($_SESSION['submanage']);
- if(x($_SESSION,'sysmsg'))
+ }
+ if (x($_SESSION,'sysmsg')) {
unset($_SESSION['sysmsg']);
- if(x($_SESSION,'sysmsg_info'))
+ }
+ if (x($_SESSION,'sysmsg_info')) {
unset($_SESSION['sysmsg_info']);
+ }
require_once('include/security.php');
authenticate_success($r[0],true,true);
- if($limited_id)
+ if ($limited_id) {
$_SESSION['submanage'] = $original_id;
+ }
$ret = array();
call_hooks('home_init',$ret);
if (! dbm::is_result($r)) {
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);
return;
}
$params = array();
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
- if($tags) {
+ if ($tags) {
$params['s'] = $tags;
- if($a->pager['page'] != 1)
+ if ($a->pager['page'] != 1)
$params['p'] = $a->pager['page'];
- if(strlen(get_config('system','directory')))
+ if (strlen(get_config('system','directory')))
$x = post_url(get_server().'/msearch', $params);
else
$x = post_url(App::get_baseurl() . '/msearch', $params);
$j = json_decode($x);
- if($j->total) {
+ if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
}
- if(count($j->results)) {
+ if (count($j->results)) {
$id = 0;
- foreach($j->results as $jj) {
+ foreach ($j->results as $jj) {
$match_nurl = normalise_link($jj->url);
$match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
intval(local_user()),
// fake it to go back to the input form if no recipient listed
- if($norecip) {
+ if ($norecip) {
$a->argc = 2;
$a->argv[1] = 'new';
- }
- else
+ } else {
goaway($_SESSION['return_url']);
+ }
}
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
// 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) {
$saved_image = array();
$img_start = strpos($orig_body, '[img');
$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);
- 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_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
$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 . '#!]';
$cnt++;
- }
- else
+ } else {
$new_body = $new_body . substr($orig_body, 0, $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 = '';
+ }
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
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) {
$origbody = $body;
$newbody = '';
- for($i = 0; $i < count($images); $i++) {
+ for ($i = 0; $i < count($images); $i++) {
$search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is';
$replace = '[url=' . z_path() . '/redir/' . $cid
. '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ;
));
- if(($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
- if(! intval($a->argv[2]))
+ if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
+ if (! intval($a->argv[2]))
return;
// Check if we should do HTML-based delete confirmation
- if($_REQUEST['confirm']) {
+ if ($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = array();
- foreach($query['args'] as $arg) {
- if(strpos($arg, 'confirm=') === false) {
+ foreach ($query['args'] as $arg) {
+ if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
}
));
}
// Now check how the user responded to the confirmation query
- if($_REQUEST['canceled']) {
+ if ($_REQUEST['canceled']) {
goaway($_SESSION['return_url']);
}
$cmd = $a->argv[1];
- if($cmd === 'drop') {
+ if ($cmd === 'drop') {
$r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]),
intval(local_user())
// as we will never again have the info we need to re-create it.
// We'll just have to orphan it.
- //if($convid) {
+ //if ($convid) {
// q("delete from conv where id = %d limit 1",
// intval($convid)
// );
}
- if(($a->argc > 1) && ($a->argv[1] === 'new')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'new')) {
$o .= $header;
$prename = $preurl = $preid = '';
- if($preselect) {
+ if ($preselect) {
$r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval(local_user()),
intval($a->argv[2])
return $o;
}
- if(($a->argc > 1) && (intval($a->argv[1]))) {
+ if (($a->argc > 1) && (intval($a->argv[1]))) {
$o .= $header;
$convid = $r[0]['convid'];
$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' ) ",
dbesc($r[0]['parent-uri']),
intval($convid)
intval(local_user())
);
}
- if(! count($messages)) {
+ if (! count($messages)) {
notice( t('Message not available.') . EOL );
return $o;
}
$seen = 0;
$unknown = false;
- foreach($messages as $message) {
- if($message['unknown'])
+ foreach ($messages as $message) {
+ if ($message['unknown']) {
$unknown = true;
- if($message['from-url'] == $myprofile) {
+ }
+ if ($message['from-url'] == $myprofile) {
$from_url = $myprofile;
$sparkle = '';
} elseif ($message['contact-id'] != 0) {
$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']);
+ }
- if($a->theme['template_engine'] === 'internal') {
+ if ($a->theme['template_engine'] === 'internal') {
$from_name_e = template_escape($message['from-name']);
$subject_e = template_escape($message['title']);
$body_e = template_escape(Smilies::replace(bbcode($message['body'])));
}
$contact = get_contact_details_by_url($message['from-url']);
- if (isset($contact["thumb"]))
+ if (isset($contact["thumb"])) {
$from_photo = $contact["thumb"];
- else
+ } else {
$from_photo = $message['from-photo'];
+ }
$mails[] = array(
- 'id' => $message['id'],
- 'from_name' => $from_name_e,
- 'from_url' => $from_url,
- 'sparkle' => $sparkle,
+ 'id' => $message['id'],
+ 'from_name' => $from_name_e,
+ 'from_url' => $from_url,
+ 'sparkle' => $sparkle,
'from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB),
- 'subject' => $subject_e,
- 'body' => $body_e,
- 'delete' => t('Delete message'),
- 'to_name' => $to_name_e,
- 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
- 'ago' => relative_date($message['created']),
+ 'subject' => $subject_e,
+ 'body' => $body_e,
+ 'delete' => t('Delete message'),
+ 'to_name' => $to_name_e,
+ 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
+ 'ago' => relative_date($message['created']),
);
$seen = $message['seen'];
$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']);
- }
- else {
+ } else {
$subjtxt_e = $message['title'];
}
$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']);
elseif (link_compare($rr['from-url'], $myprofile))
$participants = sprintf( t("You and %s"), $rr['name']);
else
$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>'));
$body_e = template_escape($rr['body']);
$to_name_e = template_escape($rr['name']);
function modexp_init(App $a) {
- if($a->argc != 2)
+ if ($a->argc != 2)
killme();
$nick = $a->argv[1];
$uid = local_user();
$verb = notags(trim($_GET['verb']));
- if(! $verb)
+ if (! $verb)
return;
$verbs = get_mood_verbs();
- if(! in_array($verb,$verbs))
+ if (! in_array($verb,$verbs))
return;
$activity = ACTIVITY_MOOD . '#' . urlencode($verb);
logger('mood: verb ' . $verb, LOGGER_DEBUG);
- if($parent) {
+ if ($parent) {
$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",
intval($parent),
$arr['body'] = $action;
$item_id = item_store($arr);
- if($item_id) {
+ if ($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
intval($uid),
$verbs = get_mood_verbs();
$shortlist = array();
- foreach($verbs as $k => $v)
- if($v !== 'NOTRANSLATION')
+ foreach ($verbs as $k => $v) {
+ if ($v !== 'NOTRANSLATION') {
$shortlist[] = array($k,$v);
+ }
+ }
$tpl = get_markup_template('mood_content.tpl');
$startrec = (($page+1) * $perpage) - $perpage;
$search = $_POST['s'];
- if(! strlen($search))
+ if (! strlen($search))
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') ",
);
if (dbm::is_result($r)) {
- foreach($r as $rr)
+ foreach ($r as $rr)
$results[] = array(
'name' => $rr['name'],
'url' => App::get_baseurl() . '/profile/' . $rr['nickname'],
if ($remember_group) {
$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;
}
- if($remember_tab) {
+ if ($remember_tab) {
// redirect if current selected tab is '/network' and
// last selected tab is _not_ '/network?f=&order=comment'.
// and this isn't a date query
parse_str( $dest_qs, $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
$net_baseurl .= '/new';
}
- if($remember_net) {
+ if ($remember_net) {
$net_args['nets'] = $last_sel_nets;
}
- else if($sel_nets!==false) {
+ else if ($sel_nets!==false) {
$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_queries = build_querystring($net_args);
}
}
- if(x($_GET['nets']) && $_GET['nets'] === 'all')
+ if (x($_GET['nets']) && $_GET['nets'] === 'all')
unset($_GET['nets']);
$group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0);
require_once('include/items.php');
require_once('include/ForumManager.php');
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside'))
$a->page['aside'] = '';
$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",
intval(local_user()),
dbesc($search)
);
}
}
- if(x($_GET,'remove')) {
+ if (x($_GET,'remove')) {
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'",
intval(local_user()),
dbesc($search)
}
// search terms header
- if(x($_GET,'search')) {
+ if (x($_GET,'search')) {
$a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => sprintf( t('Results for: %s'), $search)
));
function saved_searches($search) {
- if(! feature_enabled(local_user(),'savedsearch'))
+ if (! feature_enabled(local_user(),'savedsearch'))
return '';
$a = get_app();
$spam_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')) {
$new_active = 'active';
}
- if(x($_GET,'search')) {
+ if (x($_GET,'search')) {
$search_active = 'active';
}
- if(x($_GET,'star')) {
+ if (x($_GET,'star')) {
$starred_active = 'active';
}
- if(x($_GET,'bmark')) {
+ if (x($_GET,'bmark')) {
$bookmarked_active = 'active';
}
- if(x($_GET,'conv')) {
+ if (x($_GET,'conv')) {
$conv_active = 'active';
}
- if(x($_GET,'spam')) {
+ if (x($_GET,'spam')) {
$spam_active = 'active';
}
function network_query_get_sel_net() {
$network = false;
- if(x($_GET,'nets')) {
+ if (x($_GET,'nets')) {
$network = $_GET['nets'];
}
function network_query_get_sel_group(App $a) {
$group = false;
- if($a->argc >= 2 && is_numeric($a->argv[1])) {
+ if ($a->argc >= 2 && is_numeric($a->argv[1])) {
$group = $a->argv[1];
}
$nouveau = false;
- if($a->argc > 1) {
- for($x = 1; $x < $a->argc; $x ++) {
- if(is_a_date_arg($a->argv[$x])) {
- if($datequery)
+ if ($a->argc > 1) {
+ for ($x = 1; $x < $a->argc; $x ++) {
+ if (is_a_date_arg($a->argv[$x])) {
+ if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]);
- else {
+ } else {
$datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post';
}
- }
- elseif($a->argv[$x] === 'new') {
+ } elseif ($a->argv[$x] === 'new') {
$nouveau = true;
- }
- elseif(intval($a->argv[$x])) {
+ } elseif (intval($a->argv[$x])) {
$group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}
- if(x($_GET,'search') || x($_GET,'file'))
+ if (x($_GET,'search') || x($_GET,'file'))
$nouveau = true;
- if($cid)
+ if ($cid)
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
- if($nets) {
+ if ($nets) {
$r = qu("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0",
intval(local_user()),
dbesc($nets)
$str = '';
if (dbm::is_result($r))
- foreach($r as $rr)
+ foreach ($r as $rr)
$str .= '<' . $rr['id'] . '>';
- if(strlen($str))
+ if (strlen($str))
$def_acl = array('allow_cid' => $str);
}
set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
- if(!$update AND !$rawmode) {
+ if (!$update AND !$rawmode) {
$tabs = network_tabs($a);
$o .= $tabs;
- if($group) {
- if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
+ if ($group) {
+ 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.",
"Warning: This group contains %s members from a network that doesn't allow non public messages.",
$t), $t).EOL);
$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",
intval($group),
intval($_SESSION['uid'])
);
if (! dbm::is_result($r)) {
- if($update)
+ if ($update)
killme();
notice( t('No such group') . EOL );
goaway('network/0');
$contacts = expand_groups(array($group));
$gcontacts = expand_groups(array($group), false, true);
- if((is_array($contacts)) && count($contacts)) {
+ if ((is_array($contacts)) && count($contacts)) {
$contact_str_self = "";
$gcontact_str_self = "";
)) . $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
AND (NOT `blocked` OR `pending`) LIMIT 1",
'id' => 'network',
)) . $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);
}
}
}
- if((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) {
+ if ((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) {
$o .= get_birthdays();
$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))));
}
- if($datequery2) {
+ if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}
$order_mode = "received";
$tag = false;
- if(x($_GET,'search')) {
+ if (x($_GET,'search')) {
$search = escape_tags($_GET['search']);
- if(strpos($search,'#') === 0) {
+ if (strpos($search,'#') === 0) {
$tag = true;
$search = substr($search,1);
}
if (get_config('system','only_tag_search'))
$tag = true;
- if($tag) {
+ if ($tag) {
$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` ",
$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` ",
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
$sql_order = "`item`.`id`";
$order_mode = "id";
}
- if($conv)
+ if ($conv)
$sql_extra3 .= " AND $sql_table.`mention`";
- if($update) {
+ if ($update) {
// only setup pagination on initial page view
$pager_sql = '';
// now that we have the user settings, see if the theme forces
// 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;
$a->set_pager_itemspage($itemspage_network);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
}
- if($nouveau) {
+ if ($nouveau) {
$simple_update = (($update) ? " AND `item`.`unseen` " : '');
if ($sql_order == "")
// Normal conversation view
- if($order === 'post') {
+ if ($order === 'post') {
$ordering = "`created`";
if ($sql_order == "")
$order_mode = "created";
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
// Fetch a page full of parent items for this page
- if($update) {
+ if ($update) {
if (get_config("system", "like_no_comment"))
$sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'";
else
$date_offset = "";
if (dbm::is_result($r)) {
- foreach($r as $rr)
- if(! in_array($rr['item_id'],$parents_arr))
+ foreach ($r as $rr)
+ if (! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id'];
$parents_str = implode(", ", $parents_arr);
$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) . ' )';
}
),
);
- if(feature_enabled(local_user(),'personal_tab')) {
+ if (feature_enabled(local_user(),'personal_tab')) {
$tabs[] = array(
'label' => t('Personal'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
);
}
- if(feature_enabled(local_user(),'new_tab')) {
+ if (feature_enabled(local_user(),'new_tab')) {
$tabs[] = array(
'label' => t('New'),
'url' => str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
);
}
- if(feature_enabled(local_user(),'link_tab')) {
+ if (feature_enabled(local_user(),'link_tab')) {
$tabs[] = array(
'label' => t('Shared Links'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
);
}
- if(feature_enabled(local_user(),'star_posts')) {
+ if (feature_enabled(local_user(),'star_posts')) {
$tabs[] = array(
'label' => t('Starred'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
}
// 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) );
}
$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="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('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;
}
$plugins = get_config("system","addon");
$plugins_arr = array();
- if($plugins) {
+ if ($plugins) {
$plugins_arr = explode(",",str_replace(" ", "",$plugins));
$idx = array_search($plugin, $plugins_arr);
$last = get_config('nodeinfo','last_calucation');
- if($last) {
+ if ($last) {
// Calculate every 24 hours
$next = $last + (24 * 60 * 60);
- if($next > time()) {
+ if ($next > time()) {
logger("calculation intervall not reached");
return;
}
function noscrape_init(App $a) {
- if($a->argc > 1)
+ if ($a->argc > 1) {
$which = $a->argv[1];
- else
+ } else {
killme();
+ }
$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'];
$profile = $a->argv[1];
}
$o ="";
$o .= profile_tabs($a,True);
- if(! $update) {
+ if (! $update) {
$o .= '<h3>' . t('Personal Notes') . '</h3>';
$commpage = false;
$parents_str = '';
if (dbm::is_result($r)) {
- foreach($r as $rr)
+ foreach ($r as $rr) {
$parents_arr[] = $rr['item_id'];
+ }
$parents_str = implode(', ', $parents_arr);
$r = q("SELECT %s FROM `item` %s
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
- if($request_id === "all")
+ if ($request_id === "all")
return;
- if($request_id) {
+ if ($request_id) {
$r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($request_id),
$fid = $r[0]['fid'];
- if($_POST['submit'] == t('Discard')) {
+ if ($_POST['submit'] == t('Discard')) {
$r = q("DELETE FROM `intro` WHERE `id` = %d",
intval($intro_id)
);
- if(! $fid) {
+ if (! $fid) {
// 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
}
goaway('notifications/intros');
}
- if($_POST['submit'] == t('Ignore')) {
+ if ($_POST['submit'] == t('Ignore')) {
$r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
intval($intro_id));
goaway('notifications/intros');
$startrec = ($page * $perpage) - $perpage;
// 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');
$notif_header = t('Notifications');
$notifs['page'] = $a->pager['page'];
// Json output
- if(intval($json) === 1)
+ if (intval($json) === 1)
json_return_and_die($notifs);
$notif_tpl = get_markup_template('notifications.tpl');
// Process the data for template creation
- if($notifs['ident'] === 'introductions') {
+ if ($notifs['ident'] === 'introductions') {
$sugg = get_markup_template('suggestions.tpl');
$tpl = get_markup_template("intros.tpl");
$knowyou = '';
$dfrn_text = '';
- if($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
- if($it['network'] === NETWORK_DFRN) {
+ if ($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
+ if ($it['network'] === NETWORK_DFRN) {
$lbl_knowyou = t('Claims to be known to you: ');
$knowyou = (($it['knowyou']) ? t('yes') : t('no'));
$helptext = t('Shall your connection be bidirectional or not?');
}
}
- if($notifs['total'] == 0)
+ if ($notifs['total'] == 0)
info( t('No introductions.') . EOL);
// Normal notifications (no introductions)
// 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.
- if($show == 0 || intval($show) && $notifs['total'] > 0) {
+ if ($show == 0 || intval($show) && $notifs['total'] > 0) {
$notif_show_lnk = array(
'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
'text' => ($show ? t('Show unread') : t('Show all')),
}
// 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']);
+ }
}
$o .= replace_macros($notif_tpl, array(
function openid_content(App $a) {
$noid = get_config('system','no_openid');
- if($noid)
+ if ($noid)
goaway(z_root());
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;
- if($openid->validate()) {
+ if ($openid->validate()) {
$authid = $_REQUEST['openid_identity'];
- if(! strlen($authid)) {
+ if (! strlen($authid)) {
logger( t('OpenID protocol error. No ID returned.') . EOL);
goaway(z_root());
}
if ($k === 'namePerson/friendly') {
$nick = notags(trim($v));
}
- if($k === 'namePerson/first') {
+ if ($k === 'namePerson/first') {
$first = notags(trim($v));
}
- if($k === 'namePerson') {
+ if ($k === 'namePerson') {
$args .= '&username=' . notags(trim($v));
}
if ($k === 'contact/email') {
$redirects = 0;
// Fetch the header of the URL
$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
$hdrs = array();
$h = explode("\n", $result["header"]);
$type = $hdrs["Content-Type"];
}
if ($type) {
- if(stripos($type, "image/") !== false) {
+ if (stripos($type, "image/") !== false) {
echo $br . "[img]" . $url . "[/img]" . $br;
killme();
}
header('Etag: '.$_SERVER['HTTP_IF_NONE_MATCH']);
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
header("Cache-Control: max-age=31536000");
- if(function_exists('header_remove')) {
+ if (function_exists('header_remove')) {
header_remove('Last-Modified');
header_remove('Expires');
header_remove('Cache-Control');
$default = 'images/person-175.jpg';
- if(isset($type)) {
+ if (isset($type)) {
/**
$data = $r[0]['data'];
$mimetype = $r[0]['type'];
}
- if(! isset($data)) {
+ if (! isset($data)) {
$data = file_get_contents($default);
$mimetype = 'image/jpeg';
}
- }
- else {
+ } else {
/**
* Other photos
*/
$resolution = 0;
- foreach( Photo::supportedTypes() as $m=>$e){
+ foreach ( Photo::supportedTypes() as $m=>$e){
$photo = str_replace(".$e",'',$photo);
}
- if(substr($photo,-2,1) == '-') {
+ if (substr($photo,-2,1) == '-') {
$resolution = intval(substr($photo,-1,1));
$photo = substr($photo,0,-2);
}
}
}
- if(! isset($data)) {
- if(isset($resolution)) {
+ if (! isset($data)) {
+ if (isset($resolution)) {
switch($resolution) {
case 4:
// Resize only if its not a GIF
if ($mime != "image/gif") {
$ph = new Photo($data, $mimetype);
- if($ph->is_valid()) {
- if(isset($customres) && $customres > 0 && $customres < 500) {
+ if ($ph->is_valid()) {
+ if (isset($customres) && $customres > 0 && $customres < 500) {
$ph->scaleImageSquare($customres);
}
$data = $ph->imageString();
}
}
- if(function_exists('header_remove')) {
+ if (function_exists('header_remove')) {
header_remove('Pragma');
header_remove('pragma');
}
header("Content-type: ".$mimetype);
- if($prvcachecontrol) {
+ if ($prvcachecontrol) {
// it is a private photo that they have no permission to view.
// tell the browser not to cache it, in case they authenticate
intval($owner_uid)
);
- if (count($prvnxt)) {
+ if (dbm::is_result($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1;
}
}
- if (count($ph) == 1)
+ if (count($ph) == 1) {
$hires = $lores = $ph[0];
+ }
if (count($ph) > 1) {
if ($ph[1]['scale'] == 2) {
// original is 640 or less, we can display it directly
if ($all_events) {
$str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d');
- foreach($ev as $x) {
+ foreach ($ev as $x) {
$bd = false;
if ($x['type'] === 'birthday') {
$birthdays ++;
function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
{
$notifications = array();
- foreach($notifs as $key => $notif) {
+ foreach ($notifs as $key => $notif) {
$notifications[$key . ':note'] = $notif['message'];
$notifications[$key . ':@attributes'] = array(
if (x($_GET,'updatedSince') AND !$global) {
$ret['updatedSince'] = false;
}
+
$ret['startIndex'] = (int) $startIndex;
$ret['itemsPerPage'] = (int) $itemsPerPage;
$ret['totalResults'] = (int) $totalResults;
$ret['entry'] = array();
-
$fields_ret = array(
- 'id' => false,
- 'displayName' => false,
- 'urls' => false,
- 'updated' => false,
+ 'id' => false,
+ 'displayName' => false,
+ 'urls' => false,
+ 'updated' => false,
'preferredUsername' => false,
- 'photos' => false,
- 'aboutMe' => false,
- 'currentLocation' => false,
- 'network' => false,
- 'gender' => false,
- 'tags' => false,
- 'address' => false,
- 'contactType' => false,
- 'generation' => false
+ 'photos' => false,
+ 'aboutMe' => false,
+ 'currentLocation' => false,
+ 'network' => false,
+ 'gender' => false,
+ 'tags' => false,
+ 'address' => false,
+ 'contactType' => false,
+ 'generation' => false
);
if ((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) {
if (($rr['about'] == "") AND isset($rr['pabout'])) {
$rr['about'] = $rr['pabout'];
}
+
if ($rr['location'] == "") {
if (isset($rr['plocation'])) {
$rr['location'] = $rr['plocation'];
}
+
if (isset($rr['pregion']) AND ($rr['pregion'] != "")) {
if ($rr['location'] != "") {
$rr['location'] .= ", ";
}
+
$rr['location'] .= $rr['pregion'];
}
} else {
$entry['updated'] = $rr['updated'];
}
+
$entry['updated'] = date("c", strtotime($entry['updated']));
}
if ($fields_ret['photos']) {
if ($fields_ret['contactType']) {
$entry['contactType'] = intval($rr['contact-type']);
}
+
$ret['entry'][] = $entry;
}
} else {
} else {
http_status_exit(500);
}
+
logger("End of poco", LOGGER_DEBUG);
if ($format === 'xml') {
} else {
http_status_exit(500);
}
+
}
$target = $r[0];
- if($parent) {
+ if ($parent) {
$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",
intval($parent),
$arr['object'] .= '</link></object>' . "\n";
$item_id = item_store($arr);
- if($item_id) {
+ if ($item_id) {
//q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
// dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
// intval($uid),
$name = '';
$id = '';
- if(intval($_GET['c'])) {
+ if (intval($_GET['c'])) {
$r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_GET['c']),
intval(local_user())
$verbs = get_poke_verbs();
$shortlist = array();
- foreach($verbs as $k => $v)
- if($v[1] !== 'NOTRANSLATION')
+ foreach ($verbs as $k => $v) {
+ if ($v[1] !== 'NOTRANSLATION') {
$shortlist[] = array($k,$v[1]);
+ }
+ }
$tpl = get_markup_template('poke_content.tpl');
if ($a->argc == 1) {
$bulk_delivery = true;
- }
- else {
+ } else {
$nickname = $a->argv[2];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s'
AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
- if(! $xml)
+ if (! $xml) {
http_status_exit(500);
+ }
$msg = zot_decode($importer,$xml);
logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
- if(! is_array($msg))
+ if (! is_array($msg)) {
http_status_exit(500);
+ }
$ret = 0;
$ret = zot_incoming($bulk_delivery, $importer,$msg);
function pretheme_init(App $a) {
- if($_REQUEST['theme']) {
+ if ($_REQUEST['theme']) {
$theme = $_REQUEST['theme'];
$info = get_theme_info($theme);
- if($info) {
+ if ($info) {
// unfortunately there will be no translation for this string
$desc = $info['description'];
$version = $info['version'];
$credits = $info['credits'];
- }
- else {
+ } else {
$desc = '';
$version = '';
$credits = '';
$o .= '<br /><br />';
- if(x($_GET,'addr')) {
+ if (x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = probe_url($addr);
function profile_init(App $a) {
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside')) {
$a->page['aside'] = '';
+ }
- if($a->argc > 1)
+ if ($a->argc > 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");
if (dbm::is_result($r)) {
goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']);
- }
- else {
+ } else {
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL );
$a->error = 404;
}
$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'];
$profile = htmlspecialchars($a->argv[1]);
- }
- else {
+ } else {
auto_redir($a, $which);
}
$blocked = (((get_config('system','block_public')) && (! 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" />';
}
if (x($a->profile,'openidserver')) {
if ((! $blocked) && (! $userblock)) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
- if(strlen($keywords))
+ if (strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
}
}
// now that we have the user settings, see if the theme forces
// 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;
$a->set_pager_itemspage($itemspage_network);
$parents_str = '';
if (dbm::is_result($r)) {
- foreach($r as $rr)
+ foreach ($r as $rr) {
$parents_arr[] = $rr['item_id'];
+ }
$parents_str = implode(', ', $parents_arr);
$items = q(item_query()." AND `item`.`uid` = %d
$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_events();
}
- if($is_owner) {
+ if ($is_owner) {
$r = q("UPDATE `item` SET `unseen` = 0
WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
intval(local_user())
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
$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",
intval($_REQUEST['profile']),
intval(local_user())
// phase 2 - we have finished cropping
- if($a->argc != 2) {
+ if ($a->argc != 2) {
notice( t('Image uploaded but image cropping failed.') . EOL );
return;
}
$image_id = $a->argv[1];
- if(substr($image_id,-2,1) == '-') {
+ if (substr($image_id,-2,1) == '-') {
$scale = substr($image_id,-1,1);
$image_id = substr($image_id,0,-2);
}
$base_image = $r[0];
$im = new Photo($base_image['data'], $base_image['type']);
- if($im->is_valid()) {
+ if ($im->is_valid()) {
$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);
// 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",
dbesc($base_image['resource-id']),
intval(local_user())
}
-if(! function_exists('profile_photo_content')) {
+if (! function_exists('profile_photo_content')) {
function profile_photo_content(App $a) {
if (! local_user()) {
$newuser = false;
- if($a->argc == 2 && $a->argv[1] === 'new')
+ if ($a->argc == 2 && $a->argv[1] === 'new')
$newuser = true;
- if( $a->argv[1]=='use'){
+ if ( $a->argv[1]=='use'){
if ($a->argc<3){
notice( t('Permission denied.') . EOL );
return;
}
$havescale = false;
foreach ($r as $rr) {
- if($rr['scale'] == 5)
+ if ($rr['scale'] == 5)
$havescale = true;
}
);
- if(! x($a->config,'imagecrop')) {
+ if (! x($a->config,'imagecrop')) {
$tpl = get_markup_template('profile_photo.tpl');
}}
-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) {
$max_length = get_config('system','max_image_length');
if (! $max_length) {
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",
intval($a->argv[2]),
intval(local_user())
- 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');
);
info( t('New profile created.') . EOL);
- if(count($r3) == 1)
+ if (count($r3) == 1)
goaway('profiles/'.$r3[0]['id']);
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');
intval(local_user()),
intval($a->argv[2])
);
- if(! dbm::is_result($r1)) {
+ if (! dbm::is_result($r1)) {
notice( t('Profile unavailable to clone.') . EOL);
killme();
return;
}
- 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",
intval($a->argv[1]),
intval(local_user())
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",
intval($a->argv[1]),
intval(local_user())
);
- if(! count($orig)) {
+ if (! count($orig)) {
notice( t('Profile not found.') . EOL);
return;
}
$is_default = (($orig[0]['is-default']) ? 1 : 0);
$profile_name = notags(trim($_POST['profile_name']));
- if(! strlen($profile_name)) {
+ if (! strlen($profile_name)) {
notice( t('Profile Name is required.') . EOL);
return;
}
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
$y = substr($dob,0,4);
- if((! ctype_digit($y)) || ($y < 1900))
+ if ((! ctype_digit($y)) || ($y < 1900))
$ignore_year = true;
else
$ignore_year = false;
- if($dob != '0000-00-00') {
- if(strpos($dob,'0000-') === 0) {
+ if ($dob != '0000-00-00') {
+ if (strpos($dob,'0000-') === 0) {
$ignore_year = true;
$dob = substr($dob,5);
}
$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;
}
$name = notags(trim($_POST['name']));
- if(! strlen($name)) {
+ if (! strlen($name)) {
$name = '[No Name]';
}
- if($orig[0]['name'] != $name)
+ if ($orig[0]['name'] != $name)
$namechanged = true;
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
- if(! strlen($howlong))
+ if (! strlen($howlong))
$howlong = '0000-00-00 00:00:00';
else
$howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong);
$withchanged = false;
- if(strlen($with)) {
- if($with != strip_tags($orig[0]['with'])) {
+ if (strlen($with)) {
+ if ($with != strip_tags($orig[0]['with'])) {
$withchanged = true;
$prf = '';
$lookup = $with;
- if(strpos($lookup,'@') === 0)
+ if (strpos($lookup,'@') === 0)
$lookup = substr($lookup,1);
$lookup = str_replace('_',' ', $lookup);
- if(strpos($lookup,'@') || (strpos($lookup,'http://'))) {
+ if (strpos($lookup,'@') || (strpos($lookup,'http://'))) {
$newname = $lookup;
$links = @Probe::lrdd($lookup);
- if(count($links)) {
- foreach($links as $link) {
- if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
+ if (count($links)) {
+ foreach ($links as $link) {
+ if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
$prf = $link['@attributes']['href'];
}
}
dbesc($newname),
intval(local_user())
);
- if(! $r) {
+ if (! $r) {
$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
dbesc($lookup),
intval(local_user())
}
}
- if($prf) {
+ if ($prf) {
$with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with);
- if(strpos($with,'@') === 0)
+ if (strpos($with,'@') === 0)
$with = substr($with,1);
}
}
$changes = array();
$value = '';
- if($is_default) {
- if($marital != $orig[0]['marital']) {
+ if ($is_default) {
+ if ($marital != $orig[0]['marital']) {
$changes[] = '[color=#ff0000]♥[/color] ' . t('Marital Status');
$value = $marital;
}
- if($withchanged) {
+ if ($withchanged) {
$changes[] = '[color=#ff0000]♥[/color] ' . t('Romantic Partner');
$value = strip_tags($with);
}
- if($likes != $orig[0]['likes']) {
+ if ($likes != $orig[0]['likes']) {
$changes[] = t('Likes');
$value = $likes;
}
- if($dislikes != $orig[0]['dislikes']) {
+ if ($dislikes != $orig[0]['dislikes']) {
$changes[] = t('Dislikes');
$value = $dislikes;
}
- if($work != $orig[0]['work']) {
+ if ($work != $orig[0]['work']) {
$changes[] = t('Work/Employment');
}
- if($religion != $orig[0]['religion']) {
+ if ($religion != $orig[0]['religion']) {
$changes[] = t('Religion');
$value = $religion;
}
- if($politic != $orig[0]['politic']) {
+ if ($politic != $orig[0]['politic']) {
$changes[] = t('Political Views');
$value = $politic;
}
- if($gender != $orig[0]['gender']) {
+ if ($gender != $orig[0]['gender']) {
$changes[] = t('Gender');
$value = $gender;
}
- if($sexual != $orig[0]['sexual']) {
+ if ($sexual != $orig[0]['sexual']) {
$changes[] = t('Sexual Preference');
$value = $sexual;
}
- if($xmpp != $orig[0]['xmpp']) {
+ if ($xmpp != $orig[0]['xmpp']) {
$changes[] = t('XMPP');
$value = $xmpp;
}
- if($homepage != $orig[0]['homepage']) {
+ if ($homepage != $orig[0]['homepage']) {
$changes[] = t('Homepage');
$value = $homepage;
}
- if($interest != $orig[0]['interest']) {
+ if ($interest != $orig[0]['interest']) {
$changes[] = t('Interests');
$value = $interest;
}
- if($address != $orig[0]['address']) {
+ if ($address != $orig[0]['address']) {
$changes[] = t('Address');
// New address not sent in notifications, potential privacy issues
// 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.
}
- if($locality != $orig[0]['locality'] || $region != $orig[0]['region']
+ if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
|| $country_name != $orig[0]['country-name']) {
$changes[] = t('Location');
$comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
function profile_activity($changed, $value) {
$a = get_app();
- if(! local_user() || ! is_array($changed) || ! count($changed))
+ if (! local_user() || ! is_array($changed) || ! count($changed))
return;
- if($a->user['hidewall'] || get_config('system','block_public'))
+ if ($a->user['hidewall'] || get_config('system','block_public'))
return;
- if(! get_pconfig(local_user(),'system','post_profilechange'))
+ if (! get_pconfig(local_user(),'system','post_profilechange'))
return;
require_once('include/items.php');
intval(local_user())
);
- if(! count($self))
+ if (! count($self))
return;
$arr = array();
$changes = '';
$t = count($changed);
$z = 0;
- foreach($changed as $ch) {
- if(strlen($changes)) {
+ foreach ($changed as $ch) {
+ if (strlen($changes)) {
if ($z == ($t - 1))
$changes .= t(' and ');
else
$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 “%3$s”'), $A, $changes, $value);
$message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof);
}
$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",
intval($a->argv[1]),
intval(local_user())
require_once('include/profile_selectors.php');
-
$a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
'$baseurl' => App::get_baseurl(true),
));
$detailled_profile = (get_pconfig(local_user(),'system','detailled_profile') AND $personal_account);
$f = get_config('system','birthday_input_format');
- if(! $f)
+ if (! $f)
$f = 'ymd';
$is_default = (($r[0]['is-default']) ? 1 : 0);
else {
//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(
"SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
local_user()
}
- if($a->argc < 2) {
+ if ($a->argc < 2) {
notice( t('Invalid profile identifier.') . EOL );
return;
}
// Switch to text mod interface if we have more than 'n' contacts or group members
$switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
- if($switchtotext === false)
+ if ($switchtotext === false)
$switchtotext = get_config('system','groupedit_image_limit');
- if($switchtotext === false)
+ if ($switchtotext === false)
$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
AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
dbesc(NETWORK_DFRN),
}
- 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",
intval($a->argv[1]),
intval(local_user())
$ingroup = array();
if (dbm::is_result($r))
- foreach($r as $member)
+ foreach ($r as $member)
$ingroup[] = $member['id'];
$members = $r;
- if($change) {
- if(in_array($change,$ingroup)) {
+ if ($change) {
+ if (in_array($change,$ingroup)) {
q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d",
intval($change),
intval(local_user())
$ingroup = array();
if (dbm::is_result($r))
- foreach($r as $member)
+ foreach ($r as $member)
$ingroup[] = $member['id'];
}
}
$o .= '<div id="prof-update-wrapper">';
- if($change)
+ if ($change)
$o = '';
$o .= '<div id="prof-members-title">';
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
- foreach($members as $member) {
- if($member['url']) {
+ foreach ($members as $member) {
+ if ($member['url']) {
$member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
$o .= micropro($member,true,'mpprof', $textmode);
}
if (dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
- foreach($r as $member) {
- if(! in_array($member['id'],$ingroup)) {
+ foreach ($r as $member) {
+ if (! in_array($member['id'],$ingroup)) {
$member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
$o .= micropro($member,true,'mpprof',$textmode);
}
$o .= '</div><div id="prof-all-contacts-end"></div>';
- if($change) {
+ if ($change) {
echo $o;
killme();
}
function hub_return($valid,$body) {
- if($valid) {
+ if ($valid) {
header($_SERVER["SERVER_PROTOCOL"] . ' 200 ' . 'OK');
echo $body;
killme();
$nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
$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_topic = ((x($_GET,'hub_topic')) ? notags(trim($_GET['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']);
// should abort but let's humour them.
}
// We must initiate an unsubscribe request with a verify_token.
// Don't allow outsiders to unsubscribe us.
- if($hub_mode === 'unsubscribe') {
- if(! strlen($hub_verify)) {
+ if ($hub_mode === 'unsubscribe') {
+ if (! strlen($hub_verify)) {
logger('pubsub: bogus unsubscribe');
hub_return(false, '');
}
logger('pubsub: user-agent: ' . $_SERVER['HTTP_USER_AGENT'] );
logger('pubsub: data: ' . $xml, LOGGER_DATA);
-// if(! stristr($xml,'<?xml')) {
+// if (! stristr($xml,'<?xml')) {
// logger('pubsub_post: bad xml');
// hub_post_return();
// }
// 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).
- if($r[0]['network'] === NETWORK_DIASPORA)
+ if ($r[0]['network'] === NETWORK_DIASPORA) {
hub_post_return();
+ }
$feedhub = '';
// [hub_secret] => af11...
// [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_callback = post_var('hub_callback');
$hub_verify = post_var('hub_verify');
$contact = $r[0];
// 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 . ' != ' .
$contact['poll']);
http_status_exit(404);
$search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
- if(! strlen($search))
+ if (! strlen($search)) {
killme();
+ }
- if($search)
+ if ($search) {
$search = dbesc($search);
+ }
$results = array();
);
if (dbm::is_result($r)) {
-
- foreach($r as $rr)
+ foreach ($r as $rr) {
$results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
+ }
}
$sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
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']);
+ }
}
echo json_encode((object) $results);
$enabled = intval(get_config('system','diaspora_enabled'));
- if(! $enabled) {
+ if (! $enabled) {
logger('mod-diaspora: disabled');
http_status_exit(500);
}
$public = false;
- if(($a->argc == 2) && ($a->argv[1] === 'public')) {
+ if (($a->argc == 2) && ($a->argv[1] === 'public')) {
$public = true;
}
else {
- if($a->argc != 3 || $a->argv[1] !== 'users')
+ if ($a->argc != 3 || $a->argv[1] !== 'users')
http_status_exit(500);
$guid = $a->argv[2];
logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
- if(! $xml)
+ if (! $xml)
http_status_exit(500);
logger('mod-diaspora: message is okay', LOGGER_DEBUG);
logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
- if(! is_array($msg))
+ if (! is_array($msg))
http_status_exit(500);
logger('mod-diaspora: dispatching', LOGGER_DEBUG);
$ret = 0;
- if($public) {
+ if ($public) {
Diaspora::dispatch_public($msg);
} else {
$ret = Diaspora::dispatch($importer,$msg);
// 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);
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
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());
$cid = $r[0]['id'];
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());
}
$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'];
$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'];
$dfrn_id = '0:' . $orig_id;
}
require_once('include/bbcode.php');
require_once('include/user.php');
-if(! function_exists('register_post')) {
+if (! function_exists('register_post')) {
function register_post(App $a) {
global $lang;
call_hooks('register_post', $arr);
$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");
- if($r && $r[0]['total'] >= $max_dailies) {
+ if ($r && $r[0]['total'] >= $max_dailies) {
return;
}
}
default:
case REGISTER_CLOSED:
- if((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
+ if ((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
notice( t('Permission denied.') . EOL );
return;
}
$result = create_user($arr);
- if(! $result['success']) {
+ if (! $result['success']) {
notice($result['message']);
return;
}
$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'];
proc_run(PRIORITY_LOW, "include/directory.php", $url);
}
$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));
set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
}
$user['username'],
$result['password']);
- if($res) {
+ if ($res) {
info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
goaway(z_root());
} else {
goaway(z_root());
}
}
- elseif($a->config['register_policy'] == REGISTER_APPROVE) {
- if(! strlen($a->config['admin_email'])) {
+ elseif ($a->config['register_policy'] == REGISTER_APPROVE) {
+ if (! strlen($a->config['admin_email'])) {
notice( t('Your registration can not be processed.') . EOL);
goaway(z_root());
}
);
// invite system
- if($using_invites && $invite_id) {
+ if ($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
}
-if(! function_exists('register_content')) {
+if (! function_exists('register_content')) {
function register_content(App $a) {
// logged in users can register others (people/pages/groups)
$block = get_config('system','block_extended_register');
- if(local_user() && ($block)) {
+ if (local_user() && ($block)) {
notice("Permission denied." . EOL);
return;
}
- if((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
+ if ((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
notice("Permission denied." . EOL);
return;
}
$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");
- if($r && $r[0]['total'] >= $max_dailies) {
+ if ($r && $r[0]['total'] >= $max_dailies) {
logger('max daily registrations exceeded.');
notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
return;
}
}
- if(x($_SESSION,'theme'))
+ if (x($_SESSION,'theme'))
unset($_SESSION['theme']);
- if(x($_SESSION,'mobile-theme'))
+ if (x($_SESSION,'mobile-theme'))
unset($_SESSION['mobile-theme']);
$noid = get_config('system','no_openid');
- if($noid) {
+ if ($noid) {
$oidhtml = '';
$fillwith = '';
$fillext = '';
$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" />';
}
else {
pop_lang();
- if($res) {
+ if ($res) {
info( t('Account approved.') . EOL );
return true;
}
dbesc($hash)
);
- if(! dbm::is_result($register))
+ if (! dbm::is_result($register)) {
return false;
+ }
$user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($register[0]['uid'])
function salmon_return($val) {
- if($val >= 400)
+ if ($val >= 400)
$err = 'Error';
- if($val >= 200 && $val < 300)
+ if ($val >= 200 && $val < 300)
$err = 'OK';
logger('mod-salmon returns ' . $val);
// figure out where in the DOM tree our data is hiding
- if($dom->provenance->data)
+ if ($dom->provenance->data)
$base = $dom->provenance;
- elseif($dom->env->data)
+ elseif ($dom->env->data)
$base = $dom->env;
- elseif($dom->data)
+ elseif ($dom->data)
$base = $dom;
- if(! $base) {
+ if (! $base) {
logger('mod-salmon: unable to locate salmon data in xml ');
http_status_exit(400);
}
$author = ostatus::salmon_author($data,$importer);
$author_link = $author["author-link"];
- if(! $author_link) {
+ if (! $author_link) {
logger('mod-salmon: Could not retrieve author URI.');
http_status_exit(400);
}
$key = get_salmon_key($author_link,$keyhash);
- if(! $key) {
+ if (! $key) {
logger('mod-salmon: Could not retrieve author key.');
http_status_exit(400);
}
$verify = rsa_verify($compliant_format,$signature,$pubkey);
- if(! $verify) {
+ if (! $verify) {
logger('mod-salmon: message did not verify using protocol. Trying padding hack.');
$verify = rsa_verify($signed_data,$signature,$pubkey);
}
- if(! $verify) {
+ if (! $verify) {
logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.');
$verify = rsa_verify($stnet_signed_data,$signature,$pubkey);
}
- if(! $verify) {
+ if (! $verify) {
logger('mod-salmon: Message did not verify. Discarding.');
http_status_exit(400);
}
);
if (! dbm::is_result($r)) {
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);
- if($result['success']) {
+ if ($result['success']) {
$r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
AND `uid` = %d LIMIT 1",
dbesc(NETWORK_OSTATUS),
// Have we ignored the person?
// 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']) {
logger('mod-salmon: Ignoring this author.');
http_status_exit(202);
$o = '';
- if(! feature_enabled(local_user(),'savedsearch'))
+ if (! feature_enabled(local_user(),'savedsearch'))
return $o;
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
- if(local_user()) {
- if(x($_GET,'save') && $search) {
+ if (local_user()) {
+ if (x($_GET,'save') && $search) {
$r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
dbesc($search)
);
}
}
- if(x($_GET,'remove') && $search) {
+ if (x($_GET,'remove') && $search) {
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
dbesc($search)
function search_post(App $a) {
- if(x($_POST,'search'))
+ if (x($_POST,'search'))
$a->data['search'] = $_POST['search'];
}
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);
return;
}
- if(get_config('system','local_search') AND !local_user()) {
+ if (get_config('system','local_search') AND !local_user()) {
http_status_exit(403,
array("title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a search.")));
nav_set_selected('search');
- if(x($a->data,'search'))
+ if (x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$tag = false;
- if(x($_GET,'tag')) {
+ if (x($_GET,'tag')) {
$tag = true;
$search = ((x($_GET,'tag')) ? notags(trim(rawurldecode($_GET['tag']))) : '');
}
'$content' => search($search,'search-box','search',((local_user()) ? true : false), false)
));
- if(strpos($search,'#') === 0) {
+ if (strpos($search,'#') === 0) {
$tag = true;
$search = substr($search,1);
}
- if(strpos($search,'@') === 0) {
+ if (strpos($search,'@') === 0) {
return dirfind_content($a);
}
- if(strpos($search,'!') === 0) {
+ if (strpos($search,'!') === 0) {
return dirfind_content($a);
}
- if(x($_GET,'search-option'))
+ if (x($_GET,'search-option'))
switch($_GET['search-option']) {
case 'fulltext':
break;
break;
}
- if(! $search)
+ if (! $search)
return $o;
if (get_config('system','only_tag_search'))
// OR your own posts if you are a logged in member
// 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);
$r = q("SELECT %s
}
- if($tag)
+ if ($tag)
$title = sprintf( t('Items tagged with: %s'), $search);
else
$title = sprintf( t('Results for: %s'), $search);
),
);
- if(get_features()) {
+ if (get_features()) {
$tabs[] = array(
'label' => t('Additional features'),
'url' => 'settings/features',
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');
call_hooks('plugin_settings_post', $_POST);
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');
- 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', 'ostatus_autofriend', intval($_POST['snautofollow']));
set_pconfig(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
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_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : '');
$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;
- if(! $mail_disabled) {
+ if (! $mail_disabled) {
$failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user())
intval(local_user())
);
}
- if(strlen($mail_pass)) {
+ if (strlen($mail_pass)) {
$pass = '';
openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d",
$eacct = $r[0];
require_once('include/email.php');
$mb = construct_mailbox_name($eacct);
- if(strlen($eacct['server'])) {
+ if (strlen($eacct['server'])) {
$dcrpass = '';
openssl_private_decrypt(hex2bin($eacct['pass']),$dcrpass,$a->user['prvkey']);
$mbox = email_connect($mb,$mail_user,$dcrpass);
unset($dcrpass);
- if(! $mbox) {
+ if (! $mbox) {
$failed = true;
notice( t('Failed to connect with email account using the settings provided.') . EOL);
}
}
}
- if(! $failed)
+ if (! $failed)
info( t('Email settings updated.') . EOL);
}
}
if (($a->argc > 1) && ($a->argv[1] === 'features')) {
check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
- foreach($_POST as $k => $v) {
- if(strpos($k,'feature_') === 0) {
+ foreach ($_POST as $k => $v) {
+ if (strpos($k,'feature_') === 0) {
set_pconfig(local_user(),'feature',substr($k,8),((intval($v)) ? 1 : 0));
}
}
$itemspage_mobile_network = 100;
}
- if($mobile_theme !== '') {
+ if ($mobile_theme !== '') {
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
}
$name_change = false;
- if($username != $a->user['username']) {
+ if ($username != $a->user['username']) {
$name_change = true;
if (strlen($username) > 40) {
$err .= t(' Please use a shorter name.');
$err .= t(' Not valid email.');
}
// 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')) {
$adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
if (in_array(strtolower($email), $adminlist)) {
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');
$r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
}
$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;
- if(! $mail_disabled) {
+ if (! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
local_user()
);
}
$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" />';
} else {
$profile_in_dir = replace_macros($opt_tpl,array(
function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if((! $post_id) || (! local_user()))
+ if ((! $post_id) || (! local_user()))
killme();
$r = q("SELECT item.*, contact.network FROM `item`
intval($post_id),
intval(local_user())
);
- if(! dbm::is_result($r) || ($r[0]['private'] == 1))
+ if (! dbm::is_result($r) || ($r[0]['private'] == 1))
killme();
if (strpos($r[0]['body'], "[/share]") !== false) {
if ($a->argv[1]==="json"){
$tmp = Smilies::get_list();
$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]);
}
json_return_and_die($results);
- }
- else {
+ } else {
return Smilies::replace('',true);
}
}
function subthread_content(App $a) {
- if(! local_user() && ! remote_user()) {
+ if (! local_user() && ! remote_user()) {
return;
}
dbesc($item_id)
);
- if(! $item_id || (! dbm::is_result($r))) {
+ if (! $item_id || (! dbm::is_result($r))) {
logger('subthread: no item ' . $item_id);
return;
}
$owner_uid = $item['uid'];
- if(! can_write_wall($a,$owner_uid)) {
+ if (! can_write_wall($a,$owner_uid)) {
return;
}
$remote_owner = null;
- if(! $item['wall']) {
+ if (! $item['wall']) {
// 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",
intval($item['contact-id']),
function tagger_content(App $a) {
- if(! local_user() && ! remote_user()) {
+ if (! local_user() && ! remote_user()) {
return;
}
// no commas allowed
$term = str_replace(array(',',' '),array('','_'),$term);
- if(! $term)
+ if (! $term)
return;
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
dbesc($item_id)
);
- if(! $item_id || (! dbm::is_result($r))) {
+ if (! $item_id || (! dbm::is_result($r))) {
logger('tagger: no item ' . $item_id);
return;
}
$blocktags = $r[0]['blocktags'];
}
- if(local_user() != $owner_uid)
+ if (local_user() != $owner_uid)
return;
$r = q("select * from contact where self = 1 and uid = %d limit 1",
// );
- if(! $item['visible']) {
+ if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']),
intval($owner_uid)
intval($item['id']),
dbesc($term)
);
- if((! $blocktags) && $t[0]['tcount']==0 ) {
+ if ((! $blocktags) && $t[0]['tcount']==0 ) {
/*q("update item set tag = '%s' where id = %d",
dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($item['id'])
intval($r[0]['id']),
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)",
- intval($r[0]['id']),
- $term_objtype,
- TERM_HASHTAG,
- dbesc($term),
- dbesc(App::get_baseurl() . '/search?tag=' . $term),
- intval($owner_uid)
- );
+ intval($r[0]['id']),
+ $term_objtype,
+ TERM_HASHTAG,
+ dbesc($term),
+ dbesc(App::get_baseurl() . '/search?tag=' . $term),
+ intval($owner_uid)
+ );
}
- /*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",
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($r[0]['id'])
$result = array();
$r = q($query);
if (dbm::is_result($r)) {
- foreach($r as $rr){
+ foreach ($r as $rr){
$p = array();
- foreach($rr as $k => $v) {
+ foreach ($rr as $k => $v) {
$p[$k] = $v;
}
$result[] = $p;
$result = array();
$r = q($query);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
- foreach($rr as $k => $v) {
+ foreach ($r as $rr) {
+ foreach ($rr as $k => $v) {
$result[$k] = $v;
}
}
intval(500)
);
/*if (dbm::is_result($r)) {
- foreach($r as $rr)
- foreach($rr as $k => $v)
+ foreach ($r as $rr)
+ foreach ($rr as $k => $v)
$item[][$k] = $v;
}*/
function videos_init(App $a) {
- if($a->argc > 1)
+ if ($a->argc > 1)
auto_redir($a, $a->argv[1]);
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
$o = '';
- if($a->argc > 1) {
+ if ($a->argc > 1) {
$nick = $a->argv[1];
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick)
);
- if(! count($user))
+ if (!dbm::is_result($user)) {
return;
+ }
$a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid'];
intval($a->data['user']['uid'])
);
- if(count($albums)) {
+ if (count($albums)) {
$a->data['albums'] = $albums;
$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 .= '<h3>' . '<a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
$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
// 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;
$o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
}
$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>';
}*/
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $vcard_widget;
// 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);
return;
}
require_once('include/security.php');
require_once('include/conversation.php');
- if(! x($a->data,'user')) {
+ if (! x($a->data,'user')) {
notice( t('No videos selected') . EOL );
return;
}
// Parse arguments
//
- if($a->argc > 3) {
+ if ($a->argc > 3) {
$datatype = $a->argv[2];
$datum = $a->argv[3];
}
- elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
+ elseif (($a->argc > 2) && ($a->argv[2] === 'upload'))
$datatype = 'upload';
else
$datatype = 'summary';
- if($a->argc > 4)
+ if ($a->argc > 4)
$cmd = $a->argv[4];
else
$cmd = 'view';
$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;
else {
- if($community_page && remote_user()) {
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $v) {
- if($v['uid'] == $owner_uid) {
+ if ($community_page && remote_user()) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $v) {
+ if ($v['uid'] == $owner_uid) {
$contact_id = $v['cid'];
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",
intval($contact_id),
// 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;
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $v) {
- if($v['uid'] == $owner_uid) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $v) {
+ if ($v['uid'] == $owner_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if($contact_id) {
+ if ($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",
intval($contact_id),
}
}
- if(! $remote_contact) {
- if(local_user()) {
+ if (! $remote_contact) {
+ if (local_user()) {
$contact_id = $_SESSION['cid'];
$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);
return;
}
//
- if($datatype === 'upload') {
+ if ($datatype === 'upload') {
return; // no uploading for now
// DELETED -- look at mod/photos.php if you want to implement
}
- if($datatype === 'album') {
+ if ($datatype === 'album') {
return; // no albums for now
}
- if($datatype === 'video') {
+ if ($datatype === 'video') {
return; // no single video view for now
if ($a->argc == 4){
$theme = $a->argv[2];
$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");
+ }
}
killme();
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;
}
nav_set_selected('home');
- if($a->argc > 1) {
+ if ($a->argc > 1) {
$nick = $a->argv[1];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick)
function viewcontacts_content(App $a) {
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);
return;
}
// tabs
$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);
return $o;
}
$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'];
- else
+ } else {
$url = zrl($url);
+ }
$contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if(! $item_id) {
+ if (! $item_id) {
$a->error = 404;
notice( t('Item not found.') . EOL);
return;
);
if (dbm::is_result($r))
- if(is_ajax()) {
+ if (is_ajax()) {
echo str_replace("\n",'<br />',$r[0]['body']);
killme();
} else {
$r_json = (x($_GET,'response') && $_GET['response']=='json');
- if($a->argc > 1) {
+ if ($a->argc > 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",
dbesc($nick)
$page_owner_nick = $r[0]['nickname'];
$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;
else {
- if($community_page && remote_user()) {
+ if ($community_page && remote_user()) {
$contact_id = 0;
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $v) {
- if($v['uid'] == $page_owner_uid) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $v) {
+ if ($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid'];
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",
intval($contact_id),
}
}
}
- if(! $can_post) {
+ if (! $can_post) {
if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.')));
killme();
killme();
}
- if(! x($_FILES,'userfile')) {
+ if (! x($_FILES,'userfile')) {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
}
* 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?'));
if ($r_json) {
echo json_encode(array('error'=>$msg));
killme();
}
- if(($maxfilesize) && ($filesize > $maxfilesize)) {
+ if (($maxfilesize) && ($filesize > $maxfilesize)) {
$msg = sprintf(t('File exceeds size limit of %s'), formatBytes($maxfilesize));
if ($r_json) {
echo json_encode(array('error'=>$msg));
@unlink($src);
- if(! $r) {
+ if (! $r) {
$msg = t('File upload failed.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
$r_json = (x($_GET,'response') && $_GET['response']=='json');
- if($a->argc > 1) {
- if(! x($_FILES,'media')) {
+ if ($a->argc > 1) {
+ if (! x($_FILES,'media')) {
$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",
dbesc($nick)
$page_owner_nick = $r[0]['nickname'];
$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;
else {
- if($community_page && remote_user()) {
+ if ($community_page && remote_user()) {
$contact_id = 0;
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $v) {
- if($v['uid'] == $page_owner_uid) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $v) {
+ if ($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid'];
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",
intval($contact_id),
}
- if(! $can_post) {
+ if (! $can_post) {
if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.')));
killme();
killme();
}
- if(! x($_FILES,'userfile') && ! x($_FILES,'media')){
+ if (! x($_FILES,'userfile') && ! x($_FILES,'media')){
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
}
}
$src = "";
- if(x($_FILES,'userfile')) {
+ if (x($_FILES,'userfile')) {
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
}
- elseif(x($_FILES,'media')) {
+ elseif (x($_FILES,'media')) {
if (is_array($_FILES['media']['tmp_name']))
$src = $_FILES['media']['tmp_name'][0];
else
$maximagesize = get_config('system','maximagesize');
- if(($maximagesize) && ($filesize > $maximagesize)) {
+ if (($maximagesize) && ($filesize > $maximagesize)) {
$msg = sprintf( t('Image exceeds size limit of %s'), formatBytes($maximagesize));
if ($r_json) {
echo json_encode(array('error'=>$msg));
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
- if(! $ph->is_valid()) {
+ if (! $ph->is_valid()) {
$msg = t('Unable to process image.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
@unlink($src);
$max_length = get_config('system','max_image_length');
- if(! $max_length)
+ if (! $max_length)
$max_length = MAX_IMAGE_LENGTH;
- if($max_length > 0) {
+ if ($max_length > 0) {
$ph->scaleImage($max_length);
logger("File upload: Scaling picture to new size ".$max_length, LOGGER_DEBUG);
}
function wallmessage_post(App $a) {
$replyto = get_my_url();
- if(! $replyto) {
+ if (! $replyto) {
notice( t('Permission denied.') . EOL);
return;
}
$body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
$recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
- if((! $recipient) || (! $body)) {
+ if ((! $recipient) || (! $body)) {
return;
}
$user = $r[0];
- if(! intval($user['unkmail'])) {
+ if (! intval($user['unkmail'])) {
notice( t('Permission denied.') . EOL);
return;
}
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'])));
return;
}
function wallmessage_content(App $a) {
- if(! get_my_url()) {
+ if (! get_my_url()) {
notice( t('Permission denied.') . EOL);
return;
}
$recipient = (($a->argc > 1) ? $a->argv[1] : '');
- if(! $recipient) {
+ if (! $recipient) {
notice( t('No recipient.') . EOL);
return;
}
$user = $r[0];
- if(! intval($user['unkmail'])) {
+ if (! intval($user['unkmail'])) {
notice( t('Permission denied.') . EOL);
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'])
);
- 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'])));
return;
}
$o .= '<br /><br />';
- if(x($_GET,'addr')) {
+ if (x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = Probe::lrdd($addr);
$o .= '<pre>';
$uri = urldecode(notags(trim($_GET['uri'])));
- if(substr($uri,0,4) === 'http') {
+ if (substr($uri,0,4) === 'http') {
$acct = false;
$name = basename($uri);
} else {
$acct = true;
$local = str_replace('acct:', '', $uri);
- if(substr($local,0,2) == '//')
+ if (substr($local,0,2) == '//') {
$local = substr($local,2);
+ }
$name = substr($local,0,strpos($local,'@'));
}