Merge pull request #3381 from Quix0r/rewrites/coding-convention-split2-4-2

Coding convention applied split 2-4-2 (of 2-14-2)
This commit is contained in:
Hypolite Petovan 2017-05-12 21:40:30 -04:00 committed by GitHub
commit 2bbcbdc704
26 changed files with 1844 additions and 1822 deletions

View file

@ -5,10 +5,10 @@
use Friendica\App;
require_once('include/ForumManager.php');
require_once('include/bbcode.php');
require_once("mod/proxy.php");
require_once('include/cache.php');
require_once 'include/ForumManager.php';
require_once 'include/bbcode.php';
require_once 'mod/proxy.php';
require_once 'include/cache.php';
/**
*
@ -87,7 +87,7 @@ function profile_load(App $a, $nickname, $profile = 0, $profiledata = array()) {
$theme_info_file = "view/theme/" . current_theme() . "/theme.php";
if (file_exists($theme_info_file)) {
require_once($theme_info_file);
require_once $theme_info_file;
}
if (! (x($a->page,'aside')))
@ -537,13 +537,13 @@ function get_birthdays() {
function get_events() {
require_once('include/bbcode.php');
require_once 'include/bbcode.php';
$a = get_app();
if (! local_user() || $a->is_mobile || $a->is_tablet)
if (! local_user() || $a->is_mobile || $a->is_tablet) {
return $o;
}
// $mobile_detect = new Mobile_Detect();
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
@ -566,13 +566,15 @@ function get_events() {
$now = strtotime('now');
$istoday = false;
foreach ($r as $rr) {
if (strlen($rr['name']))
if (strlen($rr['name'])) {
$total ++;
}
$strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d');
if ($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d'))
if ($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) {
$istoday = true;
}
}
$classtoday = (($istoday) ? 'event-today' : '');
$skip = 0;
@ -580,12 +582,14 @@ function get_events() {
foreach ($r as &$rr) {
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if (strlen($title) > 35)
if (strlen($title) > 35) {
$title = substr($title,0,32) . '... ';
}
$description = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... ';
if (! $description)
if (! $description) {
$description = t('[No description]');
}
$strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
@ -632,7 +636,9 @@ function advanced_profile(App $a) {
$profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ;
if ($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
if ($a->profile['gender']) {
$profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
}
if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
$year_bd_format = t('j F, Y');
@ -647,10 +653,13 @@ function advanced_profile(App $a) {
}
if ($age = age($a->profile['dob'],$a->profile['timezone'],'')) $profile['age'] = array( t('Age:'), $age );
if ($age = age($a->profile['dob'],$a->profile['timezone'],'')) {
$profile['age'] = array( t('Age:'), $age );
}
if ($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']);
if ($a->profile['marital']) {
$profile['marital'] = array( t('Status:'), $a->profile['marital']);
}
/// @TODO Maybe use x() here, plus below?
if ($a->profile['with']) {
@ -855,8 +864,9 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
}
function get_my_url() {
if (x($_SESSION,'my_url'))
if (x($_SESSION, 'my_url')) {
return $_SESSION['my_url'];
}
return false;
}
@ -869,12 +879,10 @@ function zrl_init(App $a) {
$urlparts = parse_url($tmp_str);
$result = Cache::get("gprobe:" . $urlparts["host"]);
if (!is_null($result)) {
if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
if ((!is_null($result)) && (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
logger("DDoS attempt detected for " . $urlparts["host"] . " by " . $_SERVER["REMOTE_ADDR"] . ". server data: " . print_r($_SERVER, true), LOGGER_DEBUG);
return;
}
}
proc_run(PRIORITY_LOW, 'include/gprobe.php', bin2hex($tmp_str));
$arr = array('zrl' => $tmp_str, 'url' => $a->cmd);
@ -894,7 +902,7 @@ function zrl($s,$force = false) {
}
$achar = strpos($s, '?') ? '&' : '?';
$mine = get_my_url();
if ($mine and ! link_compare($mine,$s)) {
if ($mine && ! link_compare($mine, $s)) {
return $s . $achar . 'zrl=' . urlencode($mine);
}
return $s;
@ -916,11 +924,9 @@ function zrl($s,$force = false) {
*/
function get_theme_uid() {
$uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
if (local_user()) {
if ((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid)) {
if ((local_user()) && ((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))) {
return local_user();
}
}
return $uid;
}

View file

@ -57,8 +57,9 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
dbesc($fn_name)
);
if (dbm::is_result($r) && $r[0]['locked'])
if (dbm::is_result($r) && $r[0]['locked']) {
sleep($wait_sec);
}
} while (dbm::is_result($r) && $r[0]['locked'] && ((time() - $start) < $timeout));

