⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sreg.php

📁 简介:IceBB是一个强大
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    function parseExtensionArgs($args, $strict=false)    {        foreach (array('required', 'optional') as $list_name) {            $required = ($list_name == 'required');            $items = Auth_OpenID::arrayGet($args, $list_name);            if ($items) {                foreach (explode(',', $items) as $field_name) {                    if (!$this->requestField($field_name, $required, $strict)) {                        if ($strict) {                            return false;                        }                    }                }            }        }        $this->policy_url = Auth_OpenID::arrayGet($args, 'policy_url');        return true;    }    /**     * A list of all of the simple registration fields that were     * requested, whether they were required or optional.     */    function allRequestedFields()    {        return array_merge($this->required, $this->optional);    }    /**     * Have any simple registration fields been requested?     */    function wereFieldsRequested()    {        return count($this->allRequestedFields());    }    /**     * Was this field in the request?     */    function contains($field_name)    {        return (in_array($field_name, $this->required) ||                in_array($field_name, $this->optional));    }    /**     * Request the specified field from the OpenID user     *     * $field_name: the unqualified simple registration field name     *     * required: whether the given field should be presented to the     * user as being a required to successfully complete the request     *     * strict: whether to raise an exception when a field is added to     * a request more than once     */    function requestField($field_name,                          $required=false, $strict=false)    {        if (!Auth_OpenID_checkFieldName($field_name)) {            return false;        }        if ($strict) {            if ($this->contains($field_name)) {                return false;            }        } else {            if (in_array($field_name, $this->required)) {                return true;            }            if (in_array($field_name, $this->optional)) {                if ($required) {                    unset($this->optional[array_search($field_name,                                                       $this->optional)]);                } else {                    return true;                }            }        }        if ($required) {            $this->required[] = $field_name;        } else {            $this->optional[] = $field_name;        }        return true;    }    /**     * Add the given list of fields to the request     *     * field_names: The simple registration data fields to request     *     * required: Whether these values should be presented to the user     * as required     *     * strict: whether to raise an exception when a field is added to     * a request more than once     */    function requestFields($field_names, $required=false, $strict=false)    {        if (!is_array($field_names)) {            return false;        }        foreach ($field_names as $field_name) {            if (!$this->requestField($field_name, $required, $strict=$strict)) {                return false;            }        }        return true;    }    /**     * Get a dictionary of unqualified simple registration arguments     * representing this request.     *     * This method is essentially the inverse of     * C{L{parseExtensionArgs}}. This method serializes the simple     * registration request fields.     */    function getExtensionArgs()    {        $args = array();        if ($this->required) {            $args['required'] = implode(',', $this->required);        }        if ($this->optional) {            $args['optional'] = implode(',', $this->optional);        }        if ($this->policy_url) {            $args['policy_url'] = $this->policy_url;        }        return $args;    }}/** * Represents the data returned in a simple registration response * inside of an OpenID C{id_res} response. This object will be created * by the OpenID server, added to the C{id_res} response object, and * then extracted from the C{id_res} message by the Consumer. * * @package OpenID */class Auth_OpenID_SRegResponse extends Auth_OpenID_SRegBase {    var $ns_alias = 'sreg';    function Auth_OpenID_SRegResponse($data=null,                                      $sreg_ns_uri=Auth_OpenID_SREG_NS_URI)    {        if ($data === null) {            $this->data = array();        } else {            $this->data = $data;        }        $this->ns_uri = $sreg_ns_uri;    }    /**     * Take a C{L{SRegRequest}} and a dictionary of simple     * registration values and create a C{L{SRegResponse}} object     * containing that data.     *     * request: The simple registration request object     *     * data: The simple registration data for this response, as a     * dictionary from unqualified simple registration field name to     * string (unicode) value. For instance, the nickname should be     * stored under the key 'nickname'.     */    function extractResponse($request, $data)    {        $obj = new Auth_OpenID_SRegResponse();        $obj->ns_uri = $request->ns_uri;        foreach ($request->allRequestedFields() as $field) {            $value = Auth_OpenID::arrayGet($data, $field);            if ($value !== null) {                $obj->data[$field] = $value;            }        }        return $obj;    }    /**     * Create a C{L{SRegResponse}} object from a successful OpenID     * library response     * (C{L{openid.consumer.consumer.SuccessResponse}}) response     * message     *     * success_response: A SuccessResponse from consumer.complete()     *     * signed_only: Whether to process only data that was     * signed in the id_res message from the server.     *     * Returns a simple registration response containing the data that     * was supplied with the C{id_res} response.     */    function fromSuccessResponse(&$success_response, $signed_only=true)    {        global $Auth_OpenID_sreg_data_fields;        $obj = new Auth_OpenID_SRegResponse();        $obj->ns_uri = $obj->_getSRegNS($success_response->message);        if ($signed_only) {            $args = $success_response->getSignedNS($obj->ns_uri);        } else {            $args = $success_response->message->getArgs($obj->ns_uri);        }        if ($args === null) {            return null;        }        foreach ($Auth_OpenID_sreg_data_fields as $field_name => $desc) {            if (in_array($field_name, array_keys($args))) {                $obj->data[$field_name] = $args[$field_name];            }        }        return $obj;    }    function getExtensionArgs()    {        return $this->data;    }    // Read-only dictionary interface    function get($field_name, $default=null)    {        if (!Auth_OpenID_checkFieldName($field_name)) {            return null;        }        return Auth_OpenID::arrayGet($this->data, $field_name, $default);    }    function contents()    {        return $this->data;    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -