Handles the network administrators column output.

@since 2.0.0

@param WP_Network $network The current network object.
354532
public function column_admins( $network ) {
		$network_admins = (array) get_network_option( $network->id, 'site_admins', array() );
		$network_admins = ! empty( $network_admins ) ? array_filter( $network_admins ) : array();

		// Concatenate for markup.
		echo empty( $network_admins ) ? esc_html( join( ', ', $network_admins ) ) : esc_html( '&mdash;' );
	}
372226
public function page_edit_network() {
		$network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
		$network    = $network_id ? get_network( $network_id ) : null;

		add_meta_box( 'wpmn-edit-network-details', esc_html__( 'Details', 'wp-multi-network' ), 'wpmn_edit_network_details_metabox', get_current_screen()->id, 'normal', 'high', array( $network ) );
		add_meta_box( 'wpmn-edit-network-publish', esc_html__( 'Network', 'wp-multi-network' ), 'wpmn_edit_network_publish_metabox', get_current_screen()->id, 'side', 'high', array( $network ) );

		// Differentiate between a new network and an existing network.
		if ( empty( $network ) ) {
			$network_title = '';

			add_meta_box( 'wpmn-edit-network-new-site', esc_html__( 'Root Site', 'wp-multi-network' ), 'wpmn_edit_network_new_site_metabox', get_current_screen()->id, 'advanced', 'high', array( $network ) );
		} else {
			$network_title = get_network_option( $network->id, 'site_name', '' );

			add_meta_box( 'wpmn-edit-network-assign-sites', esc_html__( 'Site Assignment', 'wp-multi-network' ), 'wpmn_edit_network_assign_sites_metabox', get_current_screen()->id, 'advanced', 'high', array( $network ) );
		}

		$add_network_url = $this->admin_url( array( 'page' => 'add-new-network' ) );
		?>

		<div class="wrap">
			<h1>
				<?php
				if ( ! empty( $network ) ) {
					esc_html_e( 'Edit Network', 'wp-multi-network' );

					if ( current_user_can( 'create_networks' ) ) {
						?>
						<a href="<?php echo esc_url( $add_network_url ); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'network', 'wp-multi-network' ); ?></a>
						<?php
					}
				} else {
					esc_html_e( 'Add New Network', 'wp-multi-network' );
				}
				?>
			</h1>

			<form method="post" id="edit-network-form" action="">
				<div id="poststuff">
					<div id="post-body" class="metabox-holder columns-2">
						<div id="post-body-content" style="position: relative;">
							<div id="titlediv">
								<div id="titlewrap">
									<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html_e( 'Enter network title here', 'wp-multi-network' ); ?></label>
									<input type="text" name="title" size="30" id="title" spellcheck="true" autocomplete="off" value="<?php echo esc_attr( $network_title ); ?>">
								</div>
							</div>
						</div>

						<div id="postbox-container-1" class="postbox-container">
							<?php do_meta_boxes( get_current_screen()->id, 'side', $network ); ?>
						</div>

						<div id="postbox-container-2" class="postbox-container">
							<?php do_meta_boxes( get_current_screen()->id, 'normal', $network ); ?>
							<?php do_meta_boxes( get_current_screen()->id, 'advanced', $network ); ?>
						</div>
					</div>
				</div>
			</form>
		</div>

		<?php
	}
30851
public function display(array $users = [])
    {
        $headers = ['Name', 'Account Name', 'UPN'];

        $data = [];

        array_map(function (User $user) use (&$data) {
            $data[] = [
                'name' => $user->getCommonName(),
                'account_name' => $user->getAccountName(),
                'upn' => $user->getUserPrincipalName(),
            ];
        }, $users);

        $this->table($headers, $data);
    }
