GRAYBYTE WORDPRESS FILE MANAGER2433

Server IP : 68.65.123.43 / Your IP : 216.73.216.162
System : Linux server266.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
PHP Version : 8.0.30
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/inteuuod/public_html/wp-content/plugins/burst-statistics/src/Frontend/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/inteuuod/public_html/wp-content/plugins/burst-statistics/src/Frontend//class-endpoint.php
<?php
namespace Burst\Frontend;

use Burst\Traits\Helper;

defined( 'ABSPATH' ) || die();
class Endpoint {
	use Helper;

	/**
	 * Get tracking status and timestamp of last test.
	 *
	 * @return array{status: string, last_test: int}
	 */
	public static function get_tracking_status_and_time(): array {
		$status_option = get_option( 'burst_tracking_status' );

		// default to error if not false or empty.
		$status = ( false === $status_option ) ? 'error' : ( empty( $status_option ) ? 'error' : $status_option );

		$last_test = get_option( 'burst_ran_test' );
		$now       = time();
		// check if last test was more than 24 hours ago, 10 minutes if there's an error, to re-check faster.
		$time_between_tests = $status === 'error' ? 10 * MINUTE_IN_SECONDS : DAY_IN_SECONDS;
		$time_between_tests = apply_filters( 'burst_time_between_tests', $time_between_tests );
		$should_test_again  = $last_test < $now - $time_between_tests;

		if ( $should_test_again || $last_test === false ) {
			$last_test = time();
			update_option( 'burst_ran_test', $last_test );
			$status = self::test_tracking_status();
		}

		return [
			'status'    => $status,
			'last_test' => $last_test,
		];
	}

	/**
	 * Get tracking status
	 */
	public static function get_tracking_status(): string {
		$tracking = self::get_tracking_status_and_time();
		return $tracking['status'];
	}

	/**
	 * Check if tracking status is error
	 */
	public static function tracking_status_error(): bool {
		return self::get_tracking_status() === 'error';
	}

	/**
	 * Test tracking status
	 * Only returns 'error', 'rest', 'beacon'
	 */
	public static function test_tracking_status(): string {
		$endpoint_test_success = self::endpoint_test_request();

		// no tracking is possible on the Blueprint environment. Always return success there.
		if ( defined( 'BURST_BLUEPRINT' ) ) {
			$status = 'beacon';
		} elseif ( $endpoint_test_success ) {
			$status = 'beacon';
		} else {
			$rest_api_success = self::rest_api_test_request();
			$status           = $rest_api_success ? 'rest' : 'error';
		}

		update_option( 'burst_tracking_status', $status, true );

		return $status;
	}

	/**
	 * Test endpoint
	 */
	public static function endpoint_test_request(): bool {
		$url  = self::get_beacon_url();
		$data = [ 'request' => 'test' ];

		$response = wp_remote_post(
			$url,
			[
				'method'    => 'POST',
				'headers'   => [ 'Content-type' => 'application/x-www-form-urlencoded' ],
				'body'      => $data,
				'sslverify' => false,
			]
		);
		$status   = false;
		if ( ! is_wp_error( $response ) && ! empty( $response['response']['code'] ) ) {
			$status = $response['response']['code'];
		}
		if ( $status === 200 ) {
			return true;
		}
		// otherwise try with file_get_contents.

		// use key 'http' even if you send the request to https://...
		$options = [
			'http' => [
				'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
				'method'  => 'POST',
				'content' => http_build_query( $data ),
			],
			'ssl'  => [
				'verify_peer'      => false,
				'verify_peer_name' => false,
			],
		];
		$context = stream_context_create( $options );
        // phpcs:ignore
		@file_get_contents( $url, false, $context );
		$status_line = $http_response_header[0] ?? '';

		$status = false;
		if ( preg_match( '{HTTP\/\S*\s(\d{3})}', $status_line, $matches ) ) {
			$status = $matches[1];
		}

		return (int) $status === 200;
	}

	/**
	 * Test REST API
	 */
	public static function rest_api_test_request(): bool {
		$url      = get_rest_url( null, 'burst/v1/track' );
		$data     = '{"request":"test"}';
		$response = wp_remote_post(
			$url,
			[
				'headers'     => [ 'Content-Type' => 'application/json; charset=utf-8' ],
				'method'      => 'POST',
				'body'        => wp_json_encode( $data ),
				'data_format' => 'body',
				'timeout'     => 5,
			]
		);
		if ( is_wp_error( $response ) ) {
			return false;
		}
		if ( $response['response']['code'] === 200 ) {
			return true;
		}

		return false;
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:24
inteuuod / inteuuod
0755
Goals
--
July 10 2025 04:32:25
inteuuod / inteuuod
0755
Ip
--
July 10 2025 04:32:24
inteuuod / inteuuod
0755
Tracking
--
July 10 2025 04:32:24
inteuuod / inteuuod
0755
blocks
--
July 10 2025 04:32:25
inteuuod / inteuuod
0755
.htaccess
0.41 KB
July 10 2025 04:32:24
inteuuod / inteuuod
0644
class-endpoint.php
3.896 KB
May 19 2025 18:26:52
inteuuod / inteuuod
0644
class-frontend-admin.php
2.26 KB
July 07 2025 16:45:26
inteuuod / inteuuod
0644
class-frontend-statistics.php
24.384 KB
July 07 2025 16:45:26
inteuuod / inteuuod
0644
class-frontend.php
10.145 KB
July 07 2025 16:45:26
inteuuod / inteuuod
0644
class-sessions.php
1.326 KB
July 07 2025 16:45:26
inteuuod / inteuuod
0644
class-shortcodes.php
16.382 KB
July 07 2025 16:45:26
inteuuod / inteuuod
0644
index.php
0.027 KB
May 19 2025 18:26:52
inteuuod / inteuuod
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF