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-dashboard.php

<?php

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

namespace KokoAnalytics;

class Dashboard
{
    public function show_standalone_dashboard_page(): void
    {
        require __DIR__ . '/views/standalone.php';
        exit;
    }

    public function show(): void
    {
        $settings   = get_settings();
        $stats = new Stats();
        $items_per_page = (int) apply_filters('koko_analytics_items_per_page', 20);
        $dateFormat = get_option('date_format', 'Y-m-d');
        $dashboard_url = remove_query_arg(['start_date', 'end_date', 'view', 'posts', 'referrers']);

        // parse query params
        if (isset($_GET['start_date']) || isset($_GET['end_date'])) {
            $range = 'custom';
        } elseif (isset($_GET['view'])) {
            $range = trim($_GET['view']);
        } else {
            $range = $settings['default_view'];
        }
        $now = create_local_datetime('now');
        $week_starts_on = (int) get_option('start_of_week', 0);
        $dateRange = $this->get_dates_for_range($now, $range, $week_starts_on);
        $page = isset($_GET['p']) ? absint($_GET['p']) : 0;

        try {
            $dateStart  = isset($_GET['start_date']) ? create_local_datetime($_GET['start_date']) : $dateRange[0];
        } catch (\Exception $e) {
            $dateStart = $dateRange[0];
        }
        try {
            $dateEnd    = isset($_GET['end_date']) ? create_local_datetime($_GET['end_date']) : $dateRange[1];
        } catch (\Exception $e) {
            $dateEnd = $dateRange[1];
        }

        $posts_offset = isset($_GET['posts']['offset']) ? absint($_GET['posts']['offset']) : 0;
        $referrers_offset = isset($_GET['referrers']['offset']) ? absint($_GET['referrers']['offset']) : 0;
        $posts_limit = isset($_GET['posts']['limit']) ? absint($_GET['posts']['limit']) : $items_per_page;
        $referrers_limit = isset($_GET['referrers']['limit']) ? absint($_GET['referrers']['limit']) : $items_per_page;

        [$total_start_date, $total_end_date] = $stats->get_total_date_range();

        // calculate next and previous dates for datepicker component and comparison
        $nextDates = $this->get_next_period($dateStart, $dateEnd, 1);
        $prevDates = $this->get_next_period($dateStart, $dateEnd, -1);

        $totals = $stats->get_totals($dateStart->format('Y-m-d'), $dateEnd->format('Y-m-d'), $page);
        $totals_previous = $stats->get_totals($prevDates[0]->format('Y-m-d'), $prevDates[2]->format('Y-m-d'), $page);

        $posts = $stats->get_posts($dateStart->format("Y-m-d"), $dateEnd->format('Y-m-d'), $posts_offset, $posts_limit);
        $posts_count = $stats->count_posts($dateStart->format('Y-m-d'), $dateEnd->format('Y-m-d'));
        $referrers = $stats->get_referrers($dateStart->format("Y-m-d"), $dateEnd->format('Y-m-d'), $referrers_offset, $referrers_limit);
        $referrers_count = $stats->count_referrers($dateStart->format("Y-m-d"), $dateEnd->format('Y-m-d'));
        $realtime = get_realtime_pageview_count('-1 hour');

        if (isset($_GET['group']) && in_array($_GET['group'], ['day', 'week', 'month'])) {
            $groupChartBy = $_GET['group'];
        } else {
            $groupChartBy = $dateEnd->getTimestamp() - $dateStart->getTimestamp() >= 86400 * 90 ? 'month' : 'day';
        }

        $chart_data =  $stats->get_stats($dateStart->format("Y-m-d"), $dateEnd->format('Y-m-d'), $groupChartBy, $page);

        require __DIR__ . '/views/dashboard-page.php';
    }

    public function get_next_period(\DateTimeImmutable $dateStart, \DateTimeImmutable $dateEnd, int $dir = 1): array
    {
        $now = new \DateTimeImmutable('now', wp_timezone());
        $modifier = $dir > 0 ? "+" : "-";

        if ($dateStart->format('d') === "01" && $dateEnd->format('d') === $dateEnd->format('t')) {
            // cycling full months
            $diffInMonths = 1 + ((int) $dateEnd->format('Y') - (int) $dateStart->format('Y')) * 12 + (int) $dateEnd->format('m') - (int) $dateStart->format('m');
            $periodStart = $dateStart->setDate((int) $dateStart->format('Y'), (int) $dateStart->format('m') + ($dir * $diffInMonths), 1);
            $periodEnd = $dateEnd->setDate((int) $dateStart->format('Y'), (int) $dateEnd->format('m') + ($dir * $diffInMonths), 5);
            $periodEnd = $periodEnd->setDate((int) $periodEnd->format('Y'), (int) $periodEnd->format('m'), (int) $periodEnd->format('t'));
        } else {
            $diffInDays = $dateEnd->diff($dateStart)->days + 1;
            $periodStart = $dateStart->modify("{$modifier}{$diffInDays} days");
            $periodEnd = $dateEnd->modify("{$modifier}{$diffInDays} days");
        }

        if ($dateEnd > $now) {
            // limit end date to difference between now and start date, counting from start date
            $days_diff = $now->diff($dateStart)->days;
            $compareEnd = $periodStart->modify("+{$days_diff} days");
        } else {
            $compareEnd = $periodEnd;
        }


        return [ $periodStart, $periodEnd, $compareEnd ];
    }

