<? /* Basic login example with php user class http://phpUserClass.com */ require_once 'authClass_php5.php'; $user = new flexibleAccess(); if ( isset($_GET['logout']) && $_GET['logout'] == 1 ) $user->logout('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); if ( !$user->is_loaded() )//если нет userID, т.е. в конструкторе не определили, проверяем введенные данные, если ошибка - редирект на себя { //Login stuff: if ( isset($_POST['uname']) && isset($_POST['pwd'])){//если есть и логин и пароль if ( !$user->login($_POST['uname'],$_POST['pwd'],$_POST['remember'] )){//если login класса = ложь, сообщаем //Mention that we don't have to use addslashes as the class do the job echo 'Wrong username and/or password'; }else{ //если login класса = истина, редирект echo "Да,вот так вот"; //user is now loaded header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); } } echo '<h1>Login</h1> <p><form method="post" action="'.$_SERVER['PHP_SELF'].'" > username: <input type="text" name="uname" ><br><br > password: <input type="password" name="pwd" ><br ><br > Remember me? <input type="checkbox" name="remember" value="1" ><br ><br > <input type="submit" value="login" > </form> </p>'; die();
<?php $successURL = 'index.php'; //Where the user can go after a successful login if ($_GET['form'] == 1) { if (isset($_POST['nameuser'])) { require_once 'access.class.php'; $user = new flexibleAccess(); if ($user->login($_POST['nameuser'], $_POST['passuser'], true)) { echo '{' . 'succes: true,' . 'title: \'<strong>Login Success</strong>\', ' . 'content: \'You have authenticated successfuly<br />' . 'click <a href="' . $successURL . '">here</a> to continue\'' . '}'; } else { echo '{' . 'succes: false,' . 'title: \'<strong>Login Failed : User and Password combination is not valid</strong>\'' . '}'; } } else { echo '<form name="ajaxform" id="ajaxform"> <label>Username</label> <input type="text" name="nameuser" id="nameuser" class="textfield" value="' . $_POST['nameuser'] . '" /> <label>Password</label> <input type="password" name="passuser" id="passuser" class="textfield" /> <input type="submit" name="submit" id="submit" class="buttonfield" value="Login" /> </form>'; } exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ajax PHP Login with jquery</title> <meta name="robots" content="noindex,nofollow" />
$DB = new DB_Engine('mysql', $settings['dbHost'], $settings['dbUser'], $settings['dbPass'], $settings['dbName']); $DB->show_err = true; $DB->prefix = $settings['dbPrefix']; get_registry(); get_powerstatus(); $LOG = new osrLogs($registry, $DB); if ($_POST['export'] == 1) { $export = 1; include 'export.php'; } if ($_GET['logout'] == 1) { $user->logout('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } if (!$user->is_loaded()) { if (isset($_POST['uname']) && isset($_POST['pwd'])) { if (!$user->login($_POST['uname'], $_POST['pwd'], $_POST['remember'])) { $err = 2; header('Location: /com/login/'); } else { header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } } } else { if (!$user->is_active() and $_GET['code'] == '') { $err = 1; } } @(include $theme . '.model.php'); if ($component == '') { $com_path = 'frontpage'; } else {
require_once '../lib/dbsql.class.php'; $user = new flexibleAccess('', $settings); $DB = new DB_Engine('mysql', $settings['dbHost'], $settings['dbUser'], $settings['dbPass'], $settings['dbName']); $DB->prefix = $settings['dbPrefix']; $DB->show_err = FALSE; $sql = "SELECT `#__setting`.* FROM `#__setting`"; $tmp_registry = $DB->getAll($sql); foreach ($tmp_registry as $tmp) { $registry[$tmp['name']] = $tmp['value']; } if ($_GET['logout'] == 1) { $user->logout('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } if (!$user->is_loaded()) { if (isset($_POST['uname']) && isset($_POST['pwd'])) { if (!$user->login($_POST['uname'], $_POST['pwd'], $_POST['remember']) and $component != 'cron') { $err = 2; } else { header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } } } else { if (!$user->is_active()) { $err = 1; } } if ($component == '') { $com_path = 'frontpage'; } else { $com_path = $component; }
} } // ** Check if user wants to change the password $newpassword = ""; if (isset($_POST['nPass1']) && isset($_POST['nPass2'])) { if ($_POST['nPass1'] == $_POST['nPass2']) { $newpassword = substr($_POST['nPass1'], 0, 12); } else { $user->login_matchFalse(); exit; //To ensure security } } // ** User LOGIN process if $validate is true if ($validate) { $loginAttempt = $user->login(substr($_POST['user'], 0, 30), substr($_POST['token'], 0, 12), $newpassword); if ($loginAttempt == 1) { $message = "Login Success."; header("Location: " . $forwardPage); exit; //To ensure security } else { if ($loginAttempt == 0) { $l = 1 + $user->loginAttempts - $user->fAtmp; $message = "Login Failed : Login is not valid. " . $l . " attempts left."; } else { if ($loginAttempt == 2) { $message = "Login blocked for " . $user->loginTime . " minutes: Too many false login attempts."; $username = ""; } else { if ($loginAttempt == 3) {
} //login if (isset($_POST['login_submit'])) { if (empty($_POST['username'])) { $error_msg .= "<li>Please enter your username</li>"; } elseif (empty($_POST['password'])) { $error_msg .= "<li>Please enter your password</li>"; } else { //all fields are submitted correctly //sanitise the variables $username = trim($_POST['username']); $password = trim($_POST['password']); $username = filter_var($username); $password = filter_var($password); //var_dump($user); die(); if ($user->login($username, $password)) { header("location:index.php"); } else { $error_msg = "<li>Username and password combination not found.</li>"; } } } ?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>PulsePro Admin</title> <script type='text/javascript' src=''></script> <script type='text/javascript'> </script>
<? /* Basic login example with php user class http://phpUserClass.com */ require_once 'access.class.php'; $user = new flexibleAccess(); if ( $_GET['logout'] == 1 ) $user->logout('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); if ( !$user->is_loaded() ) { //Login stuff: if ( isset($_POST['uname']) && isset($_POST['pwd'])){ if ( !$user->login($_POST['uname'],$_POST['pwd'],$_POST['remember'] )){//Mention that we don't have to use addslashes as the class do the job echo 'Wrong username and/or password'; }else{ //user is now loaded header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); } } echo '<h1>Login</h1> <p><form method="post" action="'.$_SERVER['PHP_SELF'].'" /> username: <input type="text" name="uname" /><br /><br /> password: <input type="password" name="pwd" /><br /><br /> Remember me? <input type="checkbox" name="remember" value="1" /><br /><br /> <input type="submit" value="login" /> </form> </p>'; }else{ //User is loaded echo '<a href="'.$_SERVER['PHP_SELF'].'?logout=1">logout</a>';