Skip to content

Commit

Permalink
Merge branch 'craigk5n:master' into cmpsr
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannon authored Aug 31, 2024
2 parents f3aa923 + 2214b37 commit aef0060
Show file tree
Hide file tree
Showing 140 changed files with 167,410 additions and 559 deletions.
50 changes: 28 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Makefile for copying files downloaded using composer into the proper location
# for use with WebCalendar.
# Makefile for copying files downloaded using composer
# into the proper location for use with WebCalendar.
# We only copy the min number of files required from the vendor directory.
# Also, compute the SHA hash to use with the integrity tag.
# We don't want WebCalendar releases to bundle every single file in the vendor directory.
# We don't want WebCalendar releases to bundle
# every single file in the vendor directory.
#
# Also, composer dependency management sucks at asset management.
#
# NOTE: This Makefile does not work on macos, just linux. This is because there is
# no sha384sum command on macos. If you're on a Mac, you can use docker to setup
# a linux container where (after installing xdd), you can run make to generate the
# sha files.
# NOTE: This Makefile does not work on macos, just linux.
# This is because there is no sha384sum command on macos.
# If you're on a Mac, you can use docker to setup
# a linux container where (after installing xdd),
# you can run make to generate the sha files.

PHPMAILER_DIR = includes/classes/phpmailer
PHPMAILER_VENDOR_DIR = vendor/phpmailer/phpmailer/src
Expand Down Expand Up @@ -130,7 +133,7 @@ includes/load_assets.php: \
pub/jquery.min.js \
pub/jquery.min.js.sha
echo '<?php' > $@
echo '// Auto-generated by make. Do not hand-edit.' >> $@
echo '// Auto-generated by make. Do not hand-edit.' >> $@
echo '// See Makefile in source for details..' >> $@
echo '// Last updated: ' | tr -d '\012' >> $@
date >> $@
Expand Down Expand Up @@ -169,20 +172,24 @@ pub/jquery.min.js.sha: pub/jquery.min.js $(SHA384SUM)
# To get the list of files we need for the "basic" install of ckeditor,
# I downloaded the "basic package" from the website:
# https://ckeditor.com/ckeditor-4/download
# Then I looked at what was included to make the list of files we need
# to copy over from the vendor/ckeditor directory (which includes
# enough for the "full package" of 72 plugins and adds about 15Mb instead
# of the 2Mb for basic.
# To create this list from the unzipped ckeditor download, cd into the unzipped
# 'ckeditor' dir and use this command:
# Then I looked at what was included to make the list of files
# we need to copy over from the 'vendor/ckeditor' directory
# (which includes enough for the "full package" of 72 plugins
# and adds about 15Mb instead of the 2Mb for basic).
# To create this list from the unzipped ckeditor download,
# cd into the unzipped 'ckeditor' dir and use this command:
#
# find * -type f | grep -v samples | grep -v config.js | grep -v 'adapters/' | sed 's/^/\t/' | sed 's/$/ \\/' | sed 's/promise.js ./promise.js/'
# NOTE: We do not include the config.js provides by composer because it defaults to
# the full ckeditor distribution with all plugins (15+ Mb). Instead, I've downloaed
# the config.js from the 4.18 basic build and copied it manually into pub/ckeditor.
# It's possible we may need to update the pub/ckeditor/config.js file manually if
# a new 4.X release requires updates to this file.
# NOTE #2: This Makefile is assuming that the README.md file gets updated with
# each CKEditor update (seems like a safe assumption.)
#
# NOTE: We do not include the 'config.js' provided by composer
# because it defaults to the full ckeditor distribution
# with all plugins (15+ Mb).
# Instead, I've downloaded the 'config.js' from the 4.18 basic build
# and copied it manually into pub/ckeditor.
# It's possible we may need to update the 'pub/ckeditor/config.js' file
# manually if a new 4.X release requires updates to this file.
# NOTE #2: This Makefile is assuming that the 'README.md' file gets
# updated with each CKEditor update (seems like a safe assumption)
CKEDITOR_FILES = \
pub/ckeditor/CHANGES.md \
pub/ckeditor/LICENSE.md \
Expand Down Expand Up @@ -305,4 +312,3 @@ pub/ckeditor/CHANGES.md: $(CKEDITOR_VENDOR_DIR)/ckeditor/CHANGES.md
echo "Copying file: $${f}"; \
cp $${a} $${f}; \
done

