Browse Source

Use short form array syntax everywhere

- Add short form array syntax to po2php.php generation
pull/4243/head
Hypolite Petovan 3 years ago
parent
commit
e36f2bb1fb
212 changed files with 5171 additions and 5171 deletions
  1. +12
    -12
      boot.php
  2. +1
    -1
      htconfig.php
  3. +48
    -48
      include/acl_selectors.php
  4. +232
    -232
      include/api.php
  5. +5
    -5
      include/bb2diaspora.php
  6. +26
    -26
      include/bbcode.php
  7. +50
    -50
      include/conversation.php
  8. +24
    -24
      include/datetime.php
  9. +20
    -20
      include/dba.php
  10. +18
    -18
      include/enotify.php
  11. +21
    -21
      include/event.php
  12. +5
    -5
      include/friendica_smarty.php
  13. +63
    -63
      include/html2bbcode.php
  14. +28
    -28
      include/html2plain.php
  15. +84
    -84
      include/items.php
  16. +3
    -3
      include/like.php
  17. +51
    -51
      include/nav.php
  18. +23
    -23
      include/network.php
  19. +5
    -5
      include/pgettext.php
  20. +4
    -4
      include/plaintext.php
  21. +31
    -31
      include/plugin.php
  22. +8
    -8
      include/post_update.php
  23. +1
    -1
      include/queue_fn.php
  24. +9
    -9
      include/security.php
  25. +5
    -5
      include/session.php
  26. +6
    -6
      include/tags.php
  27. +85
    -85
      include/text.php
  28. +8
    -8
      include/threads.php
  29. +11
    -11
      index.php
  30. +4
    -4
      mod/_well_known.php
  31. +237
    -237
      mod/admin.php
  32. +8
    -8
      mod/allfriends.php
  33. +4
    -4
      mod/api.php
  34. +2
    -2
      mod/apps.php
  35. +2
    -2
      mod/bookmarklet.php
  36. +14
    -14
      mod/cal.php
  37. +7
    -7
      mod/common.php
  38. +11
    -11
      mod/community.php
  39. +1
    -1
      mod/contactgroup.php
  40. +86
    -86
      mod/contacts.php
  41. +18
    -18
      mod/crepair.php
  42. +6
    -6
      mod/dfrn_poll.php
  43. +10
    -10
      mod/dfrn_request.php
  44. +8
    -8
      mod/directory.php
  45. +10
    -10
      mod/dirfind.php
  46. +12
    -12
      mod/display.php
  47. +8
    -8
      mod/editpost.php
  48. +24
    -24
      mod/events.php
  49. +11
    -11
      mod/fbrowser.php
  50. +1
    -1
      mod/fetch.php
  51. +3
    -3
      mod/filer.php
  52. +6
    -6
      mod/follow.php
  53. +8
    -8
      mod/friendica.php
  54. +1
    -1
      mod/fsuggest.php
  55. +21
    -21
      mod/group.php
  56. +2
    -2
      mod/hcard.php
  57. +3
    -3
      mod/help.php
  58. +1
    -1
      mod/home.php
  59. +2
    -2
      mod/hostxrd.php
  60. +4
    -4
      mod/hovercard.php
  61. +28
    -28
      mod/install.php
  62. +3
    -3
      mod/invite.php
  63. +21
    -21
      mod/item.php
  64. +2
    -2
      mod/lockview.php
  65. +8
    -8
      mod/lostpass.php
  66. +2
    -2
      mod/maintenance.php
  67. +3
    -3
      mod/manage.php
  68. +2
    -2
      mod/manifest.php
  69. +9
    -9
      mod/match.php
  70. +33
    -33
      mod/message.php
  71. +5
    -5
      mod/msearch.php
  72. +56
    -56
      mod/network.php
  73. +15
    -15
      mod/nodeinfo.php
  74. +4
    -4
      mod/nogroup.php
  75. +6
    -6
      mod/noscrape.php
  76. +4
    -4
      mod/notes.php
  77. +19
    -19
      mod/notifications.php
  78. +6
    -6
      mod/notify.php
  79. +2
    -2
      mod/oexchange.php
  80. +2
    -2
      mod/opensearch.php
  81. +4
    -4
      mod/parse_url.php
  82. +2
    -2
      mod/photo.php
  83. +92
    -92
      mod/photos.php
  84. +38
    -38
      mod/ping.php
  85. +13
    -13
      mod/poco.php
  86. +7
    -7
      mod/poke.php
  87. +1
    -1
      mod/pretheme.php
  88. +2
    -2
      mod/probe.php
  89. +10
    -10
      mod/profile.php
  90. +6
    -6
      mod/profile_photo.php
  91. +56
    -56
      mod/profiles.php
  92. +2
    -2
      mod/profperm.php
  93. +5
    -5
      mod/proxy.php
  94. +9
    -9
      mod/register.php
  95. +2
    -2
      mod/regmod.php
  96. +2
    -2
      mod/removeme.php
  97. +2
    -2
      mod/robots_txt.php
  98. +1
    -1
      mod/salmon.php
  99. +17
    -17
      mod/search.php
  100. +179
    -179
      mod/settings.php

