From 93a03b15934dec92c4bfa7d7272dbf3f6a8aa7d4 Mon Sep 17 00:00:00 2001 From: Bruce Bannon Date: Sat, 10 Feb 2024 18:01:56 -0700 Subject: [PATCH 1/3] might help with login & not-authorized errors --- ajax.php | 2 +- autocomplete_ajax.php | 2 +- events_ajax.php | 4 ++-- freebusy.php | 2 +- icalclient.php | 2 +- includes/init.php | 10 +++++----- layers_ajax.php | 2 +- login-app.php | 2 +- login.php | 2 +- nulogin.php | 2 +- publish.php | 2 +- register.php | 2 +- rss.php | 19 ++++++++----------- rss_activity_log.php | 2 +- rss_unapproved.php | 2 +- users_ajax.php | 2 +- 16 files changed, 28 insertions(+), 31 deletions(-) diff --git a/ajax.php b/ajax.php index 9001426b4..95efc6218 100644 --- a/ajax.php +++ b/ajax.php @@ -4,6 +4,7 @@ * This is the handler for Ajax httpXmlRequests. */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -11,7 +12,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/autocomplete_ajax.php b/autocomplete_ajax.php index 1b1714ca4..a7213ad8f 100644 --- a/autocomplete_ajax.php +++ b/autocomplete_ajax.php @@ -18,6 +18,7 @@ * } */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -25,7 +26,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/events_ajax.php b/events_ajax.php index 45752b25b..35ba29061 100644 --- a/events_ajax.php +++ b/events_ajax.php @@ -12,6 +12,7 @@ * TODO: hide private events of other users. */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; require_once 'includes/classes/Event.php'; require_once 'includes/classes/RptEvent.php'; @@ -21,7 +22,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); @@ -33,8 +33,8 @@ // Load Doc classes for attachments and comments require_once 'includes/classes/Doc.php'; require_once 'includes/classes/DocList.php'; -require_once 'includes/classes/CommentList.php'; require_once 'includes/classes/AttachmentList.php'; +require_once 'includes/classes/CommentList.php'; $WebCalendar->initializeSecondPhase(); diff --git a/freebusy.php b/freebusy.php index 9e5028790..75ed29a25 100644 --- a/freebusy.php +++ b/freebusy.php @@ -41,6 +41,7 @@ */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; require_once 'includes/classes/Event.php'; require_once 'includes/classes/RptEvent.php'; @@ -50,7 +51,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/icalclient.php b/icalclient.php index 0ac31f41a..1e0bf99f0 100644 --- a/icalclient.php +++ b/icalclient.php @@ -82,6 +82,7 @@ */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -89,7 +90,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/includes/init.php b/includes/init.php index dc487c04b..778f6e30d 100644 --- a/includes/init.php +++ b/includes/init.php @@ -19,18 +19,18 @@ * 3. call the print_header function with proper arguments * * What gets called: + * - require_once 'includes/translate.php'; + * - require_once 'includes/functions.php'; + * - require_once 'includes/classes/WebCalendar.php'; * - require_once "includes/$user_inc"; * - require_once 'includes/access.php'; * - require_once 'includes/assert.php'; * - require_once 'includes/classes/Event.php'; * - require_once 'includes/classes/RptEvent.php'; - * - require_once 'includes/classes/WebCalendar.php'; * - require_once 'includes/config.php'; * - require_once 'includes/dbi4php.php'; * - require_once 'includes/formvars.php'; - * - require_once 'includes/functions.php'; * - require_once 'includes/site_extras.php'; - * - require_once 'includes/translate.php'; * - require_once 'includes/validate.php'; * * Also, for month.php, day.php, week.php, week_details.php: @@ -49,9 +49,10 @@ } require_once 'includes/translate.php'; +require_once 'includes/functions.php'; +require_once 'includes/classes/WebCalendar.php'; require_once 'includes/classes/Event.php'; require_once 'includes/classes/RptEvent.php'; -require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -59,7 +60,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/layers_ajax.php b/layers_ajax.php index 57db7ec96..a03fb9d79 100644 --- a/layers_ajax.php +++ b/layers_ajax.php @@ -4,6 +4,7 @@ * Handler for AJAX requests from layers.php. */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -11,7 +12,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/login-app.php b/login-app.php index 31bdfd07b..e56eca673 100644 --- a/login-app.php +++ b/login-app.php @@ -1,5 +1,6 @@ initializeFirstPhase(); diff --git a/login.php b/login.php index cadba7294..78779a53e 100644 --- a/login.php +++ b/login.php @@ -1,6 +1,7 @@ initializeFirstPhase(); diff --git a/publish.php b/publish.php index 8f5be190f..3dd85ac5b 100644 --- a/publish.php +++ b/publish.php @@ -24,6 +24,7 @@ */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -31,7 +32,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/register.php b/register.php index c342932b7..3514c4b3b 100644 --- a/register.php +++ b/register.php @@ -5,6 +5,7 @@ unset ( $_SESSION['webcalendar_session'] ); require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -12,7 +13,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/rss.php b/rss.php index f69589b58..76798916c 100644 --- a/rss.php +++ b/rss.php @@ -44,7 +44,6 @@ * * We do not include unapproved events in the RSS feed. * - * * TODO * Add other RSS 2.0 options such as media. * Add : dan@spam_me.com (Dan Deletekey) @@ -52,26 +51,24 @@ $debug = false; -include_once 'includes/translate.php'; +require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; require_once 'includes/classes/Event.php'; require_once 'includes/classes/RptEvent.php'; $WebCalendar = new WebCalendar( __FILE__ ); -include 'includes/formvars.php'; -include 'includes/functions.php'; -include 'includes/config.php'; -include 'includes/dbi4php.php'; +require_once 'includes/formvars.php'; +require_once 'includes/config.php'; +require_once 'includes/dbi4php.php'; $WebCalendar->initializeFirstPhase(); -include 'includes/' . $user_inc; - +require_once "includes/$user_inc"; include_once 'includes/validate.php'; -include 'includes/site_extras.php'; - -include_once 'includes/xcal.php'; +require_once 'includes/site_extras.php'; +require_once 'includes/xcal.php'; $WebCalendar->initializeSecondPhase(); diff --git a/rss_activity_log.php b/rss_activity_log.php index cacee5c91..20fbe52c0 100644 --- a/rss_activity_log.php +++ b/rss_activity_log.php @@ -34,6 +34,7 @@ */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -42,7 +43,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/rss_unapproved.php b/rss_unapproved.php index d0dd61240..7948ec653 100644 --- a/rss_unapproved.php +++ b/rss_unapproved.php @@ -33,6 +33,7 @@ */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar( __FILE__ ); @@ -41,7 +42,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); diff --git a/users_ajax.php b/users_ajax.php index 8d3a0d849..0ff002a0f 100644 --- a/users_ajax.php +++ b/users_ajax.php @@ -5,6 +5,7 @@ * and remotecal_mgmt.php. */ require_once 'includes/translate.php'; +require_once 'includes/functions.php'; require_once 'includes/classes/WebCalendar.php'; $WebCalendar = new WebCalendar(__FILE__); @@ -12,7 +13,6 @@ require_once 'includes/config.php'; require_once 'includes/dbi4php.php'; require_once 'includes/formvars.php'; -require_once 'includes/functions.php'; $WebCalendar->initializeFirstPhase(); From 6249390b45c0f45b67d81e7c1082da2864bcbc85 Mon Sep 17 00:00:00 2001 From: Bruce Bannon Date: Sun, 28 Apr 2024 02:17:58 -0600 Subject: [PATCH 2/3] update date_to_epoch() Less duplicate code --- includes/functions.php | 46 +++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 8dd9c6000..711a560f2 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -796,41 +796,31 @@ function date_selection($prefix, $date, $trigger = false, $num_years = 20) } /** - * Converts a date to a timestamp. + * date_to_epoch * - * @param string $d Date in YYYYMMDD or YYYYMMDDHHIISS format - * @param bool $gmt Whether to use GMT or LOCAL + * Converts a date to a timestamp * - * @return int Timestamp representing, in UTC or LOCAL time. + * @param mixed $d Date in YYYYMMDD or YYYYMMDDHHIISS format + * @param bool $gmt Whether to use GMT or LOCAL + * + * @return int timestamp representing, in UTC or LOCAL time */ -function date_to_epoch( $d, $gmt = true ) { - if ( $d == 0 || $d === '' ) +function date_to_epoch ( $d, $gmt = true ) { + if ( ! $d ) { return 0; - - $dH = $di = $ds = 0; - if ( strlen ( $d ) == 13 ) { // Hour value is single digit. - $dH = substr ( $d, 8, 1 ); - $di = substr ( $d, 9, 2 ); - $ds = substr ( $d, 11, 2 ); - } - if ( strlen ( $d ) == 14 ) { - $dH = substr ( $d, 8, 2 ); - $di = substr ( $d, 10, 2 ); - $ds = substr ( $d, 12, 2 ); } - if ( $gmt ) - return gmmktime ( $dH, $di, $ds, - (int)substr ( $d, 4, 2 ), - (int)substr ( $d, 6, 2 ), - (int)substr ( $d, 0, 4 ) ); - else - return mktime ( $dH, $di, $ds, - (int)substr ( $d, 4, 2 ), - (int)substr ( $d, 6, 2 ), - (int)substr ( $d, 0, 4 ) ); -} + $f = ( $gmt ? 'gm' : '' ) . 'mktime'; + return $f ( + (int) mb_substr ( $d, 8, ( mb_strlen ( $d ) === 13 ? 1 : 2 ) ), + (int) mb_substr ( $d, -4, 2 ), + (int) mb_substr ( $d, -2, 2 ), + (int) mb_substr ( $d, 4, 2 ), + (int) mb_substr ( $d, 6, 2 ), + (int) mb_substr ( $d, 0, 4 ) + ); +} /** * Converts a date in YYYYMMDD format into "Friday, December 31, 1999", From 9a5aa6f8763b446a20fc7f85442740cbc2470ee3 Mon Sep 17 00:00:00 2001 From: Bruce Bannon Date: Sat, 31 Aug 2024 10:56:28 -0600 Subject: [PATCH 3/3] Update rss.php include_once => require_once --- rss.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rss.php b/rss.php index 76798916c..745348627 100644 --- a/rss.php +++ b/rss.php @@ -66,7 +66,7 @@ $WebCalendar->initializeFirstPhase(); require_once "includes/$user_inc"; -include_once 'includes/validate.php'; +require_once 'includes/validate.php'; require_once 'includes/site_extras.php'; require_once 'includes/xcal.php';