diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..61c94de --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,46 @@ + +body { + font-family: 'Roboto', sans-serif; + background-color: #F8F9FA; +} + +.navbar { + background-color: #FFFFFF; + box-shadow: 0 2px 4px rgba(0,0,0,.1); +} + +.hero { + background-image: url('https://picsum.photos/seed/calendar-hero/1600/400'); + background-size: cover; + background-position: center; + color: white; + text-align: center; + padding: 100px 0; +} + +.hero h1 { + font-size: 3.5rem; + font-weight: 700; + text-shadow: 2px 2px 4px rgba(0,0,0,0.5); +} + +.btn-primary { + background-color: #4285F4; + border-color: #4285F4; + border-radius: 0.5rem; + padding: 10px 20px; + font-weight: 500; +} + +.btn-primary:hover { + background-color: #3367D6; + border-color: #3367D6; +} + +.calendar-placeholder { + background-color: #FFFFFF; + border-radius: 0.5rem; + padding: 2rem; + box-shadow: 0 2px 4px rgba(0,0,0,.1); + text-align: center; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..cde9f6b --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1 @@ +// Placeholder for future JS diff --git a/callback.php b/callback.php new file mode 100644 index 0000000..8464c88 --- /dev/null +++ b/callback.php @@ -0,0 +1,100 @@ + $code, + 'client_id' => GOOGLE_CLIENT_ID, + 'client_secret' => GOOGLE_CLIENT_SECRET, + 'redirect_uri' => GOOGLE_REDIRECT_URI, + 'grant_type' => 'authorization_code' +]; + +$ch = curl_init($token_url); +curl_setopt($ch, CURLOPT_POST, true); +curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($token_data)); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +$response = curl_exec($ch); +curl_close($ch); + +$token_info = json_decode($response, true); + +if (isset($token_info['access_token'])) { + // Success! Store the token and redirect. + $_SESSION['access_token'] = $token_info['access_token']; + if (isset($token_info['refresh_token'])) { + $_SESSION['refresh_token'] = $token_info['refresh_token']; + } + unset($_SESSION['last_auth_code']); // Clean up the used code. + header('Location: index.php'); + exit(); +} else { + // Log the detailed error from Google for server-side debugging. + error_log("Google OAuth Error: " . $response); + + // Display a clear, actionable error message to the user. + $error_title = "Authentication Failed!"; + $error_message = "The application was unable to get an access token from Google."; + $google_response = "
" . htmlspecialchars($response, ENT_QUOTES, 'UTF-8') . "
"; + $most_likely_cause = "This is most likely due to an incorrect Client ID or Client Secret in the google_config.php file."; + $instructions = "Please double-check that the credentials you copied from the Google Cloud Console are correct and have no typos or extra spaces."; + + // Simple HTML for the error page + echo << + + + + + {$error_title} + + + +
+

{$error_title}

+

{$error_message}

+

{$most_likely_cause}

+

{$instructions}

+ +
+ Google's Raw Response: + {$google_response} +
+ + +
+ + +HTML; + exit(); +} +?> diff --git a/google_config.php b/google_config.php new file mode 100644 index 0000000..4f9ad30 --- /dev/null +++ b/google_config.php @@ -0,0 +1,20 @@ + "Credentials". +// 4. Click "Create Credentials" -> "OAuth client ID". +// 5. Select "Web application" for the application type. +// 6. Under "Authorized redirect URIs", add the EXACT redirect URI for your application. +// You can find the correct URI by temporarily adding the following line to your index.php: +// echo "Your Redirect URI is: " . GOOGLE_REDIRECT_URI; +// 7. Click "Create". +// 8. Copy the "Client ID" and "Client Secret" and paste them below. + +define('GOOGLE_CLIENT_ID', '105420142772-pfmcst2vhtm9to0tmaeonua2varbb0qd.apps.googleusercontent.com'); +define('GOOGLE_CLIENT_SECRET', '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'); + +// Set the redirect URI to use https, as required for production apps. +define('GOOGLE_REDIRECT_URI', 'https://' . $_SERVER['HTTP_HOST'] . '/callback.php'); +?> diff --git a/index.php b/index.php index e13ae95..5f5d6d4 100644 --- a/index.php +++ b/index.php @@ -1,131 +1,74 @@ - + - - - New Style - - - - + + + My Calendar + + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

Flatlogic AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- + + + + +
+
+

Your Personal Calendar

+

All your events, in one place.

+ + + Disconnect Google Calendar + + + + Connect Google Calendar + + +
+
+ +
+ +
+

Your Upcoming Events

+

Your calendar events will be displayed here shortly.

+ +
+ +
+

Your calendar will appear here

+

Connect your Google Calendar to get started.

+
+
+ A person organizing their schedule +
+
+ A close-up of a calendar +
+
+
+ +
+ + + + + - + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..8027d63 --- /dev/null +++ b/logout.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/oauth-redirect.php b/oauth-redirect.php new file mode 100644 index 0000000..c254e7c --- /dev/null +++ b/oauth-redirect.php @@ -0,0 +1,22 @@ + GOOGLE_CLIENT_ID, + 'redirect_uri' => GOOGLE_REDIRECT_URI, + 'response_type' => 'code', + 'scope' => 'https://www.googleapis.com/auth/calendar.readonly', + 'access_type' => 'offline', // Required to get a refresh token + 'prompt' => 'consent' // Forces the consent screen to be shown every time +]); + +header('Location: ' . $auth_url); +exit(); +?>