| Server IP : 216.238.66.20 / Your IP : 216.73.216.51 Web Server : nginx/1.30.4 System : Linux woropds 5.15.0-187-generic #197-Ubuntu SMP Fri Jul 17 19:17:01 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/sweetheart.mx/htdocs/wp-content/plugins/wp-slimstat/src/Tracker/ |
Upload File : |
<?php
namespace SlimStat\Tracker;
class Routing
{
public static function addRewriteRules()
{
add_rewrite_tag('%slimstat_tracker%', '([a-f0-9]{32})');
add_rewrite_rule('^([a-f0-9]{32})\\.js$', 'index.php?slimstat_tracker=$matches[1]', 'top');
add_rewrite_rule('^([a-f0-9]{32})\\.css$', 'index.php?slimstat_tracker=$matches[1]', 'top');
add_rewrite_rule('^([a-f0-9]{32})$', 'index.php?slimstat_tracker=$matches[1]', 'top');
}
public static function outputTrackerJsIfRequested()
{
$tracker_hash = get_query_var('slimstat_tracker');
if ($tracker_hash) {
$uri = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : '';
$expected_js_hash = md5(site_url() . 'slimstat');
$expected_css_hash = md5(site_url() . 'slimstat_gdpr_banner_css');
// Serve hashed JS
if ($tracker_hash === $expected_js_hash && (false !== strpos($uri, '.js'))) {
header('Content-Type: application/javascript');
header('Cache-Control: public, max-age=31536000');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
$js_path = SLIMSTAT_ANALYTICS_DIR . 'wp-slimstat.min.js';
if (file_exists($js_path)) {
readfile($js_path);
exit;
}
status_header(404);
echo '// Tracker not found';
exit;
}
// Serve hashed GDPR CSS (used in adblock bypass mode)
if ($tracker_hash === $expected_css_hash && (false !== strpos($uri, '.css'))) {
header('Content-Type: text/css; charset=utf-8');
header('Cache-Control: public, max-age=31536000');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
$css_path = SLIMSTAT_ANALYTICS_DIR . 'assets/css/gdpr-banner.css';
if (file_exists($css_path)) {
readfile($css_path);
exit;
}
status_header(404);
echo '/* GDPR CSS not found */';
exit;
}
}
}
}