403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.216.219
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : www ( 1000)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/wp.3/wp-content/plugins/wpforms-lite/src/Integrations/AI/API/Http/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/wp.3/wp-content/plugins/wpforms-lite/src/Integrations/AI/API/Http/Request.php
<?php

namespace WPForms\Integrations\AI\API\Http;

use WPForms\Integrations\AI\Helpers;
use WPForms\Integrations\LiteConnect\LiteConnect;
use WPForms\Integrations\LiteConnect\Integration;

/**
 * Request class.
 *
 * @since 1.9.1
 */
class Request {

	/**
	 * API URL.
	 *
	 * @since 1.9.1
	 */
	private const URL = 'https://wpformsapi.com/api/v1';

	/**
	 * Request timeout.
	 *
	 * @since 1.9.1
	 */
	private const TIMEOUT = 60;

	/**
	 * Send a POST request.
	 *
	 * @since 1.9.1
	 *
	 * @param string $endpoint Endpoint to request.
	 * @param array  $args     Request arguments.
	 *
	 * @return Response Response from the API.
	 */
	public function post( string $endpoint, array $args = [] ): Response {

		return $this->request( 'POST', $endpoint, $args );
	}

	/**
	 * Make a request to the API.
	 *
	 * @since 1.9.1
	 *
	 * @param string $method   Request method.
	 * @param string $endpoint Endpoint to request.
	 * @param array  $args     Arguments to send.
	 *
	 * @return Response Response from the API.
	 * @noinspection PhpSameParameterValueInspection
	 */
	private function request( string $method, string $endpoint, array $args ): Response {

		// Once mark AI features as used when making a first request.
		Helpers::set_ai_used();

		// Add domain to the request.
		$args['domain'] = preg_replace( '/(https?:\/\/)?(www\.)?(.*)\/?/', '$3', home_url() );

		$args = $this->maybe_add_lite_connect_credentials( $args );

		$options = [
			'method'  => $method,
			'headers' => $this->get_headers(),
			'timeout' => $this->get_timeout(),
			'body'    => wp_json_encode( $args ),
		];

		$url = $this->get_request_url( $endpoint );

		return new Response( wp_safe_remote_request( $url, $options ) );
	}

	/**
	 * Get AI API request URL.
	 *
	 * @since 1.9.3
	 *
	 * @param string $endpoint Endpoint to request.
	 *
	 * @return string
	 */
	private function get_request_url( string $endpoint ): string {

		/**
		 * Filter AI API request URL.
		 *
		 * @since 1.9.3
		 *
		 * @param string $url      API request URL.
		 * @param string $endpoint Endpoint to request.
		 */
		return (string) apply_filters( 'wpforms_integrations_aiapi_http_request_url', self::URL . $endpoint, $endpoint );
	}

	/**
	 * Maybe add Lite Connect credentials to the request.
	 *
	 * @since 1.9.1
	 *
	 * @param array $args Arguments to send.
	 *
	 * @return array
	 */
	private function maybe_add_lite_connect_credentials( array $args ): array {

		if ( wpforms()->is_pro() ) {
			return $args;
		}

		if ( ! LiteConnect::is_allowed() || ! LiteConnect::is_enabled() ) {
			return $args;
		}

		return array_merge( $args, Integration::get_site_credentials() );
	}

	/**
	 * Retrieve request headers.
	 *
	 * @since 1.9.1
	 *
	 * @return array
	 */
	private function get_headers(): array {

		$headers = [
			'Content-Type' => 'application/json',
		];

		if ( wpforms()->is_pro() ) {
			$headers['x-wpforms-licensekey'] = wpforms_get_license_key();
		}

		return $headers;
	}

	/**
	 * Retrieve request timeout.
	 *
	 * @since 1.9.1
	 *
	 * @return int
	 */
	private function get_timeout(): int {

		/**
		 * Filter the API request timeout.
		 *
		 * @since 1.9.1
		 *
		 * @param int $timeout Request timeout.
		 */
		return (int) apply_filters( 'wpforms_integrations_ai_api_http_request_timeout', self::TIMEOUT ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit