diff --git a/mod/_well_known.php b/mod/_well_known.php index 622d7fd93f..9c862af71f 100644 --- a/mod/_well_known.php +++ b/mod/_well_known.php @@ -54,7 +54,7 @@ function wk_social_relay(App $a) { } $taglist = array(); - foreach($tags AS $tag) { + foreach ($tags AS $tag) { $taglist[] = $tag; } diff --git a/mod/acctlink.php b/mod/acctlink.php index 892b59655f..715f251fa3 100644 --- a/mod/acctlink.php +++ b/mod/acctlink.php @@ -4,11 +4,11 @@ require_once('include/Scrape.php'); function acctlink_init(App $a) { - if(x($_GET,'addr')) { + if (x($_GET,'addr')) { $addr = trim($_GET['addr']); $res = probe_url($addr); //logger('acctlink: ' . print_r($res,true)); - if($res['url']) { + if ($res['url']) { goaway($res['url']); killme(); } diff --git a/mod/admin.php b/mod/admin.php index b1bc8de5f2..8227252c60 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -861,6 +861,7 @@ function admin_page_site(App $a) { foreach ($files as $file) { if (intval(file_exists($file.'/unsupported'))) continue; + } $f = basename($file); @@ -1274,7 +1275,7 @@ function admin_page_users(App $a) { if ($a->argc>2) { $uid = $a->argv[3]; $user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid)); - if (count($user) == 0) { + if (!dbm::is_result($user)) { notice('User not found'.EOL); goaway('admin/users'); return ''; // NOTREACHED @@ -1609,7 +1610,7 @@ function admin_page_plugins(App $a) { * @param int $result */ function toggle_theme(&$themes,$th,&$result) { - for($x = 0; $x < count($themes); $x ++) { + for ($x = 0; $x < count($themes); $x ++) { if ($themes[$x]['name'] === $th) { if ($themes[$x]['allowed']) { $themes[$x]['allowed'] = 0; @@ -1629,7 +1630,7 @@ function toggle_theme(&$themes,$th,&$result) { * @return int */ function theme_status($themes,$th) { - for($x = 0; $x < count($themes); $x ++) { + for ($x = 0; $x < count($themes); $x ++) { if ($themes[$x]['name'] === $th) { if ($themes[$x]['allowed']) { return 1; @@ -1761,7 +1762,7 @@ function admin_page_themes(App $a) { $status="off"; $action= t("Enable"); } - $readme = Null; + $readme = null; if (is_file("view/theme/$theme/README.md")) { $readme = file_get_contents("view/theme/$theme/README.md"); $readme = Markdown($readme); diff --git a/mod/allfriends.php b/mod/allfriends.php index f51070bbe8..893cf6a5fe 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -37,8 +37,9 @@ function allfriends_content(App $a) { $total = count_all_friends(local_user(), $cid); - if(count($total)) + if (count($total)) { $a->set_pager_total($total); + } $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); diff --git a/mod/api.php b/mod/api.php index 3916636cfd..e44fcc493c 100644 --- a/mod/api.php +++ b/mod/api.php @@ -27,7 +27,7 @@ function api_post(App $a) { return; } - if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) { + if (count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/apps.php b/mod/apps.php index 199ce0f918..fea5483679 100644 --- a/mod/apps.php +++ b/mod/apps.php @@ -1,25 +1,23 @@ 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, )); - - - } diff --git a/mod/attach.php b/mod/attach.php index dd7154dfe1..80a2222bc9 100644 --- a/mod/attach.php +++ b/mod/attach.php @@ -4,7 +4,7 @@ require_once('include/security.php'); function attach_init(App $a) { - if($a->argc != 2) { + if ($a->argc != 2) { notice( t('Item not available.') . EOL); return; } @@ -38,7 +38,7 @@ function attach_init(App $a) { // error in Chrome for filenames with commas in them header('Content-type: ' . $r[0]['filetype']); header('Content-length: ' . $r[0]['filesize']); - if(isset($_GET['attachment']) && $_GET['attachment'] === '0') + if (isset($_GET['attachment']) && $_GET['attachment'] === '0') header('Content-disposition: filename="' . $r[0]['filename'] . '"'); else header('Content-disposition: attachment; filename="' . $r[0]['filename'] . '"'); diff --git a/mod/babel.php b/mod/babel.php index e8ea11c94e..f65920d789 100644 --- a/mod/babel.php +++ b/mod/babel.php @@ -25,7 +25,7 @@ function babel_content(App $a) { $o .= '

'; - if(x($_REQUEST,'text')) { + if (x($_REQUEST,'text')) { $text = trim($_REQUEST['text']); $o .= "

" . t("Source input: ") . "

" . EOL. EOL; @@ -63,7 +63,7 @@ function babel_content(App $a) { } - if(x($_REQUEST,'d2bbtext')) { + if (x($_REQUEST,'d2bbtext')) { $d2bbtext = trim($_REQUEST['d2bbtext']); $o .= "

" . t("Source input (Diaspora format): ") . "

" . EOL. EOL; diff --git a/mod/cal.php b/mod/cal.php index f43a4e8a70..97a6a9d8bb 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -10,10 +10,10 @@ require_once('include/event.php'); require_once('include/redir.php'); function cal_init(App $a) { - if($a->argc > 1) + if ($a->argc > 1) auto_redir($a, $a->argv[1]); - if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { return; } @@ -21,13 +21,13 @@ function cal_init(App $a) { $o = ''; - if($a->argc > 1) { + if ($a->argc > 1) { $nick = $a->argv[1]; $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", dbesc($nick) ); - if(! count($user)) + if (! count($user)) return; $a->data['user'] = $user[0]; @@ -54,7 +54,7 @@ function cal_init(App $a) { $cal_widget = widget_events(); - if(! x($a->page,'aside')) + if (! x($a->page,'aside')) $a->page['aside'] = ''; $a->page['aside'] .= $vcard_widget; @@ -69,6 +69,7 @@ function cal_content(App $a) { // First day of the week (0 = Sunday) $firstDay = get_pconfig(local_user(),'system','first_day_of_week'); + /// @TODO Convert all these to with curly braces if ($firstDay === false) $firstDay=0; // get the translation strings for the callendar @@ -94,8 +95,9 @@ function cal_content(App $a) { $m = 0; $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); - if($a->argc == 4) { - if($a->argv[2] == 'export') { + /// @TODO Convert to one if() statement + if ($a->argc == 4) { + if ($a->argv[2] == 'export') { $mode = 'export'; $format = $a->argv[3]; } @@ -112,15 +114,15 @@ function cal_content(App $a) { $owner_uid = $a->data['user']['uid']; $nick = $a->data['user']['nickname']; - if(is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $v) { - if($v['uid'] == $a->profile['profile_uid']) { + if (is_array($_SESSION['remote'])) { + foreach ($_SESSION['remote'] as $v) { + if ($v['uid'] == $a->profile['profile_uid']) { $contact_id = $v['cid']; break; } } } - if($contact_id) { + if ($contact_id) { $groups = init_groups_visitor($contact_id); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), @@ -131,15 +133,15 @@ function cal_content(App $a) { $remote_contact = true; } } - if(! $remote_contact) { - if(local_user()) { + if (! $remote_contact) { + if (local_user()) { $contact_id = $_SESSION['cid']; $contact = $a->contact; } } $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false); - if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) { + if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) { notice( t('Access to this profile has been restricted.') . EOL); return; } @@ -153,33 +155,33 @@ function cal_content(App $a) { $tabs .= profile_tabs($a,false, $a->data['user']['nickname']); // The view mode part is similiar to /mod/events.php - if($mode == 'view') { + if ($mode == 'view') { $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); - if(! $y) + if (! $y) $y = intval($thisyear); - if(! $m) + if (! $m) $m = intval($thismonth); // Put some limits on dates. The PHP date functions don't seem to do so well before 1900. // An upper limit was chosen to keep search engines from exploring links millions of years in the future. - if($y < 1901) + if ($y < 1901) $y = 1900; - if($y > 2099) + if ($y > 2099) $y = 2100; $nextyear = $y; $nextmonth = $m + 1; - if($nextmonth > 12) { + if ($nextmonth > 12) { $nextmonth = 1; $nextyear ++; } $prevyear = $y; - if($m > 1) + if ($m > 1) $prevmonth = $m - 1; else { $prevmonth = 12; @@ -235,9 +237,10 @@ function cal_content(App $a) { $events=array(); // transform the event in a usable array - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $r = sort_by_date($r); $events = process_events($r); + } if ($a->argv[2] === 'json'){ echo json_encode($events); killme(); @@ -255,9 +258,9 @@ function cal_content(App $a) { } // Get rid of dashes in key names, Smarty3 can't handle them - foreach($events as $key => $event) { + foreach ($events as $key => $event) { $event_item = array(); - foreach($event['item'] as $k => $v) { + foreach ($event['item'] as $k => $v) { $k = str_replace('-','_',$k); $event_item[$k] = $v; } @@ -287,15 +290,15 @@ function cal_content(App $a) { return $o; } - if($mode == 'export') { - if(! (intval($owner_uid))) { + if ($mode == 'export') { + if (! (intval($owner_uid))) { notice( t('User not found')); return; } // Test permissions // Respect the export feature setting for all other /cal pages if it's not the own profile - if( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) { + if ( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) { notice( t('Permission denied.') . EOL); goaway('cal/' . $nick); } @@ -304,7 +307,7 @@ function cal_content(App $a) { $evexport = event_export($owner_uid, $format); if (!$evexport["success"]) { - if($evexport["content"]) + if ($evexport["content"]) notice( t('This calendar format is not supported') ); else notice( t('No exportable data found')); diff --git a/mod/common.php b/mod/common.php index 5a40663f9e..d18389559d 100644 --- a/mod/common.php +++ b/mod/common.php @@ -57,20 +57,21 @@ function common_content(App $a) { return; } - if(! $cid) { - if(get_my_url()) { + if (! $cid) { + if (get_my_url()) { $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link(get_my_url())), intval($profile_uid) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $cid = $r[0]['id']; - else { + } else { $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", dbesc(normalise_link(get_my_url())) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $zcid = $r[0]['id']; + } } } } diff --git a/mod/community.php b/mod/community.php index 1743304010..2f48c985c0 100644 --- a/mod/community.php +++ b/mod/community.php @@ -18,12 +18,12 @@ function community_content(App $a, $update = 0) { if ($update) return; - if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { notice( t('Public access denied.') . EOL); return; } - if(get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) { + if (get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) { notice( t('Not available.') . EOL); return; } @@ -34,11 +34,11 @@ function community_content(App $a, $update = 0) { $o .= '

' . t('Community') . '

'; - if(! $update) { + if (! $update) { nav_set_selected('community'); } - if(x($a->data,'search')) + if (x($a->data,'search')) $search = notags(trim($a->data['search'])); else $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); @@ -79,14 +79,15 @@ function community_content(App $a, $update = 0) { $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']); } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0)); - } else + } else { $s = $r; + } // we behave the same in message lists as the search module $o .= conversation($a, $s, 'community', $update); - $o .= alt_pager($a, count($r)); + $o .= alt_pager($a, count($r)); return $o; } diff --git a/mod/contactgroup.php b/mod/contactgroup.php index 5c4cd79868..b2ddc8735c 100644 --- a/mod/contactgroup.php +++ b/mod/contactgroup.php @@ -9,16 +9,17 @@ function contactgroup_content(App $a) { killme(); } - if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { + if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($a->argv[2]), intval(local_user()) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $change = intval($a->argv[2]); + } } - if(($a->argc > 1) && (intval($a->argv[1]))) { + if (($a->argc > 1) && (intval($a->argv[1]))) { $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval($a->argv[1]), @@ -31,16 +32,16 @@ function contactgroup_content(App $a) { $group = $r[0]; $members = group_get_members($group['id']); $preselected = array(); - if(count($members)) { - foreach($members as $member) + if (count($members)) { + foreach ($members as $member) { $preselected[] = $member['id']; + } } - if($change) { - if(in_array($change,$preselected)) { + if ($change) { + if (in_array($change,$preselected)) { group_rmv_member(local_user(),$group['name'],$change); - } - else { + } else { group_add_member(local_user(),$group['name'],$change); } } diff --git a/mod/contacts.php b/mod/contacts.php index 70f4b73508..11a83f0a04 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -14,7 +14,7 @@ function contacts_init(App $a) { $contact_id = 0; - if((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) { + if ((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) { $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), @@ -107,7 +107,7 @@ function contacts_batch_actions(App $a) { ); $count_actions=0; - foreach($orig_records as $orig_record) { + foreach ($orig_records as $orig_record) { $contact_id = $orig_record['id']; if (x($_POST, 'contacts_batch_update')) { _contact_update($contact_id); @@ -281,7 +281,7 @@ function _contact_update_profile($contact_id) { $update["subhub"] = true; } - foreach($updatefields AS $field) + foreach ($updatefields AS $field) if (isset($data[$field]) AND ($data[$field] != "")) $update[$field] = $data[$field]; @@ -292,7 +292,7 @@ function _contact_update_profile($contact_id) { if (isset($data["priority"]) AND ($data["priority"] != 0)) $query = "`priority` = ".intval($data["priority"]); - foreach($update AS $key => $value) { + foreach ($update AS $key => $value) { if ($query != "") $query .= ", "; @@ -365,10 +365,10 @@ function contacts_content(App $a) { return; } - if($a->argc == 3) { + if ($a->argc == 3) { $contact_id = intval($a->argv[1]); - if(! $contact_id) + if (! $contact_id) return; $cmd = $a->argv[2]; @@ -378,25 +378,25 @@ function contacts_content(App $a) { intval(local_user()) ); - if(! count($orig_record)) { + if (! count($orig_record)) { notice( t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED } - if($cmd === 'update') { + if ($cmd === 'update') { _contact_update($contact_id); goaway('contacts/' . $contact_id); // NOTREACHED } - if($cmd === 'updateprofile') { + if ($cmd === 'updateprofile') { _contact_update_profile($contact_id); goaway('crepair/' . $contact_id); // NOTREACHED } - if($cmd === 'block') { + if ($cmd === 'block') { $r = _contact_block($contact_id, $orig_record[0]); if ($r) { $blocked = (($orig_record[0]['blocked']) ? 0 : 1); @@ -407,7 +407,7 @@ function contacts_content(App $a) { return; // NOTREACHED } - if($cmd === 'ignore') { + if ($cmd === 'ignore') { $r = _contact_ignore($contact_id, $orig_record[0]); if ($r) { $readonly = (($orig_record[0]['readonly']) ? 0 : 1); @@ -419,7 +419,7 @@ function contacts_content(App $a) { } - if($cmd === 'archive') { + if ($cmd === 'archive') { $r = _contact_archive($contact_id, $orig_record[0]); if ($r) { $archived = (($orig_record[0]['archive']) ? 0 : 1); @@ -430,16 +430,16 @@ function contacts_content(App $a) { return; // NOTREACHED } - if($cmd === 'drop') { + if ($cmd === 'drop') { // Check if we should do HTML-based delete confirmation - if($_REQUEST['confirm']) { + if ($_REQUEST['confirm']) { //
can't take arguments in its "action" parameter // so add any arguments as hidden inputs $query = explode_querystring($a->query_string); $inputs = array(); - foreach($query['args'] as $arg) { - if(strpos($arg, 'confirm=') === false) { + foreach ($query['args'] as $arg) { + if (strpos($arg, 'confirm=') === false) { $arg_parts = explode('=', $arg); $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); } @@ -488,7 +488,7 @@ function contacts_content(App $a) { $_SESSION['return_url'] = $a->query_string; - if((x($a->data,'contact')) && (is_array($a->data['contact']))) { + if ((x($a->data,'contact')) && (is_array($a->data['contact']))) { $contact_id = $a->data['contact']['id']; $contact = $a->data['contact']; @@ -522,12 +522,12 @@ function contacts_content(App $a) { break; } - if(!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) + if (!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) $relation_text = ""; $relation_text = sprintf($relation_text,htmlentities($contact['name'])); - if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) { + if (($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) { $url = "redir/{$contact['id']}"; $sparkle = ' class="sparkle" '; } @@ -542,7 +542,7 @@ function contacts_content(App $a) { ? t('Never') : datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A')); - if($contact['last-update'] !== '0000-00-00 00:00:00') + if ($contact['last-update'] !== '0000-00-00 00:00:00') $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29")); $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : ''); @@ -665,23 +665,23 @@ function contacts_content(App $a) { $ignored = false; $all = false; - if(($a->argc == 2) && ($a->argv[1] === 'all')) { + if (($a->argc == 2) && ($a->argv[1] === 'all')) { $sql_extra = ''; $all = true; } - elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) { + elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) { $sql_extra = " AND `blocked` = 1 "; $blocked = true; } - elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) { + elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) { $sql_extra = " AND `hidden` = 1 "; $hidden = true; } - elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) { + elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) { $sql_extra = " AND `readonly` = 1 "; $ignored = true; } - elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) { + elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) { $sql_extra = " AND `archive` = 1 "; $archived = true; } @@ -761,14 +761,14 @@ function contacts_content(App $a) { $searching = false; - if($search) { + if ($search) { $search_hdr = $search; $search_txt = dbesc(protect_sprintf(preg_quote($search))); $searching = true; } $sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : ""); - if($nets) + if ($nets) $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets)); $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : ''); @@ -929,7 +929,7 @@ function _contact_detail_for_template($rr){ default: break; } - if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) { + if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) { $url = "redir/{$rr['id']}"; $sparkle = ' class="sparkle" '; } @@ -971,7 +971,7 @@ function contact_actions($contact) { $contact_action = array(); // Provide friend suggestion only for Friendica contacts - if($contact['network'] === NETWORK_DFRN) { + if ($contact['network'] === NETWORK_DFRN) { $contact_actions['suggest'] = array( 'label' => t('Suggest friends'), 'url' => 'fsuggest/' . $contact['id'], @@ -981,7 +981,7 @@ function contact_actions($contact) { ); } - if($poll_enabled) { + if ($poll_enabled) { $contact_actions['update'] = array( 'label' => t('Update now'), 'url' => 'contacts/' . $contact['id'] . '/update', diff --git a/mod/content.php b/mod/content.php index 43f3fc2ba6..e7e8ca65e3 100644 --- a/mod/content.php +++ b/mod/content.php @@ -38,20 +38,18 @@ function content_content(App $a, $update = 0) { $nouveau = false; - if($a->argc > 1) { - for($x = 1; $x < $a->argc; $x ++) { - if(is_a_date_arg($a->argv[$x])) { - if($datequery) + if ($a->argc > 1) { + for ($x = 1; $x < $a->argc; $x ++) { + if (is_a_date_arg($a->argv[$x])) { + if ($datequery) { $datequery2 = escape_tags($a->argv[$x]); - else { + } else { $datequery = escape_tags($a->argv[$x]); $_GET['order'] = 'post'; } - } - elseif($a->argv[$x] === 'new') { + } elseif ($a->argv[$x] === 'new') { $nouveau = true; - } - elseif(intval($a->argv[$x])) { + } elseif (intval($a->argv[$x])) { $group = intval($a->argv[$x]); $def_acl = array('allow_gid' => '<' . $group . '>'); } @@ -81,12 +79,12 @@ function content_content(App $a, $update = 0) { - if(x($_GET,'search') || x($_GET,'file')) + if (x($_GET,'search') || x($_GET,'file')) $nouveau = true; - if($cid) + if ($cid) $def_acl = array('allow_cid' => '<' . intval($cid) . '>'); - if($nets) { + if ($nets) { $r = q("select id from contact where uid = %d and network = '%s' and self = 0", intval(local_user()), dbesc($nets) @@ -94,9 +92,9 @@ function content_content(App $a, $update = 0) { $str = ''; if (dbm::is_result($r)) - foreach($r as $rr) + foreach ($r as $rr) $str .= '<' . $rr['id'] . '>'; - if(strlen($str)) + if (strlen($str)) $def_acl = array('allow_cid' => $str); } @@ -108,13 +106,13 @@ function content_content(App $a, $update = 0) { $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) "; - if($group) { + if ($group) { $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']) ); if (! dbm::is_result($r)) { - if($update) + if ($update) killme(); notice( t('No such group') . EOL ); goaway(App::get_baseurl(true) . '/network'); @@ -122,7 +120,7 @@ function content_content(App $a, $update = 0) { } $contacts = expand_groups(array($group)); - if((is_array($contacts)) && count($contacts)) { + if ((is_array($contacts)) && count($contacts)) { $contact_str = implode(',',$contacts); } else { @@ -135,7 +133,7 @@ function content_content(App $a, $update = 0) { '$title' => sprintf( t('Group: %s'), $r[0]['name']) )) . $o; } - elseif($cid) { + elseif ($cid) { $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0 LIMIT 1", @@ -153,10 +151,10 @@ function content_content(App $a, $update = 0) { $sql_extra3 = ''; - if($datequery) { + if ($datequery) { $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); } - if($datequery2) { + if ($datequery2) { $sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); } @@ -164,10 +162,10 @@ function content_content(App $a, $update = 0) { $sql_extra3 = (($nouveau) ? '' : $sql_extra3); $sql_table = "`item`"; - if(x($_GET,'search')) { + if (x($_GET,'search')) { $search = escape_tags($_GET['search']); - if(strpos($search,'#') === 0) { + if (strpos($search,'#') === 0) { $tag = true; $search = substr($search,1); } @@ -175,7 +173,7 @@ function content_content(App $a, $update = 0) { if (get_config('system','only_tag_search')) $tag = true; - if($tag) { + if ($tag) { //$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ", // dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG)); //$sql_table = "`term` INNER JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` "; @@ -192,11 +190,11 @@ function content_content(App $a, $update = 0) { } } - if(strlen($file)) { + if (strlen($file)) { $sql_extra .= file_tag_file_query('item',unxmlify($file)); } - if($conv) { + if ($conv) { $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname']; $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace('www.','',$myurl); @@ -211,7 +209,7 @@ function content_content(App $a, $update = 0) { $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); - if($nouveau) { + if ($nouveau) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, @@ -234,7 +232,7 @@ function content_content(App $a, $update = 0) { // Normal conversation view - if($order === 'post') + if ($order === 'post') $ordering = "`created`"; else $ordering = "`commented`"; @@ -260,8 +258,8 @@ function content_content(App $a, $update = 0) { $parents_str = ''; if (dbm::is_result($r)) { - foreach($r as $rr) - if(! in_array($rr['item_id'],$parents_arr)) + foreach ($r as $rr) + if (! in_array($rr['item_id'],$parents_arr)) $parents_arr[] = $rr['item_id']; $parents_str = implode(', ', $parents_arr); @@ -328,32 +326,32 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { ); } - if($mode === 'network') { + if ($mode === 'network') { $profile_owner = local_user(); $page_writeable = true; } - if($mode === 'profile') { + if ($mode === 'profile') { $profile_owner = $a->profile['profile_uid']; $page_writeable = can_write_wall($a,$profile_owner); } - if($mode === 'notes') { + if ($mode === 'notes') { $profile_owner = local_user(); $page_writeable = true; } - if($mode === 'display') { + if ($mode === 'display') { $profile_owner = $a->profile['uid']; $page_writeable = can_write_wall($a,$profile_owner); } - if($mode === 'community') { + if ($mode === 'community') { $profile_owner = 0; $page_writeable = false; } - if($update) + if ($update) $return_url = $_SESSION['return_url']; else $return_url = $_SESSION['return_url'] = $a->query_string; @@ -378,9 +376,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $threads = array(); $threadsid = -1; - if($items && count($items)) { + if ($items && count($items)) { - if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { + if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display @@ -388,7 +386,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { //$tpl = get_markup_template('search_item.tpl'); $tpl = 'search_item.tpl'; - foreach($items as $item) { + foreach ($items as $item) { $threadsid++; $comment = ''; @@ -397,8 +395,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $owner_name = ''; $sparkle = ''; - if($mode === 'search' || $mode === 'community') { - if(((activity_match($item['verb'],ACTIVITY_LIKE)) + if ($mode === 'search' || $mode === 'community') { + if (((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)) || activity_match($item['verb'],ACTIVITY_ATTEND) || activity_match($item['verb'],ACTIVITY_ATTENDNO) @@ -411,20 +409,20 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $nickname = $a->user['nickname']; // prevent private email from leaking. - if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) + if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) continue; $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); - if($item['author-link'] && (! $item['author-name'])) + if ($item['author-link'] && (! $item['author-name'])) $profile_name = $item['author-link']; $sp = false; $profile_link = best_link_url($item,$sp); - if($profile_link === 'mailbox') + if ($profile_link === 'mailbox') $profile_link = ''; - if($sp) + if ($sp) $sparkle = ' sparkle'; else $profile_link = zrl($profile_link); @@ -442,7 +440,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); localize_item($item); - if($mode === 'network-new') + if ($mode === 'network-new') $dropping = true; else $dropping = false; @@ -463,7 +461,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $body = prepare_body($item,true); - if($a->theme['template_engine'] === 'internal') { + if ($a->theme['template_engine'] === 'internal') { $name_e = template_escape($profile_name); $title_e = template_escape($item['title']); $body_e = template_escape($body); @@ -534,20 +532,20 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { // Store the result in the $comments array $comments = array(); - foreach($items as $item) { - if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) { - if(! x($comments,$item['parent'])) + foreach ($items as $item) { + if ((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) { + if (! x($comments,$item['parent'])) $comments[$item['parent']] = 1; else $comments[$item['parent']] += 1; - } elseif(! x($comments,$item['parent'])) + } elseif (! x($comments,$item['parent'])) $comments[$item['parent']] = 0; // avoid notices later on } // map all the like/dislike/attendance activities for each parent item // Store these in the $alike and $dlike arrays - foreach($items as $item) { + foreach ($items as $item) { builtin_activity_puller($item, $conv_responses); } @@ -559,7 +557,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $blowhard_count = 0; - foreach($items as $item) { + foreach ($items as $item) { $comment = ''; $template = $tpl; @@ -569,7 +567,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { // We've already parsed out like/dislike for special treatment. We can ignore them now - if(((activity_match($item['verb'],ACTIVITY_LIKE)) + if (((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE) || activity_match($item['verb'],ACTIVITY_ATTEND) || activity_match($item['verb'],ACTIVITY_ATTENDNO) @@ -585,7 +583,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { // If a single author has more than 3 consecutive top-level posts, squash the remaining ones. // If there are more than two comments, squash all but the last 2. - if($toplevelpost) { + if ($toplevelpost) { $item_writeable = (($item['writable'] || $item['self']) ? true : false); @@ -603,7 +601,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { else { // prevent private email reply to public conversation from leaking. - if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) + if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) continue; $comments_seen ++; @@ -615,7 +613,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false); - if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { + if (($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { if (!$comments_collapsed){ $threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] ); @@ -626,7 +624,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $comment_firstcollapsed = true; } } - if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { + if (($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { $comment_lastcollapsed = true; } @@ -644,9 +642,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $osparkle = ''; - if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) { + if (($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) { - if($item['wall']) { + if ($item['wall']) { // On the network page, I am the owner. On the display page it will be the profile owner. // This will have been stored in $a->page_contact by our calling page. @@ -659,12 +657,12 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $commentww = 'ww'; } - if((! $item['wall']) && $item['owner-link']) { + if ((! $item['wall']) && $item['owner-link']) { $owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link'])); $alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$item['author-link'])); $owner_namematch = (($item['owner-name']) && $item['owner-name'] == $item['author-name']); - if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { + if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { // The author url doesn't match the owner (typically the contact) // and also doesn't match the contact alias. @@ -682,7 +680,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $template = $wallwall; $commentww = 'ww'; // If it is our contact, use a friendly redirect link - if((link_compare($item['owner-link'],$item['url'])) + if ((link_compare($item['owner-link'],$item['url'])) && ($item['network'] === NETWORK_DFRN)) { $owner_url = $redirect_url; $osparkle = ' sparkle'; @@ -696,8 +694,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $likebuttons = ''; $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); - if($page_writeable) { -/* if($toplevelpost) { */ + if ($page_writeable) { +/* if ($toplevelpost) { */ $likebuttons = array( 'like' => array( t("I like this \x28toggle\x29"), t("like")), 'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")), @@ -707,12 +705,12 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $qc = $qcomment = null; - if(in_array('qcomment',$a->plugins)) { + if (in_array('qcomment',$a->plugins)) { $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); $qcomment = (($qc) ? explode("\n",$qc) : null); } - if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { + if (($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { $comment = replace_macros($cmnt_tpl,array( '$return_path' => '', '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), @@ -751,7 +749,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $drop = ''; $dropping = false; - if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) + if ((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) $dropping = true; $drop = array( @@ -815,7 +813,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); - if($item['author-link'] && (! $item['author-name'])) + if ($item['author-link'] && (! $item['author-name'])) $profile_name = $item['author-link']; $sp = false; @@ -842,13 +840,14 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { // process action responses - e.g. like/dislike/attend/agree/whatever $response_verbs = array('like'); - if(feature_enabled($profile_owner,'dislike')) + if (feature_enabled($profile_owner,'dislike')) { $response_verbs[] = 'dislike'; - if($item['object-type'] === ACTIVITY_OBJ_EVENT) { + } + if ($item['object-type'] === ACTIVITY_OBJ_EVENT) { $response_verbs[] = 'attendyes'; $response_verbs[] = 'attendno'; $response_verbs[] = 'attendmaybe'; - if($page_writeable) { + if ($page_writeable) { $isevent = true; $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); } @@ -863,17 +862,20 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $indent = (($toplevelpost) ? '' : ' comment'); $shiny = ""; - if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) + if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) { $shiny = 'shiny'; + } // localize_item($item); $tags=array(); - foreach(explode(',',$item['tag']) as $tag){ + foreach (explode(',',$item['tag']) as $tag){ $tag = trim($tag); - if ($tag!="") $tags[] = bbcode($tag); + if ($tag!="") { + $tags[] = bbcode($tag); + } } // Build the HTML @@ -881,15 +883,14 @@ function render_content(App $a, $items, $mode, $update, $preview = false) { $body = prepare_body($item,true); //$tmp_item = replace_macros($template, - if($a->theme['template_engine'] === 'internal') { + if ($a->theme['template_engine'] === 'internal') { $body_e = template_escape($body); $text_e = strip_tags(template_escape($body)); $name_e = template_escape($profile_name); $title_e = template_escape($item['title']); $location_e = template_escape($location); $owner_name_e = template_escape($owner_name); - } - else { + } else { $body_e = $body; $text_e = strip_tags($body); $name_e = $profile_name; diff --git a/mod/crepair.php b/mod/crepair.php index ef7908661b..c5b4983d5b 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -9,7 +9,7 @@ function crepair_init(App $a) { $contact_id = 0; - if(($a->argc == 2) && intval($a->argv[1])) { + if (($a->argc == 2) && intval($a->argv[1])) { $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), @@ -109,7 +109,7 @@ function crepair_content(App $a) { $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if($cid) { + if ($cid) { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()) diff --git a/mod/delegate.php b/mod/delegate.php index 4212ec9b13..f8a0dcb599 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -23,16 +23,16 @@ function delegate_content(App $a) { $id = $a->argv[2]; - $r = q("select `nickname` from user where uid = %d limit 1", + $r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1", intval($id) ); if (dbm::is_result($r)) { - $r = q("select id from contact where uid = %d and nurl = '%s' limit 1", + $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1", intval(local_user()), dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname'])) ); if (dbm::is_result($r)) { - q("insert into manage ( uid, mid ) values ( %d , %d ) ", + q("INSERT INTO `manage` ( `uid`, `mid` ) VALUES ( %d , %d ) ", intval($a->argv[2]), intval(local_user()) ); @@ -64,34 +64,40 @@ function delegate_content(App $a) { dbesc($a->user['email']), dbesc($a->user['password']) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $full_managers = $r; + } $delegates = array(); // find everybody that currently has delegated management to this account/page - $r = q("select * from user where uid in ( select uid from manage where mid = %d ) ", + $r = q("SELECT * FROM `user` WHERE `uid` IN ( SELECT `uid` FROM `manage` WHERE `mid` = %d ) ", intval(local_user()) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $delegates = $r; + } $uids = array(); - if(count($full_managers)) - foreach($full_managers as $rr) + if (count($full_managers)) { + foreach ($full_managers as $rr) { $uids[] = $rr['uid']; + } + } - if(count($delegates)) - foreach($delegates as $rr) + if (count($delegates)) { + foreach ($delegates as $rr) { $uids[] = $rr['uid']; + } + } // find every contact who might be a candidate for delegation - $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s' - and contact.uid = %d and contact.self = 0 and network = '%s' ", + $r = q("SELECT `nurl` FROM `contact` WHERE SUBSTRING_INDEX(`contact`.`nurl`,'/',3) = '%s' + AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `network` = '%s' ", dbesc(normalise_link(App::get_baseurl())), intval(local_user()), dbesc(NETWORK_DFRN) @@ -116,12 +122,15 @@ function delegate_content(App $a) { // get user records for all potential page delegates who are not already delegates or managers - $r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )"); + $r = q("SELECT `uid`, `username`, `nickname` FROM `user` WHERE `nickname` IN ( $nicks )"); - if (dbm::is_result($r)) - foreach($r as $rr) - if(! in_array($rr['uid'],$uids)) + if (dbm::is_result($r)) { + foreach ($r as $rr) { + if (! in_array($rr['uid'],$uids)) { $potentials[] = $rr; + } + } + } require_once("mod/settings.php"); settings_init($a); diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 7e14610e33..9dd38df34b 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -24,7 +24,7 @@ require_once('include/Probe.php'); function dfrn_confirm_post(App $a, $handsfree = null) { - if(is_array($handsfree)) { + if (is_array($handsfree)) { /* * We were called directly from dfrn_request due to automatic friend acceptance. @@ -37,7 +37,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { } else { - if($a->argc > 1) + if ($a->argc > 1) $node = $a->argv[1]; } @@ -53,11 +53,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) { * */ - if(! x($_POST,'source_url')) { + if (! x($_POST,'source_url')) { $uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user()); - if(! $uid) { + if (! $uid) { notice( t('Permission denied.') . EOL ); return; } @@ -66,7 +66,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { intval($uid) ); - if(! $user) { + if (! $user) { notice( t('Profile not found.') . EOL ); return; } @@ -74,7 +74,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { // These data elements may come from either the friend request notification form or $handsfree array. - if(is_array($handsfree)) { + if (is_array($handsfree)) { logger('Confirm in handsfree mode'); $dfrn_id = $handsfree['dfrn_id']; $intro_id = $handsfree['intro_id']; @@ -99,11 +99,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) { * */ - if(strlen($dfrn_id)) + if (strlen($dfrn_id)) $cid = 0; logger('Confirming request for dfrn_id (issued) ' . $dfrn_id); - if($cid) + if ($cid) logger('Confirming follower with contact_id: ' . $cid); @@ -138,10 +138,10 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS); - if($contact['network']) + if ($contact['network']) $network = $contact['network']; - if($network === NETWORK_DFRN) { + if ($network === NETWORK_DFRN) { /* * @@ -199,19 +199,19 @@ function dfrn_confirm_post(App $a, $handsfree = null) { openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); $params['source_url'] = bin2hex($params['source_url']); - if($aes_allow && function_exists('openssl_encrypt')) { + if ($aes_allow && function_exists('openssl_encrypt')) { openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey); $params['aes_key'] = bin2hex($params['aes_key']); $params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key)); } $params['dfrn_version'] = DFRN_PROTOCOL_VERSION ; - if($duplex == 1) + if ($duplex == 1) $params['duplex'] = 1; - if($user[0]['page-flags'] == PAGE_COMMUNITY) + if ($user[0]['page-flags'] == PAGE_COMMUNITY) $params['page'] = 1; - if($user[0]['page-flags'] == PAGE_PRVGROUP) + if ($user[0]['page-flags'] == PAGE_PRVGROUP) $params['page'] = 2; logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA); @@ -234,7 +234,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $leading_junk = substr($res,0,strpos($res,' NOTIFY_CONFIRM, @@ -743,12 +742,12 @@ function dfrn_confirm_post(App $a, $handsfree = null) { // Send a new friend post if we are allowed to... - if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) { + if ($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) { $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval($local_uid) ); - if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) { + if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) { require_once('include/items.php'); @@ -756,7 +755,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { intval($local_uid) ); - if(count($self)) { + if (dbm::is_result($self)) { $arr = array(); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid); @@ -793,8 +792,9 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $arr['deny_gid'] = $user[0]['deny_gid']; $i = item_store($arr); - if($i) + if ($i) { proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); + } } } diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index d34c959f1f..63978386e1 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -28,12 +28,12 @@ function dfrn_notify_post(App $a) { $prv = (($page == 2) ? 1 : 0); $writable = (-1); - if($dfrn_version >= 2.21) { + if ($dfrn_version >= 2.21) { $writable = (($perm === 'rw') ? 1 : 0); } $direction = (-1); - if(strpos($dfrn_id,':') == 1) { + if (strpos($dfrn_id,':') == 1) { $direction = intval(substr($dfrn_id,0,1)); $dfrn_id = substr($dfrn_id,2); } @@ -100,14 +100,14 @@ function dfrn_notify_post(App $a) { logger("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DEBUG); - if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) { + if ((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) { q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d", intval(($writable == (-1)) ? $importer['writable'] : $writable), intval($forum), intval($prv), intval($importer['id']) ); - if($writable != (-1)) + if ($writable != (-1)) $importer['writable'] = $writable; $importer['forum'] = $page; } @@ -120,7 +120,7 @@ function dfrn_notify_post(App $a) { logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']); logger('dfrn_notify: data: ' . $data, LOGGER_DATA); - if($dissolve == 1) { + if ($dissolve == 1) { /* * Relationship is dissolved permanently @@ -137,7 +137,7 @@ function dfrn_notify_post(App $a) { // If we are setup as a soapbox we aren't accepting input from this person // This behaviour is deactivated since it really doesn't make sense to even disallow comments // The check if someone is a friend or simply a follower is done in a later place so it needn't to be done here - //if($importer['page-flags'] == PAGE_SOAPBOX) + //if ($importer['page-flags'] == PAGE_SOAPBOX) // xml_status(0); $rino = get_config('system','rino_encrypt'); @@ -147,7 +147,7 @@ function dfrn_notify_post(App $a) { logger("Local rino version: ". $rino, LOGGER_DEBUG); - if(strlen($key)) { + if (strlen($key)) { // if local rino is lower than remote rino, abort: should not happen! // but only for $remote_rino > 1, because old code did't send rino version @@ -160,8 +160,8 @@ function dfrn_notify_post(App $a) { logger('rino: md5 raw key: ' . md5($rawkey)); $final_key = ''; - if($dfrn_version >= 2.1) { - if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) { + if ($dfrn_version >= 2.1) { + if ((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) { openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']); } else { @@ -169,7 +169,7 @@ function dfrn_notify_post(App $a) { } } else { - if((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) { + if ((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) { openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']); } else { @@ -223,7 +223,7 @@ function dfrn_notify_post(App $a) { function dfrn_notify_content(App $a) { - if(x($_GET,'dfrn_id')) { + if (x($_GET,'dfrn_id')) { // initial communication from external contact, $direction is their direction. // If this is a duplex communication, ours will be the opposite. @@ -237,7 +237,7 @@ function dfrn_notify_content(App $a) { logger('dfrn_notify: new notification dfrn_id=' . $dfrn_id); $direction = (-1); - if(strpos($dfrn_id,':') == 1) { + if (strpos($dfrn_id,':') == 1) { $direction = intval(substr($dfrn_id,0,1)); $dfrn_id = substr($dfrn_id,2); } @@ -298,16 +298,15 @@ function dfrn_notify_content(App $a) { $pub_key = trim($r[0]['pubkey']); $dplx = intval($r[0]['duplex']); - if((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) { + if ((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) { openssl_private_encrypt($hash,$challenge,$prv_key); openssl_private_encrypt($id_str,$encrypted_id,$prv_key); - } - elseif(strlen($pub_key)) { + } elseif (strlen($pub_key)) { openssl_public_encrypt($hash,$challenge,$pub_key); openssl_public_encrypt($id_str,$encrypted_id,$pub_key); - } - else + } else { $status = 1; + } $challenge = bin2hex($challenge); $encrypted_id = bin2hex($encrypted_id); @@ -324,10 +323,9 @@ function dfrn_notify_content(App $a) { // if requested rino is higher than enabled local rino, reply with local rino if ($rino_remote < $rino) $rino = $rino_remote; - if((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) { + if ((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) { $perm = 'rw'; - } - else { + } else { $perm = 'r'; } diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 506f9f162f..13d443341d 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -20,20 +20,20 @@ function dfrn_poll_init(App $a) { $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]) ); @@ -51,7 +51,7 @@ function dfrn_poll_init(App $a) { killme(); } - if(($type === 'profile') && (! strlen($sec))) { + if (($type === 'profile') && (! strlen($sec))) { $sql_extra = ''; switch($direction) { @@ -85,13 +85,13 @@ function dfrn_poll_init(App $a) { 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']); @@ -100,7 +100,7 @@ function dfrn_poll_init(App $a) { $_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(); @@ -118,9 +118,9 @@ function dfrn_poll_init(App $a) { } - if($type === 'profile-check' && $dfrn_version < 2.2 ) { + if ($type === 'profile-check' && $dfrn_version < 2.2 ) { - if((strlen($challenge)) && (strlen($sec))) { + if ((strlen($challenge)) && (strlen($sec))) { q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", @@ -131,7 +131,7 @@ function dfrn_poll_init(App $a) { // NOTREACHED } $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", @@ -147,7 +147,7 @@ function dfrn_poll_init(App $a) { $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']); } @@ -158,10 +158,10 @@ function dfrn_poll_init(App $a) { $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'); @@ -213,9 +213,9 @@ function dfrn_poll_post(App $a) { $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'); @@ -228,7 +228,7 @@ function dfrn_poll_post(App $a) { // 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", @@ -244,7 +244,7 @@ function dfrn_poll_post(App $a) { $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']); } @@ -255,10 +255,10 @@ function dfrn_poll_post(App $a) { $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'); @@ -273,7 +273,7 @@ function dfrn_poll_post(App $a) { } $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); } @@ -329,7 +329,7 @@ function dfrn_poll_post(App $a) { $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) @@ -341,7 +341,7 @@ function dfrn_poll_post(App $a) { $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 = ''; } @@ -361,13 +361,13 @@ function dfrn_poll_post(App $a) { // 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) @@ -395,13 +395,13 @@ function dfrn_poll_content(App $a) { $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(); @@ -409,7 +409,7 @@ function dfrn_poll_content(App $a) { $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), @@ -422,7 +422,7 @@ function dfrn_poll_content(App $a) { $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)); @@ -456,7 +456,7 @@ function dfrn_poll_content(App $a) { $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']); } @@ -474,11 +474,11 @@ function dfrn_poll_content(App $a) { $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' @@ -517,7 +517,7 @@ function dfrn_poll_content(App $a) { logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); - if(strlen($s) && strstr($s,'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(); diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 52b5eb9f90..a11ea1d9e8 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -19,7 +19,7 @@ require_once('include/group.php'); function dfrn_request_init(App $a) { - if($a->argc > 1) + if ($a->argc > 1) $which = $a->argv[1]; profile_load($a,$which); @@ -44,13 +44,13 @@ function dfrn_request_init(App $a) { */ function dfrn_request_post(App $a) { - if(($a->argc != 2) || (! count($a->profile))) { + if (($a->argc != 2) || (! count($a->profile))) { logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); return; } - if(x($_POST, 'cancel')) { + if (x($_POST, 'cancel')) { goaway(z_root()); } @@ -63,13 +63,13 @@ function dfrn_request_post(App $a) { * */ - if((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) { + if ((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) { /* * Ensure this is a valid request */ - 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'])); @@ -80,7 +80,7 @@ function dfrn_request_post(App $a) { $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) @@ -92,7 +92,7 @@ function dfrn_request_post(App $a) { ); 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. @@ -105,7 +105,7 @@ function dfrn_request_post(App $a) { $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), @@ -187,7 +187,7 @@ function dfrn_request_post(App $a) { ); 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)) @@ -249,7 +249,7 @@ function dfrn_request_post(App $a) { * */ - if(! (is_array($a->profile) && count($a->profile))) { + if (! (is_array($a->profile) && count($a->profile))) { notice( t('Profile unavailable.') . EOL); return; } @@ -265,13 +265,13 @@ function dfrn_request_post(App $a) { $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) @@ -300,7 +300,7 @@ function dfrn_request_post(App $a) { ); 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']) ); @@ -325,7 +325,7 @@ function dfrn_request_post(App $a) { ); 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']) ); @@ -340,16 +340,16 @@ function dfrn_request_post(App $a) { $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; } @@ -365,10 +365,10 @@ function dfrn_request_post(App $a) { $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) @@ -470,18 +470,18 @@ function dfrn_request_post(App $a) { 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; } @@ -493,7 +493,7 @@ function dfrn_request_post(App $a) { $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", @@ -718,7 +718,7 @@ function dfrn_request_content(App $a) { 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 @@ -738,10 +738,10 @@ function dfrn_request_content(App $a) { $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, @@ -759,7 +759,7 @@ function dfrn_request_content(App $a) { )); } - if($auto_confirm) { + if ($auto_confirm) { require_once('mod/dfrn_confirm.php'); $handsfree = array( 'uid' => $r[0]['uid'], @@ -774,7 +774,7 @@ function dfrn_request_content(App $a) { } - if(! $auto_confirm) { + if (! $auto_confirm) { // If we are auto_confirming, this record will have already been nuked // in dfrn_confirm_post() @@ -794,8 +794,8 @@ function dfrn_request_content(App $a) { * 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; } diff --git a/mod/directory.php b/mod/directory.php index ba48bb3926..e49e718a5e 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -3,7 +3,7 @@ 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(); @@ -21,7 +21,7 @@ function directory_init(App $a) { function directory_post(App $a) { - if(x($_POST,'search')) + if (x($_POST,'search')) $a->data['search'] = $_POST['search']; } @@ -32,7 +32,7 @@ function directory_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()) || (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) { notice( t('Public access denied.') . EOL); return; @@ -41,18 +41,18 @@ function directory_content(App $a) { $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 @@ -110,28 +110,28 @@ function directory_content(App $a) { $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '
' : ''); $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 .= '
' . t('Age: ') . $years ; // } -// if(strlen($rr['gender'])) +// if (strlen($rr['gender'])) // $details .= '
' . 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) @@ -146,7 +146,7 @@ function directory_content(App $a) { $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 { @@ -185,8 +185,9 @@ function directory_content(App $a) { unset($profile); unset($location); - if(! $arr['entry']) + if (! $arr['entry']) { continue; + } $entries[] = $arr['entry']; diff --git a/mod/dirfind.php b/mod/dirfind.php index 1b19ad92c4..0e5f8a90d1 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -166,8 +166,9 @@ function dirfind_content(App $a, $prefix = "") { $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); } diff --git a/mod/editpost.php b/mod/editpost.php index f3746317a1..5dc5ec5086 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -51,7 +51,7 @@ function editpost_content(App $a) { $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'; @@ -64,13 +64,13 @@ function editpost_content(App $a) { $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; } } @@ -78,7 +78,7 @@ function editpost_content(App $a) { // 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 .= '
' . t("Post to Email") . '
'; diff --git a/mod/events.php b/mod/events.php index ac0c444cb5..2dd79a0296 100644 --- a/mod/events.php +++ b/mod/events.php @@ -105,9 +105,9 @@ function events_post(App $a) { 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(); } @@ -119,27 +119,27 @@ function events_post(App $a) { $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; } @@ -173,7 +173,7 @@ function events_post(App $a) { $datarray['created'] = $created; $datarray['edited'] = $edited; - if(intval($_REQUEST['preview'])) { + if (intval($_REQUEST['preview'])) { $html = format_event_html($datarray); echo $html; killme(); @@ -181,7 +181,7 @@ function events_post(App $a) { $item_id = event_store($datarray); - if(! $cid) + if (! $cid) proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id); goaway($_SESSION['return_url']); @@ -248,7 +248,7 @@ function events_content(App $a) { $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]); @@ -289,13 +289,13 @@ function events_content(App $a) { $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; @@ -371,9 +371,9 @@ function events_content(App $a) { } // Get rid of dashes in key names, Smarty3 can't handle them - foreach($events as $key => $event) { + foreach ($events as $key => $event) { $event_item = array(); - foreach($event['item'] as $k => $v) { + foreach ($event['item'] as $k => $v) { $k = str_replace('-','_',$k); $event_item[$k] = $v; } @@ -405,7 +405,7 @@ function events_content(App $a) { } - if($mode === 'edit' && $event_id) { + if ($mode === 'edit' && $event_id) { $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($event_id), intval(local_user()) @@ -415,19 +415,19 @@ function events_content(App $a) { } // 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" ' : ''); @@ -439,21 +439,24 @@ function events_content(App $a) { $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'); @@ -470,8 +473,9 @@ function events_content(App $a) { $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'); diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 9a0e9244c1..ae62ce9a32 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -66,10 +66,9 @@ function fbrowser_content(App $a) { $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']; } diff --git a/mod/filer.php b/mod/filer.php index 47c4aa5e4c..d2df7f24cd 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -16,7 +16,7 @@ function filer_content(App $a) { 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 { diff --git a/mod/friendica.php b/mod/friendica.php index f613dfd39c..f1f0a6a0f1 100644 --- a/mod/friendica.php +++ b/mod/friendica.php @@ -7,7 +7,7 @@ function friendica_init(App $a) { $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']!=''){ @@ -24,18 +24,18 @@ function friendica_init(App $a) { } $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); } @@ -80,22 +80,24 @@ function friendica_content(App $a) { $o .= '

'; $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 .= '

' . t('Installed plugins/addons/apps:') . '

'; $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; } } diff --git a/mod/fsuggest.php b/mod/fsuggest.php index b3d5439712..2cd91ea57c 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -29,7 +29,7 @@ function fsuggest_post(App $a) { $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()) @@ -80,8 +80,9 @@ function fsuggest_content(App $a) { return; } - if($a->argc != 2) + if ($a->argc != 2) { return; + } $contact_id = intval($a->argv[1]); diff --git a/mod/group.php b/mod/group.php index 2b332e401f..640fa7e60d 100644 --- a/mod/group.php +++ b/mod/group.php @@ -5,7 +5,7 @@ function validate_members(&$item) { } 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)); } @@ -20,7 +20,7 @@ function group_post(App $a) { 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'])); @@ -80,10 +80,12 @@ function group_content(App $a) { // 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'); @@ -99,8 +101,6 @@ function group_content(App $a) { '$gid' => 'new', '$form_security_token' => get_form_security_token("group_edit"), )); - - } if (($a->argc == 3) && ($a->argv[1] === 'drop')) { @@ -135,8 +135,9 @@ function group_content(App $a) { 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]))) { @@ -153,23 +154,23 @@ function group_content(App $a) { $group = $r[0]; $members = group_get_members($group['id']); $preselected = array(); - if(count($members)) { - foreach($members as $member) + if (count($members)) { + foreach ($members as $member) { $preselected[] = $member['id']; + } } - if($change) { - if(in_array($change,$preselected)) { + if ($change) { + if (in_array($change,$preselected)) { group_rmv_member(local_user(),$group['name'],$change); - } - else { + } else { group_add_member(local_user(),$group['name'],$change); } $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']; } } @@ -193,8 +194,9 @@ function group_content(App $a) { } - if(! isset($group)) + if (! isset($group)) { return; + } $groupeditor = array( 'label_members' => t('Members'), @@ -206,13 +208,13 @@ function group_content(App $a) { $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", @@ -221,8 +223,8 @@ function group_content(App $a) { 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); } @@ -232,7 +234,7 @@ function group_content(App $a) { $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(); diff --git a/mod/help.php b/mod/help.php index c380aa3913..602653eea8 100644 --- a/mod/help.php +++ b/mod/help.php @@ -30,9 +30,10 @@ function help_content(App $a) { $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); @@ -65,16 +66,22 @@ function help_content(App $a) { $toc="

TOC