modified file smtp-mailer

This commit is contained in:
2024-02-08 12:31:51 +00:00
committed by Gitium
parent a2ae510d11
commit fdae6c72fc
958 changed files with 177242 additions and 49479 deletions
wp-content/upgrade-temp-backup/plugins
activitypub
authldap
companion-auto-update
gp-premium
backgrounds
blog
colors
copyright
disable-elements
dist
elements
general
gp-premium.php
hooks
inc
langs
gp-premium-ar.mogp-premium-bn_BD.mogp-premium-cs_CZ.mogp-premium-da_DK.mogp-premium-de_DE-42da344ccb044413769d16ed3484307b.jsongp-premium-de_DE-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-de_DE-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-de_DE.mogp-premium-es_AR.mogp-premium-es_ES-42da344ccb044413769d16ed3484307b.jsongp-premium-es_ES-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-es_ES-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-es_ES-cbab080b0f20fd6c323029398be6c986.jsongp-premium-es_ES-ecf9f3c2af10c4f2dfbf4f42504922d1.jsongp-premium-es_ES.mogp-premium-fi-42da344ccb044413769d16ed3484307b.jsongp-premium-fi-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-fi-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-fi-cbab080b0f20fd6c323029398be6c986.jsongp-premium-fi-ecf9f3c2af10c4f2dfbf4f42504922d1.jsongp-premium-fi.mogp-premium-fr_FR-42da344ccb044413769d16ed3484307b.jsongp-premium-fr_FR-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-fr_FR-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-fr_FR.mogp-premium-hr.mogp-premium-hu_HU.mogp-premium-it_IT.mogp-premium-nb_NO.mogp-premium-nl_NL-42da344ccb044413769d16ed3484307b.jsongp-premium-nl_NL-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-nl_NL-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-nl_NL-cbab080b0f20fd6c323029398be6c986.jsongp-premium-nl_NL-ecf9f3c2af10c4f2dfbf4f42504922d1.jsongp-premium-nl_NL.mogp-premium-pl_PL.mogp-premium-pt_BR.mogp-premium-pt_PT-42da344ccb044413769d16ed3484307b.jsongp-premium-pt_PT-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-pt_PT-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-pt_PT.mogp-premium-ru_RU-42da344ccb044413769d16ed3484307b.jsongp-premium-ru_RU-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-ru_RU-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-ru_RU.mogp-premium-sv_SE-42da344ccb044413769d16ed3484307b.jsongp-premium-sv_SE-53e2a1d5945b8d2b1c35e81ae1e532f3.jsongp-premium-sv_SE-92fa58377f1b6f7bef9c785c31ae29ff.jsongp-premium-sv_SE-cbab080b0f20fd6c323029398be6c986.jsongp-premium-sv_SE-ecf9f3c2af10c4f2dfbf4f42504922d1.jsongp-premium-sv_SE.mogp-premium-uk.mogp-premium-vi.mogp-premium-zh_CN.mo
library
menu-plus
page-header
readme.txt
secondary-nav
sections
site-library
spacing
typography
woocommerce
wpml-config.xml
jetpack-protect
CHANGELOG.mdLICENSE.txtSECURITY.md
assets
build
composer.jsonjetpack-protect.php
jetpack_vendor
automattic
jetpack-a8c-mc-stats
jetpack-admin-ui
jetpack-assets
jetpack-config
jetpack-connection
jetpack-constants
jetpack-device-detection
jetpack-identity-crisis
jetpack-ip
jetpack-jitm
jetpack-licensing
jetpack-logo
jetpack-my-jetpack
jetpack-partner
jetpack-password-checker
jetpack-plugins-installer
jetpack-redirect
jetpack-roles
jetpack-status
jetpack-sync
jetpack-transport-helper
jetpack-waf
i18n-map.php
readme.txt
src
vendor
menu-icons
CHANGELOG.mdCONTRIBUTING.md
css
images
includes
js
languages
mailin.phpmenu-icons.phpreadme.mdreadme.txt
vendor
codeinwp
gutenberg-menu-icons
icon-picker
menu-item-custom-fields
themeisle-sdk
composer
smtp-mailer

