HEX
Server: LiteSpeed
System: Linux cde2.duelhost.dk 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: dtptviut (1121)
PHP: 8.0.30
Disabled: exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/dtptviut/public_html/wp-content/plugins/comparisonfeed-wp/functions.php
<?php
    function json_remote_get($url, $auth) {
        return json_remote_request('GET', $url, $auth, null);
    }

    function json_remote_post($url, $auth, $body) {
        return json_remote_request('POST', $url, $auth, $body);
    }

    function json_remote_delete($url, $auth, $body) {
        return json_remote_request('DELETE', $url, $auth, $body);
    }

    function json_remote_request($method, $url, $auth, $body) {
        $headers = array();

        if ($method !== 'GET') {
            $headers['Content-Type'] = 'application/json';
        }

        if ($auth && isset($auth['pid']) && isset($auth['token'])) {
            $headers['Authorization'] = 'Basic ' . base64_encode($auth['pid'] . ':' . $auth['token']);
        }

        if ($body) {
            $body = wp_json_encode($body);
        }

        $result = wp_remote_request( $url, array(
                'body'          => $body,
                'data_format'   => 'body',
                'headers'       => $headers,
                'method'        => $method
            )
        );

        if ( is_wp_error( $result ) ) {
            log_error($result->get_error_message());
        } else {
            return json_decode($result['body']);
        }
    }
    
    function debug_to_console( $data ) {
        if ( is_array( $data ) )
            $output = "<script>console.log( 'Debug Objects: " . implode( ',', $data) . "' );</script>";
        else
            $output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>";
        echo $output;
    }

    function log_error( $string ) {
        error_log("Adservice Comparison Feed: $string");
        echo "<script>console.log('Adservice Comparison Feed: $string');</script>";
    }

    function getAccounts($adservice_options) {
        /* Get accounts */
        $accounts = json_remote_get("https://api.adservice.com/v2/publisher/account/all", $adservice_options);
        $newAccounts = array();

        if (isset($accounts->success) && $accounts->success) {
            foreach ((array) $accounts->data as $account) {
                /* reorganize the structure */
                $newAccount = array(
                    "company_name" => $account->company_name,
                    "login" => $account->login,
                    "countrycode" => $account->countrycode,
                    "id" => $account->agent_id,
                );
                array_push($newAccounts, $newAccount);
            }
        }

        return $newAccounts;
    }

    function GUID() {
        if (function_exists('com_create_guid') === true) {
            return trim(com_create_guid(), '{}');
        }

        return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
    }
?>