當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserDB::insertLDAP方法代碼示例

本文整理匯總了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("登陸失敗,請稍後重試");
    }
}
開發者ID:phpscr,項目名稱:baibaiba,代碼行數:65,代碼來源:login.php


注:本文中的UserDB::insertLDAP方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。