Esempio n. 1
0
    $userArray = [];
    include "getUsersFromJSON.php";
    for ($i = 0; $i < sizeof($userArray); $i++) {
        if ($userArray[$i]->{'username'} == $username) {
            if ($userArray[$i]->{'password'} == $password) {
                $_SESSION['loggedIn'] = $username;
                $returnValue = $userArray[$i]->{'accountType'};
            } else {
                //wrong password --> returnValue doesn't need to be changed!
            }
            break;
        }
    }
    echo $returnValue;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    $password = $_POST['password'];
    if (isset($username) && isset($password) && $username != "" && $password != "") {
        include_once "functions.php";
        $password = crypt($password, getSalt());
        if (file_exists($path_config_users)) {
            checkLoginData($username, $password);
        } else {
            echo 'failure';
            //file doesn't exist
        }
    } else {
        echo "wrongInput";
    }
}
Esempio n. 2
0
$LOGINLOCKTIME = 10;
// Überprüfen: Existiert ein Benutzer? Wenn nicht: admin:install anlegen
if ($loginpassword->get("name") == "" or $loginpassword->get("pw") == "") {
    // Install Formular anzeigen
    return login_formular(false, "install_login");
}
// User hat sich ausgeloggt
if (getRequestValue('logout', 'get', false)) {
    // Session beenden und die Sessiondaten löschen
    session_destroy();
    unset($_SESSION);
}
// Wurde das Anmeldeformular verschickt?
if (getRequestValue('login', 'post', false) and false !== ($name = getRequestValue('username', 'post', false)) and false !== ($pw = getRequestValue('password', 'post', false))) {
    // Zugangsdaten prüfen
    if (checkLoginData($name, $pw)) {
        // Daten in der Session merken
        $_SESSION['username'] = $name;
        $_SESSION['login_okay'] = true;
        $_SESSION['login_tmp'] = getClientDaten();
    }
}
// Anmeldung erfolgreich
if (isset($_SESSION['login_okay']) and $_SESSION['login_okay'] === true and isset($_SESSION['login_tmp']) and $_SESSION['login_tmp'] === getClientDaten()) {
    define("LOGIN", true);
    // Counter für falsche Logins innerhalb der Sperrzeit zurücksetzen
    $LOGINCONF->set("falselogincounttemp", 0);
    return true;
    // Anmeldung fehlerhaft
} elseif (getRequestValue('login', 'post', false)) {
    // Counter hochzählen