Skip to content

Commit

Permalink
Merge branch 'elvis' of https://github.com/bbannon/webcalendar into e…
Browse files Browse the repository at this point in the history
…lvis
  • Loading branch information
Bruce Bannon committed Nov 4, 2024
2 parents 2663707 + 402a92a commit 7c24c6e
Show file tree
Hide file tree
Showing 179 changed files with 180,489 additions and 16,189 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

32 changes: 3 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ install script that the web service process has write permissions to.
### Option 2: Environment Variables

Instead of using the `includes/settings.php` file for your settings, you can use environment
variables instead.
variables instead.
This is primarily targeted towards those running WebCalendar in containers (docker, AWS Fargate, etc)
where it's easier to pass in environment settings than to write to a config file on a container.
where it's easier to pass in environment settings than to write to a config file on a container.
You can do this with the docker-compose file if you are using docker.
If you want to do this with a standard Web Server,
you can set the evironment variables within your web server's configuration.
you can set the evironment variables within your web server's configuration.
Depending on your web server, there may be more than one way to do this. You could
do this in your `php.ini` file, but those env vars would be available to all PHP apps
on the server. A better solution would be to setup a `.htaccess` file in your
Expand Down Expand Up @@ -93,19 +93,6 @@ and MariaDb running that is setup with the `docker-compose` command.

- Start the containers:
`docker-compose -f docker/docker-compose-php8.yml up`
- In order to grant the proper permissions inside of MariaDb, you
will need to run a few MySQL commands. First shell into the mariadb
container: `docker-compose -f docker/docker-compose-php8.yml exec db /bin/sh`
- Start up the db client: `/bin/mariadb -p` (the password will be
"Webcalendar.1" as specified in the `docker-compose-php8.yml' file. You
can change it to make your dev environment more secure (before you
build the containers in step above).
- Run the following db commands:
```
GRANT ALL PRIVILEGES ON *.* TO webcalendar_php8@localhost IDENTIFIED BY 'Webcalendar.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;
QUIT
```
- Start up your web browser and go to:
[http://localhost:8080/](http://localhost:8080/).
- Follow the guided web-based setup and choose "mysqli" as the database
Expand All @@ -125,19 +112,6 @@ files in the container.
`docker-compose -f docker/docker-compose-php8-dev.yml build`
- Start the containers with
`docker-compose -f docker/docker-compose-php8-dev.yml up`
- In order to grant the proper permissions inside of MariaDb, you
will need to run a few MySQL commands. First shell into the mariadb
container: `docker-compose -f docker/docker-compose-php8-dev.yml exec db /bin/sh`
- Start up the db client: `/bin/mariadb -p` (the password will be
"Webcalendar.1" as specified in the `docker-compose-php8-dev.yml' file. You
can change it to make your dev environment more secure (before you
build the containers in step above).
- Run the following db commands:
```
GRANT ALL PRIVILEGES ON *.* TO webcalendar_php8@localhost IDENTIFIED BY 'Webcalendar.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;
QUIT
```
- Start up your web browser and go to:
[http://localhost:8080/](http://localhost:8080/).
- Follow the guided web-based setup and choose "mysqli" as the database
Expand Down
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 @@ -160,11 +160,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
64 changes: 17 additions & 47 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 @@ -773,12 +766,12 @@ function save_pref ( $prefs, $src ) {
<div class="form-inline mt-1 mb-2"><label title="' . tooltip ( 'email-smtp-username' ) . '">'
. translate ( 'SMTP Username' )
. ':</label><input type="text" size="30" name="admin_SMTP_USERNAME" value="'
. ( $s['SMTP_USERNAME'] ?: '' )
. ( $s['SMTP_USERNAME'] ??= '' )
. '"></div>
<div class="form-inline mt-1 mb-2"><label title="' . tooltip ( 'email-smtp-password' ) . '">'
. translate ( 'SMTP Password' )
. ':</label><input type="text" size="30" name="admin_SMTP_PASSWORD" value="'
. ( $s['SMTP_PASSWORD'] ?: '' )
. ( $s['SMTP_PASSWORD'] ??= '' )
. '"></div>
</div>
</div>
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
Loading

0 comments on commit 7c24c6e

Please sign in to comment.