echo '<form method="post" action="pruebaLogin.php">'; echo '<input type="submit" name="botonCerrarSesion" value="Cerrar sesión">'; echo '</form>'; } function mensajeLogout() { echo '<h1>Ha cerrado sesión</h1>'; } function mensajeLoginExitoso() { echo '<h1>Ha iniciado sesión</h1>'; } function mensajeLoginFallido() { echo '<h1>No se pudo iniciar sesión</h1>'; } $options = array("dsn" => "mysql://*****:*****@localhost/controlacceso", "table" => "usuario", "usernamecol" => "numeroDocumento", "passwordcol" => "password", "cryptType" => "sha1"); $autenticacion = new Auth("MDB2", $options, "formularioLogin"); $autenticacion->setLogoutCallback("mensajeLogout"); $autenticacion->setLoginCallback("mensajeLoginExitoso"); $autenticacion->setFailedLoginCallback("mensajeLoginFallido"); $autenticacion->start(); if ($autenticacion->checkAuth()) { if (isset($_POST['botonCerrarSesion'])) { $autenticacion->logout(); $autenticacion->start(); } else { echo '<p>Logueado como: ' . $autenticacion->getUsername() . '</p>'; formularioLogout(); } }
<?php error_reporting(E_ERROR); include_once 'includes/trace.debugger.php'; require_once 'class/webpage.php'; require_once 'class/sql.php'; require_once 'PEAR.php'; require_once 'Auth.php'; //require_once 'ST.LIB.login.inc'; WEBPAGE::START(); $auth = new Auth('DB', WEBPAGE::$auth_options, 'closePopup'); $auth->setFailedLoginCallback('closePopup'); $auth->setLoginCallback('closePopup'); $auth->start(); // blocks session hacking on shared hosting with multiple emms installations if (WEBPAGE::$url != $_SESSION['_authsession']['data']['url']) { $message = 'loggedOut'; $auth->logout(); loginFunction(); exit; } // to be here you need to provide valid username/password // or have a valid session open WEBPAGE::LOAD_SESSION(); $_LABELS = WEBPAGE::getCacheData(sprintf(WEBPAGE::_APP_LABELS_FILE, WEBPAGE::$lang)); $_CONF = WEBPAGE::getCacheData(sprintf(WEBPAGE::_APP_CONF_FILE, WEBPAGE::$lang)); // check permissions here .... line below is just an example if (!is_numeric(WEBPAGE::$userAccessCode)) { exit; } require './includes/index.popup.inc';
<?php error_reporting(E_ERROR); include_once 'includes/trace.debugger.php'; require_once 'class/webpage.php'; require_once 'class/sql.php'; require_once 'PEAR.php'; require_once 'Auth.php'; require_once './includes/ST.LIB.login.inc'; WEBPAGE::START(); // check user auth. status $auth = new Auth('DB', WEBPAGE::$auth_options, 'loginFunction'); $auth->setFailedLoginCallback('loginFailedCallback'); $auth->setLoginCallback('loginCallback'); $auth->start(); //trace($_SESSION['_authsession']['data']['last'],0); // blocks session hacking from emms modules if ($_SESSION['_authsession']['data']['module'] != 'main') { $message = 'loggedOut'; $auth->logout(); loginFunction(); exit; } // blocks session hacking on shared hosting with multiple emms installations if (WEBPAGE::$url != $_SESSION['_authsession']['data']['url']) { $message = 'loggedOut'; $auth->logout(); loginFunction(); exit; } // to be here you need to provide valid username/password
die; } //---- REGISTER if ($_POST['register']) { $a->setLoginCallback('registeredCallback'); $activation = md5(uniqid(rand(), true)); // can add field testing here if ($a->addUser($_POST['username'], $_POST['password'], array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'street' => $_POST['street'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'zip' => $_POST['zip'], 'birthday' => $_POST['birthday'], 'phone' => $_POST['phone'], 'activation' => $activation))) { registeredCallback(); } else { //err here } } else { // normal login $a->setLoginCallback('loginCallback'); $a->setFailedLoginCallback('failedLoginCallback'); $a->start(); } if ($a->getAuth()) { } include 'includes/head.php'; ?> <html lang="en"> <body> <!-- Uses a header that scrolls with the text, rather than staying locked at the top --> <div class="mdl-layout mdl-js-layout"> <main class="mdl-layout__content"> <div class="page-content"> <div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect"> <div class="mdl-tabs__tab-bar"> <a href="#login-panel" class="mdl-tabs__tab is-active">Log In</a>