7.4.33 | Linux x86_64
Server128.199.10.0
Userwww-data (uid:33)
PHP7.4.33 (apache2handler)
Terminal
Upload
Files: /var/www/html/wp-includes
View: class-wp-recovery-mode-cookie-service.php
<?php /** * Error Protection API: WP_Recovery_Mode_Cookie_Service class * * @package WordPress * @since 5.2.0 */ /** * Core class used to set, validate, and clear cookies that identify a Recovery Mode session. * * @since 5.2.0 */ #[AllowDynamicProperties] final class WP_Recovery_Mode_Cookie_Service { /** * Checks whether the recovery mode cookie is set. * * @since 5.2.0 * * @return bool True if the cookie is set, false otherwise. */ public function is_cookie_set() { return ! empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ); } /** * Sets the recovery mode cookie. * * This must be immediately followed by exiting the request. * * @since 5.2.0 */ public function set_cookie() { $value = $this->generate_cookie(); /** * Filters the length of time a Recovery Mode cookie is valid for. * * @since 5.2.0 * * @param int $length Length in seconds. */ $length = apply_filters( 'recovery_mode_cookie_length', WEEK_IN_SECONDS ); $expire = time() + $length; setcookie( RECOVERY_MODE_COOKIE, $value, $expire, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); if ( COOKIEPATH !== SITECOOKIEPATH ) { setcookie( RECOVERY_MODE_COOKIE, $value, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); } } /** * Clears the recovery mode cookie. * * @since 5.2.0 */ public function clear_cookie() { setcookie( RECOVERY_MODE_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( RECOVERY_MODE_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); } /** * Validates the recovery mode cookie. * * @since 5.2.0 * * @param string $cookie Optionally specify the cookie string. * If omitted, it will be retrieved from the super global. * @return true|WP_Error True on success, error object on failure. */ public function validate_cookie( $cookie = '' ) { if ( ! $cookie ) { if ( empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ) ) { return new WP_Error( 'no_cookie', __( 'No cookie present.' ) ); } $cookie = $_COOKIE[ RECOVERY_MODE_COOKIE ]; } $parts = $this->parse_cookie( $cookie ); if ( is_wp_error( $parts ) ) { return $parts; } list( , $created_at, $random, $signature ) = $parts; if ( ! ctype_digit( $created_at ) ) { return new WP_Error( 'invalid_created_at', __( 'Invalid cookie format.' ) ); } /** This filter is documented in wp-includes/class-wp-recovery-mode-cookie-service.php */ $length = apply_filters( 'recovery_mode_cookie_length', WEEK_IN_SECONDS ); if ( time() > $created_at + $length ) { return new WP_Error( 'expired', __( 'Cookie expired.' ) ); } $to_sign = sprintf( 'recovery_mode|%s|%s', $created_at, $random ); $hashed = $this->recovery_mode_hash( $to_sign ); if ( ! hash_equals( $signature, $hashed ) ) { return new WP_Error( 'signature_mismatch', __( 'Invalid cookie.' ) ); } return true; } /** * Gets the session identifier from the cookie. * * The cookie should be validated before calling this API. * * @since 5.2.0 * * @param string $cookie Optionally specify the cookie string. * If omitted, it will be retrieved from the super global. * @return string|WP_Error Session ID on success, or error object on failure. */ public function get_session_id_from_cookie( $cookie = '' ) { if ( ! $cookie ) { if ( empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ) ) { return new WP_Error( 'no_cookie', __( 'No cookie present.' ) ); } $cookie = $_COOKIE[ RECOVERY_MODE_COOKIE ]; } $parts = $this->parse_cookie( $cookie ); if ( is_wp_error( $parts ) ) { return $parts; } list( , , $random ) = $parts; return sha1( $random ); } /** * Parses the cookie into its four parts. * * @since 5.2.0 * * @param string $cookie Cookie content. * @return array|WP_Error Cookie parts array, or error object on failure. */ private function parse_cookie( $cookie ) { $cookie = base64_decode( $cookie ); $parts = explode( '|', $cookie ); if ( 4 !== count( $parts ) ) { return new WP_Error( 'invalid_format', __( 'Invalid cookie format.' ) ); } return $parts; } /** * Generates the recovery mode cookie value. * * The cookie is a base64 encoded string with the following format: * * recovery_mode|iat|rand|signature * * Where "recovery_mode" is a constant string, * iat is the time the cookie was generated at, * rand is a randomly generated password that is also used as a session identifier * and signature is an hmac of the preceding 3 parts. * * @since 5.2.0 * * @return string Generated cookie content. */ private function generate_cookie() { $to_sign = sprintf( 'recovery_mode|%s|%s', time(), wp_generate_password( 20, false ) ); $signed = $this->recovery_mode_hash( $to_sign ); return base64_encode( sprintf( '%s|%s', $to_sign, $signed ) ); } /** * Gets a form of `wp_hash()` specific to Recovery Mode. * * We cannot use `wp_hash()` because it is defined in `pluggable.php` which is not loaded until after plugins are loaded, * which is too late to verify the recovery mode cookie. * * This tries to use the `AUTH` salts first, but if they aren't valid specific salts will be generated and stored. * * @since 5.2.0 * * @param string $data Data to hash. * @return string|false The hashed $data, or false on failure. */ private function recovery_mode_hash( $data ) { $default_keys = array_unique( array( 'put your unique phrase here', /* * translators: This string should only be translated if wp-config-sample.php is localized. * You can check the localized release package or * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php */ __( 'put your unique phrase here' ), ) ); if ( ! defined( 'AUTH_KEY' ) || in_array( AUTH_KEY, $default_keys, true ) ) { $auth_key = get_site_option( 'recovery_mode_auth_key' ); if ( ! $auth_key ) { if ( ! function_exists( 'wp_generate_password' ) ) { require_once ABSPATH . WPINC . '/pluggable.php'; } $auth_key = wp_generate_password( 64, true, true ); update_site_option( 'recovery_mode_auth_key', $auth_key ); } } else { $auth_key = AUTH_KEY; } if ( ! defined( 'AUTH_SALT' ) || in_array( AUTH_SALT, $default_keys, true ) || AUTH_SALT === $auth_key ) { $auth_salt = get_site_option( 'recovery_mode_auth_salt' ); if ( ! $auth_salt ) { if ( ! function_exists( 'wp_generate_password' ) ) { require_once ABSPATH . WPINC . '/pluggable.php'; } $auth_salt = wp_generate_password( 64, true, true ); update_site_option( 'recovery_mode_auth_salt', $auth_salt ); } } else { $auth_salt = AUTH_SALT; } $secret = $auth_key . $auth_salt; return hash_hmac( 'sha1', $data, $secret ); } }
NameSizeActions
ID3/--
IXR/--
PHPMailer/--
Requests/--
SimplePie/--
Text/--
abilities-api/--
abilities-api.php23.8KView Edit Del
abilities.php7.8KView Edit Del
admin-bar.php38.4KView Edit Del
ai-client/--
ai-client.php2.5KView Edit Del
assets/--
atomlib.php11.9KView Edit Del
author-template.php19.4KView Edit Del
block-bindings/--
block-bindings.php7.3KView Edit Del
block-editor.php28.1KView Edit Del
block-i18n.json316BView Edit Del
block-patterns/--
block-patterns.php15.2KView Edit Del
block-supports/--
block-template-utils.php61.3KView Edit Del
block-template.php17.8KView Edit Del
blocks/--
blocks.php116.6KView Edit Del
bookmark-template.php12.5KView Edit Del
bookmark.php15.1KView Edit Del
build/--
cache-compat.php10.8KView Edit Del
cache.php13.2KView Edit Del
canonical.php33.8KView Edit Del
capabilities.php42.6KView Edit Del
category-template.php55.6KView Edit Del
category.php12.5KView Edit Del
certificates/--
class-IXR.php2.6KView Edit Del
class-avif-info.php29.3KView Edit Del
class-feed.php539BView Edit Del
class-http.php367BView Edit Del
class-json.php42.7KView Edit Del
class-oembed.php401BView Edit Del
class-phpass.php6.6KView Edit Del
class-phpmailer.php664BView Edit Del
class-pop3.php20.6KView Edit Del
class-requests.php2.2KView Edit Del
class-simplepie.php453BView Edit Del
class-smtp.php457BView Edit Del
class-snoopy.php36.8KView Edit Del
class-walker-category-dropdown.php2.4KView Edit Del
class-walker-category.php8.3KView Edit Del
class-walker-comment.php13.9KView Edit Del
class-walker-nav-menu.php11.8KView Edit Del
class-walker-page-dropdown.php2.6KView Edit Del
class-walker-page.php7.4KView Edit Del
class-wp-admin-bar.php17.6KView Edit Del
class-wp-ajax-response.php5.1KView Edit Del
class-wp-application-passwords.php16.7KView Edit Del
class-wp-block-bindings-registry.php8.1KView Edit Del
class-wp-block-bindings-source.php2.9KView Edit Del
class-wp-block-editor-context.php1.3KView Edit Del
class-wp-block-list.php4.6KView Edit Del
class-wp-block-metadata-registry.php11.6KView Edit Del
class-wp-block-parser-block.php2.5KView Edit Del
class-wp-block-parser-frame.php1.9KView Edit Del
class-wp-block-parser.php11.3KView Edit Del
class-wp-block-pattern-categories-registry.php4.3KView Edit Del
class-wp-block-patterns-registry.php10.1KView Edit Del
class-wp-block-processor.php68.3KView Edit Del
class-wp-block-styles-registry.php6.3KView Edit Del
class-wp-block-supports.php6.4KView Edit Del
class-wp-block-template.php2KView Edit Del
class-wp-block-templates-registry.php6.9KView Edit Del
class-wp-block-type-registry.php4.9KView Edit Del
class-wp-block-type.php16.8KView Edit Del
class-wp-block.php24.1KView Edit Del
class-wp-classic-to-block-menu-converter.php3.9KView Edit Del
class-wp-comment-query.php47.5KView Edit Del
class-wp-comment.php9.2KView Edit Del
class-wp-connector-registry.php14.1KView Edit Del
class-wp-customize-control.php25.5KView Edit Del
class-wp-customize-manager.php198.1KView Edit Del
class-wp-customize-nav-menus.php56.6KView Edit Del
class-wp-customize-panel.php10.5KView Edit Del
class-wp-customize-section.php10.9KView Edit Del
class-wp-customize-setting.php29.3KView Edit Del
class-wp-customize-widgets.php70.9KView Edit Del
class-wp-date-query.php35.1KView Edit Del
class-wp-dependencies.php16.7KView Edit Del
class-wp-dependency.php2.6KView Edit Del
class-wp-duotone.php40KView Edit Del
class-wp-editor.php70.5KView Edit Del
class-wp-embed.php15.5KView Edit Del
class-wp-error.php7.3KView Edit Del
class-wp-exception.php253BView Edit Del
class-wp-fatal-error-handler.php8KView Edit Del
class-wp-feed-cache-transient.php3.2KView Edit Del
class-wp-feed-cache.php969BView Edit Del
class-wp-hook.php16.2KView Edit Del
class-wp-http-cookie.php7.1KView Edit Del
class-wp-http-curl.php13KView Edit Del
class-wp-http-encoding.php6.5KView Edit Del
class-wp-http-ixr-client.php3.4KView Edit Del
class-wp-http-proxy.php5.8KView Edit Del
class-wp-http-requests-hooks.php2KView Edit Del
class-wp-http-requests-response.php4.1KView Edit Del
class-wp-http-response.php2.9KView Edit Del
class-wp-http-streams.php16.4KView Edit Del
class-wp-http.php40.7KView Edit Del
class-wp-icons-registry.php7.7KView Edit Del
class-wp-image-editor-gd.php20.2KView Edit Del
class-wp-image-editor-imagick.php36.1KView Edit Del
class-wp-image-editor.php17KView Edit Del
class-wp-list-util.php7.3KView Edit Del
class-wp-locale-switcher.php6.6KView Edit Del
class-wp-locale.php16.5KView Edit Del
class-wp-matchesmapregex.php1.8KView Edit Del
class-wp-meta-query.php29.8KView Edit Del
class-wp-metadata-lazyloader.php6.7KView Edit Del
class-wp-navigation-fallback.php9KView Edit Del
class-wp-network-query.php19.3KView Edit Del
class-wp-network.php12KView Edit Del
class-wp-object-cache.php17.1KView Edit Del
class-wp-oembed-controller.php6.7KView Edit Del
class-wp-oembed.php30.9KView Edit Del
class-wp-paused-extensions-storage.php4.9KView Edit Del
class-wp-phpmailer.php4.2KView Edit Del
class-wp-plugin-dependencies.php24.6KView Edit Del
class-wp-post-type.php30KView Edit Del
class-wp-post.php6.3KView Edit Del
class-wp-query.php159.5KView Edit Del
class-wp-recovery-mode-cookie-service.php6.7KView Edit Del
class-wp-recovery-mode-email-service.php10.9KView Edit Del
class-wp-recovery-mode-key-service.php4.8KView Edit Del
class-wp-recovery-mode-link-service.php3.4KView Edit Del
class-wp-recovery-mode.php11.2KView Edit Del
class-wp-rewrite.php62.2KView Edit Del
class-wp-role.php2.5KView Edit Del
class-wp-roles.php9.1KView Edit Del
class-wp-script-modules.php39.6KView Edit Del
class-wp-scripts.php35.9KView Edit Del
class-wp-session-tokens.php7.1KView Edit Del
class-wp-simplepie-file.php3.5KView Edit Del
class-wp-simplepie-sanitize-kses.php1.9KView Edit Del
class-wp-site-query.php30.7KView Edit Del
class-wp-site.php7.3KView Edit Del
class-wp-speculation-rules.php7.4KView Edit Del
class-wp-styles.php13KView Edit Del
class-wp-tax-query.php19.1KView Edit Del
class-wp-taxonomy.php18.1KView Edit Del
class-wp-term-query.php39.8KView Edit Del
class-wp-term.php5.1KView Edit Del
class-wp-text-diff-renderer-inline.php979BView Edit Del
class-wp-text-diff-renderer-table.php18.5KView Edit Del
class-wp-textdomain-registry.php10.2KView Edit Del
class-wp-theme-json-data.php1.8KView Edit Del
class-wp-theme-json-resolver.php34.9KView Edit Del
class-wp-theme-json-schema.php7.2KView Edit Del
class-wp-theme-json.php169.6KView Edit Del
class-wp-theme.php64.2KView Edit Del
class-wp-token-map.php27.9KView Edit Del
class-wp-url-pattern-prefixer.php4.7KView Edit Del
class-wp-user-meta-session-tokens.php2.9KView Edit Del
class-wp-user-query.php43.1KView Edit Del
class-wp-user-request.php2.3KView Edit Del
class-wp-user.php22.5KView Edit Del
class-wp-walker.php13KView Edit Del
class-wp-widget-factory.php3.3KView Edit Del
class-wp-widget.php18KView Edit Del
class-wp-xmlrpc-server.php210KView Edit Del
class-wp.php25.8KView Edit Del
class-wpdb.php115.9KView Edit Del
class.wp-dependencies.php373BView Edit Del
class.wp-scripts.php343BView Edit Del
class.wp-styles.php338BView Edit Del
collaboration/--
collaboration.php2.1KView Edit Del
comment-template.php100.8KView Edit Del
comment.php130.9KView Edit Del
compat-utf8.php19.1KView Edit Del
compat.php15.7KView Edit Del
connectors.php23.5KView Edit Del
cron.php43.9KView Edit Del
css/--
customize/--
date.php400BView Edit Del
default-constants.php11.1KView Edit Del
default-filters.php36.5KView Edit Del
default-widgets.php2.2KView Edit Del
deprecated.php189.4KView Edit Del
embed-template.php338BView Edit Del
embed.php38KView Edit Del
error-protection.php4KView Edit Del
feed-atom-comments.php5.4KView Edit Del
feed-atom.php3KView Edit Del
feed-rdf.php2.6KView Edit Del
feed-rss.php1.2KView Edit Del
feed-rss2-comments.php4KView Edit Del
feed-rss2.php3.7KView Edit Del
feed.php24.6KView Edit Del
fonts/--
fonts.php9.6KView Edit Del
formatting.php346.4KView Edit Del
functions.php283.5KView Edit Del
functions.wp-scripts.php20KView Edit Del
functions.wp-styles.php8.5KView Edit Del
general-template.php170.8KView Edit Del
global-styles-and-settings.php20.3KView Edit Del
html-api/--
http.php26.6KView Edit Del
https-detection.php5.7KView Edit Del
https-migration.php4.6KView Edit Del
images/--
interactivity-api/--
js/--
kses.php80.6KView Edit Del
l10n/--
l10n.php69.7KView Edit Del
link-template.php156.4KView Edit Del
load.php55.2KView Edit Del
locale.php162BView Edit Del
media-template.php61.8KView Edit Del
media.php218.5KView Edit Del
meta.php65.2KView Edit Del
ms-blogs.php25.7KView Edit Del
ms-default-constants.php4.8KView Edit Del
ms-default-filters.php6.5KView Edit Del
ms-deprecated.php21.2KView Edit Del
ms-files.php2.8KView Edit Del
ms-functions.php89.7KView Edit Del
ms-load.php19.6KView Edit Del
ms-network.php3.7KView Edit Del
ms-settings.php4.1KView Edit Del
ms-site.php40.8KView Edit Del
nav-menu-template.php25.4KView Edit Del
nav-menu.php43.2KView Edit Del
option.php102.6KView Edit Del
php-ai-client/--
php-compat/--
pluggable-deprecated.php6.2KView Edit Del
pluggable.php124.6KView Edit Del
plugin.php35.6KView Edit Del
pomo/--
post-formats.php6.9KView Edit Del
post-template.php67KView Edit Del
post-thumbnail-template.php10.6KView Edit Del
post.php289.6KView Edit Del
query.php36.2KView Edit Del
registration-functions.php200BView Edit Del
registration.php200BView Edit Del
rest-api/--
rest-api.php98.5KView Edit Del
revision.php30KView Edit Del
rewrite.php19KView Edit Del
robots-template.php5.1KView Edit Del
rss-functions.php255BView Edit Del
rss.php22.7KView Edit Del
script-loader.php159.3KView Edit Del
script-modules.php11.7KView Edit Del
session.php258BView Edit Del
shortcodes.php23.5KView Edit Del
sitemaps/--
sitemaps.php3.2KView Edit Del
sodium_compat/--
speculative-loading.php8.4KView Edit Del
spl-autoload-compat.php441BView Edit Del
style-engine/--
style-engine.php7.4KView Edit Del
taxonomy.php173KView Edit Del
template-canvas.php544BView Edit Del
template-loader.php4.2KView Edit Del
template.php36KView Edit Del
theme-compat/--
theme-i18n.json1.8KView Edit Del
theme-previews.php2.8KView Edit Del
theme-templates.php4KView Edit Del
theme.json8.8KView Edit Del
theme.php131.5KView Edit Del
update.php37.4KView Edit Del
user.php174.6KView Edit Del
utf8.php7.1KView Edit Del
vars.php6.5KView Edit Del
version.php1.1KView Edit Del
view-transitions.php602BView Edit Del
widgets/--
widgets.php69.2KView Edit Del
wp-db.php445BView Edit Del
wp-diff.php799BView Edit Del