Revert "Coding convention applied - part 1"

This commit is contained in:
Hypolite Petovan
2017-03-21 12:02:59 -04:00
committed by GitHub
parent 9c2c483996
commit 7b352f3f74
181 changed files with 3507 additions and 4338 deletions

View File

@@ -24,7 +24,7 @@ require_once('include/Probe.php');
function dfrn_confirm_post(App $a, $handsfree = null) {
if (is_array($handsfree)) {
if(is_array($handsfree)) {
/*
* We were called directly from dfrn_request due to automatic friend acceptance.
@@ -37,7 +37,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
}
else {
if ($a->argc > 1)
if($a->argc > 1)
$node = $a->argv[1];
}
@@ -53,11 +53,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
*
*/
if (! x($_POST,'source_url')) {
if(! x($_POST,'source_url')) {
$uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user());
if (! $uid) {
if(! $uid) {
notice( t('Permission denied.') . EOL );
return;
}
@@ -66,7 +66,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid)
);
if (! $user) {
if(! $user) {
notice( t('Profile not found.') . EOL );
return;
}
@@ -74,7 +74,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
// These data elements may come from either the friend request notification form or $handsfree array.
if (is_array($handsfree)) {
if(is_array($handsfree)) {
logger('Confirm in handsfree mode');
$dfrn_id = $handsfree['dfrn_id'];
$intro_id = $handsfree['intro_id'];
@@ -99,11 +99,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
*
*/
if (strlen($dfrn_id))
if(strlen($dfrn_id))
$cid = 0;
logger('Confirming request for dfrn_id (issued) ' . $dfrn_id);
if ($cid)
if($cid)
logger('Confirming follower with contact_id: ' . $cid);
@@ -138,10 +138,10 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);
if ($contact['network'])
if($contact['network'])
$network = $contact['network'];
if ($network === NETWORK_DFRN) {
if($network === NETWORK_DFRN) {
/*
*
@@ -199,19 +199,19 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']);
if ($aes_allow && function_exists('openssl_encrypt')) {
if($aes_allow && function_exists('openssl_encrypt')) {
openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
$params['aes_key'] = bin2hex($params['aes_key']);
$params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));
}
$params['dfrn_version'] = DFRN_PROTOCOL_VERSION ;
if ($duplex == 1)
if($duplex == 1)
$params['duplex'] = 1;
if ($user[0]['page-flags'] == PAGE_COMMUNITY)
if($user[0]['page-flags'] == PAGE_COMMUNITY)
$params['page'] = 1;
if ($user[0]['page-flags'] == PAGE_PRVGROUP)
if($user[0]['page-flags'] == PAGE_PRVGROUP)
$params['page'] = 2;
logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA);
@@ -234,7 +234,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$leading_junk = substr($res,0,strpos($res,'<?xml'));
$res = substr($res,strpos($res,'<?xml'));
if (! strlen($res)) {
if(! strlen($res)) {
// No XML at all, this exchange is messed up really bad.
// We shouldn't proceed, because the xml parser might choke,
@@ -245,7 +245,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
return;
}
if (strlen($leading_junk) && get_config('system','debugging')) {
if(strlen($leading_junk) && get_config('system','debugging')) {
// This might be more common. Mixed error text and some XML.
// If we're configured for debugging, show the text. Proceed in either case.
@@ -253,7 +253,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
notice( t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL );
}
if (stristr($res, "<status")===false) {
if(stristr($res, "<status")===false) {
// wrong xml! stop here!
notice( t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL );
return;
@@ -265,7 +265,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
switch($status) {
case 0:
info( t("Confirmation completed successfully.") . EOL);
if (strlen($message))
if(strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
case 1:
@@ -279,19 +279,19 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
case 2:
notice( t("Temporary failure. Please wait and try again.") . EOL);
if (strlen($message))
if(strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
case 3:
notice( t("Introduction failed or was revoked.") . EOL);
if (strlen($message))
if(strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
}
if (($status == 0) && ($intro_id)) {
if(($status == 0) && ($intro_id)) {
// Success. Delete the notification.
@@ -302,7 +302,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
}
if ($status != 0)
if($status != 0)
return;
}
@@ -323,13 +323,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
logger('dfrn_confirm: confirm - imported photos');
if ($network === NETWORK_DFRN) {
if($network === NETWORK_DFRN) {
$new_relation = CONTACT_IS_FOLLOWER;
if (($relation == CONTACT_IS_SHARING) || ($duplex))
if(($relation == CONTACT_IS_SHARING) || ($duplex))
$new_relation = CONTACT_IS_FRIEND;
if (($relation == CONTACT_IS_SHARING) && ($duplex))
if(($relation == CONTACT_IS_SHARING) && ($duplex))
$duplex = 0;
$r = q("UPDATE `contact` SET `rel` = %d,
@@ -349,7 +349,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc(NETWORK_DFRN),
intval($contact_id)
);
} else {
}
else {
// $network !== NETWORK_DFRN
@@ -357,13 +358,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$notify = (($contact['notify']) ? $contact['notify'] : '');
$poll = (($contact['poll']) ? $contact['poll'] : '');
if ((! $contact['notify']) || (! $contact['poll'])) {
if((! $contact['notify']) || (! $contact['poll'])) {
$arr = Probe::lrdd($contact['url']);
if (count($arr)) {
foreach ($arr as $link) {
if ($link['@attributes']['rel'] === 'salmon')
if(count($arr)) {
foreach($arr as $link) {
if($link['@attributes']['rel'] === 'salmon')
$notify = $link['@attributes']['href'];
if ($link['@attributes']['rel'] === NAMESPACE_FEED)
if($link['@attributes']['rel'] === NAMESPACE_FEED)
$poll = $link['@attributes']['href'];
}
}
@@ -372,13 +373,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$new_relation = $contact['rel'];
$writable = $contact['writable'];
if ($network === NETWORK_DIASPORA) {
if ($duplex)
if($network === NETWORK_DIASPORA) {
if($duplex)
$new_relation = CONTACT_IS_FRIEND;
else
$new_relation = CONTACT_IS_FOLLOWER;
if ($new_relation != CONTACT_IS_FOLLOWER)
if($new_relation != CONTACT_IS_FOLLOWER)
$writable = 1;
}
@@ -443,7 +444,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid)
);
if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
require_once('include/items.php');
@@ -451,7 +452,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($uid)
);
if (count($self)) {
if(count($self)) {
$arr = array();
$arr['guid'] = get_guid(32);
@@ -490,14 +491,14 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr);
if ($i)
if($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
}
}
$def_gid = get_default_group($uid, $contact["network"]);
if ($contact && intval($def_gid))
if($contact && intval($def_gid))
group_add_member($uid, '', $contact['id'], $def_gid);
// Let's send our user to the contact editor in case they want to
@@ -564,7 +565,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$local_uid = $r[0]['uid'];
if (! strstr($my_prvkey,'PRIVATE KEY')) {
if(! strstr($my_prvkey,'PRIVATE KEY')) {
$message = t('Our site encryption key is apparently messed up.');
xml_status(3,$message);
}
@@ -575,7 +576,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
openssl_private_decrypt($source_url,$decrypted_source_url,$my_prvkey);
if (! strlen($decrypted_source_url)) {
if(! strlen($decrypted_source_url)) {
$message = t('Empty site URL was provided or URL could not be decrypted by us.');
xml_status(3,$message);
// NOTREACHED
@@ -585,18 +586,17 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc($decrypted_source_url),
intval($local_uid)
);
if (!dbm::is_result($ret)) {
if (strstr($decrypted_source_url,'http:')) {
if(! count($ret)) {
if(strstr($decrypted_source_url,'http:'))
$newurl = str_replace('http:','https:',$decrypted_source_url);
} else {
else
$newurl = str_replace('https:','http:',$decrypted_source_url);
}
$ret = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newurl),
intval($local_uid)
);
if (!dbm::is_result($ret)) {
if(! count($ret)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = t('Contact record was not found for you on our site.');
xml_status(3,$message);
@@ -611,7 +611,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$foreign_pubkey = $ret[0]['site-pubkey'];
$dfrn_record = $ret[0]['id'];
if (! $foreign_pubkey) {
if(! $foreign_pubkey) {
$message = sprintf( t('Site public key not available in contact record for URL %s.'), $newurl);
xml_status(3,$message);
}
@@ -619,7 +619,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$decrypted_dfrn_id = "";
openssl_public_decrypt($dfrn_id,$decrypted_dfrn_id,$foreign_pubkey);
if (strlen($aes_key)) {
if(strlen($aes_key)) {
$decrypted_aes_key = "";
openssl_private_decrypt($aes_key,$decrypted_aes_key,$my_prvkey);
$dfrn_pubkey = openssl_decrypt($public_key,'AES-256-CBC',$decrypted_aes_key);
@@ -650,7 +650,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
// It's possible that the other person also requested friendship.
// If it is a duplex relationship, ditch the issued-id if one exists.
if ($duplex) {
if($duplex) {
$r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d",
intval($dfrn_record)
);
@@ -722,7 +722,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
if (dbm::is_result($r))
$combined = $r[0];
if ((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
$mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array(
'type' => NOTIFY_CONFIRM,
@@ -742,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');
@@ -755,7 +755,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($local_uid)
);
if (dbm::is_result($self)) {
if(count($self)) {
$arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
@@ -792,9 +792,8 @@ 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);
}
}
}