function login() { if (attemptLogin($_POST["loginEmail"], $_POST["loginPassword"])) { $_SESSION["user"] = $_POST["loginEmail"]; $GLOBALS["conn"]->close(); header("Location: home"); } else { $GLOBALS["errors"]["loginError"] = "Login failed."; } }
parentOpenFolder(); } if ($ftpAction == "editProcess") { editProcess(); } } } } else { if ($ajaxRequest == 0) { // Check if logout link has been clicked checkLogOut(); // Include the header displayHeader(); } // Attempt to login with session or post vars attemptLogin(); // Check referer if (checkReferer() == 1) { // Process any FTP actions processActions(); // Display content when logged in if ($_SESSION["loggedin"] == 1) { if ($ajaxRequest == 0) { displayFormStart(); displayFtpActions(); displayAjaxDivOpen(); } // Display FTP folder history displayFtpHistory(); // Display folder/file listing displayFiles();
function existingUsername($salt_db, $hash_db, $password, $username) { echo $salt_db; $crypto = new Crypto(); $hash = $crypto->generateHash($password, $salt_db); echo '<br/>Generated hash: ' . $hash . '<br/>'; echo 'Hash From db ' . $hash_db; if ($hash_db == $hash && !isUserBlocked($username)) { $_SESSION['username'] = $username; return true; } else { attemptLogin($username); return false; } }
<?php session_start(); header('Content-type: application/json'); require_once '../db.php'; $response = array('valid' => false); if (!isset($_POST['user']) || !isset($_POST['hash'])) { $response['error'] = 'params'; } elseif (isset($_SESSION['userId'])) { // If already loged in, throw an error. $response['error'] = 'relog'; } else { $error = ''; if (attemptLogin(mongoUserSanitize($_POST['user']), mongoHexSanitize($_POST['hash']), $error)) { $response['valid'] = true; } else { // Return the same error for bad pass as no user //$response['error'] = $error; $response['error'] = 'badcombo'; } } echo json_encode($response);