Esempio n. 1
0
function retrieve_calendar_data($client)
{
    $t = filter_input(INPUT_GET, 't', FILTER_SANITIZE_STRING);
    $e = filter_input(INPUT_GET, 'e', FILTER_SANITIZE_STRING);
    $code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_URL);
    if (isset($t) && isset($e)) {
        $_SESSION['token_id'] = $t;
        $_SESSION['event_id'] = $e;
        sql_check_token();
        $auth_url = $client->createAuthUrl();
        header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
    } elseif (isset($code)) {
        $client->authenticate($code);
        //Authenticate client with code
        if ($client->isAccessTokenExpired()) {
            $auth_url = $client->createAuthUrl();
            header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
        }
        $_SESSION['access_token'] = $client->getAccessToken();
        //Store access token in session
        redirect_local(GOOGLE_CALENDAR_ACCESS_PATH);
    } else {
        redirect_local(ERROR_PATH . "/?e=missing_token");
    }
}
Esempio n. 2
0
    session_start();
}
$homedir = "../../";
require_once $homedir . "config/mysqli_connect.php";
$ti = 1;
//these should get their values from a failed attempt at a POST request
$errors = [];
$warnings = [];
$notifications = [];
$scrubbed = array_map("spam_scrubber", $_POST);
if (!(isset($_SESSION['access_token']) && $_SESSION['access_token'])) {
    redirect_local(OAUTH2_PATH . '?' . $_SESSION['token_id']);
}
if (!empty($_POST['checkboxvar'])) {
    $_SESSION['user_calendar_summaries'] = filter_var_array(explode(",", $scrubbed['checkboxvar']), FILTER_SANITIZE_STRING);
    redirect_local(GOOGLE_CALENDAR_ACCESS_PATH);
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="icon" type="image/png" href="<?php 
echo $homedir;
?>
favicon.png" sizes="128x128">
        
        <link rel="stylesheet" type="text/css" href="<?php 
echo $homedir . "css/goog.css";
?>
">
Esempio n. 3
0
        break;
    case "invalid_event":
        $error_message = 'Event was invalid or has been removed.';
        break;
    case "invalid_email":
        $error_message = 'Email found was invalid. This is due to an unknown error. Please try the link again.';
        break;
    case "missing_token":
        $error_message = 'URL does not include access token.';
        break;
    case "missing_event":
        $error_message = 'URL does not include event id.';
        break;
    case "sql_connection":
        $error_message = 'SQL database connection error.';
        break;
    case "sql_insertion":
        $error_message = 'SQL database insertion error, no lines changed.';
        break;
    case "sql_charset":
        $error_message = 'SQL database error: Error loading character set utf8';
        break;
    default:
        $error_message = 'Unknown error, please try again';
        break;
}
session_destroy();
session_start();
$_SESSION['calendarsaved'] = array("messagetype" => "errors", "message" => $error_message);
redirect_local("../index.php");
Esempio n. 4
0
function insert_mysql_info($events_array)
{
    $serialized_events = (string) json_encode($events_array);
    insert_event_data($serialized_events);
    unset_session_variables();
    $_SESSION['calendarsaved'] = array("messagetype" => "notifications", "message" => "Success! Your calendar data has been saved. Thank you for using MESA. You may now close the page.");
    redirect_local("../index.php");
    exit;
}
Esempio n. 5
0
function connect_sql()
{
    $dbc = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    if ($dbc->connect_errno) {
        redirect_local(ERROR_PATH . "/?e=sql_connection");
    }
    if (!mysqli_set_charset($dbc, "utf8")) {
        redirect_local(ERROR_PATH . "/?e=sql_charset");
    }
    return $dbc;
}