PHP 8.2.31
Preview: pipe.php Size: 1.87 KB
/home/nshryvcy/himaltourism.com/wp-content/plugins/contact-form-7/includes/pipe.php

<?php
/**
 * Pipe-related classes.
 *
 * @link https://contactform7.com/selectable-recipient-with-pipes/
 */


/**
 * Class representing a pair of pipe.
 */
class WPCF7_Pipe {

	public $before = '';
	public $after = '';

	public function __construct( $text ) {
		$text = (string) $text;

		$pipe_pos = strpos( $text, '|' );

		if ( false === $pipe_pos ) {
			$this->before = $this->after = trim( $text );
		} else {
			$this->before = trim( substr( $text, 0, $pipe_pos ) );
			$this->after = trim( substr( $text, $pipe_pos + 1 ) );
		}
	}
}


/**
 * Class representing a list of pipes.
 */
class WPCF7_Pipes {

	private $pipes = array();

	public function __construct( array $texts ) {
		foreach ( $texts as $text ) {
			$this->add_pipe( $text );
		}
	}

	private function add_pipe( $text ) {
		$pipe = new WPCF7_Pipe( $text );
		$this->pipes[] = $pipe;
	}

	public function do_pipe( $input ) {
		$input_canonical = wpcf7_canonicalize( $input, array(
			'strto' => 'as-is',
		) );

		foreach ( $this->pipes as $pipe ) {
			$before_canonical = wpcf7_canonicalize( $pipe->before, array(
				'strto' => 'as-is',
			) );

			if ( $input_canonical === $before_canonical ) {
				return $pipe->after;
			}
		}

		return $input;
	}

	public function collect_befores() {
		$befores = array();

		foreach ( $this->pipes as $pipe ) {
			$befores[] = $pipe->before;
		}

		return $befores;
	}

	public function collect_afters() {
		$afters = array();

		foreach ( $this->pipes as $pipe ) {
			$afters[] = $pipe->after;
		}

		return $afters;
	}

	public function zero() {
		return empty( $this->pipes );
	}

	public function random_pipe() {
		if ( $this->zero() ) {
			return null;
		}

		return $this->pipes[array_rand( $this->pipes )];
	}

	public function to_array() {
		return array_map(
			function( WPCF7_Pipe $pipe ) {
				return array(
					$pipe->before,
					$pipe->after,
				);
			},
			$this->pipes
		);
	}
}

Directory Contents

Dirs: 4 × Files: 25

Name Size Perms Modified Actions
- drwxr-xr-x 2023-04-04 05:34:36
Edit Download
css DIR
- drwxr-xr-x 2023-04-04 05:34:36
Edit Download
js DIR
- drwxr-xr-x 2023-04-04 05:34:36
Edit Download
swv DIR
- drwxr-xr-x 2023-04-04 05:34:35
Edit Download
834 B lrw-r--r-- 2023-04-04 05:34:35
Edit Download
24.61 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
9.15 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
5.55 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
29.15 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
3.02 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
370 B lrw-r--r-- 2026-02-09 05:50:56
Edit Download
10.11 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
13.16 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
14.22 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
12.09 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
15.37 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
16.31 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
8.73 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
3.37 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
15.01 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
1.87 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
325 B lrw-r--r-- 2023-04-04 05:34:36
Edit Download
12.63 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
2.65 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
6.04 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
21.53 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
2.05 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download
5.27 KB lrw-r--r-- 2023-04-04 05:34:35
Edit Download
3.22 KB lrw-r--r-- 2023-04-04 05:34:36
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).