/** * This function returns the name of the main script minus the .php extension in * order to help identify the current page * * @return array Filename of current script without .php and logged in status */ function plugins_get_context() { global $authmech; if (!$authmech) { $authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method); } $basename = basename($_SERVER['SCRIPT_NAME'], '.php'); $logged_in = !$authmech->needsLogin(); return array($basename, $logged_in); }
<?php /** * Licensed to The Apereo Foundation under one or more contributor license * agreements. See the NOTICE file distributed with this work for * additional information regarding copyright ownership. * The Apereo Foundation licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ require_once "config.php"; $authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method); if ($authmech->hasLogout()) { _debug("Single Logout"); $authmech->logout(); } session_destroy();
function login_processing($exit = true) { global $errors, $authmech, $xerte_toolkits_site; /** * Check to see if anything has been posted to distinguish between log in attempts */ $authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method); if ($_SERVER['REQUEST_METHOD'] !== "POST") { if ($authmech->needsLogin() && $exit) { login_form($errors, $xerte_toolkits_site); exit(0); } } if ($authmech->needsLogin()) { /** * Check if we are logged in */ if (isset($_SESSION['toolkits_logon_username']) && !isset($_POST['login'])) { return array(true, array()); } /** * * Check if setting language */ if (isset($_POST['language'])) { login_form($errors, $xerte_toolkits_site); exit(0); } /** * Username and password left empty */ if (empty($_POST["login"]) && empty($_POST["password"])) { $errors[] = INDEX_USERNAME_AND_PASSWORD_EMPTY; /* * Username left empty */ } else { if (empty($_POST["login"])) { $errors[] = INDEX_USERNAME_EMPTY; /* * Password left empty */ } else { if (empty($_POST["password"])) { $errors[] = INDEX_PASSWORD_EMPTY; } } } if (!empty($_POST['login']) && $_POST["login"] == $xerte_toolkits_site->admin_username && (!empty($_POST['password']) && $_POST["password"] == $xerte_toolkits_site->admin_password)) { $errors[] = INDEX_SITE_ADMIN; } $success = false; if (empty($errors)) { try { $authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method); } catch (InvalidArgumentException $e) { $errors[] = "Invalid authentication choice; check config.php (authentication_method)"; } if (empty($errors)) { if ($authmech->check()) { $success = $authmech->login($_POST['login'], $_POST['password']); } $errors = $authmech->getErrors(); } } if ($exit === true) { if (!$success || !empty($errors)) { login_form($errors, $xerte_toolkits_site); exit(0); } } else { //not exit return array($success, $errors); } } }