From 37b0277617e73ccb2934a6e38007f270b32162bb Mon Sep 17 00:00:00 2001 From: Bruce Bannon Date: Tue, 26 Sep 2023 11:48:00 -0600 Subject: [PATCH 1/3] example convert to + + ' + . ( empty ( $credits ) ? '' : " ', '', true, false, true ); echo ' diff --git a/day.php b/day.php index e4d9abbda..83debb516 100644 --- a/day.php +++ b/day.php @@ -64,7 +64,7 @@ } $eventinfo = ( empty ( $eventinfo ) ? '' : $eventinfo ); $trailerStr = print_trailer(); -print_header( array( 'js/popups.js/true', 'js/dblclick_add.js/true' ), +print_header ( ['js/popups.js/true', 'js/dblclick_add.js/true'], generate_refresh_meta(), '', false, false, false, false ); echo << 0 ) $query_params[] = $old_id; @@ -715,7 +714,7 @@ function sort_byday( $a, $b ) { $cat_owner = ( ( ! empty( $user ) && strlen( $user ) ) && ( $is_assistant || $is_admin ) ? $user : $login ); dbi_execute( 'DELETE FROM webcal_entry_categories WHERE cal_id = ? - AND ( cat_owner = ? OR cat_owner = "" )', array( $id, $cat_owner ) ); + AND ( cat_owner = ? OR cat_owner = "" )', [$id, $cat_owner] ); if( ! empty( $cat_id ) ) { $categories = explode( ',', $cat_id ); @@ -723,8 +722,8 @@ function sort_byday( $a, $b ) { foreach( $categories as $i ) { $j++; - $names = array( 'cal_id', 'cat_id' ); - $values = array( $id, abs( $i ) ); + $names = ['cal_id', 'cat_id']; + $values = [$id, abs( $i )]; $names[] = 'cat_owner'; $values[] = $cat_owner; @@ -762,7 +761,7 @@ function sort_byday( $a, $b ) { //$value = $$extra_name; $value = getPostValue( $extra_name ); $sql = ''; - $query_params = array(); + $query_params = []; if( strlen( $extra_name ) || $extra_type == EXTRA_DATE ) { if( $extra_type == EXTRA_CHECKBOX @@ -781,7 +780,7 @@ function sort_byday( $a, $b ) { $sql = 'INSERT INTO webcal_site_extras ( cal_id, cal_name, cal_type, cal_data ) VALUES ( ?, ?, ?, ? )'; - $query_params = array( $id, $extra_name, $extra_type, $value ); + $query_params = [$id, $extra_name, $extra_type, $value]; if( ! empty( $extra_email ) ) { $value = @@ -795,7 +794,7 @@ function sort_byday( $a, $b ) { getPostValue( $extra_name . 'day' ) ); $sql = 'INSERT INTO webcal_site_extras ( cal_id, cal_name, cal_type, cal_date ) VALUES ( ?, ?, ?, ? )'; - $query_params = array( $id, $extra_name, $extra_type, $edate ); + $query_params = [$id, $extra_name, $extra_type, $edate]; if( ! empty( $extra_email ) ) $extra_email_data .= $extra_name . ': ' . $edate . "\n"; @@ -809,7 +808,7 @@ function sort_byday( $a, $b ) { // Process reminder. if( ! dbi_execute( 'DELETE FROM webcal_reminders WHERE cal_id = ?', - array( $id ) ) ) + [$id] ) ) $error = $dberror . dbi_error(); if( $DISABLE_REMINDER_FIELD != 'Y' && $reminder == true ) { @@ -849,25 +848,25 @@ function sort_byday( $a, $b ) { if( ! dbi_execute( 'INSERT INTO webcal_reminders ( cal_id, cal_date, cal_offset, cal_related, cal_before, cal_repeats, cal_duration, cal_action, cal_last_sent, cal_times_sent ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )', - array( $id, $reminder_date, $reminder_offset, $rem_related, $rem_before, + [$id, $reminder_date, $reminder_offset, $rem_related, $rem_before, $reminder_repeats, $reminder_duration, $rem_action, $rem_last_sent, - $rem_times_sent ) ) ) + $rem_times_sent] ) ) $error = $dberror . dbi_error(); } if( empty( $error ) ) { // Clearly, we want to delete the old repeats, before inserting new... - foreach( array( + foreach ( [ 'repeats', - 'repeats_not' ) as $d ) { + 'repeats_not'] as $d ) { if( ! dbi_execute( 'DELETE FROM webcal_entry_' . $d - . ' WHERE cal_id = ?', array( $id ) ) ) + . ' WHERE cal_id = ?', [$id] ) ) $error .= $dberror . dbi_error(); } // Add repeating info. if( ! empty( $rpt_type ) && strlen( $rpt_type ) && $rpt_type != 'none' ) { - $names = array( 'cal_id', 'cal_type', 'cal_frequency' ); - $values = array( $id, $rpt_type, ( $rpt_freq ? $rpt_freq : 1 ) ); + $names = ['cal_id', 'cal_type', 'cal_frequency']; + $values = [$id, $rpt_type, ( $rpt_freq ? $rpt_freq : 1 )]; if( ! empty( $bymonth ) ) { $names[] = 'cal_bymonth'; @@ -919,8 +918,8 @@ function sort_byday( $a, $b ) { foreach( $exceptions as $i ) { if( ! dbi_execute( 'INSERT INTO webcal_entry_repeats_not ( cal_id, cal_date, cal_exdate ) VALUES ( ?, ?, ? )', - array( $id, substr( $i, 1, 8 ), - ( ( substr( $i, 0, 1 ) == '+' ) ? 0 : 1 ) ) ) ) + [$id, substr ( $i, 1, 8 ), + ( ( substr ( $i, 0, 1 ) == '+' ) ? 0 : 1 )] ) ) $error = $dberror . dbi_error(); } } //end exceptions @@ -1055,11 +1054,11 @@ function sort_byday( $a, $b ) { // on the following add... As a safety measure, delete any // existing entry with the id. Ignore the result. dbi_execute( 'DELETE FROM webcal_entry_user - WHERE cal_id = ? AND cal_login = ?', array( $id, $i ) ); + WHERE cal_id = ? AND cal_login = ?', [$id, $i] ); if( ! dbi_execute( 'INSERT INTO webcal_entry_user ( cal_id, cal_login, cal_status, cal_percent ) VALUES ( ?, ?, ?, ? )', - array( $id, $i, $status, $new_percent ) ) ) { + [$id, $i, $status, $new_percent] ) ) { $error = $dberror . dbi_error(); break; } else { @@ -1131,9 +1130,7 @@ function sort_byday( $a, $b ) { } //end for loop participants // Add external participants. - $ext_emails = - $ext_names = - $matches = array(); + $ext_emails = $ext_names = $matches = []; $ext_count = 0; $externalparticipants = getPostValue( 'externalparticipants' ); @@ -1143,7 +1140,7 @@ function sort_byday( $a, $b ) { $lines = explode( "\n", $externalparticipants ); if( ! is_array( $lines ) ) - $lines = array( $externalparticipants ); + $lines = [$externalparticipants]; if( is_array( $lines ) ) { $linecnt = count( $lines ); @@ -1151,7 +1148,7 @@ function sort_byday( $a, $b ) { $ext_words = explode( ' ', $lines[$i] ); if( ! is_array( $ext_words ) ) - $ext_words = array( $lines[$i] ); + $ext_words = [$lines[$i]]; if( is_array( $ext_words ) ) { $ext_emails[$ext_count] = @@ -1196,8 +1193,8 @@ function sort_byday( $a, $b ) { if( strlen( $ext_names[$i] ) ) { if( ! dbi_execute( 'INSERT INTO webcal_entry_ext_user ( cal_id, cal_fullname, cal_email ) VALUES ( ?, ?, ? )', - array( $id, $ext_names[$i], - ( strlen( $ext_emails[$i] ) ? $ext_emails[$i] : null ) ) ) ) + [$id, $ext_names[$i], + ( strlen ( $ext_emails[$i] ) ? $ext_emails[$i] : null )] ) ) $error = $dberror . dbi_error(); // Send mail notification if enabled. diff --git a/icons.php b/icons.php index 6f8785bf2..36c868761 100644 --- a/icons.php +++ b/icons.php @@ -8,7 +8,7 @@ if (!$can_edit) do_redirect('category.php'); -print_header(array('js/visible.php', 'js/icons.js'), '', '', true); +print_header ( ['js/visible.php', 'js/icons.js'], '', '', true ); $icons = []; diff --git a/import.php b/import.php index e4532f9f9..7e8703342 100644 --- a/import.php +++ b/import.php @@ -103,7 +103,7 @@ function print_categories() { $upload_enabled = ( ! empty( $upload ) && preg_match( '/(On|1|true|yes)/i', $upload ) ); -print_header (array('js/import.php'), '', 'onload="toggle_import();"' ); +print_header ( ['js/import.php'], '', 'onload="toggle_import();"' ); echo '

' . translate ( 'Import' ) . ' '
  . translate ( 'Help' ) . ' 1, 'css_cacher.php' => 1, 'edit_template.php' => 1, @@ -87,7 +87,7 @@ 'js_cacher.php' => 1, 'nulogin.php' => 1, 'register.php' => 1 - ); +]; /* The following array provides a way to convert a page filename into a numeric * $ACCESS_XXX number. The array key is a regular expression. If the page @@ -98,7 +98,7 @@ * @global array $GLOBAL['page_lookup'] * @name $page_lookup */ -$GLOBALS['page_lookup'] = array( +$GLOBALS['page_lookup'] = [ ACCESS_EVENT_VIEW =>'(view_entry.php|select_user.php|purge.php|category*php|doc.php)', ACCESS_EVENT_EDIT =>'(add_entry|approve_entry|del_entry|edit_entry|edit_entry_handler|help_edit_entry|reject_entry|set_entry_cat|list_unapproved|usersel|availability|datesel|catsel|docadd|docdel)', ACCESS_DAY => 'day.php', @@ -128,7 +128,7 @@ ACCESS_ANOTHER_CALENDAR => 'select_user_.*php', ACCESS_SECURITY_AUDIT => 'security_audit.*php', ACCESS_NUMBER_FUNCTIONS => '' - ); +]; /** * Is user access control enabled? @@ -238,7 +238,7 @@ function access_load_user_permissions( $useCache = true ) { // $admin_override = ( $row[1] == '__default__' && $is_admin // && ! empty( $ADMIN_OVERRIDE_UAC ) && $ADMIN_OVERRIDE_UAC == 'Y' ); $key = $row[0] . '.' . $row[1]; - $access_other_cals[$key] = array( + $access_other_cals[$key] = [ 'cal_login' => $row[0], 'cal_other_user' => $row[1], 'view' => ( $admin_override ? CAN_DOALL : $row[2] ), @@ -247,7 +247,7 @@ function access_load_user_permissions( $useCache = true ) { 'email' => ( $admin_override ? 'Y' : $row[5] ), 'invite' => ( $admin_override ? 'Y' : $row[6] ), 'time' => ( $admin_override ? 'N' : $row[7] ) - ); + ]; } dbi_free_result( $res ); return $access_other_cals; @@ -264,7 +264,7 @@ function access_load_user_permissions( $useCache = true ) { function access_get_viewable_users( $user ) { global $access_other_cals, $login; - $ret = array(); + $ret = []; if( empty( $user ) ) $user = $login; @@ -300,12 +300,12 @@ function access_load_user_functions( $user ) { return $permissions[$user]; $ret = ''; - $rets = array(); - $users = array( $user, '__default__' ); + $rets = []; + $users = [$user, '__default__']; for( $i = 0, $cnt = count( $users ); $i < $cnt && empty( $ret ); $i++ ) { $res = dbi_execute( 'SELECT cal_permissions FROM webcal_access_function - WHERE cal_login = ?', array( $users[$i] ) ); + WHERE cal_login = ?', [$users[$i]] ); if ( $res ) { if( $row = dbi_fetch_row( $res ) ) $rets[$users[$i]] = $row[0]; diff --git a/includes/classes/CommentList.php b/includes/classes/CommentList.php index b234495ee..e96c42ca3 100644 --- a/includes/classes/CommentList.php +++ b/includes/classes/CommentList.php @@ -8,23 +8,19 @@ * @package WebCalendar * @subpackage Doc */ - /** * A list of Doc comment objects. */ class CommentList extends DocList { - /** - * Creates a new attachment list for the specified event. + * __construct * - * @param int $event_id The event id - * @return AttachmentList The new AttachmentList object + * @param int $event_id + * @return CommentList The new object for the specified event. * @access public */ - function __construct ( $event_id ) - { + function __construct ( $event_id ) { parent::__construct ( $event_id, 'C' ); } - } ?> diff --git a/includes/classes/DocList.php b/includes/classes/DocList.php index 1820b33e4..80da8e867 100644 --- a/includes/classes/DocList.php +++ b/includes/classes/DocList.php @@ -53,7 +53,7 @@ function __construct ( $event_id, $type ) { $this->_event_id = $event_id; $this->_type = $type; - $this->_arr = array(); + $this->_arr = []; if ( $type != 'A' && $type != 'C' ) die_miserable_death ( "Invalid DocList type '$type'" ); diff --git a/includes/classes/WebCalendar.php b/includes/classes/WebCalendar.php index ab8aa5c90..cd628e052 100644 --- a/includes/classes/WebCalendar.php +++ b/includes/classes/WebCalendar.php @@ -72,7 +72,7 @@ class WebCalendar { ['InitFirstPhase', 'Config', 'PHPDBI', 'Functions'], ['User', 'Validate', 'Connect', 'SiteExtras', 'Access', 'InitSecondPhase']]]; // Provide translation of translation file (trimming the ".txt" to the proper value for mb_language) - private $mb_language_map = array( + private $mb_language_map = [ 'Arabic_utf8' => 'Arabic', 'Chinese-Big5' => 'Chinese', 'Chinese-GB2312' => 'Chinese', @@ -86,8 +86,8 @@ class WebCalendar { 'Russian' => 'Russian', 'Russian_utf8' => 'Russian', 'Spanish' => 'Spanish', - ); - + ]; + /** * WebCalendar constructor. * diff --git a/includes/config.php b/includes/config.php index a50c54d99..f6cfc0708 100644 --- a/includes/config.php +++ b/includes/config.php @@ -254,7 +254,7 @@ function do_config() ) dbi_set_debug(true); - foreach (array('db_type', 'db_host', 'db_login') as $s) { + foreach ( ['db_type', 'db_host', 'db_login'] as $s) { if (empty($settings[$s])) die_miserable_death(str_replace( 'XXX', diff --git a/includes/date_formats.php b/includes/date_formats.php index 35782805d..c485467de 100644 --- a/includes/date_formats.php +++ b/includes/date_formats.php @@ -33,7 +33,7 @@ $DecStr = translate ( 'Dec' ); $datestyles = $datestyles_md = $datestyles_my = $datestyles_task = -array ( 'LANGUAGE_DEFINED', translate ( 'LANGUAGE DEFINED' ) ); + ['LANGUAGE_DEFINED', translate ( 'LANGUAGE DEFINED' )]; // Day Month Year format $datestyles += [ diff --git a/includes/dbi4php.php b/includes/dbi4php.php index 7af4bdc47..3716d9672 100644 --- a/includes/dbi4php.php +++ b/includes/dbi4php.php @@ -83,7 +83,7 @@ function dbi_connect( $host, $login, $password, $database, $lazy = true ) { $db_query_count = 0; if( ! isset( $db_connection_info ) ) - $db_connection_info = array(); + $db_connection_info = []; $db_connection_info['connected'] = false; $db_connection_info['connection'] = 0; @@ -331,7 +331,7 @@ function dbi_query( $sql, $fatalOnError = true, $showError = true ) { global $c, $db_connection_info, $db_query_count, $phpdbiVerbose, $SQLLOG; if( ! isset( $SQLLOG ) && ! empty( $db_connection_info['debug'] ) ) - $SQLLOG = array(); + $SQLLOG = []; if( ! empty( $db_connection_info['debug'] ) ) $SQLLOG[] = $sql; @@ -518,8 +518,8 @@ function dbi_affected_rows( $conn, $res ) { function dbi_update_blob( $table, $column, $key, $data ) { global $unavail_DBI_Update_blob, $db_connection_info; - $unavail_DBI_Update_blob = str_replace( array( 'XXX', 'YYY' ), - array( '"dbi_update_blob"', $GLOBALS['db_type'] ), + $unavail_DBI_Update_blob = str_replace ( ['XXX', 'YYY'], + ['dbi_update_blob', $GLOBALS['db_type']], translate( 'Unfortunately, XXX is not implemented for YYY' ) ); assert( ! empty( $table ) ); @@ -773,7 +773,7 @@ function dbi_escape_string( $string ) { * to the {@link dbi_fetch_row()} function to obtain the * results), or true/false on insert or delete queries. */ -function dbi_execute( $sql, $params = array(), $fatalOnError = true, +function dbi_execute ( $sql, $params = [], $fatalOnError = true, $showError = true ) { if( count( $params ) == 0 ) @@ -801,7 +801,7 @@ function dbi_execute( $sql, $params = array(), $fatalOnError = true, * Anything other than that will clear out the entire cache * (until we add more intelligent caching logic). */ -function dbi_get_cached_rows( $sql, $params = array(), +function dbi_get_cached_rows ( $sql, $params = [], $fatalOnError = true, $showError = true ) { global $db_cache_count, $db_connection_info; $file = ''; @@ -824,7 +824,7 @@ function dbi_get_cached_rows( $sql, $params = array(), $res = dbi_execute( $sql, $params, $fatalOnError, $showError ); if( $res ) { - $rows = array(); + $rows = []; while( $row = dbi_fetch_row( $res ) ) { $rows[] = $row; } @@ -856,7 +856,7 @@ function dbi_init_cache( $dir ) { global $db_connection_info; if( ! isset( $db_connection_info ) ) - $db_connection_info = array(); + $db_connection_info = []; $db_connection_info['cachedir'] = $dir; } @@ -869,7 +869,7 @@ function dbi_set_debug( $status = false ) { global $db_connection_info; if( ! isset( $db_connection_info ) ) - $db_connection_info = array(); + $db_connection_info = []; $db_connection_info['debug'] = $status; } @@ -913,8 +913,8 @@ function dbi_clear_cache() { if( ! @unlink( $fullpath ) ) { $errcnt++; - $errstr .= '\n"; // TODO: log this somewhere??? } diff --git a/includes/formvars.php b/includes/formvars.php index 29df006c9..30cc44db2 100644 --- a/includes/formvars.php +++ b/includes/formvars.php @@ -266,7 +266,7 @@ function chkXSS($name) { return ''; $cleanXSS = true; //add more array elements as needed - foreach (array( 'Ajax.Request', 'onerror') as $i) { + foreach ( ['Ajax.Request', 'onerror'] as $i) { if (preg_match("/$i/i", $name)) { activity_log(0, $login, $login, SECURITY_VIOLATION, 'Hijack attempt:' . $i); $cleanXSS = false; diff --git a/includes/help_list.php b/includes/help_list.php index 191aeba89..1a5306e8a 100644 --- a/includes/help_list.php +++ b/includes/help_list.php @@ -6,7 +6,7 @@ */ defined ( '_ISVALID' ) or ( 'You cannot access this file directly!' ); // DO NOT DELETE translate ( 'Index' ) translate ( 'Documentation' ) -$help_list = array(); +$help_list = []; $help_list['Index'] = 'help_index.php'; $can_add = true; diff --git a/includes/init.php b/includes/init.php index c7c71ed9f..d5fc235ee 100644 --- a/includes/init.php +++ b/includes/init.php @@ -182,8 +182,8 @@ function print_header( $includes = '', $HeadX = '', $BodyX = '', // non-empty, including this as a normal stylesheet so they can see how it // will look when printed. This maintains backwards-compatibility for browsers // that don't support media="print" stylesheets. - $cs_ar = array( 'css/styles.css', 'css/print_styles.css' ); - $js_ar = array(); + $cs_ar = ['css/styles.css', 'css/print_styles.css']; + $js_ar = []; $ret = send_doctype( $appStr ); // Use "punctuation.css" to start getting punctuation out of the code to where the translators can get at it. diff --git a/includes/js/popups.js b/includes/js/popups.js index 1f9eb0f22..8c35070c2 100644 --- a/includes/js/popups.js +++ b/includes/js/popups.js @@ -59,12 +59,12 @@ if( typeof document.getElementsBySelector == 'undefined' ) { document.getElementsBySelector = function( selector ) { // Attempt to fail gracefully in lesser browsers. if( ! document.getElementsByTagName ) - return new Array(); + return []; // Split selector in to tokens. var tokens = selector.split( ' ' ), - currentContext = new Array( document ); + currentContext = [document]; for( var i = 0; i < tokens.length; i++ ) { token = tokens[i].replace( /^\s+/,'' ).replace( /\s+$/,'' ); @@ -79,10 +79,10 @@ if( typeof document.getElementsBySelector == 'undefined' ) { if( tagName && element.nodeName.toLowerCase() != tagName ) { // Tag with that ID not found, return false. - return new Array(); + return []; } // Set currentContext to contain just this element. - currentContext = new Array( element ); + currentContext = [element]; continue; // Skip to next token. } if( token.indexOf( '.' ) > -1 ) { diff --git a/includes/js/translate.js.php b/includes/js/translate.js.php index ccf7ca755..deb72ab04 100644 --- a/includes/js/translate.js.php +++ b/includes/js/translate.js.php @@ -6,7 +6,7 @@ $tmp1 = $tmp2 = ''; -foreach( array( 'SU','MO','TU','WE','TH','FR','SA' ) as $b ) { +foreach ( ['SU','MO','TU','WE','TH','FR','SA'] as $b ) { $tmp1 .= '\'' . $b . '\','; $tmp2 .= '\'' . translate( $b ) . '\','; } diff --git a/includes/js/usersel.php b/includes/js/usersel.php index 35c94903e..b5e479639 100644 --- a/includes/js/usersel.php +++ b/includes/js/usersel.php @@ -29,7 +29,7 @@ function OkButton() { echo $form . '.elements[' . $listid?>], thislist = document.userselform.elements[0], // Store current selections. - tmp = new Array(); + tmp = []; for ( i = 0; i < thislist.length; i++ ) { if ( thislist.options[i].selected ) @@ -75,7 +75,7 @@ function toggleGroup( state ) { echo ' if ( selNum == ' . $i . ' ) {'; $res = dbi_execute( 'SELECT cal_login from webcal_group_user - WHERE cal_group_id = ?', array( $groups[$i]['cal_group_id'] ) ); + WHERE cal_group_id = ?', [$groups[$i]['cal_group_id']] ); if ( $res ) { while ( $row = dbi_fetch_row( $res ) ) { diff --git a/includes/js/util.js b/includes/js/util.js index e13c26b21..7864961dd 100644 --- a/includes/js/util.js +++ b/includes/js/util.js @@ -60,11 +60,11 @@ function getAllChildren(e) { document.getElementsBySelector = function(selector) { // Attempt to fail gracefully in lesser browsers if (!document.getElementsByTagName) { - return new Array(); + return []; } // Split selector in to tokens var tokens = selector.split(' '); - var currentContext = new Array(document); + var currentContext = [document]; for (var i = 0; i < tokens.length; i++) { token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,''); if (token.indexOf('#') > -1) { @@ -75,10 +75,10 @@ document.getElementsBySelector = function(selector) { var element = document.getElementById(id); if (tagName && element.nodeName.toLowerCase() != tagName) { // tag with that ID not found, return false - return new Array(); + return []; } // Set currentContext to contain just this element - currentContext = new Array(element); + currentContext = [element]; continue; // Skip to next token } if (token.indexOf('.') > -1) { @@ -90,7 +90,7 @@ document.getElementsBySelector = function(selector) { tagName = '*'; } // Get elements matching tag, filter them for class selector - var found = new Array; + var found = []; var foundCount = 0; for (var h = 0; h < currentContext.length; h++) { var elements; @@ -103,7 +103,7 @@ document.getElementsBySelector = function(selector) { found[foundCount++] = elements[j]; } } - currentContext = new Array; + currentContext = []; var currentContextIndex = 0; for (var k = 0; k < found.length; k++) { if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) { @@ -122,7 +122,7 @@ document.getElementsBySelector = function(selector) { tagName = '*'; } // Grab all of the tagName elements within current context - var found = new Array; + var found = []; var foundCount = 0; for (var h = 0; h < currentContext.length; h++) { var elements; @@ -135,7 +135,7 @@ document.getElementsBySelector = function(selector) { found[foundCount++] = elements[j]; } } - currentContext = new Array; + currentContext = []; var currentContextIndex = 0; var checkFunction; // This function will be used to filter the elements switch (attrOperator) { @@ -161,7 +161,7 @@ document.getElementsBySelector = function(selector) { // Just test for existence of attribute checkFunction = function(e) { return e.getAttribute(attrName); }; } - currentContext = new Array; + currentContext = []; var currentContextIndex = 0; for (var k = 0; k < found.length; k++) { if (checkFunction(found[k])) { @@ -173,7 +173,7 @@ document.getElementsBySelector = function(selector) { } // If we get here, token is JUST an element (not a class or ID selector) tagName = token; - var found = new Array; + var found = []; var foundCount = 0; for (var h = 0; h < currentContext.length; h++) { var elements = currentContext[h].getElementsByTagName(tagName); diff --git a/includes/menu.php b/includes/menu.php index 6bf0363c5..cc7a80149 100644 --- a/includes/menu.php +++ b/includes/menu.php @@ -161,7 +161,7 @@ if ($rows) { for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) { $row = $rows[$i]; - $tmp = array(); + $tmp = []; $tmp['name'] = htmlspecialchars($row[0], ENT_QUOTES); $tmp['url'] = 'report.php?report_id=' . $row[1] . $u_url; $reports_link[] = $tmp; @@ -246,7 +246,7 @@ // Year does not show events, so you cannot manage someone's cal. } $xurl = str_replace('&', '&', $xurl); - $tmp = array(); + $tmp = []; $tmp['name'] = $f; $tmp['url'] = $xurl; $groups[] = $tmp; diff --git a/includes/validate.php b/includes/validate.php index ee6e901e4..d18a5413c 100644 --- a/includes/validate.php +++ b/includes/validate.php @@ -13,7 +13,7 @@ function doDbSanityCheck() { WebCalendar System Administrator\'s Guide?'; $res = @dbi_execute ( 'SELECT COUNT( cal_value ) FROM webcal_config', - array(), false, false ); + [], false, false ); if ( $res ) { if ( $row = dbi_fetch_row ( $res ) ) // Found database. All is peachy. diff --git a/install/default_config.php b/install/default_config.php index 071b72591..cccfbc6ea 100644 --- a/install/default_config.php +++ b/install/default_config.php @@ -3,7 +3,7 @@ * The file contains a listing of all the current WebCalendar config settings * and their default values. */ -$webcalConfig = array( +$webcalConfig = [ 'ADD_LINK_IN_VIEWS' => 'N', 'ADMIN_OVERRIDE_UAC' => 'Y', 'ALLOW_ATTACH' => 'N', @@ -160,7 +160,7 @@ 'WEEKNUMBER' => '#f06030', 'WORK_DAY_END_HOUR' => '17', 'WORK_DAY_START_HOUR' => '8' - ); +]; /** * db_load_config (needs description) @@ -176,14 +176,14 @@ function db_load_config() { foreach ($webcalConfig as $key => $val) { $res = dbi_execute( 'SELECT cal_value FROM webcal_config - WHERE cal_setting = ?', array( $key ), false, false ); + WHERE cal_setting = ?', [$key], false, false ); if( ! $res ) { - dbi_execute( $sql, array( $key, $val ) ); + dbi_execute( $sql, [$key, $val] ); } else { // SQLite returns $res always. $row = dbi_fetch_row( $res ); if( ! isset( $row[0] ) ) - dbi_execute( $sql, array( $key, $val ) ); + dbi_execute( $sql, [$key, $val] ); dbi_free_result( $res ); } diff --git a/install/headless.php b/install/headless.php index 50ab417b7..dfc8c9576 100644 --- a/install/headless.php +++ b/install/headless.php @@ -1,7 +1,7 @@ ' . "\n"; } else { @@ -523,7 +522,7 @@ } elseif( $db_type == 'mysql' ) { $c = dbi_connect( $db_host, $db_login, $db_password, 'mysql', false ); if( $c ) { - dbi_execute( $sql . ';', array(), false, $show_all_errors ); + dbi_execute ( $sql . ';', [], false, $show_all_errors ); if( ! @mysql_select_db( $db_database ) ) $response_msg = $failure . dbi_error() . '' . "\n"; else { @@ -535,7 +534,7 @@ } elseif( $db_type == 'mysqli' ) { $c = dbi_connect( $db_host, $db_login, $db_password, '', false ); if( $c ) { - dbi_execute( $sql . ';', array(), false, $show_all_errors ); + dbi_execute ( $sql . ';', [], false, $show_all_errors ); if( ! $c->select_db($db_database ) ) $response_msg = $failure . dbi_error() . '' . "\n"; else { @@ -547,7 +546,7 @@ } elseif( $db_type == 'postgresql' ) { $c = dbi_connect( $db_host, $db_login, $db_password, 'template1', false ); if( $c ) { - dbi_execute( $sql, array(), false, $show_all_errors ); + dbi_execute( $sql, [], false, $show_all_errors ); $_SESSION['db_noexist'] = false; } else $response_msg = $failure . dbi_error() . '' . "\n"; @@ -725,14 +724,14 @@ dbi_execute( 'INSERT INTO webcal_config ( cal_setting, cal_value ) VALUES ( \'APPLICATION_NAME\', ? )', - array($_SESSION['application_name']) + [$_SESSION['application_name']] ); } if (isset($_SESSION['server_url'])) { dbi_execute('DELETE FROM webcal_config WHERE cal_setting = \'SERVER_URL\''); dbi_execute('INSERT INTO webcal_config ( cal_setting, cal_value ) - VALUES ( \'SERVER_URL\', ? )', array($_SESSION['server_url'])); + VALUES ( "SERVER_URL", ? )', [$_SESSION['server_url']] ); } } $do_load_admin = getPostValue('load_admin'); @@ -1224,7 +1223,7 @@ function chkPassword() {