| @@ -1472,9 +1472,10 @@ | ||
| 1472 | 1472 | 'forgot_modal' => uwp_get_option("design_style", 'bootstrap') == 'bootstrap' && uwp_get_option("forgot_modal", 1) ? 1 : '', |
| 1473 | 1473 | 'uwp_pass_strength' => uwp_get_option("register_min_password_strength", 0), |
| 1474 | 1474 | 'uwp_strong_pass_msg' => !empty($pass_msg) ? $pass_msg : __("Please enter valid strong password.", "userswp"), |
| 1475 | 1475 | 'default_banner' => uwp_get_default_banner_uri(), |
| 1476 | - 'basicNonce' => esc_attr(wp_create_nonce('uwp_basic_nonce')) | |
| 1476 | + 'basicNonce' => esc_attr(wp_create_nonce('uwp_basic_nonce')), | |
| 1477 | + 'wordfence_2fa_active' => ( class_exists( '\WordfenceLS\Controller_Users' ) && class_exists( '\WordfenceLS\Controller_TOTP' ) ) ? 1 : '' | |
| 1477 | 1478 | ); |
| 1478 | 1479 | |
| 1479 | 1480 | return apply_filters('uwp_localize_data', $uwp_localize_data); |
| 1480 | 1481 | } |
| @@ -1870,13 +1871,17 @@ | ||
| 1870 | 1871 | $key = wp_generate_password(20, false); |
| 1871 | 1872 | |
| 1872 | 1873 | do_action('uwp_activation_key', $user_data->user_login, $key); |
| 1873 | 1874 | |
| 1874 | - if (empty($wp_hasher)) { | |
| 1875 | - require_once ABSPATH . 'wp-includes/class-phpass.php'; | |
| 1876 | - $wp_hasher = new PasswordHash(8, true); | |
| 1875 | + if ( function_exists( 'wp_fast_hash' ) ) { | |
| 1876 | + $hashed = wp_fast_hash( $key ); | |
| 1877 | + } else { | |
| 1878 | + if ( empty( $wp_hasher ) ) { | |
| 1879 | + require_once ABSPATH . 'wp-includes/class-phpass.php'; | |
| 1880 | + $wp_hasher = new PasswordHash( 8, true ); | |
| 1881 | + } | |
| 1882 | + $hashed = $wp_hasher->HashPassword( $key ); | |
| 1877 | 1883 | } |
| 1878 | - $hashed = $wp_hasher->HashPassword($key); | |
| 1879 | 1884 | $wpdb->update($wpdb->users, array('user_activation_key' => time() . ":" . $hashed), array('user_login' => $user_data->user_login)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
| 1880 | 1885 | update_user_meta($user_id, 'uwp_mod', 'email_unconfirmed'); |
| 1881 | 1886 | |
| 1882 | 1887 | $activation_args = array( |
| @@ -2032,5 +2037,89 @@ | ||
| 2032 | 2037 | |
| 2033 | 2038 | $display_name = ! empty($user_data->display_name) ? $user_data->display_name : $user_data->user_login; |
| 2034 | 2039 | |
| 2035 | 2040 | return apply_filters('uwp_get_username', $display_name, $user_id, $user_data); |
| 2041 | +} | |
| 2042 | + | |
| 2043 | +/** | |
| 2044 | + * File relative url. | |
| 2045 | + * | |
| 2046 | + * @since 1.2.66 | |
| 2047 | + * | |
| 2048 | + * @param string $url URL. | |
| 2049 | + * @param bool $full_path Optional. Full Path. Default false. | |
| 2050 | + * @return string | |
| 2051 | + */ | |
| 2052 | +function uwp_get_file_relative_url( $url, $full_path = false ) { | |
| 2053 | + $url = trim( $url ); | |
| 2054 | + | |
| 2055 | + if ( !$url ) { | |
| 2056 | + return $url; | |
| 2057 | + } | |
| 2058 | + | |
| 2059 | + $relative_url = $url; | |
| 2060 | + $url = trim( $url, '/\\' ); // clean slashes | |
| 2061 | + | |
| 2062 | + $upload_dir = wp_upload_dir(); | |
| 2063 | + $upload_basedir = $upload_dir['basedir']; | |
| 2064 | + $upload_baseurl = $upload_dir['baseurl']; | |
| 2065 | + $content_dir = untrailingslashit( WP_CONTENT_DIR ); | |
| 2066 | + $content_url = untrailingslashit( WP_CONTENT_URL ); | |
| 2067 | + | |
| 2068 | + if ( strpos( $upload_baseurl, 'https://' ) === 0 ) { | |
| 2069 | + $https = 'https://'; | |
| 2070 | + $match_upload_baseurl = str_replace( 'https://', '', $upload_baseurl ); | |
| 2071 | + $content_url = str_replace( 'http://', 'https://', $content_url ); | |
| 2072 | + } else { | |
| 2073 | + $https = 'http://'; | |
| 2074 | + $match_upload_baseurl = str_replace( 'http://', '', $upload_baseurl ); | |
| 2075 | + $content_url = str_replace( 'https://', 'http://', $content_url ); | |
| 2076 | + } | |
| 2077 | + | |
| 2078 | + $match_content_url = strpos( $content_url, 'https://' ) === 0 ? str_replace( 'https://', '', $content_url ) : str_replace( 'http://', '', $content_url ); | |
| 2079 | + $match_url = strpos( $url, 'https://' ) === 0 ? str_replace( 'https://', '', $url ) : str_replace( 'http://', '', $url ); | |
| 2080 | + | |
| 2081 | + // www. | |
| 2082 | + $www = ''; | |
| 2083 | + if ( strpos( $match_upload_baseurl, 'www.' ) === 0 ) { | |
| 2084 | + $www = 'www.'; | |
| 2085 | + $match_upload_baseurl = str_replace( 'www.', '', $match_upload_baseurl ); | |
| 2086 | + } | |
| 2087 | + if ( strpos( $match_content_url, 'www.' ) === 0 ) { | |
| 2088 | + $match_content_url = str_replace( 'www.', '', $match_content_url ); | |
| 2089 | + } | |
| 2090 | + if ( strpos( $match_url, 'www.' ) === 0 ) { | |
| 2091 | + $match_url = str_replace( 'www.', '', $match_url ); | |
| 2092 | + } | |
| 2093 | + | |
| 2094 | + if ( $full_path ) { | |
| 2095 | + if ( strpos( $relative_url, 'http://' ) === 0 || strpos( $relative_url, 'https://' ) === 0 ) { | |
| 2096 | + if ( strpos( $match_url, $match_upload_baseurl ) === 0 || strpos( $match_url, $match_content_url ) === 0 ) { | |
| 2097 | + $relative_url = $https . $www . $match_url; | |
| 2098 | + } | |
| 2099 | + } else { | |
| 2100 | + if ( is_file( $content_dir . '/' . $match_url ) && file_exists( $content_dir . '/' . $match_url ) ) { // url contains content url | |
| 2101 | + $relative_url = $content_url . '/' . $match_url; | |
| 2102 | + } elseif ( is_file( $upload_basedir . '/' . $match_url ) && file_exists( $upload_basedir . '/' . $match_url ) ) { // url contains content url | |
| 2103 | + $relative_url = $upload_baseurl . '/' . $match_url; | |
| 2104 | + } | |
| 2105 | + } | |
| 2106 | + } else { | |
| 2107 | + if ( substr_count( $match_url, $match_upload_baseurl ) > 1 || substr_count( $match_url, $match_content_url ) > 1 ) { | |
| 2108 | + return ''; | |
| 2109 | + } | |
| 2110 | + | |
| 2111 | + if ( strpos( $match_url, $match_upload_baseurl ) === 0 ) { // url contains uploads baseurl | |
| 2112 | + $relative_url = substr( $match_url, strlen( $match_upload_baseurl ) ); | |
| 2113 | + } elseif ( strpos( $match_url, $match_content_url ) === 0 ) { // url contains content url | |
| 2114 | + $relative_url = substr( $match_url, strlen( $match_content_url ) ); | |
| 2115 | + } | |
| 2116 | + | |
| 2117 | + $relative_url = trim( $relative_url, '/\\' ); | |
| 2118 | + | |
| 2119 | + if ( false !== strpos( $relative_url, '..' ) ) { | |
| 2120 | + return ''; | |
| 2121 | + } | |
| 2122 | + } | |
| 2123 | + | |
| 2124 | + return apply_filters( 'uwp_get_file_relative_url', $relative_url, $url, $full_path ); | |
| 2036 | 2125 | } |