+ 12
- 12
boot.php View File

@ -288,7 +288,7 @@ define('NETWORK_PHANTOM', 'unkn'); // Place holder
* and existing allocations MUST NEVER BE CHANGED
* OR RE-ASSIGNED! You may only add to them.
*/
$netgroup_ids = array(
$netgroup_ids = [
NETWORK_DFRN => (-1),
NETWORK_ZOT => (-2),
NETWORK_OSTATUS => (-3),
@ -310,7 +310,7 @@ $netgroup_ids = array(
NETWORK_PNUT => (-20),
NETWORK_PHANTOM => (-127),
);
];
/**
* Maximum number of "people who like (or don't like) this" that we will list by name
@ -504,7 +504,7 @@ function startup()
ini_set('pcre.backtrack_limit', 500000);
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
$process = [&$_GET, &$_POST, &$_COOKIE, &$_REQUEST];
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
@ -817,11 +817,11 @@ function check_plugins(App $a)
if (DBM::is_result($r)) {
$installed = $r;
} else {
$installed = array();
$installed = [];
}
$plugins = Config::get('system', 'addon');
$plugins_arr = array();
$plugins_arr = [];
if ($plugins) {
$plugins_arr = explode(',', str_replace(' ', '', $plugins));
@ -829,7 +829,7 @@ function check_plugins(App $a)
$a->plugins = $plugins_arr;
$installed_arr = array();
$installed_arr = [];
if (count($installed)) {
foreach ($installed as $i) {
@ -966,7 +966,7 @@ function notice($s)
{
$a = get_app();
if (!x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array();
$_SESSION['sysmsg'] = [];
}
if ($a->interactive) {
$_SESSION['sysmsg'][] = $s;
@ -989,7 +989,7 @@ function info($s)
}
if (!x($_SESSION, 'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array();
$_SESSION['sysmsg_info'] = [];
}
if ($a->interactive) {
$_SESSION['sysmsg_info'][] = $s;
@ -1010,7 +1010,7 @@ function get_max_import_size()
function current_theme()
{
$app_base_themes = array('duepuntozero', 'dispy', 'quattro');
$app_base_themes = ['duepuntozero', 'dispy', 'quattro'];
$a = get_app();
@ -1238,10 +1238,10 @@ function explode_querystring($query)
$args = array_values($args);
}
return array(
return [
'base' => $base,
'args' => $args,
);
];
}
/**
@ -1571,7 +1571,7 @@ function infinite_scroll_data($module)
$reload_uri .= "&offset=" . urlencode($a->page_offset);
}
$arr = array("pageno" => $pageno, "reload_uri" => $reload_uri);
$arr = ["pageno" => $pageno, "reload_uri" => $reload_uri];
return $arr;
}


+ 1
- 1
htconfig.php View File

@ -86,7 +86,7 @@ $a->config['system']['no_regfullname'] = true;
$a->config['system']['directory'] = 'https://dir.friendica.social';
// Allowed protocols in link URLs; HTTP protocols always are accepted
$a->config['system']['allowed_link_protocols'] = array('ftp', 'ftps', 'mailto', 'cid', 'gopher');
$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher'];
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;

+ 48
- 48
include/acl_selectors.php View File

@ -28,7 +28,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
);
$arr = array('group' => $r, 'entry' => $o);
$arr = ['group' => $r, 'entry' => $o];
// e.g. 'network_pre_group_deny', 'profile_pre_group_allow'
@ -87,20 +87,20 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
if (x($options, 'networks')) {
switch ($options['networks']) {
case 'DFRN_ONLY':
$networks = array(NETWORK_DFRN);
$networks = [NETWORK_DFRN];
break;
case 'PRIVATE':
if (is_array($a->user) && $a->user['prvnets']) {
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
} else {
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA);
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA];
}
break;
case 'TWO_WAY':
if (is_array($a->user) && $a->user['prvnets']) {
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
} else {
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS);
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS];
}
break;
default: /// @TODO Maybe log this call?
@ -109,7 +109,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
}
}
$x = array('options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks);
$x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks];
call_hooks('contact_select_options', $x);
@ -150,7 +150,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
);
$arr = array('contact' => $r, 'entry' => $o);
$arr = ['contact' => $r, 'entry' => $o];
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
@ -228,13 +228,13 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
);
$arr = array('contact' => $r, 'entry' => $o);
$arr = ['contact' => $r, 'entry' => $o];
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
call_hooks($a->module . '_pre_' . $selname, $arr);
$receiverlist = array();
$receiverlist = [];
if (DBM::is_result($r)) {
foreach ($r as $rr) {
@ -270,7 +270,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
function fixacl(&$item) {
$item = intval(str_replace(array('<', '>'), array('', ''), $item));
$item = intval(str_replace(['<', '>'], ['', ''], $item));
}
function prune_deadguys($arr) {
@ -284,14 +284,14 @@ function prune_deadguys($arr) {
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
if (DBM::is_result($r)) {
$ret = array();
$ret = [];
foreach ($r as $rr) {
$ret[] = intval($rr['id']);
}
return $ret;
}
return array();
return [];
}
@ -300,13 +300,13 @@ function get_acl_permissions($user = null) {
if (is_array($user)) {
$allow_cid = ((strlen($user['allow_cid']))
? explode('><', $user['allow_cid']) : array() );
? explode('><', $user['allow_cid']) : [] );
$allow_gid = ((strlen($user['allow_gid']))
? explode('><', $user['allow_gid']) : array() );
? explode('><', $user['allow_gid']) : [] );
$deny_cid = ((strlen($user['deny_cid']))
? explode('><', $user['deny_cid']) : array() );
? explode('><', $user['deny_cid']) : [] );
$deny_gid = ((strlen($user['deny_gid']))
? explode('><', $user['deny_gid']) : array() );
? explode('><', $user['deny_gid']) : [] );
array_walk($allow_cid,'fixacl');
array_walk($allow_gid,'fixacl');
array_walk($deny_cid,'fixacl');
@ -315,12 +315,12 @@ function get_acl_permissions($user = null) {
$allow_cid = prune_deadguys($allow_cid);
return array(
return [
'allow_cid' => $allow_cid,
'allow_gid' => $allow_gid,
'deny_cid' => $deny_cid,
'deny_gid' => $deny_gid,
);
];
}
@ -361,7 +361,7 @@ function populate_acl($user = null, $show_jotnets = false) {
}
$tpl = get_markup_template("acl_selector.tpl");
$o = replace_macros($tpl, array(
$o = replace_macros($tpl, [
'$showall'=> t("Visible to everybody"),
'$show' => t("show"),
'$hide' => t("don't show"),
@ -375,10 +375,10 @@ function populate_acl($user = null, $show_jotnets = false) {
'$jotnets' => $jotnets,
'$aclModalTitle' => t('Permissions'),
'$aclModalDismiss' => t('Close'),
'$features' => array(
'$features' => [
'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "false")
),
));
],
]);
return $o;
@ -475,8 +475,8 @@ function acl_lookup(App $a, $out_type = 'json')
$tot = $group_count + $contact_count;
$groups = array();
$contacts = array();
$groups = [];
$contacts = [];
if ($type == '' || $type == 'g') {
/// @todo We should cache this query.
@ -495,7 +495,7 @@ function acl_lookup(App $a, $out_type = 'json')
);
foreach ($r as $g) {
$groups[] = array(
$groups[] = [
"type" => "g",
"photo" => "images/twopeople.png",
"name" => htmlentities($g['name']),
@ -503,10 +503,10 @@ function acl_lookup(App $a, $out_type = 'json')
"uids" => array_map("intval", explode(",",$g['uids'])),
"link" => '',
"forum" => '0'
);
];
}
if ((count($groups) > 0) && ($search == "")) {
$groups[] = array("separator" => true);
$groups[] = ["separator" => true];
}
}
@ -558,34 +558,34 @@ function acl_lookup(App $a, $out_type = 'json')
} elseif ($type == 'x') {
// autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a);
$contacts = array();
$contacts = [];
if ($r) {
foreach ($r as $g) {
$contacts[] = array(
$contacts[] = [
'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
'name' => $g['name'],
'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
'network' => $g['network'],
'link' => $g['url'],
'forum' => (x($g['community']) ? 1 : 0),
);
];
}
}
$o = array(
$o = [
'start' => $start,
'count' => $count,
'items' => $contacts,
);
];
echo json_encode($o);
killme();
} else {
$r = array();
$r = [];
}
if (DBM::is_result($r)) {
$forums = array();
$forums = [];
foreach ($r as $g) {
$entry = array(
$entry = [
'type' => 'c',
'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
'name' => htmlentities($g['name']),
@ -595,7 +595,7 @@ function acl_lookup(App $a, $out_type = 'json')
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']),
'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0),
);
];
if ($entry['forum']) {
$forums[] = $entry;
} else {
@ -604,7 +604,7 @@ function acl_lookup(App $a, $out_type = 'json')
}
if (count($forums) > 0) {
if ($search == "") {
$forums[] = array("separator" => true);
$forums[] = ["separator" => true];
}
$contacts = array_merge($forums, $contacts);
}
@ -623,7 +623,7 @@ function acl_lookup(App $a, $out_type = 'json')
}
, $contacts);
$unknown_contacts = array();
$unknown_contacts = [];
$r = q("SELECT `author-link`
FROM `item` WHERE `parent` = %d
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
@ -641,7 +641,7 @@ function acl_lookup(App $a, $out_type = 'json')
$contact = Contact::getDetailsByURL($row['author-link']);
if (count($contact) > 0) {
$unknown_contacts[] = array(
$unknown_contacts[] = [
'type' => 'c',
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
'name' => htmlentities($contact['name']),
@ -651,7 +651,7 @@ function acl_lookup(App $a, $out_type = 'json')
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']),
'forum' => $contact['forum']
);
];
}
}
}
@ -660,7 +660,7 @@ function acl_lookup(App $a, $out_type = 'json')
$tot += count($unknown_contacts);
}
$results = array(
$results = [
'tot' => $tot,
'start' => $start,
'count' => $count,
@ -669,27 +669,27 @@ function acl_lookup(App $a, $out_type = 'json')
'items' => $items,
'type' => $type,
'search' => $search,
);
];
call_hooks('acl_lookup_end', $results);
if ($out_type === 'html') {
$o = array(
$o = [
'tot' => $results['tot'],
'start' => $results['start'],
'count' => $results['count'],
'groups' => $results['groups'],
'contacts' => $results['contacts'],
);
];
return $o;
}
$o = array(
$o = [
'tot' => $results['tot'],
'start' => $results['start'],
'count' => $results['count'],
'items' => $results['items'],
);
];
echo json_encode($o);
@ -717,7 +717,7 @@ function navbar_complete(App $a) {
// don't search if search term has less than 2 characters
if (! $search || mb_strlen($search) < 2) {
return array();
return [];
}
if (substr($search,0,1) === '@') {


+ 232
- 232
include/api.php
File diff suppressed because it is too large
View File


+ 5
- 5
include/bb2diaspora.php View File

@ -51,7 +51,7 @@ function diaspora2bb($s) {
$s = preg_replace('/^([^\*]+)\*([^\*]*)$/im', '$1\*$2', $s);
// The parser cannot handle paragraphs correctly
$s = str_replace(array('</p>', '<p>', '<p dir="ltr">'), array('<br>', '<br>', '<br>'), $s);
$s = str_replace(['</p>', '<p>', '<p dir="ltr">'], ['<br>', '<br>', '<br>'], $s);
// Escaping the hash tags
$s = preg_replace('/\#([^\s\#])/', '&#35;$1', $s);
@ -178,11 +178,11 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
}
// mask some special HTML chars from conversation to markdown
$Text = str_replace(array('&lt;', '&gt;', '&amp;'), array('&_lt_;', '&_gt_;', '&_amp_;'), $Text);
$Text = str_replace(['&lt;', '&gt;', '&amp;'], ['&_lt_;', '&_gt_;', '&_amp_;'], $Text);
// If a link is followed by a quote then there should be a newline before it
// Maybe we should make this newline at every time before a quote.
$Text = str_replace(array("</a><blockquote>"), array("</a><br><blockquote>"), $Text);
$Text = str_replace(["</a><blockquote>"], ["</a><br><blockquote>"], $Text);
$stamp1 = microtime(true);
@ -191,12 +191,12 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
$Text = $converter->convert($Text);
// unmask the special chars back to HTML
$Text = str_replace(array('&\_lt\_;', '&\_gt\_;', '&\_amp\_;'), array('&lt;', '&gt;', '&amp;'), $Text);
$Text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['&lt;', '&gt;', '&amp;'], $Text);
$a->save_timestamp($stamp1, "parser");
// Libertree has a problem with escaped hashtags.
$Text = str_replace(array('\#'), array('#'), $Text);
$Text = str_replace(['\#'], ['#'], $Text);
// Remove any leading or trailing whitespace, as this will mess up
// the Diaspora signature verification and cause the item to disappear


+ 26
- 26
include/bbcode.php View File

@ -60,7 +60,7 @@ function bb_attachment($return, $simplehtml = false, $tryoembed = true)
if (isset($data["title"])) {
$data["title"] = strip_tags($data["title"]);
$data["title"] = str_replace(array("http://", "https://"), "", $data["title"]);
$data["title"] = str_replace(["http://", "https://"], "", $data["title"]);
}
if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && ($data["image"] != "")) {
@ -280,7 +280,7 @@ function bb_find_open_close($s, $open, $close, $occurence = 1) {
return false;
}
$res = array( 'start' => $start_pos, 'end' => $end_pos );
$res = [ 'start' => $start_pos, 'end' => $end_pos ];
return $res;
}
@ -316,16 +316,16 @@ function get_bb_tag_pos($s, $name, $occurence = 1) {
return false;
}
$res = array(
'start' => array(
$res = [
'start' => [
'open' => $start_open,
'close' => $start_close
),
'end' => array(
],
'end' => [
'open' => $end_open,
'close' => $end_open + strlen('[/' . $name . ']')
),
);
],
];
if ($start_equal !== false) {
$res['start']['equal'] = $start_equal + 1;
@ -360,7 +360,7 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) {
function bb_extract_images($body) {
$saved_image = array();
$saved_image = [];
$orig_body = $body;
$new_body = '';
@ -398,7 +398,7 @@ function bb_extract_images($body) {
$new_body = $new_body . $orig_body;
return array('body' => $new_body, 'images' => $saved_image);
return ['body' => $new_body, 'images' => $saved_image];
}
function bb_replace_images($body, $images) {
@ -595,14 +595,14 @@ function bb_ShareAttributes($share, $simplehtml)
$avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB);
$tpl = get_markup_template('shared_content.tpl');
$text .= replace_macros($tpl, array(
$text .= replace_macros($tpl, [
'$profile' => $profile,
'$avatar' => $avatar,
'$author' => $author,
'$link' => $link,
'$posted' => $posted,
'$content' => trim($share[3])
));
]);
}
break;
}
@ -752,7 +752,7 @@ function bb_RemovePictureLinks($match) {
$xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]");
foreach ($list as $node) {
$attr = array();
$attr = [];
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
@ -809,7 +809,7 @@ function bb_CleanPictureLinksSub($match) {
$xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]");
foreach ($list as $node) {
$attr = array();
$attr = [];
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
@ -951,10 +951,10 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// removing multiplicated newlines
if (Config::get("system", "remove_multiplicated_lines")) {
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
"\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n");
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
"[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]");
$search = ["\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
"\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"];
$replace = ["\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
"[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]"];
do {
$oldtext = $Text;
$Text = str_replace($search, $replace, $Text);
@ -986,14 +986,14 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// Handle attached links or videos
$Text = bb_attachment($Text, $simplehtml, $tryoembed);
$Text = str_replace(array("\r","\n"), array('<br />', '<br />'), $Text);
$Text = str_replace(["\r","\n"], ['<br />', '<br />'], $Text);
if ($preserve_nl) {
$Text = str_replace(array("\n", "\r"), array('', ''), $Text);
$Text = str_replace(["\n", "\r"], ['', ''], $Text);
}
// Remove all hashtag addresses
if ((!$tryoembed || $simplehtml) && !in_array($simplehtml, array(3, 7))) {
if ((!$tryoembed || $simplehtml) && !in_array($simplehtml, [3, 7])) {
$Text = preg_replace("/([#@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
} elseif ($simplehtml == 3) {
$Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
@ -1015,7 +1015,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$Text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
"[bookmark=$1]$2[/bookmark]", $Text);
if (in_array($simplehtml, array(2, 6, 7, 8, 9))) {
if (in_array($simplehtml, [2, 6, 7, 8, 9])) {
$Text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "bb_expand_links", $Text);
//$Text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $Text);
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]',$Text);
@ -1353,13 +1353,13 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$Text = preg_replace('/\<([^>]*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism', '<$1$2=$3&$4>', $Text);
// sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails)
static $allowed_src_protocols = array('http', 'redir', 'cid');
static $allowed_src_protocols = ['http', 'redir', 'cid'];
$Text = preg_replace('#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism',
'<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . t('Invalid source protocol') . '">', $Text);
// sanitize href attributes (only whitelisted protocols URLs)
// default value for backward compatibility
$allowed_link_protocols = Config::get('system', 'allowed_link_protocols', array('ftp', 'mailto', 'gopher', 'cid'));
$allowed_link_protocols = Config::get('system', 'allowed_link_protocols', ['ftp', 'mailto', 'gopher', 'cid']);
// Always allowed protocol even if config isn't set or not including it
$allowed_link_protocols[] = 'http';
@ -1386,7 +1386,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
@$doc->loadHTML($encoding.$doctype."<html><body>".$Text."</body></html>");
$doc->encoding = 'UTF-8';
$Text = $doc->saveHTML();
$Text = str_replace(array("<html><body>", "</body></html>", $doctype, $encoding), array("", "", "", ""), $Text);
$Text = str_replace(["<html><body>", "</body></html>", $doctype, $encoding], ["", "", "", ""], $Text);
$Text = str_replace('<br></li>', '</li>', $Text);
@ -1427,7 +1427,7 @@ function remove_abstract($text) {
*/
function fetch_abstract($text, $addon = "") {
$abstract = "";
$abstracts = array();
$abstracts = [];
$addon = strtolower($addon);
if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism",$text, $results, PREG_SET_ORDER))


+ 50
- 50
include/conversation.php View File

@ -19,7 +19,7 @@ require_once "include/acl_selectors.php";
function item_extract_images($body) {
$saved_image = array();
$saved_image = [];
$orig_body = $body;
$new_body = '';
@ -57,7 +57,7 @@ function item_extract_images($body) {
$new_body = $new_body . $orig_body;
return array('body' => $new_body, 'images' => $saved_image);
return ['body' => $new_body, 'images' => $saved_image];
}
function item_redir_and_replace_images($body, $images, $cid) {
@ -145,7 +145,7 @@ function localize_item(&$item) {
default:
if ($obj['resource-id']) {
$post_type = t('photo');
$m = array();
$m = [];
preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1];
} else {
@ -283,7 +283,7 @@ function localize_item(&$item) {
default:
if ($obj['resource-id']) {
$post_type = t('photo');
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$m=[]; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1];
} else {
$post_type = t('status');
@ -382,7 +382,7 @@ function visible_activity($item) {
* likes (etc.) can apply to other things besides posts. Check if they are post children,
* in which case we handle them specially
*/
$hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
$hidden_activities = [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE];
foreach ($hidden_activities as $act) {
if (activity_match($item['verb'], $act)) {
return false;
@ -595,18 +595,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$_SESSION['return_url'] = $a->query_string;
}
$cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);
$cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview];
call_hooks('conversation_start',$cb);
$items = $cb['items'];
$conv_responses = array(
'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','title')),
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
);
$conv_responses = [
'like' => ['title' => t('Likes','title')], 'dislike' => ['title' => t('Dislikes','title')],
'attendyes' => ['title' => t('Attending','title')], 'attendno' => ['title' => t('Not attending','title')], 'attendmaybe' => ['title' => t('Might attend','title')]
];
// array with html for each thread (parent+comments)
$threads = array();
$threads = [];
$threadsid = -1;
$page_template = get_markup_template("conversation.tpl");
@ -620,7 +620,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$community_readonly = false;
$writable = true;
} else {
$writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN));
$writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
}
} else {
$writable = false;
@ -673,15 +673,15 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$profile_name = $item['author-link'];
}
$tags = array();
$hashtags = array();
$mentions = array();
$tags = [];
$hashtags = [];
$mentions = [];
$searchpath = System::baseUrl()."/search?tag=";
$taglist = dba::select('term', array('type', 'term', 'url'),
array("`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION),
array('order' => array('tid')));
$taglist = dba::select('term', ['type', 'term', 'url'],
["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION],
['order' => ['tid']]);
while ($tag = dba::fetch($taglist)) {
if ($tag["url"] == "") {
@ -731,7 +731,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
}
}
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
$locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
call_hooks('render_location',$locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
@ -743,12 +743,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$dropping = false;
}
$drop = array(
$drop = [
'dropping' => $dropping,
'pagedrop' => $page_dropping,
'select' => t('Select'),
'delete' => t('Delete'),
);
];
$star = false;
$isstarred = "unstarred";
@ -773,7 +773,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$item['item_network'] = $item['network'];
}
$tmp_item = array(
$tmp_item = [
'template' => $tpl,
'id' => (($preview) ? 'P0' : $item['item_id']),
'guid' => (($preview) ? 'Q0' : $item['guid']),
@ -814,18 +814,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'like' => '',
'dislike' => '',
'comment' => '',
'conv' => (($preview) ? '' : array('href'=> 'display/'.$item['guid'], 'title'=> t('View in context'))),
'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> t('View in context')]),
'previewing' => $previewing,
'wait' => t('Please wait'),
'thread_level' => 1,
);
];
$arr = array('item' => $item, 'output' => $tmp_item);
$arr = ['item' => $item, 'output' => $tmp_item];
call_hooks('display_item', $arr);
$threads[$threadsid]['id'] = $item['item_id'];
$threads[$threadsid]['network'] = $item['item_network'];
$threads[$threadsid]['items'] = array($arr['output']);
$threads[$threadsid]['items'] = [$arr['output']];
}
} else {
@ -878,12 +878,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$threads = $conv->getTemplateData($conv_responses);
if (!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
$threads = array();
$threads = [];
}
}
}
$o = replace_macros($page_template, array(
$o = replace_macros($page_template, [
'$baseurl' => System::baseUrl($ssl_state),
'$return_path' => $a->query_string,
'$live_update' => $live_update_div,
@ -892,7 +892,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'$user' => $a->user,
'$threads' => $threads,
'$dropping' => ($page_dropping && Feature::isEnabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False),
));
]);
return $o;
}
@ -910,7 +910,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
function community_add_items($parents) {
$max_comments = Config::get("system", "max_comments", 100);
$items = array();
$items = [];
foreach ($parents AS $parent) {
$thread_items = dba::p(item_query()." AND `item`.`uid` = ?
@ -932,7 +932,7 @@ function community_add_items($parents) {
}
}
if (!$parent_found) {
$comments = array();
$comments = [];
}
}
@ -1046,13 +1046,13 @@ function item_photo_menu($item) {
$contact_url = 'contacts/' . $cid;
$posts_link = 'contacts/' . $cid . '/posts';
if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA))) {
if (in_array($network, [NETWORK_DFRN, NETWORK_DIASPORA])) {
$pm_url = 'message/new/' . $cid;
}
}
if (local_user()) {
$menu = array(
$menu = [
t('Follow Thread') => $sub_link,
t('View Status') => $status_link,
t('View Profile') => $profile_link,
@ -1060,21 +1060,21 @@ function item_photo_menu($item) {
t('Network Posts') => $posts_link,
t('View Contact') => $contact_url,
t('Send PM') => $pm_url
);
];
if ($network == NETWORK_DFRN) {
$menu[t("Poke")] = $poke_link;
}
if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) &&
in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
in_array($item['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
$menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
}
} else {
$menu = array(t('View Profile') => $item['author-link']);
$menu = [t('View Profile') => $item['author-link']];
}
$args = array('item' => $item, 'menu' => $menu);
$args = ['item' => $item, 'menu' => $menu];
call_hooks('item_photo_menu', $args);
@ -1142,7 +1142,7 @@ function builtin_activity_puller($item, &$conv_responses) {
if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))
&& (is_array($conv_responses[$mode][$item['thr-parent'] . '-l'])))) {
$conv_responses[$mode][$item['thr-parent'] . '-l'] = array();
$conv_responses[$mode][$item['thr-parent'] . '-l'] = [];
}
// only list each unique author once
@ -1250,11 +1250,11 @@ function format_like($cnt, array $arr, $type, $id) {
}
$phrase .= EOL ;
$o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array(
$o .= replace_macros(get_markup_template('voting_fakelink.tpl'), [
'$phrase' => $phrase,
'$type' => $type,
'$id' => $id
));
]);
$o .= $expanded;
return $o;
@ -1264,10 +1264,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
{
$o = '';
$geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '';
$geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), []) : '';
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
$a->page['htmlhead'] .= replace_macros($tpl, [
'$newpost' => 'true',
'$baseurl' => System::baseUrl(true),
'$geotag' => $geotag,
@ -1280,10 +1280,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$fileas' => t('Save to Folder:'),
'$whereareu' => t('Where are you right now?'),
'$delitems' => t('Delete item(s)?')
));
]);
$tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array(
$a->page['end'] .= replace_macros($tpl, [
'$newpost' => 'true',
'$baseurl' => System::baseUrl(true),
'$geotag' => $geotag,
@ -1295,7 +1295,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$term' => t('Tag term:'),
'$fileas' => t('Save to Folder:'),
'$whereareu' => t('Where are you right now?')
));
]);
$jotplugins = '';
call_hooks('jot_tool', $jotplugins);
@ -1308,7 +1308,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
$query_str = $a->query_string;
if (strpos($query_str, 'public=1') !== false) {
$query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
$query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str);
}
/*
@ -1325,7 +1325,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
// $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$tpl = get_markup_template("jot.tpl");
$o .= replace_macros($tpl,array(
$o .= replace_macros($tpl,[
'$return_path' => $query_str,
'$action' => 'item',
'$share' => defaults($x, 'button', t('Share')),
@ -1379,7 +1379,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
//jot nav tab (used in some themes)
'$message' => t('Message'),
'$browser' => t('Browser'),
));
]);
if ($popup == true) {
@ -1636,9 +1636,9 @@ function render_location_dummy($item) {
/// @TODO Add type-hint
function get_responses($conv_responses, $response_verbs, $ob, $item) {
$ret = array();
$ret = [];
foreach ($response_verbs as $v) {
$ret[$v] = array();
$ret[$v] = [];
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], '');
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', '');
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');


+ 24
- 24
include/datetime.php View File

@ -102,9 +102,9 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
$options = str_replace('</select>','', $options);
$tpl = get_markup_template('field_select_raw.tpl');
return replace_macros($tpl, array(
'$field' => array($name, $label, $current, $help, $options),
));
return replace_macros($tpl, [
'$field' => [$name, $label, $current, $help, $options],
]);
}
@ -189,16 +189,16 @@ function dob($dob)
$age = ((intval($value)) ? age($value, $a->user["timezone"], $a->user["timezone"]) : "");
$o = replace_macros(get_markup_template("field_input.tpl"), array(
'$field' => array(
$o = replace_macros(get_markup_template("field_input.tpl"), [
'$field' => [
'dob',
t('Birthday:'),
$value,
(((intval($age)) > 0 ) ? t('Age: ') . $age : ""),
'',
'placeholder="' . t('YYYY-MM-DD or MM-DD') . '"'
)
));
]
]);
/// @TODO Old-lost code?
// if ($dob && $dob > '0001-01-01')
@ -279,7 +279,7 @@ function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pick
$lang = substr(get_browser_language(), 0, 2);
// Check if the detected language is supported by the picker
if (!in_array($lang, array("ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu"))) {
if (!in_array($lang, ["ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu"])) {
$lang = Config::get('system', 'language', 'en');
}
@ -327,9 +327,9 @@ function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pick
$readable_format = str_replace('i','MM',$readable_format);
$tpl = get_markup_template('field_input.tpl');
$o .= replace_macros($tpl, array(
'$field' => array($id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'),
));
$o .= replace_macros($tpl, [
'$field' => [$id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'],
]);
$o .= "<script type='text/javascript'>";
$o .= "\$(function () {var picker = \$('#id_$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
@ -368,14 +368,14 @@ function relative_date($posted_date, $format = null) {
return t('less than a second ago');
}
$a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')),
30 * 24 * 60 * 60 => array( t('month'), t('months')),
7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
24 * 60 * 60 => array( t('day'), t('days')),
60 * 60 => array( t('hour'), t('hours')),
60 => array( t('minute'), t('minutes')),
1 => array( t('second'), t('seconds'))
);
$a = [ 12 * 30 * 24 * 60 * 60 => [ t('year'), t('years')],
30 * 24 * 60 * 60 => [ t('month'), t('months')],
7 * 24 * 60 * 60 => [ t('week'), t('weeks')],
24 * 60 * 60 => [ t('day'), t('days')],
60 * 60 => [ t('hour'), t('hours')],
60 => [ t('minute'), t('minutes')],
1 => [ t('second'), t('seconds')]
];
foreach ($a as $secs => $str) {
$d = $etime / $secs;
@ -449,9 +449,9 @@ function age($dob, $owner_tz = '', $viewer_tz = '') {
*/
function get_dim($y, $m) {
$dim = array( 0,
$dim = [ 0,
31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31);
31, 31, 30, 31, 30, 31];
if ($m != 2) {
return $dim[$m];
@ -498,12 +498,12 @@ function get_first_dim($y,$m) {
function cal($y = 0, $m = 0, $links = null, $class = '')
{
// month table - start at 1 to match human usage.
$mtab = array(' ',
$mtab = [' ',
'January', 'February', 'March',
'April' , 'May' , 'June',
'July' , 'August' , 'September',
'October', 'November', 'December'
);
];
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
@ -515,7 +515,7 @@ function cal($y = 0, $m = 0, $links = null, $class = '')
$m = intval($thismonth);
}
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
$f = get_first_dim($y, $m);
$l = get_dim($y, $m);
$d = 1;


+ 20
- 20
include/dba.php View File

@ -21,7 +21,7 @@ class dba {
private static $errorno = 0;
private static $affected_rows = 0;
private static $in_transaction = false;
private static $relation = array();
private static $relation = [];
public static function connect($serveraddr, $user, $pass, $db, $install = false) {
if (!is_null(self::$db)) {
@ -157,7 +157,7 @@ class dba {
}
// Only do the explain on "select", "update" and "delete"
if (!in_array(strtolower(substr($query, 0, 6)), array("select", "update", "delete"))) {
if (!in_array(strtolower(substr($query, 0, 6)), ["select", "update", "delete"])) {
return;
}
@ -253,8 +253,8 @@ class dba {
* @return string The input SQL string modified if necessary.
*/
public static function clean_query($sql) {
$search = array("\t", "\n", "\r", " ");
$replace = array(' ', ' ', ' ', ' ');
$search = ["\t", "\n", "\r", " "];
$replace = [' ', ' ', ' ', ' '];
do {
$oldsql = $sql;
$sql = str_replace($search, $replace, $sql);
@ -324,7 +324,7 @@ class dba {
// Renumber the array keys to be sure that they fit
$i = 0;
$args = array();
$args = [];
foreach ($params AS $param) {
// Avoid problems with some MySQL servers and boolean values. See issue #3645
if (is_bool($param)) {
@ -408,7 +408,7 @@ class dba {
// There are SQL statements that cannot be executed with a prepared statement
$parts = explode(' ', $orig_sql);
$command = strtolower($parts[0]);
$can_be_prepared = in_array($command, array('select', 'update', 'insert', 'delete'));
$can_be_prepared = in_array($command, ['select', 'update', 'insert', 'delete']);
// The fallback routine is called as well when there are no arguments
if (!$can_be_prepared || (count($args) == 0)) {
@ -437,7 +437,7 @@ class dba {
}
$params = '';
$values = array();
$values = [];
foreach ($args AS $param => $value) {
if (is_int($args[$param])) {
$params .= 'i';
@ -453,7 +453,7 @@ class dba {
if (count($values) > 0) {
array_unshift($values, $params);
call_user_func_array(array($stmt, 'bind_param'), $values);
call_user_func_array([$stmt, 'bind_param'], $values);
}
if (!$stmt->execute()) {
@ -564,12 +564,12 @@ class dba {
return false;
}
$fields = array();
$fields = [];
$array_element = each($condition);
$array_key = $array_element['key'];
if (!is_int($array_key)) {
$fields = array($array_key);
$fields = [$array_key];
}
$stmt = self::select($table, $fields, $condition, ['limit' => 1]);
@ -678,14 +678,14 @@ class dba {
// This code works, but is slow
// Bind the result to a result array
$cols = array();
$cols = [];
$cols_num = array();
$cols_num = [];
for ($x = 0; $x < $stmt->field_count; $x++) {
$cols[] = &$cols_num[$x];
}
call_user_func_array(array($stmt, 'bind_result'), $cols);
call_user_func_array([$stmt, 'bind_result'], $cols);
if (!$stmt->fetch()) {
return false;
@ -697,7 +697,7 @@ class dba {
$result = $stmt->result_metadata();
$fields = $result->fetch_fields();
$columns = array();
$columns = [];
foreach ($cols_num AS $param => $col) {
$columns[$fields[$param]->name] = $col;
}