403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.188.39.45
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/7779/cwd/plugins/give/src/Tracking/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/cwd/plugins/give/src/Tracking/TrackClient.php
<?php

namespace Give\Tracking;

use Give\Tracking\Contracts\TrackData;
use Give\Tracking\Enum\EventType;
use Give\Tracking\Repositories\TelemetryAccessDetails;
use WP_Error;

/**
 * Class TrackClient
 *
 * This class has responsibility to send tracking information
 *
 * @package Give\Tracking
 *
 * @since 2.10.0
 */
class TrackClient
{
    const SERVER_URL = 'https://telemetry.givewp.com/api/v1/track-plugin-usage';

    /**
     * @var TelemetryAccessDetails
     */
    private $telemetryAccessDetails;

    /**
     * TrackClient constructor.
     *
     * @param TelemetryAccessDetails $telemetryAccessDetails
     */
    public function __construct(TelemetryAccessDetails $telemetryAccessDetails)
    {
        $this->telemetryAccessDetails = $telemetryAccessDetails;
    }

    /**
     * Send a track event.
     *
     * @since 2.10.0
     *
     * @param EventType $eventType
     * @param TrackData $trackData
     * @param array     $requestArgs
     *
     * @return array|WP_Error
     */
    public function post(EventType $eventType, TrackData $trackData, $requestArgs = [])
    {
        $id = $eventType->getValue();
        $data = $trackData->get();

        if ( ! $id || ! $data) {
            return new WP_Error('invalid-telemetry-request', 'Pass valid track id and tracked data to TrackClient');
        }

        $default_request_args = [
            'headers' => [
                'content-type:' => 'application/json',
                'Authorization' => 'Bearer ' . $this->telemetryAccessDetails->getAccessTokenOptionValue(),
            ],
            'timeout' => 8,
            'httpversion' => '1.1',
            'blocking' => false,
            'user-agent' => 'GIVE/' . GIVE_VERSION . ' ' . get_bloginfo('url'),
            'body' => wp_json_encode($data),
            'data_format' => 'body',
        ];

        return wp_remote_post($this->getApiUrl($id), wp_parse_args($requestArgs, $default_request_args));
    }

    /**
     * Get api url.
     *
     * @since 2.10.0
     *
     * @param string $trackId
     *
     * @return string
     */
    public function getApiUrl($trackId)
    {
        return self::SERVER_URL . '/' . $trackId;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit