| Server IP : 213.255.246.8 / Your IP : 216.73.217.138 Web Server : Apache System : Linux dublin.stapolin.com 5.14.0-362.18.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 29 07:05:48 EST 2024 x86_64 User : stapolin ( 1019) PHP Version : 8.4.24 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/stapolin/public_html/tracking.stapolin.com/admin/ |
Upload File : |
<?php
declare(strict_types=1);
require_once __DIR__ . '/../includes/bootstrap.php';
$currentUser = require_login();
$id = (int) ($_GET['id'] ?? 0);
$website = db_fetch_one('SELECT * FROM websites WHERE id = ?', 'i', [$id]);
if ($website === null) {
http_response_code(404);
exit('Website not found.');
}
$pageTitle = 'Test tracking';
$domains = db_fetch_all('SELECT domain FROM website_domains WHERE website_id = ? ORDER BY domain', 'i', [$id]);
$primaryHost = parse_url((string) $website['primary_url'], PHP_URL_HOST);
$primaryHost = is_string($primaryHost) ? strtolower($primaryHost) : '';
$domainValues = array_column($domains, 'domain');
$trackerPath = APP_ROOT . '/tracker.js';
$collectorPath = APP_ROOT . '/api/collect.php';
$checks = [
'Tracker file exists' => is_file($trackerPath),
'Collector endpoint exists' => is_file($collectorPath),
'Website is active' => $website['status'] === 'active',
'Primary URL has a valid host' => $primaryHost !== '',
'Primary host is allowed' => $primaryHost !== '' && in_array($primaryHost, $domainValues, true),
'Public tracking ID exists' => $website['public_id'] !== '',
];
$snippet = '<script async src="' . app_url('tracker.js') . '" data-site-id="' . $website['public_id'] . '"></script>';
$debugUrl = app_url('dev/test-tracker.php?site_id=' . urlencode((string) $website['public_id']));
require APP_ROOT . '/templates/admin_header.php';
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="h3 mb-1">Test tracking</h1>
<p class="text-muted mb-0"><?= e($website['name']) ?></p>
</div>
<a class="btn btn-outline-secondary" href="<?= e(app_url('admin/websites-view.php?id=' . $id)) ?>">Back to website</a>
</div>
<div class="row g-4">
<section class="col-lg-6">
<div class="card">
<div class="card-header bg-white">Installation checks</div>
<ul class="list-group list-group-flush">
<?php foreach ($checks as $label => $passed): ?>
<li class="list-group-item d-flex justify-content-between">
<span><?= e($label) ?></span>
<span class="badge text-bg-<?= $passed ? 'success' : 'danger' ?>"><?= $passed ? 'OK' : 'Check' ?></span>
</li>
<?php endforeach; ?>
</ul>
</div>
</section>
<section class="col-lg-6">
<div class="card mb-4">
<div class="card-header bg-white">Tracking snippet</div>
<div class="card-body">
<textarea class="form-control tracking-code" readonly><?= e($snippet) ?></textarea>
</div>
</div>
<div class="card">
<div class="card-header bg-white">Debug test page</div>
<div class="card-body">
<?php if (config_value('debug', false)): ?>
<p>Debug mode is enabled, so the local test page is available.</p>
<a class="btn btn-primary" href="<?= e($debugUrl) ?>" target="_blank" rel="noreferrer">Open test page</a>
<?php else: ?>
<p class="text-muted mb-0">Enable <code>debug</code> in <code>config/config.php</code> to use the local developer tracking test page.</p>
<?php endif; ?>
</div>
</div>
</section>
</div>
<?php require APP_ROOT . '/templates/admin_footer.php'; ?>