Пример #1
0
function getRememberMe($expiration)
{
    if (empty($_COOKIE['rememberme_data']) || empty($_COOKIE['rememberme_token'])) {
        return false;
    }
    $current_time = time();
    // On définit le timestamp actuel
    $token = getUserToken();
    // On crypt les informations du cookie concaténées avec le jeton
    $crypted_token = hash('sha256', $token . $_COOKIE['rememberme_data']);
    // On vérifie que le jeton du cookie est égal au jeton crypté au dessus
    if (strcmp($_COOKIE['rememberme_token'], $crypted_token) !== 0) {
        return false;
    }
    // On récupère les infos du cookie dans 2 variables, correspondant aux 2 entrées du tableau renvoyé par explode
    list($user_time, $user_id) = explode('.', $_COOKIE['rememberme_data']);
    // On vérifie que le timestamp défini dans le cookie expire dans le futur et qu'il a été défini dans le passé
    if ($user_time + $expiration > $current_time && $user_time < $current_time) {
        return $user_id;
    }
    return false;
}
Пример #2
0
<?php

require '../core/sessions.php';
require '../core/functions.php';
getGetVar();
require_once '../core/db.php';
startSession();
getPersonalList($id);
getUserToken($id);
if ($_COOKIE['online'] == $id) {
    if (isset($_POST['list_name_submit']) && !empty($_POST['list_name_submit'])) {
        if (empty($_POST['list_name'])) {
            $_SESSION['temp_msg'] = 'Please enter a list name';
            header('Location: ../edit-list.php?id=' . $id . '&success=false');
            exit;
        }
        $listName = $_POST['list_name'];
        addList($userID, $listName);
        $_SESSION['temp_msg'] = $listAdded_success;
        header('Location: ../edit-list.php?id=' . $id . '&success=true');
        exit;
    }
}
?>

Пример #3
0
/**
 * Get Channel API token for a given user
 * @param $user logged in user
 * @return false, if the attempt failed, else the Channel API token
 */
function wespot_msg_get_channel_token($user, $refresh = false)
{
    global $SESSION;
    $token = NULL;
    if (!$refresh && isset($SESSION['__elgg_wespot_msg_channel_token_created']) && time() - $SESSION['__elgg_wespot_msg_channel_token_created'] < 7200 && isset($SESSION['__elgg_wespot_msg_channel_token'])) {
        $token = $SESSION['__elgg_wespot_msg_channel_token'];
    } else {
        $arlearn_user_token = getUserToken($user->getGUID());
        $results = getARLearnChannelAPIToken($arlearn_user_token);
        if ($results != false) {
            $datareturned = json_decode($results);
            if (!isset($datareturned->error)) {
                $token = $datareturned->token;
                $SESSION['__elgg_wespot_msg_channel_token_created'] = time();
                $SESSION['__elgg_wespot_msg_channel_token'] = $token;
            } else {
                register_error(elgg_echo("wespot_msg:channel:error", $datareturned->error));
            }
        } else {
            //register_error(elgg_echo("wespot_msg:channel:failed"));
        }
    }
    return $token;
}
require 'gmail/autoload.php';
include "../config.php";
include "config.php";
define('APPLICATION_NAME', 'Gmail API Quickstart');
define('CLIENT_SECRET_PATH', 'client_secret.json');
define('SCOPES', implode(' ', array(Google_Service_Gmail::GMAIL_READONLY)));
if (isset($_GET['action'])) {
    $action = $_GET['action'];
} else {
    $action = "none";
}
if (isset($_COOKIE['MoodleSession'])) {
    $userid = getMoodleIdFromSession($_COOKIE['MoodleSession']);
    //echo "User ID = $userid ";
    if (isStudent($userid)) {
        $userToken = getUserToken($userid);
        if (isset($userToken)) {
            printUnreadMessages($userToken);
        } else {
            if ($action == 'getToken') {
                getNewToken();
            } else {
                echo "0";
            }
        }
    } else {
        echo "null";
    }
}
function printUnreadMessages($userToken)
{
Пример #5
0
<?php

require_once 'config.php';
require_once 'functions.php';
if (!isLoggedIn()) {
    redirect('login.php');
}
$uid = (int) $_SESSION['userid'];
$userTokens = getUserToken($uid);
$query = mysql_query("SELECT * FROM `token_shop_pokemon` ORDER BY `price` ASC");
if (mysql_num_rows($query) == 0) {
    include '_header.php';
    echo '
        <div class="error">The token shop has no pokemon!</div>
    ';
    include '_footer.php';
}
$salePokemon = array();
while ($row = mysql_fetch_assoc($query)) {
    $salePokemon[$row['name']] = $row['price'];
}
include '_header.php';
printHeader('Token Shop');
if (isset($_POST['buyPoke'])) {
    $pokeName = $_POST['buyPoke'];
    if (in_array($pokeName, array_keys($salePokemon))) {
        $price = $salePokemon[$pokeName];
        if ($price > $userTokens) {
            echo '<div class="error">You do not have enough tokens!</div>';
        } else {
            $userTokens -= $price;