@ -0,0 +1,209 @@
<?php
namespace Activitypub\Collection;
use WP_Error;
use WP_User_Query;
use Activitypub\Model\User;
use Activitypub\Model\Blog_User;
use Activitypub\Model\Application_User;
use function Activitypub\is_user_disabled;
class Users {
/**
* The ID of the Blog User
*
* @var int
*/
const BLOG_USER_ID = 0;
/**
* The ID of the Application User
*
* @var int
*/
const APPLICATION_USER_ID = -1;
/**
* Get the User by ID
*
* @param int $user_id The User-ID.
*
* @return \Acitvitypub\Model\User The User.
*/
public static function get_by_id( $user_id ) {
if ( is_string( $user_id ) || is_numeric( $user_id ) ) {
$user_id = (int) $user_id;
}
if ( is_user_disabled( $user_id ) ) {
return new WP_Error(
'activitypub_user_not_found',
\__( 'User not found', 'activitypub' ),
array( 'status' => 404 )
);
}
if ( self::BLOG_USER_ID === $user_id ) {
return Blog_User::from_wp_user( $user_id );
} elseif ( self::APPLICATION_USER_ID === $user_id ) {
return Application_User::from_wp_user( $user_id );
} elseif ( $user_id > 0 ) {
return User::from_wp_user( $user_id );
}
return new WP_Error(
'activitypub_user_not_found',
\__( 'User not found', 'activitypub' ),
array( 'status' => 404 )
);
}
/**
* Get the User by username.
*
* @param string $username The User-Name.
*
* @return \Acitvitypub\Model\User The User.
*/
public static function get_by_username( $username ) {
// check for blog user.
if ( Blog_User::get_default_username() === $username ) {
return self::get_by_id( self::BLOG_USER_ID );
}
if ( get_option( 'activitypub_blog_user_identifier' ) === $username ) {
return self::get_by_id( self::BLOG_USER_ID );
}
// check for application user.
if ( 'application' === $username ) {
return self::get_by_id( self::APPLICATION_USER_ID );
}
// check for 'activitypub_username' meta
$user = new WP_User_Query(
array(
'number' => 1,
'hide_empty' => true,
'fields' => 'ID',
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'activitypub_user_identifier',
'value' => $username,
'compare' => 'LIKE',
),
),
)
);
if ( $user->results ) {
return self::get_by_id( $user->results[0] );
}
// check for login or nicename.
$user = new WP_User_Query(
array(
'search' => $username,
'search_columns' => array( 'user_login', 'user_nicename' ),
'number' => 1,
'hide_empty' => true,
'fields' => 'ID',
)
);
if ( $user->results ) {
return self::get_by_id( $user->results[0] );
}
return new WP_Error(
'activitypub_user_not_found',
\__( 'User not found', 'activitypub' ),
array( 'status' => 404 )
);
}
/**
* Get the User by resource.
*
* @param string $resource The User-Resource.
*
* @return \Acitvitypub\Model\User The User.
*/
public static function get_by_resource( $resource ) {
if ( \strpos( $resource, '@' ) === false ) {
return new WP_Error(
'activitypub_unsupported_resource',
\__( 'Resource is invalid', 'activitypub' ),
array( 'status' => 400 )
);
}
$resource = \str_replace( 'acct:', '', $resource );
$resource_identifier = \substr( $resource, 0, \strrpos( $resource, '@' ) );
$resource_host = self::normalize_host( \substr( \strrchr( $resource, '@' ), 1 ) );
$blog_host = self::normalize_host( \wp_parse_url( \home_url( '/' ), \PHP_URL_HOST ) );
if ( $blog_host !== $resource_host ) {
return new WP_Error(
'activitypub_wrong_host',
\__( 'Resource host does not match blog host', 'activitypub' ),
array( 'status' => 404 )
);
}
return self::get_by_username( $resource_identifier );
}
/**
* Get the User by resource.
*
* @param string $resource The User-Resource.
*
* @return \Acitvitypub\Model\User The User.
*/
public static function get_by_various( $id ) {
if ( is_numeric( $id ) ) {
return self::get_by_id( $id );
} elseif ( filter_var( $id, FILTER_VALIDATE_URL ) ) {
return self::get_by_resource( $id );
} else {
return self::get_by_username( $id );
}
}
/**
* Normalize the host.
*
* @param string $host The host.
*
* @return string The normalized host.
*/
public static function normalize_host( $host ) {
return \str_replace( 'www.', '', $host );
}
/**
* Get the User collection.
*
* @return array The User collection.
*/
public static function get_collection() {
$users = \get_users(
array(
'capability__in' => array( 'publish_posts' ),
)
);
$return = array();
foreach ( $users as $user ) {
$return[] = User::from_wp_user( $user->ID );
}
return $return;
}
}