function basic_auth(array $setupconfig) { try { $user = $_SERVER['PHP_AUTH_USER']; $pass = $_SERVER['PHP_AUTH_PW']; //try to use the export user if (isset($setupconfig['export_user']) && isset($setupconfig['export_key'])) { $export_user = strtolower($setupconfig['export_user']); $export_key = $setupconfig['export_key']; if (strtolower($user) == $export_user && $pass == $export_key) { $logged_in = true; } } //if not, try to authenticate against Google Apps if (!$logged_in) { try { $auth = new \NRG\Login\Google\ClientLogin($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); //Attempt to authenticate the user $auth->login(); if ($auth->isSuccessful()) { $logged_in = true; } } catch (\NRG\Login\Google\ClientLoginException $e) { $logged_in = false; ajax_http_auth_error("Invalid username or password"); } } //if none of the options above worked, return an error if (!$logged_in) { ajax_http_auth_error("Invalid username or password"); } } catch (Exception $e) { ajax_http_auth_error($e->getMessage()); } }
* @todo Change the code to return only XML and use HTTP status codes. * @warning The XSL file used will be cached, if possible. If you update your * XSL, make sure to disable APC caching. * @see ../utils/subjectdata.php */ require_once "auth.php"; require_once "NRG/Configuration.php"; require_once "NRG/Login/Google/ClientLogin.php"; require_once '../database.php'; require_once "../utils/subjectdata.php"; ini_set('memory_limit', 256 * 1024 * 1024); //256MB define('XSL_SUBJECT_DATA', '../xsl/subjectdata.xsl'); define('MAX_LABELS', 100); if (!isset($_SERVER['PHP_AUTH_USER'])) { ajax_http_auth_error("This service requires an authenticated user"); } $config = NULL; $dbconfig = NULL; $setupconfig = NULL; $db = NULL; $logged_in = false; try { $config = new \NRG\Configuration("../config.ini.php"); $dbconfig = $config->Database; $setupconfig = $config->Setup; $db = new Database($dbconfig['host'], $dbconfig['user'], $dbconfig['pass'], $dbconfig['name']); } catch (Exception $e) { ajax_error($e->getMessage()); } if (!isset($_REQUEST['label']) || empty($_REQUEST['label'])) {