| Server IP : 172.67.201.108 / Your IP : 216.73.216.11 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/ |
Upload File : |
<?php
/**
* Track Recommended/For You A/B Test Clicks
* Replaces: track_rf.cfm
*
* Logs A/B test interactions to bway_bww.foryoutest with client IP detection.
*/
require_once __DIR__ . '/db/mysql_bootstrap.php';
header('Content-Type: application/json');
$type = $_GET['type'] ?? 'ROS';
$abTestName = $_GET['abTestName'] ?? '';
$abTestVariant = $_GET['abTestVariant'] ?? '';
$sortMethod = $_GET['sortMethod'] ?? '';
$articleId = $_GET['articleId'] ?? '';
$articleTitle = $_GET['articleTitle'] ?? '';
// Try to get the real IP from various possible sources
$cf_connecting_ip = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? '';
$x_forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '';
$x_real_ip = $_SERVER['HTTP_X_REAL_IP'] ?? '';
$x_client_ip = $_SERVER['HTTP_X_CLIENT_IP'] ?? '';
$remote_addr = $_SERVER['REMOTE_ADDR'] ?? '';
$realIP = $cf_connecting_ip;
if (empty(trim($realIP)) && !empty(trim($x_forwarded_for))) {
$ipList = explode(',', $x_forwarded_for);
if (count($ipList) > 0) {
$realIP = trim($ipList[0]);
}
}
if (empty(trim($realIP))) $realIP = $x_real_ip;
if (empty(trim($realIP))) $realIP = $x_client_ip;
if (empty(trim($realIP))) $realIP = $remote_addr;
// Validate required parameters
if (empty(trim($abTestName)) || empty(trim($abTestVariant)) || empty(trim($sortMethod))) {
echo json_encode(['success' => false, 'error' => 'Missing required parameters']);
exit;
}
try {
$db = new PDO(
'mysql:host=amazonaurora.cluster-cemzxojvmybt.us-east-1.rds.amazonaws.com;dbname=amazonrds;charset=utf8mb4',
'admin',
'xxatN6Lb8Kbwb9MiU1At',
mysqlPdoOptions([PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false])
);
$numericArticleId = is_numeric($articleId) ? (int)$articleId : 0;
$stmt = $db->prepare("INSERT INTO bway_bww.foryoutest (abtestname, variant, method, colid, typer, ipaddress) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->execute([$abTestName, $abTestVariant, $sortMethod, $numericArticleId, $type, $realIP]);
$xffParsed = !empty(trim($x_forwarded_for)) ? trim(explode(',', $x_forwarded_for)[0]) : '';
echo json_encode([
'success' => true,
'message' => 'Click tracked successfully',
'debug' => [
'cf_connecting_ip' => $cf_connecting_ip,
'x_forwarded_for' => $x_forwarded_for,
'x_forwarded_for_parsed' => $xffParsed,
'real_ip' => $realIP
]
]);
} catch (Exception $e) {
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}