16923
private function _network()
    {
        if (CommonFunctions::executeProgram('netstat', '-nbdi | cut -c1-24,42- | grep Link', $netstat, PSI_DEBUG)) {
            $lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
            foreach ($lines as $line) {
                $ar_buf = preg_split("/\s+/", $line, 10);
                if (!empty($ar_buf[0])) {
                    $dev = new NetDevice();
                    $dev->setName($ar_buf[0]);
                    $dev->setTxBytes($ar_buf[8]);
                    $dev->setRxBytes($ar_buf[5]);
                    $dev->setErrors($ar_buf[4] + $ar_buf[7]);
                    if (isset($ar_buf[10])) {
                        $dev->setDrops($ar_buf[10]);
                    }
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS) && (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' 2>/dev/null', $bufr2, PSI_DEBUG))) {
                        $bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
                        foreach ($bufe2 as $buf2) {
                            if (preg_match('/^\s+ether\s+(\S+)/i', $buf2, $ar_buf2)) {
                                if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
                            } elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2)) {
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
                            } elseif ((preg_match('/^\s+inet6\s+([^\s%]+)\s+prefixlen/i', $buf2, $ar_buf2)
                                  || preg_match('/^\s+inet6\s+([^\s%]+)%\S+\s+prefixlen/i', $buf2, $ar_buf2))
                                  && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
                            } elseif (preg_match('/^\s+media:\s+/i', $buf2) && preg_match('/[\(\s](\d+)(G*)base/i', $buf2, $ar_buf2)) {
                                if (isset($ar_buf2[2]) && strtoupper($ar_buf2[2])=="G") {
                                    $unit = "G";
                                } else {
                                    $unit = "M";
                                }
                                if (preg_match('/[<\s]([^\s<]+)-duplex/i', $buf2, $ar_buf3))
                                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s '.strtolower($ar_buf3[1]));
                                else
                                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s');
                            }
                        }
                    }
                    $this->sys->setNetDevices($dev);
                }
            }
        }
    }
782559
private function checkAdminUser($wtname, $wtuser, $wtpass, $wtemail): string
    {
        if ($wtname === '' || $wtuser === '' || $wtpass === '' || $wtemail === '') {
            return I18N::translate('You must enter all the administrator account fields.');
        }

        if (mb_strlen($wtpass) < 6) {
            return I18N::translate('The password needs to be at least six characters long.');
        }

        return '';
    }
927967
function set_network_active( $is_network_active = true, $is_delegated_connection = false ) {
            $this->_is_network_active       = $is_network_active;
            $this->_is_delegated_connection = $is_delegated_connection;
        }
98775
public function network_admin_notices() {
		$message = '';
		$type    = '';
		foreach ( $this->feedback_strings as $slug => $messages ) {
			$passed = filter_input( INPUT_GET, $slug );

			if ( is_string( $passed ) ) {
				if ( '1' === $passed ) {
					$message = $messages['1'];
					$type    = 'updated';
				} else {
					$message = $messages['0'];
					$type    = 'error';
				}

				break;
			}
		}

		if ( empty( $message ) || empty( $type ) ) {
			return;
		}
		?>

		<div id="message" class="<?php echo esc_attr( $type ); ?> notice is-dismissible">
			<p>
				<?php echo esc_html( $message ); ?>
				<a href="<?php echo esc_url( $this->admin_url() ); ?>"><?php esc_html_e( 'Back to Networks.', 'wp-multi-network' ); ?></a>
			</p>
			<button type="button" class="notice-dismiss">
				<span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice', 'wp-multi-network' ); ?></span>
			</button>
		</div>

		<?php
	}
