SILENT KILLERPanel

Current Path: > home > codekrsu > > escapematrixonline.com > wp-content > plugins > koko-analytics > src >


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//escapematrixonline.com/wp-content/plugins/koko-analytics/src/

NameTypeSizeLast ModifiedActions
views Directory - -
backwards-compat.php File 370 bytes June 12 2025 11:44:36.
class-actions.php File 845 bytes February 10 2025 14:48:06.
class-admin-actions.php File 4609 bytes June 12 2025 11:44:36.
class-admin-bar.php File 713 bytes February 18 2025 13:13:36.
class-admin-page.php File 5425 bytes June 12 2025 11:44:36.
class-admin.php File 4019 bytes February 10 2025 14:48:06.
class-aggregator.php File 2952 bytes February 25 2025 13:03:20.
class-burst-importer.php File 11294 bytes June 13 2025 15:30:02.
class-chart-view.php File 5748 bytes June 12 2025 11:44:36.
class-command.php File 514 bytes April 15 2025 12:32:12.
class-dashboard-widget.php File 1548 bytes February 18 2025 13:13:36.
class-dashboard.php File 9510 bytes June 12 2025 11:44:36.
class-data-exporter.php File 3168 bytes February 18 2025 13:13:36.
class-data-importer.php File 2270 bytes February 18 2025 13:13:36.
class-endpoint-installer.php File 5526 bytes June 13 2025 10:27:30.
class-fingerprinter.php File 2279 bytes June 12 2025 11:44:36.
class-fmt.php File 1332 bytes February 18 2025 13:13:36.
class-jetpack-importer.php File 15592 bytes June 13 2025 15:30:02.
class-migrations.php File 2436 bytes January 17 2025 13:46:42.
class-notice-pro.php File 4591 bytes March 24 2025 11:30:04.
class-pageview-aggregator.php File 12890 bytes March 10 2025 11:31:16.
class-plugin.php File 1234 bytes June 12 2025 11:44:36.
class-pruner.php File 1460 bytes April 15 2025 12:32:12.
class-query-loop-block.php File 1533 bytes March 10 2025 11:31:16.
class-rest.php File 8271 bytes February 10 2025 14:48:06.
class-script-loader.php File 4741 bytes June 12 2025 11:44:36.
class-shortcode-most-viewed-posts.php File 1861 bytes February 25 2025 13:03:20.
class-shortcode-site-counter.php File 1727 bytes March 10 2025 11:31:16.
class-stats.php File 7099 bytes June 12 2025 11:44:36.
class-widget-most-viewed-posts.php File 5828 bytes February 10 2025 14:48:06.
collect-functions.php File 9907 bytes June 18 2025 21:02:18.
external-strings.php File 7144 bytes April 15 2025 12:32:12.
functions.php File 6447 bytes June 12 2025 11:44:36.
global-functions.php File 2521 bytes January 17 2025 13:46:42.
template-functions.php File 567 bytes February 18 2025 13:13:36.

Reading File: /home/codekrsu//escapematrixonline.com/wp-content/plugins/koko-analytics/src//class-rest.php

<?php

/**
 * @package koko-analytics
 * @license GPL-3.0+
 * @author Danny van Kooten
 */

namespace KokoAnalytics;

class Rest
{
    public static function register_routes(): void
    {
        $instance = new Rest();
        $route_namespace = 'koko-analytics/v1';

        register_rest_route(
            $route_namespace,
            '/stats',
            [
                'callback'            => [$instance, 'get_stats'],
                'args'                => [
                    'start_date' => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                    'end_date'   => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                    'monthly' => [
                        'sanitize_callback' => [$instance, 'sanitize_bool_param'],
                    ],
                ],
                'permission_callback' => [$instance, 'permission_callback'],
            ]
        );

        register_rest_route(
            $route_namespace,
            '/totals',
            [
                'callback'            => [$instance, 'get_totals'],
                'args'                => [
                    'start_date' => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                    'end_date'   => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                ],
                'permission_callback' => [$instance, 'permission_callback'],
            ]
        );

        register_rest_route(
            $route_namespace,
            '/posts',
            [
                'callback'            => [$instance, 'get_posts'],
                'args'                => [
                    'start_date' => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                    'end_date'   => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                ],
                'permission_callback' => [$instance, 'permission_callback'],
            ]
        );

        register_rest_route(
            $route_namespace,
            '/referrers',
            [
                'callback'            => [$instance, 'get_referrers'],
                'args'                => [
                    'start_date' => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                    'end_date'   => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                ],
                'permission_callback' => [$instance, 'permission_callback'],
            ]
        );

        register_rest_route(
            $route_namespace,
            '/realtime',
            [
                'callback'            => [$instance, 'get_realtime_pageview_count'],
                'args'                => [
                    'since' => [
                        'validate_callback' => [$instance, 'validate_date_param'],
                    ],
                ],
                'permission_callback' => [$instance, 'permission_callback'],
            ]
        );
    }

