<?php /* * userLogin.php * */ require_once './vendor/autoload.php'; use Zend\Config\Factory; DEFINE('__ACTIVE_VERSION_DIR__', Factory::fromFile('config/config.php', true)->get('ACTIVE_VERSION_DIR')); require __ACTIVE_VERSION_DIR__ . "/Constants/debug_mode.php"; /* Debug mode */ require __ACTIVE_VERSION_DIR__ . "/Classes/Login.php"; //catch case that is missed by .htaccess --> /Stomp/ (where there is no request) if (!array_key_exists('request', $_REQUEST)) { $_REQUEST['request'] = 'invalidEnpoint'; } // Requests from the same server don't have a HTTP_ORIGIN header if (!array_key_exists('HTTP_ORIGIN', $_SERVER)) { $_SERVER['HTTP_ORIGIN'] = $_SERVER['SERVER_NAME']; } try { $login = new Login($_REQUEST['request'], $_SERVER['HTTP_ORIGIN']); echo $login->processLogin() . "\n"; } catch (Exception $e) { echo json_encode(array('error' => $e->getMessage())) . "\n"; }
# Login class. $login = new Login($help->sess_dir); $login->startsession(); if (isset($_GET['act']) && $_GET['act'] == 'signout') { $login->login_page = '?act=l'; # This script with (index.php?act=l). Redirect here after logging out. $login->logout($help->sessname); # Log the user out. $login->redirectIfNotLoggedIn($help->sessname, '?act=l'); # Send to login page (/help/?act=l). exit; } // End if sign out code. if (isset($_GET['act']) && $_GET['act'] == 'l') { // Send required fields so method can check whether they're not empty. $errrotext = $login->processLogin(array('txt_user' => 'Username', 'txt_pass' => 'Password'), $help); } // End if login attempted. require '../../../includes/classes/Document.php'; if (isset($_GET['act']) && $_GET['act'] == 'l') { if ($login->isLoggedIn($help->sessname)) { exit; } $document = new Document('Help::Login to view this page!'); $login->showLogin(array('user' => 'Username', 'pass' => 'Password'), $login->invalid); # Not currently logged in unset($document); exit; } // End if. $login->redirectIfNotLoggedIn($help->sessname, '?act=l');
<?php if (Login::isLogged()) { Helper::redirect(Login::$_default); } $objForm = new Form(); $objValid = new Validation($objForm); $objMember = new Member(); if ($objForm->isPost('login_email')) { $member = $objMember->getMembers(array('personal_email' => $objForm->getPost('login_email'), 'password' => Login::hash($objForm->getPost('login_password')))); if (!empty($member) && count($member) == 1) { //echo '<h1>VALID</h1>'; Login::processLogin($member[0]['id'], '/sugarkms/' . $this->objURL->href($this->objURL->get(Login::$_referrer)), $objForm->getPost('remember')); } else { $objValid->add2Errors('login'); } } require_once '_header.php'; ?> <h1>Login</h1> <form action="" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="tbl_insert"> <tr> <?php echo $objValid->validate('login'); ?> <td><label for="login_email">Email:</label></td> <td><input type="text" name="login_email" id="login_email" class="fld" value="" /></td> </tr> <tr> <td><label for="login_password">Password:</label></td> <td><input type="password" name="login_password" id="login_password" class="fld" value="" /></td>