586867
public function admin_bar( $wp_admin_bar ) {

		// Bail if logged out user or single site mode.
		if ( ! is_user_logged_in() || ! is_multisite() ) {
			return;
		}

		$networks = user_has_networks();

		// Bail if user does not have networks or they can't manage networks.
		if ( empty( $networks ) || ! current_user_can( 'manage_networks' ) ) {
			return;
		}

		$wp_admin_bar->add_menu( array(
			'id'    => 'my-networks',
			'title' => __( 'My Networks', 'wp-multi-network' ),
			'href'  => network_admin_url( 'admin.php?page=networks' ),
			'meta'  => array(
				'class' => 'networks-parent',
			),
		) );

		foreach ( $networks as $network_id ) {
			$network = get_network( $network_id );
			if ( ! $network ) {
				continue;
			}

			switch_to_network( $network_id );

			if ( ! current_user_can( 'manage_network' ) ) {
				restore_current_network();
				continue;
			}

			$wp_admin_bar->add_group( array(
				'parent' => 'my-networks',
				'id'     => 'group-network-admin-' . $network_id,
			) );

			$wp_admin_bar->add_menu( array(
				'parent' => 'group-network-admin-' . $network_id,
				'id'     => 'network-admin-' . $network_id,
				'title'  => $network->site_name,
				'href'   => network_admin_url(),
			) );

			$wp_admin_bar->add_menu( array(
				'parent' => 'network-admin-' . $network_id,
				'id'     => 'network-admin-d',
				// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
				'title'  => __( 'Dashboard' ),
				'href'   => network_admin_url(),
			) );

			if ( current_user_can( 'manage_sites' ) ) {
				$wp_admin_bar->add_menu( array(
					'parent' => 'network-admin-' . $network_id,
					'id'     => 'network-admin-s' . $network_id,
					// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
					'title'  => __( 'Sites' ),
					'href'   => network_admin_url( 'sites.php' ),
				) );
			}

			if ( current_user_can( 'manage_network_users' ) ) {
				$wp_admin_bar->add_menu( array(
					'parent' => 'network-admin-' . $network_id,
					'id'     => 'network-admin-u' . $network_id,
					// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
					'title'  => __( 'Users' ),
					'href'   => network_admin_url( 'users.php' ),
				) );
			}

			if ( current_user_can( 'manage_network_themes' ) ) {
				$wp_admin_bar->add_menu( array(
					'parent' => 'network-admin-' . $network_id,
					'id'     => 'network-admin-t' . $network_id,
					// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
					'title'  => __( 'Themes' ),
					'href'   => network_admin_url( 'themes.php' ),
				) );
			}

			if ( current_user_can( 'manage_network_plugins' ) ) {
				$wp_admin_bar->add_menu( array(
					'parent' => 'network-admin-' . $network_id,
					'id'     => 'network-admin-p' . $network_id,
					// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
					'title'  => __( 'Plugins' ),
					'href'   => network_admin_url( 'plugins.php' ),
				) );
			}

			if ( current_user_can( 'manage_network_options' ) ) {
				$wp_admin_bar->add_menu( array(
					'parent' => 'network-admin-' . $network_id,
					'id'     => 'network-admin-o' . $network_id,
					// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
					'title'  => __( 'Settings' ),
					'href'   => network_admin_url( 'settings.php' ),
				) );
			}

			restore_current_network();
		}
	}
560288
function input_admin_l10n( $l10n )
	{
		if( !empty($this->l10n) )
		{
			$l10n[ $this->name ] = $this->l10n;
		}
		
		return $l10n;
	}
1051362
public function onClose(Connection $conn)
    {
        $this->onPublishResponse($conn, "CONN_CLOSED", new NsqException("connection close, maybe disposable connection timeout"));

        if (!$conn->isDisposable()) {
            $this->lookup->removeConnection($conn);

            $remainConnNum = count($this->getNsqdConns());
            sys_echo("nsq({$conn->getAddr()}) producer onClose: there are $remainConnNum connections left alive");

            if ($this->lookup->isStopped()/* && $remainConnNum === 0*/) {
                return;
            }

            Task::execute($this->reconnectToNSQD($conn));
        }
    }