View file

@ -196,9 +196,8 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) {
if (preg_match('/(Location:|URI:)(.*?)\n/i', $header, $matches)) {
$newurl = trim(array_pop($matches));
}
if (strpos($newurl,'/') === 0) {
$newurl = $old_location_info['scheme'] . '://' . $old_location_info['host'] . $newurl;
$newurl = $old_location_info["scheme"]."://".$old_location_info["host"].$newurl;
}
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
@ -342,7 +341,7 @@ function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
$newurl = trim(array_pop($matches));
if (strpos($newurl, '/') === 0) {
$newurl = $old_location_info['scheme'] . '://' . $old_location_info['host'] . $newurl;
$newurl = $old_location_info["scheme"] . "://" . $old_location_info["host"] . $newurl;
}
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
@ -502,7 +501,6 @@ function allowed_url($url) {
$host = strtolower($h['host']);
// always allow our own site
if ($host == strtolower($_SERVER['SERVER_NAME'])) {
return true;
}
@ -563,14 +561,15 @@ function blocked_url($url) {
*/
function allowed_email($email) {
$domain = strtolower(substr($email,strpos($email,'@') + 1));
if(! $domain)
if (! $domain) {
return false;
}
$str_allowed = get_config('system','allowed_email');
if(! $str_allowed)
if (! $str_allowed) {
return true;
}
$found = false;

View file

@ -306,7 +306,9 @@ function oembed_html2bbcode($text) {
$xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
foreach ($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
if (!is_null($href)) {
$e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
}
}
return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
} else {

View file

@ -170,7 +170,7 @@ function onepoll_run(&$argv, &$argc){
// But this may be our first communication, so set the writable flag if it isn't set already.
if (! intval($contact['writable'])) {
q("update contact set writable = 1 where id = %d", intval($contact['id']));
q("UPDATE `contact` SET `writable` = 1 WHERE `id` = %d", intval($contact['id']));
}
$url = $contact['poll'] . '?dfrn_id=' . $idtosend
@ -437,17 +437,19 @@ function onepoll_run(&$argv, &$argc){
if ($raw_refs) {
$refs_arr = explode(' ', $raw_refs);
if (count($refs_arr)) {
for($x = 0; $x < count($refs_arr); $x ++)
for ($x = 0; $x < count($refs_arr); $x ++) {
$refs_arr[$x] = "'" . msgid2iri(str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x]))) . "'";
}
}
$qstr = implode(',',$refs_arr);
$r = q("SELECT `uri` , `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1",
intval($importer_uid)
);
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$datarray['parent-uri'] = $r[0]['parent-uri']; // Set the parent as the top-level item
//$datarray['parent-uri'] = $r[0]['uri'];
}
}
// Decoding the header
$subject = imap_mime_header_decode($meta->subject);
@ -611,14 +613,17 @@ function onepoll_run(&$argv, &$argc){
consume_feed($xml,$importer,$contact,$hub,1,2);
$hubmode = 'subscribe';
if ($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
if ($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly']) {
$hubmode = 'unsubscribe';
}
if (($contact['network'] === NETWORK_OSTATUS || $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify']))
if (($contact['network'] === NETWORK_OSTATUS || $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify'])) {
$hub_update = true;
}
if ($force)
if ($force) {
$hub_update = true;
}
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);

View file

@ -70,6 +70,7 @@ class ostatus {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET));
if (dbm::is_result($r)) {
$contact = $r[0];
$author["contact-id"] = $r[0]["id"];
@ -79,6 +80,7 @@ class ostatus {
// Should not happen
$contact = dba::fetch_first("SELECT * FROM `contact` WHERE `uid` = ? AND `addr` = ? AND `network` != ?",
$importer["uid"], $addr, NETWORK_STATUSNET);
if (dbm::is_result($contact)) {
$author["contact-id"] = $contact["id"];
$author["author-link"] = $contact["url"];
@ -91,22 +93,26 @@ class ostatus {
$href = "";
$width = 0;
foreach ($avatar->attributes AS $attributes) {
if ($attributes->name == "href")
if ($attributes->name == "href") {
$href = $attributes->textContent;
if ($attributes->name == "width")
}
if ($attributes->name == "width") {
$width = $attributes->textContent;
}
if (($width > 0) AND ($href != ""))
}
if (($width > 0) AND ($href != "")) {
$avatarlist[$width] = $href;
}
}
if (count($avatarlist) > 0) {
krsort($avatarlist);
$author["author-avatar"] = Probe::fixAvatar(current($avatarlist), $author["author-link"]);
}
$displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
if ($displayname != "")
if ($displayname != "") {
$author["author-name"] = $displayname;
}
$author["owner-name"] = $author["author-name"];
$author["owner-link"] = $author["author-link"];
@ -1146,6 +1152,7 @@ class ostatus {
continue;
}
/// @TODO One statment is okay (until if () )
$arr = array();
$arr["network"] = $details["network"];
$arr["uri"] = $single_conv->id;

View file

@ -8,8 +8,9 @@ define("IMPORT_DEBUG", False);
function last_insert_id() {
global $db;
if (IMPORT_DEBUG)
if (IMPORT_DEBUG) {
return 1;
}
return $db->insert_id();
}
@ -56,8 +57,9 @@ function db_import_assoc($table, $arr) {
$vals = implode("','", array_map('dbesc', array_values($arr)));
$query = "INSERT INTO `$table` (`$cols`) VALUES ('$vals')";
logger("uimport: $query", LOGGER_TRACE);
if (IMPORT_DEBUG)
if (IMPORT_DEBUG) {
return true;
}
return q($query);
}
@ -101,6 +103,7 @@ function import_account(App $a, $file) {
}
/*
* @TODO Old-lost code?
// this is not required as we remove columns in json not in current db schema
if ($account['schema'] != DB_UPDATE_VERSION) {
notice(t("Error! I can't import this file: DB schema version is not compatible."));
@ -139,11 +142,11 @@ function import_account(App $a, $file) {
unset($account['user']['account_expired']);
unset($account['user']['account_expires_on']);
unset($account['user']['expire_notification_sent']);
foreach ($account['user'] as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
}
// import user
$r = db_import_assoc('user', $account['user']);
if ($r === false) {
@ -162,9 +165,10 @@ function import_account(App $a, $file) {
foreach ($account['profile'] as &$profile) {
foreach ($profile as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
foreach (array("profile", "avatar") as $k)
foreach (array("profile", "avatar") as $k) {
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
}
}
$profile['uid'] = $newuid;
$r = db_import_assoc('profile', $profile);
if ($r === false) {
@ -180,15 +184,15 @@ function import_account(App $a, $file) {
if ($contact['uid'] == $olduid && $contact['self'] == '1') {
foreach ($contact as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
foreach (array("profile", "avatar", "micro") as $k)
foreach (array("profile", "avatar", "micro") as $k) {
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
}
}
}
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
// set contacts 'avatar-date' to NULL_DATE to let poller to update urls
$contact["avatar-date"] = NULL_DATE;
switch ($contact['network']) {
case NETWORK_DFRN:
// send relocate message (below)

View file

@ -6,6 +6,7 @@ function login_content(App $a) {
if (x($_SESSION, 'theme')) {
unset($_SESSION['theme']);
}
if (x($_SESSION, 'mobile-theme')) {
unset($_SESSION['mobile-theme']);
}

View file

@ -11,4 +11,3 @@
</section>
</body>
</html>

View file

@ -59,4 +59,3 @@
</div>
<div id="group-all-contacts-end"></div>
</div>

View file

@ -83,4 +83,3 @@
</li>
</ul>
</div>