本文整理汇总了PHP中userLogin函数的典型用法代码示例。如果您正苦于以下问题:PHP userLogin函数的具体用法?PHP userLogin怎么用?PHP userLogin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了userLogin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginFunctions
function loginFunctions()
{
global $dbc;
$response = array();
if (isset($_POST['email'], $_POST['password'])) {
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'Invalid Email Address';
}
$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
if (strlen($password) != 128) {
$errors[] = 'Invalid password configuration. ';
}
}
if (isset($_POST['firstName'], $_POST['lastName'])) {
$firstName = filter_input(INPUT_POST, 'firstName', FILTER_SANITIZE_STRING);
$lastName = filter_input(INPUT_POST, 'lastName', FILTER_SANITIZE_STRING);
}
if (empty($errors)) {
if ($_POST['call'] == 'login') {
$response = userLogin($email, $password);
} else {
$response = userSignup($firstName, $lastName, $email, $password);
}
} else {
$response['success'] = false;
$response['errors'] = $errors;
}
echo json_encode($response);
}
示例2: authenticate
function authenticate()
{
global $db, $authRealm, $style;
$rmt = $authRealm != false;
$extAuth = externalAuth();
if (!$rmt || $extAuth === false) {
// built-in authentication attempt
if (empty($_REQUEST['u']) || !isset($_POST['p'])) {
// simple logout
return false;
}
$authData = array("user" => $_REQUEST['u'], "pass" => $_POST['p'], "email" => false);
} else {
// external authentication
if (isset($_REQUEST['u']) && empty($_REQUEST['u'])) {
// remote logout
header('HTTP/1.0 401 Unauthorized');
header('WWW-Authenticate: Basic realm="' . $authRealm . '"');
includeTemplate("{$style}/include/rmtlogout.php");
return null;
}
$authData = $extAuth;
}
// verify if we have administration rights
$DATA = userLogin($authData["user"], $authData["pass"], $rmt, $authData["email"]);
// check if the external authenticator provides an email address
if ($DATA !== false && empty($DATA["email"])) {
$DATA['email'] = $authData["email"];
}
return $DATA;
}
示例3: LoginAPI
function LoginAPI($databasename, $user, $password)
{
global $PathPrefix;
// For included files
include '../config.php';
// Include now for the error code values.
include '../includes/UserLogin.php';
/* Login checking and setup */
$RetCode = array();
// Return result.
if (!isset($_SESSION['DatabaseName']) or $_SESSION['DatabaseName'] == '') {
// Establish the database connection for this session.
$_SESSION['DatabaseName'] = $databasename;
/* Drag in the code to connect to the DB, and some other
* functions. If the connection is established, the
* variable $db will be set as the DB connection id.
* NOTE: This is needed here, as the api_session.inc file
* does NOT include this if there is no database name set.
*/
include '../includes/ConnectDB.inc';
// Need to ensure we have a connection.
if (!isset($db)) {
$RetCode[0] = NoAuthorisation;
$RetCode[1] = UL_CONFIGERR;
return $RetCode;
}
$_SESSION['db'] = $db;
// Set in above include
}
$rc = userLogin($user, $password, $_SESSION['db']);
switch ($rc) {
case UL_OK:
$RetCode[0] = 0;
// All is well
DoSetup();
// Additional setting up
break;
case UL_NOTVALID:
case UL_BLOCKED:
case UL_CONFIGERR:
case UL_SHOWLOGIN:
// Following not in use at 18 Nov 09.
// Following not in use at 18 Nov 09.
case UL_MAINTENANCE:
/* Just return an error for now */
$RetCode[0] = NoAuthorisation;
$RetCode[1] = $rc;
break;
}
return $RetCode;
}
示例4: md5
if (mb_strlen($pwdNew, 'UTF8') < 4 || mb_strlen($pwdNew, 'UTF8') > 16) {
return 'bad.密码长度应在4-16字符之间';
exit;
}
if (md5($pwdInput . "sdshare") != $pwdNow) {
return 'bad.原密码错误';
exit;
}
$pwdNew = md5($pwdNew . "sdshare");
$sql = "UPDATE `sd_users` SET `pwd` = '{$pwdNew}' WHERE `uid` = {$userId}";
mysqli_query($con, $sql);
return 'ok.密码修改成功';
}
switch ($action) {
case 'login':
print_r(userLogin($_POST['username'], $_POST['password'], $con));
break;
case 'register':
print_r(userReg($_POST['username-reg'], $_POST['password-reg'], $con));
break;
case 'delshare':
print_r(delShare($_POST['key'], $con, $userInfo['uid']));
break;
case 'delshares':
print_r(delShareS($_POST['key'], $con, $userInfo['uid']));
break;
case 'changepwd':
print_r(changePwd($_POST['pwd'], $con, $userInfo['pwd'], $_POST['pwdnow'], $userInfo['uid']));
break;
default:
# code...
示例5: userLogin
<?php
include "incl/config.php";
$pageId = "login";
// Check if the url contains a querystring with a page-part.
$p = null;
if (isset($_GET["p"])) {
$p = $_GET["p"];
}
// Is the action a known action?
$content = null;
$output = null;
if ($p == "login") {
$title = "Logga in";
$content = userLogin();
} else {
if ($p == "logout") {
$title = "Logga ut";
$content = userLogout();
} else {
$title = "Status login / logout";
}
}
?>
<?php
include "incl/header.php";
?>
<div id="content">
<div class="left borderRight width80"">
示例6: login
/**
* Logs a user in.
*
* @param string $username
* @param string $password
* @return User or Error
*/
function login($username, $password)
{
global $CFG;
if ($password == "" || $username == "") {
$ERROR = new Error();
$ERROR->createLoginFailedError();
return $ERROR;
}
$user = userLogin($username, $password);
if ($user instanceof Error) {
return $user;
} else {
if ($user instanceof User) {
$user->setPHPSessID(session_id());
return $user;
} else {
$ERROR = new Error();
return $ERROR->createLoginFailedError();
}
}
}
示例7: ini_set
<?php
//Session management
ini_set("session.cookie_secure", 0);
session_start();
if (empty($_SESSION['token'])) {
$_SESSION['token'] = base64_encode(mcrypt_create_iv(8, MCRYPT_DEV_URANDOM));
}
if (!empty($_POST['action']) and isEqual($_POST['action'], "login") and !empty($_POST['username']) and !empty($_POST['password']) and !empty($_POST['CRSFtoken'])) {
$user = userLogin($file_db, $_POST['username'], $_POST['password'], $_POST['CRSFtoken']);
error_log($user);
} elseif (isLoged()) {
$user = userInfo($file_db, $_SESSION['userId']);
}
示例8: checkLoginExternalAuth
function checkLoginExternalAuth($uid = "", $userPassword = "")
{
global $userDn_rz, $userDN, $suffix, $suffix_ext, $ldapError, $standpwd;
# Abfrage, ob das Loginformular Daten enthält
if (!($uid == "" || $userPassword == "")) {
# UID und Passwort wurden eingegeben
# Fallunterscheidung welche Logins möglich sind
if ($ds_rz = rzLdapConnect($uid, $userPassword)) {
# RZ-LDAP-Login erfolgreich,
# -> Mache Datenabgleich und anschließenden Login am LSM-LDAP
datenabgleich($uid, $ds_rz);
ldap_unbind($ds_rz);
# echo "RZ Bind OK<br>";
if (dummyUidCheck($uid)) {
userLogin($uid, $standpwd);
} else {
# Nachricht User melden bei ... d.h. von Hand anlegen zur Kontrolle
#userAnlegen($uid,$userPassword,$ds_rz);
ldap_unbind($ds_rz);
redirect(3, "index.php", "<h3>Benutzer lokal nicht angelegt!<h3>" . $ldapError, FALSE);
die;
}
} elseif (!($ds_rz = rzLdapConnect($uid, $userPassword)) && ($ds = uniLdapConnect($uid, $userPassword))) {
# RZ-LDAP-Login nicht erfolgreich, LSM-LDAP-Login erfolgreich,
# -> User nicht in RZ-LDAP gespeichert.
# -> Login am LSM-LDAP (z.B. für lokale Spezialuser ... )
# echo "RZ Bind FAILED / LSM Bind OK<br>";
ldap_unbind($ds);
userLogin($uid, $userPassword);
} else {
# In anderen Fällen waren die Zugangsdaten nicht korrekt.
# -> Redirect auf index.php.
redirect(3, "index.php", "<h3>Bitte geben Sie korrekte Zugangsdaten ein.<h3>" . $ldapError, FALSE);
die;
}
} else {
# UID und/oder Passwort wurden NICHT eingegeben
redirect(3, "index.php", "<h3>Bitte geben Sie User-Id und Passwort ein.</h3>" . $ldapError, FALSE);
die;
}
}
示例9: array
$types = array();
$changes = getFormChanges($dbUser, $_REQUEST['newUser'], $types);
if ($_REQUEST['newUser']['Password']) {
$changes['Password'] = "Password = password(" . dbEscape($_REQUEST['newUser']['Password']) . ")";
} else {
unset($changes['Password']);
}
if (count($changes)) {
if (!empty($_REQUEST['uid'])) {
dbQuery("update Users set " . implode(", ", $changes) . " where Id = ?", array($_REQUEST['uid']));
} else {
dbQuery("insert into Users set " . implode(", ", $changes));
}
$refreshParent = true;
if ($dbUser['Username'] == $user['Username']) {
userLogin($dbUser['Username'], $dbUser['Password']);
}
}
$view = 'none';
} elseif ($action == "state") {
if (!empty($_REQUEST['runState'])) {
//if ( $cookies ) session_write_close();
packageControl($_REQUEST['runState']);
$refreshParent = true;
}
} elseif ($action == "save") {
if (!empty($_REQUEST['runState']) || !empty($_REQUEST['newState'])) {
$sql = "select Id,Function,Enabled from Monitors order by Id";
$definitions = array();
foreach (dbFetchAll($sql) as $monitor) {
$definitions[] = $monitor['Id'] . ":" . $monitor['Function'] . ":" . $monitor['Enabled'];
示例10: externalAuth
$extAuth = externalAuth();
$authData = httpBasicDecode($_SERVER['HTTP_X_AUTHORIZATION']);
if ($rmt || $extAuth !== false) {
// enforce double auth/consistency when using remote authentication
if ($authData === false || $extAuth === false || $authData["user"] !== $extAuth["user"] || $extAuth["pass"] !== false && $authData["pass"] !== $extAuth["pass"]) {
logError('inconsistent double authorization token');
unset($authData);
}
}
}
if (isset($authData)) {
if (empty($authData["user"]) || !$rmt && empty($authData["pass"])) {
logError('missing credentials');
httpUnauthorized();
}
$auth = userLogin($authData["user"], $authData["pass"], $rmt);
unset($authData);
}
if (empty($auth)) {
logError('invalid credentials');
httpUnauthorized();
}
// action
$args = explode("/", $_SERVER["PATH_INFO"]);
if ($args[0] !== "" || count($args) < 2 || !isset($rest[$args[1]])) {
logError('unknown request action or arguments');
httpNotFound();
}
$act = strtolower($args[1]);
array_splice($args, 0, 2);
if ($rest[$act]['admin'] && !$auth['admin']) {
示例11: htmlspecialchars
<?php
require "init.php";
require_once 'CamsDatabase.php';
require_once 'users.php';
if (!empty($_POST)) {
$username = htmlspecialchars($_POST['userid']);
$password = htmlspecialchars($_POST['password']);
if (empty($username) || empty($password)) {
$_SESSION["login_error"] = 'User Name and Password cannot be blank';
} else {
if (!userExists($username)) {
$_SESSION["login_error"] = 'User Does not exist.';
} else {
$user = userLogin($username, $password);
if (!$user) {
$_SESSION["login_error"] = 'incorrect password';
} else {
$_SESSION['FirstName'] = $user['FirstName'];
$_SESSION['LastName'] = $user['LastName'];
$_SESSION['userid'] = $user['userid'];
$_SESSION['Email'] = $user['Email'];
$_SESSION['Empno'] = $user['Empno'];
$_SESSION['Phone'] = $user['Phone'];
$_SESSION['Role'] = $user['Role'];
$_SESSION['Agy'] = $user['Agy'];
$_SESSION['Dpt'] = $user['Dpt'];
}
}
}
header('Location: ../index.php');
示例12: elseif
}
return $msgStr;
}
//controllers start here
if (isset($_POST['sig_response'])) {
if (function_exists('verifyDuoSign')) {
if (!verifyDuoSign($_POST)) {
$_GET['errorMsg'] = "duoFailed";
}
}
} elseif (!empty($_GET['passlink'])) {
verifyPasscode($_GET['passlink'], 'link');
} elseif (!empty($_POST['passcode'])) {
verifyPasscode($_POST);
} elseif (!empty($_POST['email']) && !empty($_POST['password'])) {
userLogin($_POST);
} elseif (!empty($_GET['logout'])) {
userLogout(true);
} elseif (!empty($_POST['action']) && ($_POST['action'] == 'resetPasswordSendMail' || $_POST['action'] == 'resetPasswordChange')) {
userLoginResetPassword($_POST);
} elseif (!empty($_GET['view']) && $_GET['view'] == 'resetPasswordChange') {
userLoginResetPassword($_GET);
}
//controllers ends here
$min = '.min';
?>
<!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" />
<meta name="robots" content="noindex">
示例13: cleanInput
<?php
$loggedin = FALSE;
if (isset($_POST['user']) && isset($_POST['pass'])) {
$user = cleanInput($_POST['user']);
$pass = md5(cleanInput($_POST['pass']));
//echo $_POST['pass'] . "<br />";
//echo $pass . "<br />";
$userinfo = userLogin($user, $pass);
if ($userinfo[0] != 0) {
$_SESSION['uid'] = $userinfo[0];
$_SESSION['uname'] = $userinfo[1];
} else {
$_SESSION['uid'] = 0;
$_SESSION['uname'] = "";
echo "Wrong Username or Password";
}
//echo "Hello, " . $_POST["verified_user"];
}
if ($_SESSION['uid'] == 0) {
echo "<form name=\"input\" action=\"/index.php\" method=\"post\">\n";
echo "<table>\n";
echo "\t<tr>\n";
echo "\t\t<td>Username:</td><td><input type=\"text\" name=\"user\" /></td>\n";
echo "\t</tr>\n";
echo "\t<tr>\n";
echo "\t\t<td>Password:</td><td><input type=\"password\" name=\"pass\" /></td>\n";
echo "\t</tr>\n";
echo "\t<tr>\n";
echo "\t\t<td></td><td><input type=\"submit\" value=\"Submit\" /></td>\n";
echo "\t</tr>\n";
示例14: userCheck
function userCheck($user, $pass)
{
return userLogin($user, $pass, false);
}
示例15: password_hash
if (!$new_user_name) {
// Encrypt the user's password.
$user_password = password_hash($_POST['password'], PASSWORD_DEFAULT) . "";
// Insert a new row for the newly-registered user.
$database->insert("users2", ["email" => $_POST['email'], "password" => $user_password, "name" => $_POST['name'], "created_at" => date("Y-m-d H:i:s"), "ip" => $_SERVER['REMOTE_ADDR']]);
// $database->error();
// echo $database->last_query();
$new_user_data = $database->get("users2", ["name", "email"], ["email" => $_POST['email']]);
$new_user_name = $new_user_data['name'];
if ($new_user_name) {
echo 'Hey, thanks for registering, ' . $_POST['name'] . '! <a href="/?a=dash">Proceeding to dashboard now...</a>';
} else {
echo '<br> <font color="red">Oh jeez.</font> You were not registered for some reason. SQL problem? form data: <br>';
// print_r($_POST);
}
userLogin($_POST['email']);
} else {
echo 'It seems you are already registered. Have you forgotten your password? <a href="/?a=forgotten">Reset it.</a>';
}
} else {
// Show form if no submission
echo '
<form method="POST" action="?a=register">
<input type="text" required name="name" placeholder="Your name" /> <br>
<input type="text" required name="email" placeholder="Email" /> <br>
<input type="password" required name="password" placeholder="Password" /> <br>
<button type="submit">Submit</button>
</form>
';
}
break;