    public function permission_callback(): bool
    {
        $settings = get_settings();
        $is_dashboard_public = $settings['is_dashboard_public'];
        return $is_dashboard_public || current_user_can('view_koko_analytics');
    }

    private function is_request_for_completed_date_range(\WP_REST_Request $request): bool
    {
        $end_date = $request->get_param('end_date');
        if ($end_date === null) {
            return false;
        }

        $end_date = create_local_datetime($end_date);
        $now = create_local_datetime('now');
        return $end_date < $now;
    }

    private function respond($data, bool $send_cache_headers = false): \WP_REST_Response
    {
        $result = new \WP_REST_Response($data, 200);

        // instruct browsers to cache the response for 7 days
        if ($send_cache_headers) {
            $result->set_headers(['Cache-Control' => 'max-age=604800']);
        }
        return $result;
    }

    public function validate_date_param($param, $one, $two): bool
    {
        return \strtotime($param) !== false;
    }

    public function sanitize_bool_param($value, $request, $param): bool
    {
        return ! \in_array($value, ['no', 'false', '0'], true);
    }

    /**
     * Returns a daily tally of visitors and pageviews between two dates
     */
    public function get_stats(\WP_REST_Request $request): \WP_REST_Response
    {
        $params             = $request->get_query_params();
        $start_date         = $params['start_date'] ?? create_local_datetime('first day of this month')->format('Y-m-d');
        $end_date           = $params['end_date'] ?? create_local_datetime('now')->format('Y-m-d');
        $group = ($params['monthly'] ?? false) ? 'month' : 'day';
        $page = $params['page'] ?? 0;
        $result = (new Stats())->get_stats($start_date, $end_date, $group, $page);
        $send_cache_headers = WP_DEBUG === false && $this->is_request_for_completed_date_range($request);
        return $this->respond($result, $send_cache_headers);
    }

    /**
     * Returns the total number of visitos and pageviews between two dates.
     */
    public function get_totals(\WP_REST_Request $request): \WP_REST_Response
    {
        $params     = $request->get_query_params();
        $start_date = $params['start_date'] ?? create_local_datetime('first day of this month')->format('Y-m-d');
        $end_date   = $params['end_date'] ?? create_local_datetime('now')->format('Y-m-d');
        $page = $params['page'] ?? 0;
        $result = (new Stats())->get_totals($start_date, $end_date, $page);
        $send_cache_headers = WP_DEBUG === false && $this->is_request_for_completed_date_range($request);
        return $this->respond($result, $send_cache_headers);
    }

    /**
     * Returns the total number of pageviews and visitors per post, ordered by most pageviews first.
     */
    public function get_posts(\WP_REST_Request $request): \WP_REST_Response
    {
        $send_cache_headers = WP_DEBUG === false && $this->is_request_for_completed_date_range($request);
        $params     = $request->get_query_params();
        $start_date = $params['start_date'] ?? create_local_datetime('first day of this month')->format('Y-m-d');
        $end_date   = $params['end_date'] ?? create_local_datetime('now')->format('Y-m-d');
        $offset     = isset($params['offset']) ? absint($params['offset']) : 0;
        $limit      = isset($params['limit']) ? absint($params['limit']) : 10;
        $results = (new Stats())->get_posts($start_date, $end_date, $offset, $limit);
        return $this->respond($results, $send_cache_headers);
    }

    /**
     * Returns the total number of visitors and pageviews per referrer URL, ordered by most pageviews first.
     */
    public function get_referrers(\WP_REST_Request $request): \WP_REST_Response
    {
        $params             = $request->get_query_params();
        $start_date         = $params['start_date'] ?? create_local_datetime('first day of this month')->format('Y-m-d');
        $end_date           = $params['end_date'] ?? create_local_datetime('now')->format('Y-m-d');
        $offset             = isset($params['offset']) ? absint($params['offset']) : 0;
        $limit              = isset($params['limit']) ? absint($params['limit']) : 10;
        $results = (new Stats())->get_referrers($start_date, $end_date, $offset, $limit);
        $send_cache_headers = WP_DEBUG === false && $this->is_request_for_completed_date_range($request);
        return $this->respond($results, $send_cache_headers);
    }

    /**
     * Returns the total number of recorded pageviews in the last hour
     * @return int|mixed
     */
    public function get_realtime_pageview_count(\WP_REST_Request $request)
    {
        $params = $request->get_query_params();
        return get_realtime_pageview_count($params['since'] ?? null);
    }
}

SILENT KILLER Tool