Skip to content

Commit

Permalink
Merge pull request #424 from bbannon/master
Browse files Browse the repository at this point in the history
convert to short arrays
  • Loading branch information
craigk5n authored Oct 2, 2023
2 parents f632671 + 9df365c commit 36f582a
Show file tree
Hide file tree
Showing 50 changed files with 183 additions and 193 deletions.
3 changes: 1 addition & 2 deletions about.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
if ( empty( $data ) ) {
// Read in and format AUTHORS file.
$data = file_get_contents ( 'AUTHORS' );
$patterns = array ();
$replacements = array ();
$patterns = $replacements = [];
$patterns[0] = "/\r\n|\n/";
$replacements[0] = "<br>";
// Strip email addresses out
Expand Down
2 changes: 1 addition & 1 deletion adminhome.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$accessEnabled = access_is_enabled();
$assistStr = translate ( 'Assistants' );
$prefStr = translate ( 'Preferences' );
$names = $links = array();
$links = $names = [];
/* Disabled for now...will move to menu when working properly
if ( $is_admin && ! empty ( $SERVER_URL ) &&
access_can_access_function ( ACCESS_SYSTEM_SETTINGS ) ) {
Expand Down
4 changes: 2 additions & 2 deletions availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
}

print_header (
array ( 'js/availability.php/false/' . "$month/$day/$year/"
. getGetValue ( 'form' ) ), '', 'onload="focus();"', true, false, true );
['js/availability.php/false/' . "$month/$day/$year/"
. getGetValue ( 'form' )], '', 'onload="focus();"', true, false, true );

$next_url = $prev_url = '?users=' . $users;
$time = mktime ( 0, 0, 0, $month, $day, $year );
Expand Down
2 changes: 1 addition & 1 deletion category.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
$showIconStyle = ( ! empty ( $catIcon ) && file_exists ( $catIcon )
? '' : 'display: none;' );

print_header ( array ( 'js/visible.php' ) );
print_header ( ['js/visible.php'] );
echo '
<h2>' . translate ( 'Categories' ) . '</h2>
' . display_admin_link( false );
Expand Down
2 changes: 1 addition & 1 deletion catsel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if ( strlen ( $entryCatStr ) < 30 )
$entryCatStr = $entryCatFiller . $entryCatStr . $entryCatFiller;

print_header( array( 'js/catsel.php/false/' . $form ),
print_header ( ['js/catsel.php/false/' . $form],
'<script type=text/javascript" src="includes/js/catsel.js"></script>',
'', true, false, true );
echo '
Expand Down
2 changes: 1 addition & 1 deletion day.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<<EOT
Expand Down
4 changes: 2 additions & 2 deletions edit_entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function time_selection($prefix, $time = '', $trigger = false)
}

$BodyX = 'onload="onLoad();"';
$INC = array('js/translate.js.php', 'js/edit_entry.php/false/' . $user, 'js/visible.php');
$INC = ['js/translate.js.php', 'js/edit_entry.php/false/' . $user, 'js/visible.php'];
$textareasize = ($ALLOW_HTML_DESCRIPTION === 'Y' ? '20' : '15');

// Add Modal Dialog javascript/CSS
Expand Down Expand Up @@ -394,7 +394,7 @@ function time_selection($prefix, $time = '', $trigger = false)
$hour = $time = -1;

$defusers = getGetValue('defusers');
$defusers_ar = array();
$defusers_ar = [];
if (!empty($defusers)) {
$defusers_ar = explode(',', $defusers);
for ($i = 0, $cnt = count($defusers_ar); $i < $cnt; $i++) {
Expand Down
75 changes: 36 additions & 39 deletions edit_entry_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function sort_byday( $a, $b ) {
$old_id = $id;
}

$old_status = array();
$old_status = [];

// Pass all string values through getPostValue.
$access = getPostValue( 'access' );
Expand Down Expand Up @@ -177,7 +177,7 @@ function sort_byday( $a, $b ) {
// site (possibly a malware site). This could be from a public submission
// on an event calendar, and the admin gets sent to the malware site when
// viewing the event to approve/reject it.
foreach( array(
foreach ( [
'APPLET',
'BODY',
'HEAD',
Expand All @@ -186,7 +186,7 @@ function sort_byday( $a, $b ) {
'META',
'OBJECT',
'SCRIPT',
'TITLE' ) as $i ) {
'TITLE'] as $i ) {
if( preg_match( "/<\s*$i/i", $description ) ) {
$error = translate( 'Security violation!' );
activity_log( 0, $login, $login, SECURITY_VIOLATION, 'Hijack attempt:edit_entry' );
Expand Down Expand Up @@ -374,7 +374,7 @@ function sort_byday( $a, $b ) {
} else {
// Event owner or assistant?
$res = dbi_execute( 'SELECT cal_create_by FROM webcal_entry WHERE cal_id = ?',
array( $id ) );
[$id] );

if( $res ) {
$row = dbi_fetch_row( $res );
Expand All @@ -398,7 +398,7 @@ function sort_byday( $a, $b ) {
// Is user a participant of the event?
$res = dbi_execute( 'SELECT cal_id FROM webcal_entry_user WHERE cal_id = ?
AND cal_login = ? AND cal_status IN( \'W\', \'A\' )',
array( $id, $login ) );
[$id, $login] );

if( $res ) {
$row = dbi_fetch_row( $res );
Expand Down Expand Up @@ -517,11 +517,10 @@ function sort_byday( $a, $b ) {
mktime( $rpt_hour, $rpt_minute, 0, $rpt_month, $rpt_day, $rpt_year );
}

$exception_list =
$inclusion_list = array();
$exception_list = $inclusion_list = [];

if(empty( $exceptions ) || !is_array($exceptions))
$exceptions = array();
$exceptions = [];
else {
foreach( $exceptions as $i ) {
if( substr( $i, 0, 1 ) == '+' )
Expand Down Expand Up @@ -609,7 +608,7 @@ function sort_byday( $a, $b ) {
$newevent = false;
// Save old values of participants.
$res = dbi_execute( 'SELECT cal_login, cal_status, cal_percent
FROM webcal_entry_user WHERE cal_id = ? ', array( $id ) );
FROM webcal_entry_user WHERE cal_id = ? ', [$id] );

if( $res ) {
for( $i = 0; $tmprow = dbi_fetch_row( $res ); $i++ ) {
Expand All @@ -621,14 +620,14 @@ function sort_byday( $a, $b ) {
$error = $dberror . dbi_error();

if( empty( $error ) ) {
foreach( array(
foreach ( [
'entry',
'entry_ext_user',
'entry_repeats',
'entry_user',
'site_extras' ) as $d ) {
'site_extras'] as $d ) {
dbi_execute( 'DELETE FROM webcal_' . $d . ' WHERE cal_id = ?',
array( $id ) );
[$id] );
}
}
$newevent = false;
Expand All @@ -637,11 +636,11 @@ function sort_byday( $a, $b ) {
if( $do_override ) {
if( ! dbi_execute( 'INSERT INTO webcal_entry_repeats_not
( cal_id, cal_date, cal_exdate ) VALUES ( ?, ?, ? )',
array( $old_id, $override_date, 1 ) ) )
[$old_id, $override_date, 1] ) )
$error = $dberror . dbi_error();
}

$query_params = array( $id );
$query_params = [$id];

if( $old_id > 0 )
$query_params[] = $old_id;
Expand Down Expand Up @@ -715,16 +714,16 @@ 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 );
$j = 0;
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;
Expand Down Expand Up @@ -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
Expand All @@ -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 =
Expand All @@ -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";
Expand All @@ -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 ) {
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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' );

Expand All @@ -1143,15 +1140,15 @@ 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 );
for( $i = 0; $i < $linecnt; $i++ ) {
$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] =
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down
2 changes: 1 addition & 1 deletion import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<h2>' . translate ( 'Import' ) . '&nbsp;<img src="images/bootstrap-icons/question-circle-fill.svg" alt="'
. translate ( 'Help' ) . '" class="help" onclick="window.open( '
. "'help_import.php', 'cal_help', '"
Expand Down
Loading

0 comments on commit 36f582a

Please sign in to comment.