HEX
Server: LiteSpeed
System: Linux server801.shared.spaceship.host 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: yvigantdvn (2232)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //opt/hc_php/unversioned/EventPublisher.php
<?php
namespace HcEventPublisher;

include_once('JsonRPC/Client.php');

use JsonRPC;

const USER_MDS_SOCKET = '/var/run/hc_mds/user_mds.socket';
const ROOT_MDS_SOCKET = '/var/run/hc_mds/root_mds.socket';
const METHOD = 'event';
const DEBUG = false;

const BASE_PATH = '/var/cpanel/userdata';
const TOKEN_FILE = 'hc_mds.token';


class EventPublisher extends JsonRPC\Client {

    public function __construct()
    {   
        $processUser = posix_getpwuid(posix_geteuid());
        $this->user = $processUser['name'];
        if ($this->user == 'root') {
            parent::__construct(ROOT_MDS_SOCKET);
        } else {
            parent::__construct(USER_MDS_SOCKET);
        }
        $this->debug = DEBUG;
    }

    public function send($params=array()) {
        // Add token to the request if user is not root.
        if ($this->user != 'root') {
            $full_token_path = sprintf('%s/%s/%s', BASE_PATH, $this->user, TOKEN_FILE);
            if (file_exists($full_token_path)) {

                $params['metadata']['token'] = trim(file_get_contents($full_token_path));
            }
        }
        return $this->execute(METHOD, $params);
    }
} 

?>