Querying statistics objects in WHMCS

You can display usage statistics with the ostor-usage service and parameter obj specifying the statistics object. WHMCS displays the accessed buckets, user ID, and counters when you click the Get button. Create a file S3_getStatsForObject.php with the following contents:

<?php

// Load configuration and libraries.
require('../../includes/staas_scripts/S3_getConfig.php');
require('../../includes/staas_scripts/S3_requestCurl.php');
require('../../init.php');

// Get s3 statistics object.
function S3_getStatsObjects($object) {

    // Load configuration.
    $s3_config = s3_getConfig();

    // Get s3 statistics object.
    $s3_client = S3_requestCurl(
        $s3_config['s3_key'],
        $s3_config['s3_secret'],
        $s3_config['s3_gateway'],
        "/?ostor-usage&obj=" . $object,
        "GET"
    );

    // Store s3 result.
    $_SESSION['s3_object_statistic'] = $s3_client;
    $_SESSION['s3_object'] = $object;

    // Redirect back.
    header('Location: ' . $_SERVER['HTTP_REFERER']);
}

// Call function.
S3_getStatsObjects($_GET['object']);

?>