本文整理汇总了PHP中UserDB::insertLDAP方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDB::insertLDAP方法的具体用法?PHP UserDB::insertLDAP怎么用?PHP UserDB::insertLDAP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDB
的用法示例。
在下文中一共展示了UserDB::insertLDAP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processLogin
function processLogin()
{
/*if(isset($_GET["username"]) and $_GET["username"]=="guest"){
$_SESSION["username"]="guest";
$_SESSION["email"]="CY0000";
header("Location:home.php");
}*/
if (isset($_POST["email"]) and isset($_POST["password"])) {
require_once "class.db.Utils.php";
require_once "class.LDAP.php";
require_once "class.MD5.php";
require_once "class.db.Log.php";
$ldap = new LDAP();
$md5 = new MD5();
$email = $_POST["email"];
if ($email != "") {
if (!strpos($email, "@cyou-inc.com")) {
$email = $email . '@cyou-inc.com';
}
if ($_POST["password"] != "") {
$usermsg = "";
$usermsg = $ldap->login($email, $_POST["password"]);
if ($usermsg) {
$email = substr($_POST["email"], 0, strpos($_POST["email"], "@"));
$username = $usermsg["username"];
$employee_id = $usermsg["employee_id"];
$department = $usermsg["department"];
$db = new UserDB();
$user = $db->hasUser($_POST["email"]);
//如果数据库里修改了用户名则使用修改后的,否则使用num值
if ($user) {
$username = $user["username"];
} else {
$db->insertLDAP(array("email" => $_POST["email"], "username" => $username, "employee_id" => $employee_id, "department" => $department));
}
//保存session
$_SESSION["username"] = $username;
$_SESSION["email"] = $email;
$_SESSION["password"] = $md5->string2secret($_POST["password"]);
//保存cookie
setcookie("email", $_SESSION["email"], time() + 3600 * 24 * 7);
setcookie("username", $_SESSION["username"], time() + 3600 * 24 * 7);
setcookie("password", $_SESSION["password"], time() + 3600 * 24 * 7);
//记录登陆日志
$data['event'] = 'login';
$data['page'] = 'login.php';
$data['description'] = 'login success';
$data['username'] = $_SESSION["email"];
$data['ip'] = getIP();
$db = new LogDB();
$db->insertLog($data);
header("Location: home.php");
} else {
displayLoginForm("您输入的帐号或密码有误,请重试");
}
} else {
displayLoginForm("密码不能为空");
}
} else {
displayLoginForm("帐号不能为空");
}
} else {
displayLoginForm("登陆失败,请稍后重试");
}
}