| Server IP : 172.67.201.108 / Your IP : 216.73.216.25 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/banners/public_html/bway/pixel/ |
Upload File : |
<?php
/**
* Pixel Article Tracking Endpoint
* Replaces: pixel-article.cfm
*
* Tracks article views, enriches user interest cookies,
* and queues interaction data for batch processing.
*/
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/PixelResponse.php';
require_once __DIR__ . '/BotFilter.php';
require_once __DIR__ . '/EventBuffer.php';
require_once __DIR__ . '/CookieManager.php';
require_once __DIR__ . '/TopicCache.php';
// --- Validate inputs ---
$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$headline = filter_input(INPUT_GET, 'headline', FILTER_VALIDATE_INT) ?: 1;
$hot = filter_input(INPUT_GET, 'hot', FILTER_VALIDATE_INT);
$prodid = filter_input(INPUT_GET, 'prodid', FILTER_VALIDATE_INT);
$sourcevar = isset($_GET['sourcevar']) ? trim($_GET['sourcevar']) : '';
$uuid = isset($_GET['uuid']) ? trim($_GET['uuid']) : '';
$prod = isset($_GET['prod']) ? trim($_GET['prod']) : '';
if ($sourcevar !== '' && strlen($sourcevar) > SOURCEVAR_MAX_LENGTH) {
// Prevent oversized referrers from rolling back entire articlesource batches.
$sourcevar = substr($sourcevar, 0, SOURCEVAR_MAX_LENGTH);
}
// --- Check if we should skip processing (but still return pixel) ---
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$skipProcessing = (stripos($userAgent, 'EZAutoInsert') !== false);
// --- Cookie operations (MUST happen before GIF flush) ---
if (!$skipProcessing) {
CookieManager::resetInterestsIfOversized();
CookieManager::clearLegacyCookies();
// Rolling article cookie
if ($id) {
CookieManager::updateArticleCookie($id);
}
// Topic interest enrichment via ?hot= param
if ($hot && !in_array($hot, EXCLUDED_TOPIC_IDS, true)) {
$topicName = TopicCache::getTopicName($hot);
if ($topicName !== null) {
CookieManager::updateInterestsCookie($topicName);
}
}
// Direct production name enrichment via ?prod= param
if ($prod !== '') {
CookieManager::updateInterestsCookie($prod);
}
}
// --- Send 1x1 GIF and close client connection ---
PixelResponse::sendPixelAndFlush();
// --- Everything below is invisible to the client ---
if ($skipProcessing || !BotFilter::shouldTrack($userAgent)) {
exit;
}
$today = date('Y-m-d');
$datetime = date('Y-m-d H:i:s');
// Article stats
if ($id) {
EventBuffer::append('articlestats', [
'id' => $id,
'date' => $today,
'type' => 'story2',
'headline' => $headline,
]);
// Source tracking
if ($sourcevar !== '') {
EventBuffer::append('articlesource', [
'id' => $id,
'date' => $today,
'sourcevar' => $sourcevar,
]);
}
}
// Production stats
if ($prodid) {
EventBuffer::append('prodstats', [
'id' => $prodid,
]);
}
// Interaction logging — UUID path vs IP path
$interactionProdId = ($hot && $hot > 0) ? $hot : 0;
if ($uuid !== '' && $id) {
EventBuffer::append('uuidinteractions', [
'user_id' => $uuid,
'article_id' => $id,
'timestamp' => $datetime,
'showid' => $interactionProdId,
]);
} elseif ($id) {
$ip = getClientIp();
if ($ip !== '' && $ip !== '0.0.0.0') {
EventBuffer::append('noidinteractions', [
'user_id' => $ip,
'article_id' => $id,
'timestamp' => $datetime,
'showid' => $interactionProdId,
]);
}
}