219293
private function handle_add_network() {
		$options_to_clone = filter_input( INPUT_POST, 'options_to_clone', FILTER_FORCE_ARRAY );
		if ( ! empty( $options_to_clone ) ) {
			$options_to_clone = array_keys( $options_to_clone );
		} else {
			$options_to_clone = array_keys( network_options_to_copy() );
		}

		$clone = filter_input( INPUT_POST, 'clone_network', FILTER_SANITIZE_NUMBER_INT );
		if ( empty( $clone ) ) {
			$clone = get_current_site()->id;
		}

		$network_title  = wp_unslash( filter_input( INPUT_POST, 'title', FILTER_SANITIZE_STRING ) );
		$network_domain = wp_unslash( filter_input( INPUT_POST, 'domain', FILTER_SANITIZE_STRING ) );
		$network_path   = wp_unslash( filter_input( INPUT_POST, 'path', FILTER_SANITIZE_STRING ) );
		$site_name      = wp_unslash( filter_input( INPUT_POST, 'new_site', FILTER_SANITIZE_STRING ) );

		$network_title  = strip_tags( $network_title );
		$network_domain = str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) );
		$network_path   = str_replace( ' ', '', strtolower( sanitize_text_field( $network_path ) ) );
		$site_name      = ! empty( $site_name ) ? strip_tags( $site_name ) : $network_title;

		// Bail if missing fields.
		if ( empty( $network_title ) || empty( $network_domain ) || empty( $network_path ) ) {
			$this->handle_redirect( array(
				'page'            => 'add-new-network',
				'network_created' => '0',
			) );
		}

		$result  = add_network( array(
			'domain'           => $network_domain,
			'path'             => $network_path,
			'site_name'        => $site_name,
			'user_id'          => get_current_user_id(),
			'clone_network'    => $clone,
			'options_to_clone' => $options_to_clone,
		) );
		$success = '0';

		if ( ! empty( $result ) && ! is_wp_error( $result ) ) {
			if ( ! empty( $posted['title'] ) ) {
				update_network_option( $result, 'site_name', $posted['title'] );
			}

			update_network_option( $result, 'active_sitewide_plugins', array(
				'wp-multi-network/wpmn-loader.php' => time(),
			) );

			$success = '1';
		}

		$this->handle_redirect( array(
			'network_created' => $success,
		) );
	}
508976
public function enterNode(Node $node): void
    {
        $name = null;

        if ($node instanceof Name) {
            $name = $node->toString();
        }

        if ($name === null
            || (array_key_exists($name, $this->symbols)
                && $this->symbols[$name] === false
            )
        ) {
            return;
        }

        if (!$this->filter->__invoke($name)) {
            $this->symbols[$name] = false;
            return;
        }

        if (!array_key_exists($name, $this->symbols)) {
            $this->symbols[$name] = [];
        }

        $this->symbols[$name][] = $node;
    }
137129
private function _network()
    {
        if (CommonFunctions::executeProgram('netstat', '-ni | tail -n +2', $netstat)) {
            $lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
            foreach ($lines as $line) {
                $ar_buf = preg_split("/\s+/", $line);
                if (! empty($ar_buf[0]) && ! empty($ar_buf[3])) {
                    $dev = new NetDevice();
                    $dev->setName($ar_buf[0]);
                    $dev->setRxBytes($ar_buf[4]);
                    $dev->setTxBytes($ar_buf[6]);
                    $dev->setErrors($ar_buf[5] + $ar_buf[7]);
                    //$dev->setDrops($ar_buf[8]);
                    $this->sys->setNetDevices($dev);
                }
            }
        }
    }
415764
protected function commandStats(array $data, ConnectionInterface $conn)
    {
        try {
            $slave = $this->slaves->getByConnection($conn);
            $slave->setUsedMemory($data['memory_usage']);
            if ($this->output->isVeryVerbose()) {
                $this->output->writeln(
                    sprintf(
                        'Current memory usage for worker %d: %.2f MB',
                        $slave->getPort(),
                        $data['memory_usage']
                    )
                );
            }
        } catch (\Exception $e) {
            // silent
        }
    }
