<?php if (empty($_GET["lang"])) { $lang = !empty($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2) == "fr" ? "fr" : "en"; header("Location: ?lang={$lang}"); exit; } session_start(); header('Content-Type: text/html; charset=utf-8'); require_once "tequila.php"; $oClient = new TequilaClient(); //$ret = array(); //$ret["status"] = 500; //echo "<pre>"; //print_r($_SESSION); //exit; if (!empty($_GET["logout"])) { unset($_SESSION["user"]); unset($_SESSION["tequila_key"]); echo "<p>Logged out</p>\n"; echo "<p><a href=\"?\">Login again</a></p>"; exit; } if (!empty($_SESSION["tequila_key"])) { $key = $_SESSION["tequila_key"]; unset($_SESSION["tequila_key"]); $attributes = $oClient->fetchAttributes($key); if ($attributes) { $_SESSION["user"] = $attributes; // } else { // die("f****r");
<?php require_once "tequila.php"; $oClient = new TequilaClient(); $ret = array(); $ret["status"] = 500; if (!empty($_GET["key"])) { $attributes = $oClient->fetchAttributes($_GET["key"]); if ($attributes) { $ret["status"] = 200; $ret["attributes"] = $attributes; } } elseif (!empty($_GET["app_url"]) && !empty($_GET["app_name"])) { $oClient->SetApplicationName($_GET["app_name"]); $oClient->SetApplicationURL($_GET["app_url"]); $oClient->SetWantedAttributes(array('uniqueid', 'name', 'firstname', 'unit', 'unitid', 'where', 'group', 'email', 'title')); $oClient->SetAllowsFilter("categorie=Shibboleth|categorie=epfl-guests"); $oClient->createRequest(); $key = $oClient->GetKey(); if ($key) { $ret["status"] = 200; $ret["key"] = $key; $ret["redirect"] = $oClient->getAuthenticationUrl(); } } echo json_encode($ret);