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

📄 ax.php

📁 简介:IceBB是一个强大
💻 PHP
📖 第 1 页 / 共 3 页
字号:
                $if_available[] = $alias;            }            if ($attribute->count != 1) {                $ax_args['count.' . $alias] = strval($attribute->count);            }            $ax_args['type.' . $alias] = $type_uri;        }        if ($required) {            $ax_args['required'] = implode(',', $required);        }        if ($if_available) {            $ax_args['if_available'] = implode(',', $if_available);        }        return $ax_args;    }    /**     * Get the type URIs for all attributes that have been marked as     * required.     *     * @return A list of the type URIs for attributes that have been     * marked as required.     */    function getRequiredAttrs()    {        $required = array();        foreach ($this->requested_attributes as $type_uri => $attribute) {            if ($attribute->required) {                $required[] = $type_uri;            }        }        return $required;    }    /**     * Extract a FetchRequest from an OpenID message     *     * @param message: The OpenID message containing the attribute     * fetch request     *     * @returns mixed An Auth_OpenID_AX_Error or the     * Auth_OpenID_AX_FetchRequest extracted from the message if     * successful     */    function &fromOpenIDRequest($message)    {        $obj = new Auth_OpenID_AX_FetchRequest();        $ax_args = $message->getArgs($obj->ns_uri);        $result = $obj->parseExtensionArgs($ax_args);        if (Auth_OpenID_AX::isError($result)) {            return $result;        }        if ($obj->update_url) {            // Update URL must match the openid.realm of the            // underlying OpenID 2 message.            $realm = $message->getArg(Auth_OpenID_OPENID_NS, 'realm',                        $message->getArg(                                  Auth_OpenID_OPENID_NS,                                  'return_to'));            if (!$realm) {                $obj = new Auth_OpenID_AX_Error(                  sprintf("Cannot validate update_url %s " .                          "against absent realm", $obj->update_url));            } else if (!Auth_OpenID_TrustRoot::match($realm,                                                     $obj->update_url)) {                $obj = new Auth_OpenID_AX_Error(                  sprintf("Update URL %s failed validation against realm %s",                          $obj->update_url, $realm));            }        }        return $obj;    }    /**     * Given attribute exchange arguments, populate this FetchRequest.     *     * @return $result Auth_OpenID_AX_Error if the data to be parsed     * does not follow the attribute exchange specification. At least     * when 'if_available' or 'required' is not specified for a     * particular attribute type.  Returns true otherwise.    */    function parseExtensionArgs($ax_args)    {        $result = $this->_checkMode($ax_args);        if (Auth_OpenID_AX::isError($result)) {            return $result;        }        $aliases = new Auth_OpenID_NamespaceMap();        foreach ($ax_args as $key => $value) {            if (strpos($key, 'type.') === 0) {                $alias = substr($key, 5);                $type_uri = $value;                $alias = $aliases->addAlias($type_uri, $alias);                if ($alias === null) {                    return new Auth_OpenID_AX_Error(                      sprintf("Could not add alias %s for URI %s",                              $alias, $type_uri)                      );                }                $count_s = Auth_OpenID::arrayGet($ax_args, 'count.' . $alias);                if ($count_s) {                    $count = Auth_OpenID::intval($count_s);                    if (($count === false) &&                        ($count_s === Auth_OpenID_AX_UNLIMITED_VALUES)) {                        $count = $count_s;                    }                } else {                    $count = 1;                }                if ($count === false) {                    return new Auth_OpenID_AX_Error(                      sprintf("Integer value expected for %s, got %s",                              'count.' . $alias, $count_s));                }                $attrinfo = Auth_OpenID_AX_AttrInfo::make($type_uri, $count,                                                          false, $alias);                if (Auth_OpenID_AX::isError($attrinfo)) {                    return $attrinfo;                }                $this->add($attrinfo);            }        }        $required = Auth_OpenID_AX_toTypeURIs($aliases,                         Auth_OpenID::arrayGet($ax_args, 'required'));        foreach ($required as $type_uri) {            $attrib =& $this->requested_attributes[$type_uri];            $attrib->required = true;        }        $if_available = Auth_OpenID_AX_toTypeURIs($aliases,                             Auth_OpenID::arrayGet($ax_args, 'if_available'));        $all_type_uris = array_merge($required, $if_available);        foreach ($aliases->iterNamespaceURIs() as $type_uri) {            if (!in_array($type_uri, $all_type_uris)) {                return new Auth_OpenID_AX_Error(                  sprintf('Type URI %s was in the request but not ' .                          'present in "required" or "if_available"',                          $type_uri));            }        }        $this->update_url = Auth_OpenID::arrayGet($ax_args, 'update_url');        return true;    }    /**     * Iterate over the AttrInfo objects that are contained in this     * fetch_request.     */    function iterAttrs()    {        return array_values($this->requested_attributes);    }    function iterTypes()    {        return array_keys($this->requested_attributes);    }    /**     * Is the given type URI present in this fetch_request?     */    function contains($type_uri)    {        return in_array($type_uri, $this->iterTypes());    }}/** * An abstract class that implements a message that has attribute keys * and values. It contains the common code between fetch_response and * store_request. * * @package OpenID */class Auth_OpenID_AX_KeyValueMessage extends Auth_OpenID_AX_Message {    function Auth_OpenID_AX_KeyValueMessage()    {        $this->data = array();    }    /**     * Add a single value for the given attribute type to the     * message. If there are already values specified for this type,     * this value will be sent in addition to the values already     * specified.     *     * @param type_uri: The URI for the attribute     * @param value: The value to add to the response to the relying     * party for this attribute     * @return null     */    function addValue($type_uri, $value)    {        if (!array_key_exists($type_uri, $this->data)) {            $this->data[$type_uri] = array();        }        $values =& $this->data[$type_uri];        $values[] = $value;    }    /**     * Set the values for the given attribute type. This replaces any     * values that have already been set for this attribute.     *     * @param type_uri: The URI for the attribute     * @param values: A list of values to send for this attribute.     */    function setValues($type_uri, &$values)    {        $this->data[$type_uri] =& $values;    }    /**     * Get the extension arguments for the key/value pairs contained     * in this message.     *     * @param aliases: An alias mapping. Set to None if you don't care     * about the aliases for this request.     *     * @access private     */    function _getExtensionKVArgs(&$aliases)    {        if ($aliases === null) {            $aliases = new Auth_OpenID_NamespaceMap();        }        $ax_args = array();        foreach ($this->data as $type_uri => $values) {            $alias = $aliases->add($type_uri);            $ax_args['type.' . $alias] = $type_uri;            $ax_args['count.' . $alias] = strval(count($values));            foreach ($values as $i => $value) {              $key = sprintf('value.%s.%d', $alias, $i + 1);              $ax_args[$key] = $value;            }        }        return $ax_args;    }    /**     * Parse attribute exchange key/value arguments into this object.     *     * @param ax_args: The attribute exchange fetch_response     * arguments, with namespacing removed.     *     * @return Auth_OpenID_AX_Error or true     */    function parseExtensionArgs($ax_args)    {        $result = $this->_checkMode($ax_args);        if (Auth_OpenID_AX::isError($result)) {            return $result;        }        $aliases = new Auth_OpenID_NamespaceMap();        foreach ($ax_args as $key => $value) {            if (strpos($key, 'type.') === 0) {                $type_uri = $value;                $alias = substr($key, 5);                $result = Auth_OpenID_AX_checkAlias($alias);                if (Auth_OpenID_AX::isError($result)) {                    return $result;                }                $alias = $aliases->addAlias($type_uri, $alias);                if ($alias === null) {                    return new Auth_OpenID_AX_Error(                      sprintf("Could not add alias %s for URI %s",                              $alias, $type_uri)                      );                }            }        }        foreach ($aliases->iteritems() as $pair) {            list($type_uri, $alias) = $pair;            if (array_key_exists('count.' . $alias, $ax_args)) {                $count_key = 'count.' . $alias;                $count_s = $ax_args[$count_key];                $count = Auth_OpenID::intval($count_s);                if ($count === false) {                    return new Auth_OpenID_AX_Error(                      sprintf("Integer value expected for %s, got %s",                              'count. %s' . $alias, $count_s,                              Auth_OpenID_AX_UNLIMITED_VALUES)                                                    );                }                $values = array();                for ($i = 1; $i < $count + 1; $i++) {                    $value_key = sprintf('value.%s.%d', $alias, $i);                    if (!array_key_exists($value_key, $ax_args)) {                      return new Auth_OpenID_AX_Error(                        sprintf(                                "No value found for key %s",

⌨️ 快捷键说明

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