530525
protected function handle_row_actions( $network, $column_name, $primary ) {

		// Bail if not primary column.
		if ( $primary !== $column_name ) {
			return;
		}

		switch_to_network( $network->id );
		$network_admin_url = network_admin_url();
		$network_home_url  = network_home_url();
		restore_current_network();

		$base_url = add_query_arg( array(
			'page' => 'networks',
			'id'   => $network->id,
		) );

		$actions = array();

		// Edit the network.
		if ( current_user_can( 'edit_network', $network->id ) ) {
			$edit_network_url = add_query_arg( array(
				'action' => 'edit_network',
			), $base_url );

			$actions['edit'] = '<span class="edit"><a href="' . esc_url( $edit_network_url ) . '">' . esc_html__( 'Edit', 'wp-multi-network' ) . '</a></span>';
		}

		// Visit the network dashboard.
		if ( current_user_can( 'manage_networks' ) ) {
			$actions['network_admin'] = '<span><a href="' . esc_url( $network_admin_url ) . '">' . esc_html__( 'Dashboard', 'wp-multi-network' ) . '</a></span>';
		}

		// Visit the network main site.
		$actions['visit'] = '<span><a href="' . esc_url( $network_home_url ) . '">' . esc_html__( 'Visit', 'wp-multi-network' ) . '</a></span>';

		// Delete the network.
		if ( $this->can_delete( $network ) ) {
			$delete_network_url = wp_nonce_url( add_query_arg( array(
				'action' => 'delete_network',
			), $base_url ) );

			$actions['delete'] = '<span class="delete"><a href="' . esc_url( $delete_network_url ) . '">' . esc_html__( 'Delete', 'wp-multi-network' ) . '</a></span>';
		}

		/**
		 * Filters the networks list table row action links.
		 *
		 * @since 2.0.0
		 *
		 * @param array  Action links as $slug => $link_markup pairs.
		 * @param int    The current network ID.
		 * @param string The current network name.
		 */
		$actions = apply_filters( 'manage_networks_action_links', array_filter( $actions ), $network->id, $network->sitename );

		return $this->row_actions( $actions );
	}
896423
public function renderPresentationNetworks( $networks, $instance, $formulas, $observer, $evaluationResults, $echo = true )
	{
		$result = array();

		foreach ( $networks as $elr => $network )
		{
			// error_log( $elr );
			$result[ $elr ] = array(
				'entities' => $this->renderPresentationNetwork( $network, $elr, $instance, $formulas, $observer, $evaluationResults, $echo ),
				'text' => $networks[ $elr ]['text']
			);
		}

		return $result;
	}
993112
function delete_network_account_event( $check_user = true ) {
            $this->_logger->entrance( 'slug = ' . $this->_slug );

            if ( $check_user && ! $this->is_user_admin() ) {
                return;
            }

            $this->do_action( 'before_network_account_delete' );

            // Clear all admin notices.
            $this->_admin_notices->clear_all_sticky();

            $this->_delete_plans( false, false );

            $this->_delete_licenses( false );

            // Delete add-ons related to plugin's account.
            $this->_delete_account_addons( false );

            // @todo Delete plans and licenses of add-ons.

            self::$_accounts->store( true );

            /**
             * IMPORTANT:
             *  Clear crons must be executed before clearing all storage.
             *  Otherwise, the cron will not be cleared.
             */
            $this->clear_sync_cron( true );
            $this->clear_install_sync_cron( true );

            $sites = self::get_sites();

            $install_ids = array();
            foreach ( $sites as $site ) {
                $blog_id = self::get_site_blog_id( $site );

                $install_id = $this->_delete_site( true, $blog_id );

                // Clear all storage data.
                $this->_storage->clear_all( true, array( 'connectivity_test' ), $blog_id );

                if ( FS_Site::is_valid_id( $install_id ) ) {
                    $install_ids[] = $install_id;
                }

                switch_to_blog( $blog_id );

                $this->do_action( 'after_account_delete' );

                restore_current_blog();
            }

            $this->_storage->clear_all( true, array(
                'connectivity_test',
                'is_on',
            ), true );

            // Send delete event.
            if ( ! empty( $install_ids ) ) {
                $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', $install_ids ), 'delete' );
            }

            $this->do_action( 'after_network_account_delete' );
        }