Skip to content

Commit

Permalink
Merge branch 'craigk5n:master' into newLanguages
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannon authored Aug 31, 2024
2 parents 202e32c + 1fe120c commit 96d8dd1
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 125 deletions.
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
2 changes: 1 addition & 1 deletion category_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function updateIconBlob($catId, $iconData, $iconMimeType) {
if (!dbi_execute(
'DELETE FROM webcal_entry_categories
WHERE cat_id = ? AND ( cat_owner = ?'
. ($is_admin ? ' OR cat_owner = '' )' : ' )'),
. ($is_admin ? ' OR cat_owner = \'\'' : ' )'),
[$id, $login]
)) {
$error = db_error();
Expand Down
31 changes: 14 additions & 17 deletions docker/docker-compose-php8-dev.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
# Run docker-compose from the top-level WebCalendar directory and not from this "docker" subdirectory.
# The first time you run this, you will need to grant permission
# for the webcalendar user to access mariadb (after you have run
# docker-compose up). You only need to do this once.
#
# Start a shell on the mariadb container:
# docker-compose -f docker/docker-compose-php8-dev.yml exec db-mariadb /bin/sh
# Start the mariadb client:
# /bin/mariadb -p
# (enter the MYSQL_ROOT_PASSWORD below)
# Execute the following three db commands:
# GRANT ALL PRIVILEGES ON *.* TO webcalendar@localhost IDENTIFIED BY 'Webcalendar.1' WITH GRANT OPTION;
# FLUSH PRIVILEGES;
# QUIT
#
# Run docker compose from the top-level WebCalendar directory and not from this "docker" subdirectory.
# If you need shell access on the webserver container running WebCalendar, you can use
# the following command:
# docker-compose -f docker/docker-compose-php8-dev.yml exec webcalendar-php8-mariadb /bin/sh
# docker compose -f docker/docker-compose-php8-dev.yml exec webcalendar-php8-mariadb /bin/sh

version: '3.1'

Expand All @@ -27,6 +13,17 @@ services:
volumes:
- mysql-data:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
# install sql at start
# To test the installer's built-in installer, comment this out
# - type: bind
# source: ../install/sql/tables-mysql.sql
# target: /docker-entrypoint-initdb.d/tables-mysql.sql
# Set mariadb access policy
# NOTE: The specified SQL needs to match the password specified
# in the ENV vars listed below.
- type: bind
source: ../install/sql/permissions-mysql.sql
target: /docker-entrypoint-initdb.d/permissions-mysql.sql
environment:
- MYSQL_ROOT_PASSWORD=Webcalendar.1
- MYSQL_PASSWORD=Webcalendar.1
Expand Down Expand Up @@ -84,7 +81,7 @@ services:
- WEBCALENDAR_MODE=dev

# To access the pgsql command line:
# docker-compose -f docker/docker-compose-php8-dev.yml exec db-pgsql /bin/bash
# docker compose -f docker/docker-compose-php8-dev.yml exec db-pgsql /bin/bash
# Before the webcalendar db is created:
# psql -h localhost -p 5432 -U webcalendar -W -d postgres
db-pgsql:
Expand Down
29 changes: 13 additions & 16 deletions docker/docker-compose-php8.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
# Run docker-compose from the top-level WebCalendar directory and not from this "docker" subdirectory.
# The first time you run this, you will need to grant permission
# for the webcalendar user to access mariadb (after you have run
# docker-compose up). You only need to do this once.
#
# Start a shell on the mariadb container:
# docker-compose -f docker/docker-compose-php8.yml exec db /bin/sh
# Start the mariadb client:
# /bin/mariadb -p
# (enter the MYSQL_ROOT_PASSWORD below)
# Execute the following three db commands:
# GRANT ALL PRIVILEGES ON *.* TO webcalendar@localhost IDENTIFIED BY 'Webcalendar.1' WITH GRANT OPTION;
# FLUSH PRIVILEGES;
# QUIT
#
# Run docker compose from the top-level WebCalendar directory and not from this "docker" subdirectory.
# If you need shell access on the webserver container running WebCalendar, you can use
# the following command:
# docker-compose -f docker/docker-compose-php8.yml exec webcalendar-php8 /bin/sh
# docker compose -f docker/docker-compose-php8.yml exec webcalendar-php8 /bin/sh

version: '3.1'

Expand All @@ -27,6 +13,17 @@ services:
volumes:
- mysql-data:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
# install sql at start
# To test the installer's built-in installer, comment this out
- type: bind
source: ../install/sql/tables-mysql.sql
target: /docker-entrypoint-initdb.d/tables-mysql.sql
# Set mariadb access policy
# NOTE: The specified SQL needs to match the password specified
# in the ENV vars listed below.
- type: bind
source: ../install/sql/permissions-mysql.sql
target: /docker-entrypoint-initdb.d/permissions-mysql.sql
environment:
- MYSQL_ROOT_PASSWORD=Webcalendar.1
- MYSQL_PASSWORD=Webcalendar.1
Expand Down
4 changes: 2 additions & 2 deletions docs/WebCalendar-UserManual.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>
<body id="manual">
<h1>WebCalendar User Manual</h1>
<p class="b">WebCalendar Version: 1.9.9</p>
<p class="b">WebCalendar Version: 1.9.12</p>
<h2>Table of Contents</h2>
<ul>
<li><a href="#intro">Introduction</a></li>
Expand Down Expand Up @@ -340,7 +340,7 @@ <h2><a id="categories">Categories</a></h2>
<p>Events may be associated with one or more categories, but it is not required. Categories can be user-level or global. Each user maintains his/her own list of user-level categories, while the system administrator maintains the list of global categories.</p>
<p>When creating or editing event, you may specify the categories for the event. If the category you select isn't a global category, and you select participants other than yourself for that event, other users will see "None" as the category. If you selected a global category, all users will be able to see the same category.</p>
<p>When viewing the calendar (month, week or day), a selection box is displayed near the top of the page that allows you to filter events based on a category. When you select a category from this menu, only events associated with that category will appear on your calendar.</p>
<p>If enabled, icons can also be uploaded and assigned to categories to be displayed before the event name. You will also be able to choose an icon from existing icons that have already been uploaded. This requires that a folder named <tt>icons</tt> exist in the WebCalendar directory.</p>
<p>If enabled, icons can also be uploaded and assigned to categories to be displayed before the event name. You will also be able to choose an icon from existing icons that have already been uploaded. This requires that a folder named <span class="tt">icons</span> exist in the WebCalendar directory.</p>
<a href="#" target="_top">↑&nbsp;top</a>
<hr>
<h2><a id="views">Views</a></h2>
Expand Down
20 changes: 11 additions & 9 deletions includes/assert.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?php
/**
* This file implements the assertion handler.
* Implements the assertion handler.
*
* This is called anytime a WebCalendar call to assert() fails.
*
* @todo Create a link that will pass all the bug details to a form hosted on
* k5n.us so that it can be easily submitted.
* @todo Create a link that will pass all the bug details to a form
* hosted on k5n.us so that it can be easily submitted.
*
* @author Craig Knudsen <[email protected]>
* @copyright Craig Knudsen, <[email protected]>, http://k5n.us/webcalendar
* @license https://gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL
*
* @package WebCalendar
*/

/*
/**
* Setup callback function only if $settings.php mode == dev
*/
if ( ! empty ( $run_mode ) && $run_mode == 'dev' )
Expand Down Expand Up @@ -79,17 +81,17 @@ function assert_backtrace() {
*
* Abort execution, print the specified error message along with a stack trace.
*
* @param string $script Pathname where assertion failed
* @param int $line Line number where assertion failed
* @param string $msg Failed assertion expression
* @param string $script Pathname where assertion failed
* @param int $line number where assertion failed
* @param string $msg Failed assertion expression
*/
function assert_handler ( $script, $line, $msg='' ) {
if ( empty ( $msg ) )
$msg = 'Assertion failed<br>' . "\n";
$msg = "Assertion failed<br>\n";
$trace = ( function_exists ( 'debug_backtrace' )
? assert_backtrace() : basename( $script ) . ': ' . $line . ' ' . $msg );
$msg .= ( function_exists ( 'debug_backtrace' ) ? '<b>Stack Trace:</b><br><br>' : '' )
. '<blockquote><tt>' . nl2br ( $trace ) . '</tt></blockquote>';
. '<blockquote class="tt">' . nl2br ( $trace ) . '</blockquote>';
if ( function_exists ( 'die_miserable_death' ) )
die_miserable_death ( $msg );
else {
Expand Down
55 changes: 27 additions & 28 deletions includes/classes/WebCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ class WebCalendar {
/**
* WebCalendar constructor.
*
* @param string $path Full path of file being viewed.
* @param string $path full path of file being viewed
*
* @return WebCalendar New WebCalendar object.
* @return WebCalendar new WebCalendar object
*
* @access public
*/
Expand Down Expand Up @@ -126,8 +126,7 @@ function _initInitFirstPhase() {
if ( empty ( $HTTP_POST_VARS ) )
$HTTP_POST_VARS = $_POST;

if ( ! empty ( $HTTP_GET_VARS ) && empty ( $HTTP_GET_VARS['user'] ) && !
empty ( $HTTP_POST_VARS ) && empty ( $HTTP_POST_VARS['user'] ) &&
if ( ! empty ( $HTTP_GET_VARS ) && empty ( $HTTP_GET_VARS['user'] ) && ! empty ( $HTTP_POST_VARS ) && empty ( $HTTP_POST_VARS['user'] ) &&
isset ( $GLOBALS['user'] ) )
unset ( $GLOBALS['user'] );

Expand Down Expand Up @@ -234,10 +233,10 @@ function _initInitSecondPhase() {
if ( $PUBLIC_ACCESS_OTHERS != 'Y' )
$user = ''; // Security precaution.
}
if (!$is_admin && !$is_assistant && !$is_nonuser_admin) {
if ( ! $is_admin && ! $is_assistant && ! $is_nonuser_admin ) {
if ($is_nonuser)
$can_add = false;
else if (!empty($user) && $user != $login && $user != '__public__')
elseif ( ! empty ( $user ) && $user !== $login && $user !== '__public__' )
$can_add = false;
}

Expand All @@ -258,7 +257,7 @@ function _initInitSecondPhase() {

if ( ! empty ( $user ) ) {
$u_url = 'user=' . $user . '&amp;';
if (!user_load_variables ( $user, 'user_' ))
if ( ! user_load_variables ( $user, 'user_' ) )
nonuser_load_variables($user, 'user_');
if ( $user == '__public__' )
$user_fullname = translate ( $PUBLIC_ACCESS_FULLNAME );
Expand Down Expand Up @@ -582,7 +581,7 @@ function _initValidate() {
if ( empty($cooie_check[0]) || empty($cooie_check[1]))
$session_not_found = true;
}
if (! $session_not_found) {
if ( ! $session_not_found ) {
$login_pw = explode('|', decode_string($encoded_login));
$login = $login_pw[0];
$cryptpw = $login_pw[1];
Expand All @@ -598,9 +597,9 @@ function _initValidate() {
// The following deletes the bad cookie.
// So, the user just needs to reload.
sendCookie ( 'webcalendar_session', '', 0 );
die_miserable_death ( 'Illegal characters in login <tt>'
die_miserable_death ( 'Illegal characters in login <span class="tt">'
. htmlentities ( $login )
. '</tt>. Press browser reload to clear bad cookie.' );
. '</span>. Press browser reload to clear bad cookie.' );
}

// Make sure we are connected to the database for password check.
Expand Down Expand Up @@ -684,8 +683,8 @@ function _initConnect() {
// make sure that the login selected is a valid login.
if ( $single_user == 'Y' ) {
if ( empty ( $single_user_login ) )
die_miserable_death ( 'You have not defined <tt>single_user_login</tt> '
. 'in <tt>includes/settings.php</tt>.' );
die_miserable_death ( 'You have not defined <span class="tt">single_user_login</span> '
. 'in <span class="tt">includes/settings.php</span>.' );

$res = dbi_execute ( 'SELECT COUNT( * ) FROM webcal_user
WHERE cal_login = ?', [$single_user_login] );
Expand All @@ -699,8 +698,8 @@ function _initConnect() {
if ( ! dbi_execute ( 'INSERT INTO webcal_user ( cal_login, cal_passwd,
cal_is_admin ) VALUES ( ?, ?, ? )',
[$single_user_login, md5 ( $single_user_login ), 'Y'] ) )
die_miserable_death ( 'User <tt>' . $single_user_login
. '</tt> does not exist in <tt>webcal_user</tt> table and we were '
die_miserable_death ( 'User <span class="tt">' . $single_user_login
. '</span> does not exist in <span class="tt">webcal_user</span> table and we were '
. 'not able to add it for you:<br><blockquote>' . dbi_error()
. '</blockquote>' );

Expand Down Expand Up @@ -942,7 +941,7 @@ function _initTranslate() {
if (extension_loaded('mbstring')) {
$mb_lang = strtok($lang, '-');
// Check the language against the map, default to 'neutral' if not found
$mapped_lang = isset($this->mb_language_map[$mb_lang]) ? $this->mb_language_map[$mb_lang] : 'neutral';
$mapped_lang = $this->mb_language_map[$mb_lang] ?? 'neutral';
if (@mb_language($mapped_lang) && mb_internal_encoding(translate('charset'))) {
$enable_mbstring = true;
} else {
Expand All @@ -958,7 +957,7 @@ function _initTranslate() {
/**
* Gets the initialization phases for the page being viewed.
*
* @return array Array of initialization phases.
* @return array of initialization phases
*
* @access private
*/
Expand All @@ -976,9 +975,9 @@ function _getPhases() {
/**
* Gets the initialization steps for the current page and phase.
*
* @param int $phase Initialization phase number
* @param int $phase Initialization phase number
*
* @return array Array of initialization steps.
* @return array of initialization steps
*
* @access private
*/
Expand All @@ -991,7 +990,7 @@ function _getSteps ( $phase ) {
/**
* Performs initialization steps.
*
* @param int $phase Which step of initialization should we perform?
* @param int $phase Which step of initialization should we perform?
*
* @access private
*/
Expand All @@ -1006,7 +1005,7 @@ function _doInit ( $phase ) {
/**
* Begins initialization of WebCalendar.
*
* @param string $path Full path of page being viewed
* @param string $path Full path of page being viewed
*
* @access public
*/
Expand All @@ -1017,7 +1016,7 @@ function initializeFirstPhase() {
/**
* Continues initialization of WebCalendar.
*
* @param string $path Full path of page being viewed
* @param string $path Full path of page being viewed
*
* @access public
*/
Expand All @@ -1034,13 +1033,13 @@ function setLanguage() {
$this->_initTranslate();
}

/**
* Construct an absolute path.
*
* @param string $path The path relative to the WebCalendar install directory
*
* @return string The absolute path
*/
/**
* Construct an absolute path.
*
* @param string $path relative to the WebCalendar install directory
*
* @return string The absolute path
*/
function absolutePath ( $path ) {
return $this->_directory . $path;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/css/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ul {
}

.tt {
font: 0.85rem monospace;
font: 0.85rem 'Lucida Console', monospace;
}

.vtop {
Expand Down
Loading

0 comments on commit 96d8dd1

Please sign in to comment.