Skip to content

Commit

Permalink
Merge branch 'craigk5n:master' into documentors
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannon authored Oct 2, 2023
2 parents 064961f + 549439d commit 40b1a0f
Show file tree
Hide file tree
Showing 50 changed files with 221 additions and 214 deletions.
62 changes: 39 additions & 23 deletions about.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
<?php
/**
* About WebCalendar
*
* Acknowledge contributors.
*
* @package WebCalendar
*/
/**
* Include the basics.
*
* // Required to end the page docBlock without getting errors..
*/
require_once 'includes/init.php';

$credits = getPostValue( 'Credits' );
$credits = getPostValue ( 'Credits' );
static $data;

if ( empty( $data ) ) {
// Read in and format AUTHORS file.
if ( empty ( $data ) ) {
// Read in and format AUTHORS file.
$data = file_get_contents ( 'AUTHORS' );
$patterns = array ();
$replacements = array ();
$patterns[0] = "/\r\n|\n/";
$replacements[0] = "<br>";
$patterns = $replacements = [];
$patterns[] = "/\r\n|\n/";
$replacements[] = '<br>';
// Strip email addresses out
$patterns[1] = "<\S*@\S*>";
$replacements[1] = "";
$patterns[] = "<\S*@\S*>";
$replacements[] = '';
$data = preg_replace ( $patterns, $replacements, $data );
}
print_header ( [], '<link href="includes/css/about.css" rel="stylesheet">',
'', true, false, true );
echo ' <div id="creds">' . ( empty( $credits ) ? '
<a title="' . $PROGRAM_NAME . '" href="' . $PROGRAM_URL
. '" target="_blank">
<h2>' . translate( 'Title' ) . '</h2>
<p>' . str_replace( 'XXX', $PROGRAM_VERSION,
translate( 'version XXX' ) ) . '<br>' . $PROGRAM_DATE . '</p></a>
echo ' <div id="creds">'
. ( empty ( $credits ) ? '
<a href="' . $PROGRAM_URL
. '" target="_blank" title="' . $PROGRAM_NAME . '">
<h2>' . translate ( 'Title' ) . '</h2>
<p>' . str_replace ( 'XXX', $PROGRAM_VERSION,
translate ( 'version XXX' ) ) . '<br>' . $PROGRAM_DATE . '</p></a>
<br>
<p>' . translate( 'WebCalendar is a PHP application used...' ) . '</p>' : '' ) . '
<p>' . translate ( 'WebCalendar is a PHP application used...' ) . '</p>' : '' ) . '
</div>
<form action="about.php" name="aboutform" id="aboutform" method="post">';
<form id="aboutform" name="aboutform" action="about.php" method="post">';
print_form_key();
echo '<input type="submit" name="' . ( empty( $credits )
? 'Credits" value="' . translate( 'Credits' )
: 'About" value="' . translate( 'About' ) ) . '">
<input type="button" id="ok" name="ok" value="' . translate( 'OK' )
. '" onclick="window.close()">
</form>' . ( empty ( $credits ) ? '' : "
echo '
<button type="submit" name="'
. ( empty ( $credits )
? 'Credits">' . translate ( 'Credits' )
: 'About">' . translate ( 'About' ) )
. '</button>
<button id="ok" name="ok" type="button" onclick="window.close()">'
. translate ( 'OK' ) . '</button>
</form>'
. ( empty ( $credits ) ? '' : "
<script src=\"includes/js/v_h_scrolls.js\"></script>
<script>
function start() {
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
Loading

0 comments on commit 40b1a0f

Please sign in to comment.