当前位置: 首页>>代码示例>>PHP>>正文


PHP PearDatabase::requirePsSingleResult方法代码示例

本文整理汇总了PHP中PearDatabase::requirePsSingleResult方法的典型用法代码示例。如果您正苦于以下问题:PHP PearDatabase::requirePsSingleResult方法的具体用法?PHP PearDatabase::requirePsSingleResult怎么用?PHP PearDatabase::requirePsSingleResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PearDatabase的用法示例。


在下文中一共展示了PearDatabase::requirePsSingleResult方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doLogin

 /**
  * Checks the config.php AUTHCFG value for login type and forks off to the proper module
  *
  * @param string $user_password - The password of the user to authenticate
  * @return true if the user is authenticated, false otherwise
  */
 function doLogin($userPassword)
 {
     $userName = $this->column_fields["user_name"];
     $userid = $this->retrieve_user_id($userName);
     $this->log->debug("Start of authentication for user: {$userName}");
     $result = $this->db->pquery('SELECT * FROM yetiforce_auth');
     $auth = [];
     for ($i = 0; $i < $this->db->num_rows($result); $i++) {
         $row = $this->db->raw_query_result_rowdata($result, $i);
         $auth[$row['type']][$row['param']] = $row['value'];
     }
     if ($auth['ldap']['active'] == 'true') {
         $this->log->debug('Start LDAP authentication');
         $users = explode(',', $auth['ldap']['users']);
         if (in_array($userid, $users)) {
             $bind = FALSE;
             $port = $auth['ldap']['port'] == '' ? 389 : $auth['ldap']['port'];
             $ds = @ldap_connect($auth['ldap']['server'], $port);
             if (!$ds) {
                 $this->log->error('Error LDAP authentication: Could not connect to LDAP server.');
             }
             @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
             // Try version 3.  Will fail and default to v2.
             @ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
             if ($port != 636) {
                 @ldap_start_tls($ds);
             }
             $bind = @ldap_bind($ds, $userName . $auth['ldap']['domain'], $userPassword);
             if (!$bind) {
                 $this->log->error('LDAP authentication: LDAP bind failed.');
             }
             return $bind;
         } else {
             $this->log->error("{$userName} user does not belong to the LDAP");
         }
         $this->log->debug('End LDAP authentication');
     }
     //Default authentication
     $this->log->debug('Using integrated/SQL authentication');
     $query = "SELECT crypt_type, user_name FROM {$this->table_name} WHERE user_name=?";
     $result = $this->db->requirePsSingleResult($query, array($userName), false);
     if (empty($result)) {
         $this->log->error("User not found: {$userName}");
         return FALSE;
     }
     $cryptType = $this->db->query_result($result, 0, 'crypt_type');
     $this->column_fields["user_name"] = $this->db->query_result($result, 0, 'user_name');
     $encryptedPassword = $this->encrypt_password($userPassword, $cryptType);
     $query = "SELECT 1 from {$this->table_name} where user_name=? AND user_password=? AND status = ?";
     $result = $this->db->requirePsSingleResult($query, array($userName, $encryptedPassword, 'Active'), false);
     if (!empty($result)) {
         $this->log->debug("Authentication OK. User: {$userName}");
         return TRUE;
     }
     $this->log->debug("Authentication failed. User: {$userName}");
     return FALSE;
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:63,代码来源:Users.php

示例2: array

 /** Function to authenticate the current user with the given password
  * @param $password -- password::Type varchar
  * @returns true if authenticated or false if not authenticated
  */
 function authenticate_user($password)
 {
     $usr_name = $this->column_fields["user_name"];
     $query = "SELECT * from {$this->table_name} where user_name=? AND user_hash=?";
     $params = array($usr_name, $password);
     $result = $this->db->requirePsSingleResult($query, $params, false);
     if (empty($result)) {
         $this->log->fatal("SECURITY: failed login by {$usr_name}");
         return false;
     }
     return true;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:16,代码来源:Users.php

示例3: doLogin

    /**
     * Checks the config.php AUTHCFG value for login type and forks off to the proper module
     *
     * @param string $user_password - The password of the user to authenticate
     * @return true if the user is authenticated, false otherwise
     */
    function doLogin($user_password) {
        global $AUTHCFG;
        $usr_name = $this->column_fields["user_name"];

        switch (strtoupper($AUTHCFG['authType'])) {
            case 'LDAP':
                $this->log->debug("Using LDAP authentication");
                require_once('modules/Users/authTypes/LDAP.php');
                $result = ldapAuthenticate($this->column_fields["user_name"], $user_password);
                if ($result == NULL) {
                    return false;
                } else {
                    return true;
                }
                break;

            case 'AD':
                $this->log->debug("Using Active Directory authentication");
                require_once('modules/Users/authTypes/adLDAP.php');
                $adldap = new adLDAP();
                if ($adldap->authenticate($this->column_fields["user_name"],$user_password)) {
                    return true;
                } else {
                    return false;
                }
                break;

            default:
                $this->log->debug("Using integrated/SQL authentication");
                $query = "SELECT crypt_type, user_name FROM $this->table_name WHERE user_name=?";
                $result = $this->db->requirePsSingleResult($query, array($usr_name), false);
                if (empty($result)) {
                    return false;
                }
                $crypt_type = $this->db->query_result($result, 0, 'crypt_type');
				$this->column_fields["user_name"] = $this->db->query_result($result, 0, 'user_name');
                $encrypted_password = $this->encrypt_password($user_password, $crypt_type);
                $query = "SELECT 1 from $this->table_name where user_name=? AND user_password=? AND status = ?";
                $result = $this->db->requirePsSingleResult($query, array($usr_name, $encrypted_password, 'Active'), false);
                if (empty($result)) {
                    return false;
                } else {
                    return true;
                }
                break;
        }
        return false;
    }
开发者ID:Wasage,项目名称:werpa,代码行数:54,代码来源:Users.php


注:本文中的PearDatabase::requirePsSingleResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。