diff --git a/LitCalDiocesanData.php b/LitCalDiocesanData.php index 620a88c2..64115987 100644 --- a/LitCalDiocesanData.php +++ b/LitCalDiocesanData.php @@ -8,6 +8,10 @@ include_once( 'includes/enums/ReturnType.php' ); include_once( 'includes/APICore.php' ); +if( file_exists("allowedOrigins.php") ) { + include_once( 'allowedOrigins.php' ); +} + $allowedOrigins = [ "https://johnromanodorazio.com", "https://www.johnromanodorazio.com", @@ -15,6 +19,10 @@ "https://litcal-staging.johnromanodorazio.com" ]; +if( defined('ALLOWED_ORIGINS') && is_array( ALLOWED_ORIGINS ) ) { + $allowedOrigins = array_merge( $allowedOrigins, ALLOWED_ORIGINS ); +} + $LitCalDiocesanData = new LitCalDiocesanData(); $LitCalDiocesanData->APICore->setAllowedOrigins( $allowedOrigins ); @@ -47,7 +55,6 @@ private function handleGetPostRequests( array $REQUEST ) { $this->DATA = (object)$REQUEST; } $this->retrieveDiocesanCalendar(); - } private function handlePutPatchDeleteRequests( string $requestMethod ) { @@ -70,7 +77,6 @@ private function handlePutPatchDeleteRequests( string $requestMethod ) { } private function handleRequestedMethod() { - switch( strtoupper( $_SERVER[ "REQUEST_METHOD" ] ) ) { case RequestMethod::GET: $this->handleGetPostRequests( $_GET ); @@ -192,12 +198,10 @@ private function deleteDiocesanCalendar() { } public function Init() { - $this->APICore->Init(); $this->APICore->setResponseContentTypeHeader(); $this->loadIndex(); $this->handleRequestedMethod(); - } } diff --git a/LitCalNationalAndRegionalData.php b/LitCalNationalAndRegionalData.php index e917d1db..e598eb5a 100644 --- a/LitCalNationalAndRegionalData.php +++ b/LitCalNationalAndRegionalData.php @@ -16,9 +16,7 @@ "https://johnromanodorazio.com", "https://www.johnromanodorazio.com", "https://litcal.johnromanodorazio.com", - "https://litcal-staging.johnromanodorazio.com", - "https://litcal.org", - "https://www.litcal.org" + "https://litcal-staging.johnromanodorazio.com" ]; if( defined('ALLOWED_ORIGINS') && is_array( ALLOWED_ORIGINS ) ) { @@ -48,6 +46,7 @@ public function __construct(){ } private function handleGetPostRequests( array $REQUEST ) { + $this->APICore->validateAcceptHeader( true ); if( $this->APICore->getRequestContentType() === 'application/json' ) { $this->DATA = $this->APICore->retrieveRequestParamsFromJsonBody();