function isLoggedIn() { global $User, $_COOKIE; if (isset($User)) return true; if (isset($_COOKIE['auth'])) { $r = redisLink(); $authcookie = $_COOKIE['auth']; if ($userid = $r->get("auth:$authcookie")) { if ($r->get("uid:$userid:auth") != $authcookie) return false; loadUserInfo($userid); return true; } } return false; }
function isLoggedIn() { global $User, $_COOKIE; if (isset($User)) { return true; } if (isset($_COOKIE['auth'])) { $r = redisLink(); $authcookie = $_COOKIE['auth']; if ($userid = $r->hget("auths", $authcookie)) { if ($r->hget("user:{$userid}", "auth") != $authcookie) { return false; } loadUserInfo($userid); return true; } } return false; }
function isLoggedIn() { global $User, $_COOKIE; if (isset($User)) { return true; } if (isset($_COOKIE['secret'])) { $r = redisLink(); $authcookie = $_COOKIE['secret']; if ($userid = $r->get("auth:{$authcookie}")) { if ($r->get("uid:{$userid}:auth") != $authcookie) { return false; } loadUserInfo($userid); return true; } } return false; }
/** * isLoggedIn * checks to see if user is looged in **/ function isLoggedIn() { global $User, $_COOKIE; $redis = new Predis\Client(); if (isset($User)) { return true; } if (isset($_COOKIE['auth'])) { $authcookie = $_COOKIE['auth']; if ($userid = $redis->get("auth:{$authcookie}")) { if ($redis->get("uid:{$userid}:auth") != $authcookie) { return false; } loadUserInfo($userid); return true; } } return false; }
<?php require 'redis.php'; if (!isLoggedIn()) { header('Location: ' . SITEURL . 'login-register.php'); } loadUserInfo($User['id']); $total = getCurrentValue($User['id']); include 'header.php'; include 'game.php'; include 'footer.php';
use Tsugi\Core\LTIX; // Sanity checks $LTI = LTIX::requireData(); $p = $CFG->dbprefix; $user_info = false; $links = array(); $user_sql = false; $class_sql = false; $summary_sql = false; $link_id = 0; if (isset($_GET['link_id'])) { $link_id = $_GET['link_id'] + 0; } $link_info = false; if ($USER->instructor && $link_id > 0) { $link_info = loadUserInfo($link_id); } if ($USER->instructor && isset($_GET['viewall'])) { $query_parms = array(":CID" => $CONTEXT->id); $orderfields = array("R.user_id", "displayname", "email", "user_key", "grade_count"); $searchfields = array("R.user_id", "displayname", "email", "user_key"); $summary_sql = "SELECT R.user_id AS user_id, displayname, email, COUNT(grade) AS grade_count, user_key\n FROM {$p}lti_result AS R JOIN {$p}lti_link as L\n ON R.link_id = L.link_id\n JOIN {$p}lti_user as U\n ON R.user_id = U.user_id\n WHERE L.context_id = :CID AND R.grade IS NOT NULL\n GROUP BY R.user_id"; } else { if ($USER->instructor && isset($_GET['link_id'])) { $query_parms = array(":LID" => $link_id, ":CID" => $CONTEXT->id); $searchfields = array("R.user_id", "displayname", "grade", "R.updated_at", "server_grade", "retrieved_at"); $class_sql = "SELECT R.user_id AS user_id, displayname, grade,\n R.updated_at as updated_at, server_grade, retrieved_at\n FROM {$p}lti_result AS R JOIN {$p}lti_link as L\n ON R.link_id = L.link_id\n JOIN {$p}lti_user as U\n ON R.user_id = U.user_id\n WHERE R.link_id = :LID AND L.context_id = :CID AND R.grade IS NOT NULL"; } else { // Gets grades for the current or specified $user_id = $USER->id; if ($USER->instructor && isset($_GET['user_id'])) {