    public function get_date_presets(): array
    {
        return [
            'today' => __('Today', 'koko-analytics'),
            'yesterday' => __('Yesterday', 'koko-analytics'),
            'this_week' => __('This week', 'koko-analytics'),
            'last_week' => __('Last week', 'koko-analytics'),
            'last_14_days' => __('Last 14 days', 'koko-analytics'),
            'last_28_days' => __('Last 28 days', 'koko-analytics'),
            'this_month' => __('This month', 'koko-analytics'),
            'last_month' => __('Last month', 'koko-analytics'),
            'this_year' => __('This year', 'koko-analytics'),
            'last_year' => __('Last year', 'koko-analytics'),
            'all_time' => __('All time', 'koko-analytics'),
        ];
    }

    private function maybe_show_adblocker_notice(): void
    {
        ?>
        <div class="notice notice-warning is-dismissible" id="koko-analytics-adblock-notice" style="display: none;">
            <p>
                <?php echo esc_html__('You appear to be using an ad-blocker that has Koko Analytics on its blocklist. Please whitelist this domain in your ad-blocker setting if your dashboard does not seem to be working correctly.', 'koko-analytics'); ?>
            </p>
        </div>
        <script src="<?php echo plugins_url('/assets/dist/js/koko-analytics-script-test.js', KOKO_ANALYTICS_PLUGIN_FILE); ?>?v=<?php echo KOKO_ANALYTICS_VERSION; ?>" defer onerror="document.getElementById('koko-analytics-adblock-notice').style.display = '';"></script>
        <?php
    }

    private function maybe_show_pro_notice(): void
    {
        if (! current_user_can('manage_koko_analytics')) {
            return;
        }

        new Notice_Pro();
    }

    public function get_dates_for_range(\DateTimeImmutable $now, string $key, int $week_starts_on = 0): array
    {
        switch ($key) {
            case 'today':
                return [
                    $now->modify('today midnight'),
                    $now->modify('tomorrow midnight, -1 second')
                ];
            case 'yesterday':
                return [
                    $now->modify('yesterday midnight'),
                    $now->modify('today midnight, -1 second')
                ];
            case 'this_week':
                $start = $this->get_first_day_of_current_week($now, $week_starts_on);
                return [
                    $start,
                    $start->modify('+7 days, midnight, -1 second')
                ];
            case 'last_week':
                $start = $this->get_first_day_of_current_week($now, $week_starts_on)->modify('-7 days');
                return [
                    $start,
                    $start->modify('+7 days, midnight, -1 second')
                ];
            case 'last_14_days':
                return [
                    $now->modify('-14 days'),
                    $now->modify('tomorrow midnight, -1 second')
                ];
            default:
            case 'last_28_days':
                return [
                    $now->modify('-28 days'),
                    $now->modify('tomorrow midnight, -1 second')
                ];
            case 'this_month':
                return [
                    $now->modify('first day of this month'),
                    $now->modify('last day of this month')
                ];
            case 'last_month':
                return [
                    $now->modify('first day of last month, midnight'),
                    $now->modify('last day of last month')
                ];
            case 'this_year':
                return [
                    $now->setDate((int) $now->format('Y'), 1, 1),
                    $now->setDate((int) $now->format('Y'), 12, 31),
                ];
            case 'last_year':
                return [
                    $now->setDate((int) $now->format('Y') - 1, 1, 1),
                    $now->setDate((int) $now->format('Y') - 1, 12, 31),
                ];
            case 'all_time':
                return (new Stats())->get_total_date_range();
        }
    }

    public function get_first_day_of_current_week(\DateTimeImmutable $now, int $week_starts_on = 0): \DateTimeImmutable
    {
        if ((int) $now->format('w') === $week_starts_on) {
            return $now;
        }

        return $now->modify("last sunday, +{$week_starts_on} days");
    }
}

SILENT KILLER Tool