6 changes: 3 additions & 3 deletions about.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
$replacements[] = '';
$data = preg_replace ( $patterns, $replacements, $data );
}
print_header ( [], '<link href="includes/css/about.css" rel="stylesheet">',
'', true, false, true );
echo ' <div id="creds">'
print_header ( ['css/about.css'], '', '', true, false, true );
echo '
<div id="creds">'
. ( empty ( $credits ) ? '
<a href="' . $PROGRAM_URL
. '" target="_blank" title="' . $PROGRAM_NAME . '">
Expand Down
7 changes: 2 additions & 5 deletions access.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@
}
}
}
print_header( '',
'<script src="includes/js/access.js?'
. filemtime( 'includes/js/access.js' ) . '"></script>
<link href="includes/css/access.css?'
. filemtime( 'includes/css/access.css' ) . '" rel="stylesheet">',

print_header ( ['css/access.css', 'js/access.js'], '',
( ! empty( $op['time'] ) && $op['time'] == 'Y'
? 'onload="enableAll( true );"' : '' ) );

Expand Down
6 changes: 2 additions & 4 deletions activity_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
<div class="navigation">'
// Go BACK in time.
. ( ! empty ( $nextpage ) ? '
<a title="' . $prevStr . '&nbsp;' . $PAGE_SIZE . '&nbsp;' . $eventsStr
. '" class="prev" href="activity_log.php?startid=' . $nextpage
<a class="prev" href="activity_log.php?startid=' . $nextpage
. ( $sys ? '&amp;system=1' : '' ) . '">' . $prevStr . '&nbsp;' . $PAGE_SIZE
. '&nbsp;' . $eventsStr . '</a>' : '' );

Expand All @@ -46,8 +45,7 @@
if ( $row = dbi_fetch_row ( $res ) )
// Go FORWARD in time.
echo '
<a title="' . $nextStr . '&nbsp;' . $PAGE_SIZE . '&nbsp;' . $eventsStr
. '" class="next" href="activity_log.php' . ( $row[0] <= $previd
<a class="next" href="activity_log.php' . ( $row[0] <= $previd
? ( $sys ? '?system=1' : '' )
: '?startid=' . $previd . ( $sys ? '&amp;system=1' : '' ) ) . '">'
. $nextStr . '&nbsp;' . $PAGE_SIZE . '&nbsp;' . $eventsStr . '</a><br>';
Expand Down
60 changes: 15 additions & 45 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,7 @@ function save_pref ( $prefs, $src ) {
// Make sure globals values passed to styles.php are for this user.
// Makes the demo calendar and Page title accurate.
$GLOBALS['APPLICATION_NAME'] = $s['APPLICATION_NAME'];
$GLOBALS['BGCOLOR'] = $s['BGCOLOR'];
$GLOBALS['CELLBG'] = $s['CELLBG'];
$GLOBALS['FONTS'] = $s['FONTS'];
$GLOBALS['H2COLOR'] = $s['H2COLOR'];
$GLOBALS['HASEVENTSBG'] = $s['HASEVENTSBG'];
$GLOBALS['MYEVENTS'] = $s['MYEVENTS'];
$GLOBALS['OTHERMONTHBG'] = $s['OTHERMONTHBG'];
$GLOBALS['TABLEBG'] = $s['TABLEBG'];
$GLOBALS['TEXTCOLOR'] = $s['TEXTCOLOR'];
$GLOBALS['THBG'] = $s['THBG'];
$GLOBALS['THFG'] = $s['THFG'];
$GLOBALS['TODAYCELLBG'] = $s['TODAYCELLBG'];
$GLOBALS['WEEKENDBG'] = $s['WEEKENDBG'];
$GLOBALS['WEEKNUMBER'] = $s['WEEKNUMBER'];

define_languages(); // Load the language list.
reset ( $languages );
Expand Down Expand Up @@ -127,8 +114,9 @@ function save_pref ( $prefs, $src ) {

$option = '
<option value="';
$color_sets = $datestyle_md = $datestyle_my = $datestyle_tk = '';
$datestyle_ymd = $lang_list = $prefer_vu = '';

$cch = $color_sets = $datestyle_md = $datestyle_my = $datestyle_tk = '';
$datestyle_ymd = $lang_list = $prefer_vu = $rc = '';
$start_wk_on = $start_wkend_on = $tabs = $user_vu = '';
$work_hr_end = $work_hr_start = '';

Expand Down Expand Up @@ -225,10 +213,15 @@ function save_pref ( $prefs, $src ) {
'POPUP_BG' => translate('Event popup background'),
'POPUP_FG' => translate('Event popup text')
];

foreach ( $colors as $k => $v ) {
$handler = 'color_change_handler_' . $k;
$color_sets .= print_color_input_html ( $k, $v, '', '', 'p', '', $handler );
$GLOBALS[$k] = $s[$k];
// Change the color in the current page
$cch .= " function color_change_handler_$k() {\n var color = $('#admin_' + $k).val();\n\n $('body').get(0).style.setProperty('--' + $k.toLowerCase, color);\n }\n";
$color_sets .= print_color_input_html ( $k, $v, '', '', 'p', '', 'color_change_handler_' . $k );
$rc .= "\n $('#admin_' + $k).val(" . $GLOBALS[$k] . ");\n $('body').get(0).style.setProperty('--' + $k.toLowerCase, '" . $GLOBALS[$k] . "');\n";
}

$csp = ( $s['CSP'] ?: 'none' );

set_today ( date ( 'Ymd' ) );
Expand Down Expand Up @@ -852,36 +845,13 @@ function save_pref ( $prefs, $src ) {
</div>
<div style="clear:both;">
<button class="btn btn-primary" name="" type="submit">'
. $saveStr . '</button>
. $saveStr . "</button>
</div>
</form>
</div>
</div>
</div>';

echo "\n<script>\n";

// Change the color in the current page
foreach ( $colors as $k => $v ) {
echo "function color_change_handler_$k() {\n";
echo " var color = $('#admin_" . $k . "').val();\n";
echo " $('body').get(0).style.setProperty('--" . strtolower($k) . "', color);\n";
echo "}\n";
}

?>
function reset_colors() {
<?php
foreach ( $colors as $k => $v ) {
echo " $('body').get(0).style.setProperty('--" . strtolower($k) . "', '$GLOBALS[$k]');\n";
echo " $('#admin_" . $k . "').val('$GLOBALS[$k]');\n";
}
?>
}

</script>
<?php

<script>\n" . $cch . "
function reset_colors() {" . $rc . '
}
</script>';
} else {
// if $error
echo print_error ( $error, true );
Expand Down
13 changes: 1 addition & 12 deletions adminhome.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,7 @@

$_SESSION['webcal_tmp_login'] = 'SheIsA1Fine!';

print_header( '',
/*
'<style>
#adminhome table,
#adminhome td a {
background:' . $CELLBG . '
}
</style>
If this is the proper way to call css_cacher.php from here?
*/
'<link href="css_cacher.php" rel="stylesheet">
<link href="includes/css/styles.css" rel="stylesheet">' );
print_header();

echo '
<h2>' . translate( 'Administrative Tools' ) . '</h2>
Expand Down
3 changes: 1 addition & 2 deletions assistant_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
if ( $user != $login )
$user = ( ( $is_admin || $is_nonuser_admin ) && $user ) ? $user : $login;

print_header( '', ! $GROUPS_ENABLED == 'Y' ? '' :
'<script src="includes/js/assistant_edit.js"></script>' );
print_header ( $GROUPS_ENABLED !== 'Y' ? [] : ['js/assistant_edit.js'] );
echo '
<form action="assistant_edit_handler.php" method="post" '
. 'name="assistanteditform">' . csrf_form_key() . ( $user ? '
Expand Down
10 changes: 5 additions & 5 deletions autocomplete_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@
}

$data = $sug = [];
for ($i = 0; $i < count ($ret); $i++) {
$sug[$i] = $ret[$i]['name'];
}
for ($i = 0; $i < count ($ret); $i++) {
$data[$i] = $ret[$i]['text'];

foreach ( $ret as $i ) {
$sug[] = $i['name'];
$data[] = $i['text'];
}

ajax_send_object('matches', $sug, $sendPlainText);
} else {
ajax_send_error(translate("Error"));
Expand Down
4 changes: 2 additions & 2 deletions availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@

echo '
<div style="width:99%;">
<a title="' . $prevStr . '" class="prev" href="' . $prev_url
<a class="prev" href="' . $prev_url
. '"><img src="images/bootstrap-icons/arrow-left-circle.svg" class="prev" alt="'
. $prevStr . '"></a>
<a title="' . $nextStr . '" class="next" href="' . $next_url
<a class="next" href="' . $next_url
. '"><img src="images/bootstrap-icons/arrow-right-circle.svg" class="next" alt="'
. $nextStr . '"></a>
<div class="title">
Expand Down
4 changes: 2 additions & 2 deletions category.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
. '<a href="category.php" class="form-control btn btn-secondary ml-1">Cancel</a> '
. (!empty($id) ? '
<button class="form-control btn btn-danger ml-1" name="delete" '
. 'type="submit" onclick="return confirm('
. 'type="submit" value="delete" onclick="return confirm(\''
. translate ( 'Are you sure you want to delete this entry?', true )
. '\')">' . translate ( 'Delete' ) . '</button>' : '' ) . '
</div>
Expand Down Expand Up @@ -116,7 +116,7 @@

if (!empty($V['cat_icon_mime'])) {
echo '<img src="getIcon.php?cat_id=' . $K . '" alt="'
. $catIconStr . '" title="' . $catIconStr . '">';
. $catIconStr . '">';
}
echo '</li>';
}
Expand Down
8 changes: 4 additions & 4 deletions category_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ function updateIconBlob($catId, $iconData, $iconMimeType) {
$error = db_error();
}

if (!dbi_execute(
'DELETE FROM webcal_entry_categories
WHERE cat_id = ? AND ( cat_owner = ?'
. ($is_admin ? ' OR cat_owner = \'\'' : ' )'),
if (!dbi_execute("
DELETE FROM `webcal_entry_categories`
WHERE `cat_id` = ? AND ( `cat_owner` = ?"
. ($is_admin ? " OR `cat_owner` = '' )" : " )"),
[$id, $login]
)) {
$error = db_error();
Expand Down
5 changes: 2 additions & 3 deletions catsel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
if ( strlen ( $entryCatStr ) < 30 )
$entryCatStr = $entryCatFiller . $entryCatStr . $entryCatFiller;

print_header ( ['js/catsel.php/false/' . $form],
'<script type=text/javascript" src="includes/js/catsel.js"></script>',
'', true, false, true );
print_header ( ['js/catsel.php/false/' . $form, 'js/catsel.js'],
'', '', true, false, true );
echo '
<table class="aligncenter" width="90%">
<tr>
Expand Down
2 changes: 1 addition & 1 deletion day.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
$eventinfo = ( empty ( $eventinfo ) ? '' : $eventinfo );
$trailerStr = print_trailer();
print_header ( ['js/popups.js/true', 'js/dblclick_add.js/true'],
generate_refresh_meta(), '', false, false, false, false );
generate_refresh_meta() );

echo <<<EOT
Expand Down
2 changes: 1 addition & 1 deletion edit_entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function time_selection($prefix, $time = '', $trigger = false)
$real_user = ((!empty($user) && strlen($user)) &&
($is_assistant || $is_admin)) ? $user : $login;

print_header($INC, $HEAD, $BodyX);
print_header ( $INC, $HEAD, $BodyX );

if ($readonly == 'Y' || $is_nonuser)
$can_edit = false;
Expand Down
2 changes: 1 addition & 1 deletion edit_remotes_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function_exists ( 'simplexml_load_string' ) ) {
$errorStr = '<br><br>
<b>' . translate ( 'Error' ) . ':</b> ';

print_header ( '', '', '', true, false, true );
print_header ( [], '', '', true, false, true );
if ( count ( $data ) && empty ( $errormsg ) ) {
// Delete existing events.
delete_events ( $nid );
Expand Down
4 changes: 2 additions & 2 deletions edit_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* @author Craig Knudsen <cknudsen@cknudsen.com>
* @copyright Craig Knudsen, <cknudsen@cknudsen.com>, http://k5n.us/webcalendar
* @license https://gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL
* @package WebCalendar
* @subpackage Reports
*
* @package WebCalendar\Reports
*/

/* Security:
Expand Down
21 changes: 5 additions & 16 deletions edit_report_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,13 @@
$names[] = 'cal_report_id';
$values[] = $newid;

$sql = 'INSERT INTO webcal_report ( ';
$sql_v = '';

$namecnt = count ( $names );
for ( $i = 0; $i < $namecnt; $i++ ) {
$sql .= ( $i > 0 ? ', ' : '' ) . $names[$i];
$sql_v .= ( $i > 0 ? ', ' : '' ) . '?';
}
$sql .= ' ) VALUES ( ' . $sql_v . ' )';
$sql = 'INSERT INTO webcal_report ( ' . implode ( ',', $names )
. ' ) VALUES ( ?' . str_repeat ( ',?', count ( $names ) - 1 ) . ' )';
$report_id = $newid;
} else {
$sql = 'UPDATE webcal_report SET ';
$namecnt = count ( $names );
for ( $i = 0; $i < $namecnt; $i++ ) {
$sql .= ( $i > 0 ? ', ' : '' ) . "$names[$i] = ?";
}
$sql .= ' WHERE cal_report_id = ?';
$values[] = $report_id; // Push the $report_id to $values.
$sql = 'UPDATE webcal_report SET ' . implode ( ' = ?,', $names )
. ' = ? WHERE cal_report_id = ?';
$values[] = $report_id;
}
}

Expand Down
2 changes: 1 addition & 1 deletion edit_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
}
}

print_header ( '', '', '', true );
print_header ( [], '', '', true );
/*
echo 'report_id: ' . $report_id . '<br>
report_name: ' . $report_name . '<br>
Expand Down
Loading

0 comments on commit aef0060

Please sign in to comment.