<?php /* * User profile page. User can view/edit his * password and credit card information from here. */ require_once __DIR__ . '/../bootstrap.php'; session_start(); if (!isSignedIn()) { header('Location: sign_in.php'); exit; } try { $user = getUser(getSignedInUser()); if (isset($user['creditcard_id']) && $user['creditcard_id'] != NULL) { $card = getCreditCard($user['creditcard_id']); } // Sign in form postback if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Confirm that the user has provided the correct current password if (validateLogin($_POST['user']['email'], $_POST['user']['current_password'])) { $creditCardId = NULL; $newPassword = NULL; $newCard = array_map('trim', $_POST['user']['credit_card']); $newValues = count(array_filter($newCard, 'strlen')); // Update credit card info if new credit card data has been provided if ($newValues > 0 && $newValues < 5) { $message = "Please fill in all required credit card values."; $messageType = "error"; } else { if ($newValues == 5) {
<?php $basePath = strstr($_SERVER['PHP_SELF'], "/index.php") ? "." : ".."; require_once 'bootstrap.php'; if (isSignedIn()) { ?> <div class='navbar navbar-static-top'> <div class='navbar-inner'> <div class='container'> <ul class="nav navbar-nav"> <li><a href="<?php echo HOST; ?> manage/index.php">Manage key</a></li> <li><a href="<?php echo HOST; ?> manage/updateprice.php">Update price</a></li> </ul> </div> </div> </div> <?php }
<?php /* * An order confirmation screen for the buyer. The buyer * is required to choose a payment method here. * Available payment methods are paypal and credit card. */ require_once __DIR__ . '/../bootstrap.php'; session_start(); if (!isSignedIn() || !isset($_GET['order'])) { header('Location: ../user/sign_in.php'); exit; } $amount = $_GET['order']['amount']; $description = $_GET['order']['description']; // Figure out what funding instruments are available for this buyer $availableFundingInstruments = array(); $user = getUser(getSignedInUser()); if (isset($user['creditcard_id']) && $user['creditcard_id'] != NULL) { $availableFundingInstruments[] = 'credit_card'; } $availableFundingInstruments[] = 'paypal'; ?> <!DOCTYPE html> <html lang='en'> <head> <meta charset='utf-8'> <meta content='IE=Edge,chrome=1' http-equiv='X-UA-Compatible'> <meta content='width=device-width, initial-scale=1.0' name='viewport'> <title>PizzaShop</title> <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
$googleClient->addScope(Google_Service_Calendar::CALENDAR_READONLY); /** * Configure User Access */ // Check if access token available if (isset($_SESSION['google_access_token']) && $_SESSION['google_access_token'] !== null) { // Set the access token $googleClient->setAccessToken($_SESSION['google_access_token']); //unset($_SESSION['google_connect']); // Check if it has expired if ($googleClient->isAccessTokenExpired()) { // Remove the access token because it has expired unset($_SESSION['google_access_token']); } } ChromePhp: log($_SESSION); // Check if the access token is not available and the refresh token is available if ((!isset($_SESSION['google_access_token']) || $_SESSION['google_access_token'] === null) && isSignedIn() && $me['google_refresh_token'] !== null) { try { // Refresh the access token using the refresh token $googleClient->refreshToken($me['google_refresh_token']); // Set the new access token $_SESSION['google_access_token'] = $googleClient->getAccessToken(); } catch (Exception $e) { } } else { if ((!isset($_SESSION['google_access_token']) || $_SESSION['google_access_token'] === null) && isSignedIn() && $me['google_refresh_token'] == null && !isset($_SESSION['google_connect'])) { header('Location:' . $googleClient->createAuthUrl()); } }
<?php require_once __DIR__ . '/../../google.php'; /** * Authentication */ if (isset($_GET['code'])) { // Authenticate $googleClient->authenticate($_GET['code']); // Store access token $_SESSION['google_access_token'] = $googleClient->getAccessToken(); // Get the refresh token $googleToken = json_decode($_SESSION['google_access_token']); if (isset($googleToken->refresh_token) && isSignedIn()) { $sql = 'UPDATE users SET google_refresh_token = :googleRefreshToken WHERE id = :id'; $statement = $database->prepare($sql); $statement->bindParam(':googleRefreshToken', $googleToken->refresh_token, PDO::PARAM_STR); $statement->bindParam(':id', $_SESSION[USER_SESSION_NAME], PDO::PARAM_INT); $statement->execute(); } } else { // There was an error $_SESSION['error_message'] = 'There was an error authenticating with Google. Please try again.'; } /** * Redirect */ $redirect = APP_PATH . '/'; header('Location: ' . $redirect);