| 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/archive/ |
Upload File : |
<?php
// Start output buffering for better performance
ob_start();
// Set cache headers
header('Cache-Control: public, max-age=300'); // 5 minutes for dynamic content
header('Vary: Cookie');
$time_start = microtime(true);
// Use persistent connection for better performance with timeout options
$link = mysqli_init();
mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 2);
mysqli_options($link, MYSQLI_OPT_READ_TIMEOUT, 2);
mysqli_real_connect($link, 'p:amazonaurora.cluster-ro-cemzxojvmybt.us-east-1.rds.amazonaws.com', 'admin', 'xxatN6Lb8Kbwb9MiU1At', 'amazonrds');
$GLOBALS["___mysqli_ston"] = $link;
if(isset($_REQUEST['threader']))
{
// Use separate lightweight connection for tracking to avoid blocking main query
$trackLink = mysqli_init();
mysqli_options($trackLink, MYSQLI_OPT_CONNECT_TIMEOUT, 1);
mysqli_real_connect($trackLink, 'p:amazonaurora.cluster-ro-cemzxojvmybt.us-east-1.rds.amazonaws.com', 'admin', 'xxatN6Lb8Kbwb9MiU1At', 'amazonrds');
$sql = "INSERT DELAYED INTO bway_bww.wbtrack (photoid) VALUES (" . intval($_REQUEST['thread']) . ")";
mysqli_query($trackLink, $sql);
mysqli_close($trackLink);
}
else if(isset($_REQUEST['colid']) && (isset($_REQUEST['sourcevar']) && $_REQUEST['sourcevar'] != '' && ($_REQUEST['colid']>2058774)))
{
$today = date("Y-m-d");
}
?>
<html><head><link rel="preconnect" href="https://cloudimages.broadwayworld.com">
<link rel="dns-prefetch" href="https://cloudimages.broadwayworld.com"><meta name="googlebot" content="noindex,indexifembedded" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recommended for You</title>
<?php
if(isset($_GET['new'])) { // check if "new" parameter exists in the URL
// if "new" parameter exists, use this CSS
echo '<link href="https://cloudimages.broadwayworld.com/bworld1523/assets/css/style44min.css" rel="stylesheet">
<Style type="text/css">@charset UTF-8;body{
font-family: "Poppins"!important;
font-weight: normal;
font-style: normal;
margin:0;padding:0;background:#ffffff;font-display:auto;
}
.recommended-container {
display: flex;
flex-wrap: wrap;
gap: 10px;
width: 100%;
padding-top:0px;
box-sizing: border-box;
max-width: 740px;
margin: 0 auto;
}
.recommended-item {
flex: 1 1 calc(25% - 8px);
min-width: calc(50% - 5px);
max-width: calc(50% - 5px);
display: flex;
flex-direction: column;
word-break: break-word;
overflow: hidden;
}
@media (min-width: 560px) {
.recommended-item {
flex: 1 1 calc(25% - 8px);
min-width: calc(25% - 8px);
max-width: calc(25% - 8px);
}
}
a{
margin:0;
font-size: 13px;
line-height:16px;
letter-spacing: -.3px;
color:#313131;
text-decoration:none;
display: flex;
flex-direction: column;
height: 100%;
}
img{
max-width:100%;
height:auto;
display: block;
}
a:hover{
color:#b20223;
}
.recommended-image {
width: 100%;
aspect-ratio: 16/10;
object-fit: cover;
margin-bottom: 6px;
border-radius: 3px;
}
.recommended-title {
font-size: 13px;
line-height: 16px;
font-weight: 600;
margin: 0;
flex-grow: 1;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
a, button {
color: #222222;
font-size: 13px;
font-weight: normal;
line-height: 16px;
color: #222222;
outline: medium none;
}
h4 {
margin: 0;
padding: 0;
}
</style></head><body style="margin-top:0;padding:0;"><Div style="width:100%;margin:0px;padding:8px 0;">';
} else {
// if "new" parameter does not exist, use this CSS
echo '<Style type="text/css">@charset UTF-8;
body{
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
margin:0;
padding:0;
background:#ffffff;
font-display:auto;
}
.recommended-container {
display: flex;
flex-wrap: wrap;
gap: 10px;
width: 100%;
padding: 8px 0;
box-sizing: border-box;
max-width: 740px;
margin: 0 auto;
}
.recommended-item {
flex: 1 1 calc(25% - 8px);
min-width: calc(50% - 5px);
max-width: calc(50% - 5px);
display: flex;
flex-direction: column;
word-break: break-word;
overflow: hidden;
}
@media (min-width: 560px) {
.recommended-item {
flex: 1 1 calc(25% - 8px);
min-width: calc(25% - 8px);
max-width: calc(25% - 8px);
}
}
a{
margin:0;
font-weight:600;
font-size: 13px;
line-height:16px;
letter-spacing: -.3px;
color:#313131;
text-decoration:none;
display: flex;
flex-direction: column;
height: 100%;
}
img{
max-width:100%;
height:auto;
display: block;
}
a:hover{
color:#b20223;
}
.recommended-image {
width: 100%;
aspect-ratio: 16/10;
object-fit: cover;
margin-bottom: 6px;
border-radius: 3px;
}
.recommended-title {
font-size: 13px;
line-height: 16px;
font-weight: 600;
margin: 0;
flex-grow: 1;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
h4 {
margin: 0;
padding: 0;
}
</style></head><body><Div style="width:100%;padding:0px 0;margin:0px;">';
}
?>
<?php
if(isset($_GET['black'])) {?>
<Style type="text/css">
body a {
color: #fff;
}
body {background-color:#000;}
</Style>
<?php }?>
<?php
/** queries an sql statement and returns a record **/
function q($query,$link)
{
$result=mysqli_query( $link, $query);
if($result AND mysqli_num_rows($result)>0)
{
// collect query results
$out = array();
while($row = mysqli_fetch_assoc($result))
{
$out[] = $row;
}
return $out;
}
return NULL;
}
$reginc=0;
if(isset($_COOKIE["REGION2023"]) && isset($_COOKIE["REGIONDIR"]) && isset($_COOKIE["REGNAME"]) ){
$reginc = $_COOKIE["REGION2023"];
} else {
// If Cloudflare didn't set HTTP_CF_IPCOUNTRY, default to 'US'.
$country = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? 'US';
switch ($country)
{
case 'GB': $reginc = 4; break;
case 'UK': $reginc = 4; break;
case 'FR': $reginc = 149; break;
case 'NZ': $reginc = 3; break;
case 'CN': $reginc = 66; break;
case 'JP': $reginc = 67; break;
case 'DE': $reginc = 68; break;
case 'KR': $reginc = 94; break;
case 'PH': $reginc = 120; break;
case 'ES': $reginc = 146; break;
case 'NL': $reginc = 147; break;
case 'IT': $reginc = 148; break;
case 'BR': $reginc = 150; break;
case 'AR': $reginc = 151; break;
case 'MX': $reginc = 152; break;
case 'IN': $reginc = 153; break;
case 'IE': $reginc = 154; break;
case 'IL': $reginc = 156; break;
case 'ZA': $reginc = 157; break;
case 'BE': $reginc = 158; break;
case 'CH': $reginc = 159; break;
case 'CZ': $reginc = 160; break;
case 'PL': $reginc = 161; break;
case 'SE': $reginc = 162; break;
case 'HU': $reginc = 163; break;
case 'TR': $reginc = 164; break;
case 'NO': $reginc = 165; break;
case 'AT': $reginc = 166; break;
case 'RU': $reginc = 167; break;
case 'MY': $reginc = 168; break;
case 'ID': $reginc = 169; break;
case 'FI': $reginc = 170; break;
case 'MC': $reginc = 187; break;
case 'LU': $reginc = 188; break;
case 'SG': $reginc = 196; break;
case 'PT': $reginc = 316; break;
case 'CO': $reginc = 317; break;
case 'VE': $reginc = 318; break;
case 'PE': $reginc = 319; break;
case 'CU': $reginc = 320; break;
case 'EG': $reginc = 321; break;
case 'QA': $reginc = 322; break;
case 'HK': $reginc = 336; break;
case 'DK': $reginc = 338; break;
case 'GR': $reginc = 339; break;
case 'IS': $reginc = 340; break;
case 'PA': $reginc = 341; break;
case 'EE': $reginc = 346; break;
case 'BG': $reginc = 347; break;
case 'CY': $reginc = 348; break;
case 'BM': $reginc = 349; break;
case 'MT': $reginc = 350; break;
// Added this case for US visitors:
case 'US':
$reginc = 1; // <-- Adjust this value as needed
break;
// Optional fallback if some other country code isn't in the list:
default:
$reginc = 0; // or whatever default you want
break;
}
if($reginc==0)
{
// get user IP address
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = '127.0.0.1'; // Default to localhost instead of 'UNKNOWN'
// Handle comma-separated IPs (from proxies) by taking the first one
if (strpos($ipaddress, ',') !== false) {
$ipaddress = trim(explode(',', $ipaddress)[0]);
}
return $ipaddress;
}
// Helper functions for IP geolocation
function isIPv6($ip) {
if ($ip == "" || $ip == "UNKNOWN") {
return 0;
}
// Use filter_var for proper IP validation
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
return 1;
} elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
return 0;
} else {
// Fallback to string-based detection for malformed IPs
if(strpos($ip, ":") !== false) {
return 1;
} else {
return 0;
}
}
}
// Convert IPV4 to ip2location database integer
function IPV4toInteger ($IPaddr) {
if ($IPaddr == "" || !filter_var($IPaddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
return 0;
}
else {
$ips = explode(".", "$IPaddr");
// Check if we have exactly 4 parts and all are numeric
if (count($ips) != 4) {
return 0;
}
// Validate each octet is numeric and within valid range
foreach ($ips as $octet) {
if (!is_numeric($octet) || $octet < 0 || $octet > 255) {
return 0;
}
}
return (intval($ips[3]) + intval($ips[2]) * 256 + intval($ips[1]) * 256 * 256 + intval($ips[0]) * 256 * 256 * 256);
}
}
// Convert IPV6 to ip2location database integer
function IPV6ToInteger($ipv6) {
if ($ipv6 == "" || !filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
return 0;
}
$packed = inet_pton($ipv6);
if ($packed === false) {
return 0;
}
// Try GMP first (if available)
if (function_exists('gmp_import')) {
return (string) gmp_import($packed);
}
// Fallback to BCMath (if available)
if (function_exists('bcmul') && function_exists('bcadd')) {
$unpacked = unpack('C*', $packed);
if ($unpacked === false) {
return 0;
}
$result = '0';
foreach ($unpacked as $byte) {
$result = bcmul($result, '256');
$result = bcadd($result, (string)$byte);
}
return $result;
}
// Final fallback: Use hex string format that MySQL can handle
// MySQL can compare hex strings when used in numeric context
// Format: CONV(hex_string, 16, 10) or use 0x prefix
// For the query, we'll use the hex format which MySQL can convert
return '0x' . bin2hex($packed);
}
// Function to perform IP lookup - optimized to remove nested subqueries
function performIPLookup($clientIp, $link) {
if(isIPv6($clientIp)){
$ip = IPV6ToInteger($clientIp);
// Check if result is hex string (starts with 0x) - means GMP/BCMath not available
if (is_string($ip) && substr($ip, 0, 2) === '0x') {
// Use MySQL CONV function to convert hex to decimal for comparison
$hexValue = mysqli_real_escape_string($link, substr($ip, 2)); // Remove 0x prefix
// Optimized: Single query, no nested subquery
$query="SELECT *
FROM bway_bwdb.ip2locationipv6
WHERE ipv61 <= CONV('".$hexValue."', 16, 10)
AND ipv62 >= CONV('".$hexValue."', 16, 10)
LIMIT 1";
} else {
// Normal numeric comparison (GMP or BCMath was available)
// Optimized: Single query, no nested subquery
$query="SELECT *
FROM bway_bwdb.ip2locationipv6
WHERE ipv61 <= ".mysqli_real_escape_string($link, $ip)."
AND ipv62 >= ".mysqli_real_escape_string($link, $ip)."
LIMIT 1";
}
} else {
$ip = IPV4toInteger($clientIp);
// Optimized: Single query, no nested subquery
$query="SELECT *
FROM bway_bwdb.ip2locationipv4
WHERE ipv41 <= ".mysqli_real_escape_string($link, $ip)."
AND ipv42 >= ".mysqli_real_escape_string($link, $ip)."
LIMIT 1";
}
$result=mysqli_query( $link, $query);
return mysqli_fetch_assoc($result);
}
// Cache IP geolocation lookup in APCu shared memory (24h TTL)
$clientIp = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? get_client_ip();
$ipCacheKey = 'ip_geo_' . md5($clientIp);
$getcolumn = apcu_fetch($ipCacheKey, $hit);
if (!$hit) {
$getcolumn = performIPLookup($clientIp, $link);
if ($getcolumn !== false && $getcolumn !== null) {
apcu_store($ipCacheKey, $getcolumn, 86400);
}
}
if(isset($getcolumn['regid']) && $getcolumn['regid']!='')
{
$reginc=$getcolumn['regid'];
setcookie("REGION2023", $reginc, time()+32*24*60*60, "/", ".broadwayworld.com");
setcookie("REGIONDIR", $getcolumn['regdir'], time()+32*24*60*60, "/", ".broadwayworld.com");
setcookie("REGNAME", $getcolumn['regname'], time()+32*24*60*60, "/", ".broadwayworld.com");
} else {
$reginc=1;
setcookie("REGION2023", 1, time()+32*24*60*60, "/", ".broadwayworld.com");
}
} // end if($reginc==0)
}
mysqli_set_charset($link, "utf8");
if($reginc==324 )
{$reginc=1;
}
?>
<?php
// ✅ A/B Test Randomizer for sort method - cache variant per user session
if(isset($_COOKIE["ABTEST2023"])) {
$abTestVariant = (int)$_COOKIE["ABTEST2023"];
} else {
$abTestVariant = rand(1,2);
setcookie("ABTEST2023", $abTestVariant, time()+86400, "/", ".broadwayworld.com");
}
if ($abTestVariant === 1) {
$sortMethod = "views DESC";
$abTestName = "views_based";
} else {
$sortMethod = "r.dateposted DESC";
$abTestName = "date_based";
}
// ✅ Date filter logic - pre-calculate date cutoff to avoid DATE_SUB in query
$dateInterval = ($reginc < 4) ? 7 : 10;
$dateCutoff = date('Y-m-d H:i:s', strtotime("-$dateInterval days"));
$dateCutoffEscaped = mysqli_real_escape_string($link, $dateCutoff);
$regincEscaped = (int)$reginc;
if(isset($_COOKIE["MYARTICLES20228"]))
{
// Optimized cookie handling - quick length check
$myArticlesCookie = $_COOKIE["MYARTICLES20228"];
if(strlen($myArticlesCookie) > 3000)
{
setcookie("MYARTICLES20228", "", time()-3600, "/", ".broadwayworld.com");
setcookie("MYINTERESTS20228", "", time()-3600, "/", ".broadwayworld.com");
$myArticlesCookie = "";
}
$myArticlesEscaped = mysqli_real_escape_string($link, $myArticlesCookie);
if ($abTestVariant === 1) {
// Variant 1: Views-based sorting - use subquery instead of JOIN
$query="SELECT DISTINCT r.colid, r.title, r.regionid, r.dirname, r.seo_friendly, r.mainswapbig, r.mainswap100,
(SELECT Views FROM bway_bww.columnstats WHERE id = r.colid LIMIT 1) as views
FROM amazonrds.recommendationengine r
WHERE r.regionid = ".$regincEscaped."
AND r.dateposted >= '".$dateCutoffEscaped."'
AND r.colid NOT IN (".$myArticlesEscaped.")
ORDER BY views DESC
LIMIT 4";
} else {
// Variant 2: Date-based sorting - no need for columnstats at all
$query="SELECT DISTINCT r.colid, r.title, r.regionid, r.dirname, r.seo_friendly, r.mainswapbig, r.mainswap100
FROM amazonrds.recommendationengine r
WHERE r.regionid = ".$regincEscaped."
AND r.dateposted >= '".$dateCutoffEscaped."'
AND r.colid NOT IN (".$myArticlesEscaped.")
ORDER BY r.dateposted DESC
LIMIT 4";
}
// Cache recommendation results in APCu (1h TTL)
$cacheKey = 'rec_q_' . md5($query);
$rows = apcu_fetch($cacheKey, $hit);
if (!$hit) {
$rows = q($query, $link);
apcu_store($cacheKey, $rows, 3600);
}
} else {
if ($abTestVariant === 1) {
// Variant 1: Views-based sorting - use subquery instead of JOIN
$query="SELECT r.colid, r.title, r.regionid, r.dirname, r.seo_friendly, r.mainswapbig, r.mainswap100,
(SELECT Views FROM bway_bww.columnstats WHERE id = r.colid LIMIT 1) as views
FROM recommendationengine r
WHERE r.colid > 2380000
AND r.regionid = ".$regincEscaped."
AND r.dateposted >= '".$dateCutoffEscaped."'
ORDER BY views DESC
LIMIT 4";
} else {
// Variant 2: Date-based sorting - no need for columnstats at all
$query="SELECT r.colid, r.title, r.regionid, r.dirname, r.seo_friendly, r.mainswapbig, r.mainswap100
FROM recommendationengine r
WHERE r.colid > 2380000
AND r.regionid = ".$regincEscaped."
AND r.dateposted >= '".$dateCutoffEscaped."'
ORDER BY r.dateposted DESC
LIMIT 4";
}
// Cache recommendation results in APCu (1h TTL)
$cacheKey = 'rec_q_' . md5($query);
$rows = apcu_fetch($cacheKey, $hit);
if (!$hit) {
$rows = q($query, $link);
apcu_store($cacheKey, $rows, 3600);
}
}
if (is_array($rows) || is_object($rows))
{
echo '<div class="recommended-container">';
foreach($rows as $row)
{
echo '<div class="recommended-item">';
echo '<h4><a target="_top" href="https://www.broadwayworld.com/';
if ($row['dirname'] != '') {
echo $row['dirname'] . '/';
}
echo 'article/' . $row['seo_friendly'] . '"
onclick="trackArticleClick(\'' . $abTestName . '\', \'' . $abTestVariant . '\', \'' . htmlspecialchars($sortMethod, ENT_QUOTES) . '\', \'' . $row['colid'] . '\', \'' . $row['colid'] . '\')">';
// Optimize image loading with WebP format and proper srcset
$imgSmall = str_replace('cloudimages.broadwayworld.com', 'cloudimages2.broadwayworld.com', $row['mainswap100']);
$imgBig = str_replace('cloudimages.broadwayworld.com', 'cloudimages2.broadwayworld.com', $row['mainswapbig']);
$titleEscaped = htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8');
echo '<img loading="lazy" decoding="async" class="recommended-image" width="300" height="169" src="' . htmlspecialchars($imgSmall . '?format=webp&width=300&quality=80', ENT_QUOTES) . '" srcset="' . htmlspecialchars($imgBig . '?format=webp&width=600&quality=80', ENT_QUOTES) . ' 2x" alt="' . $titleEscaped . '"/>';
echo '<span class="recommended-title">' . htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8') . '</span>';
echo '</a></h4></div>';
}
echo '</div>';
}
?>
<?php if($reginc!=1 && $reginc!=4 && isset($_GET["dirname"]) && $_GET["dirname"]!='') { ?>
<small><a href="https://www.broadwayworld.com/<?php if($_GET["dirname"]!=''){?><?php echo $_GET["dirname"]; echo '/';}?>" target="_top">View More Local News</a></small><p>
<?php }?><? mysqli_close($link);
// Clean up old cookies at the end (non-blocking)
if (isset($_COOKIE['MYARTICLES2020'])) {
setcookie('MYARTICLES2020', null, -1, '/');
}
if (isset($_COOKIE['MYARTICLES20221'])) {
setcookie('MYARTICLES20221', null, -1, '/');
}
if (isset($_COOKIE['MYARTICLES2021'])) {
setcookie('MYARTICLES2021', null, -1, '/');
}
// Flush output buffer
ob_end_flush();
?></body></html>
<script>
function trackArticleClick(abTestName, abTestVariant, sortMethod, articleId, articleTitle) {
var url = '/track_rf.cfm?abTestName=' + encodeURIComponent(abTestName) +
'&abTestVariant=' + encodeURIComponent(abTestVariant) +
'&sortMethod=' + encodeURIComponent(sortMethod) +
'&articleId=' + encodeURIComponent(articleId) +
'&articleTitle=' + encodeURIComponent(articleId);
// Use sendBeacon for better performance (non-blocking, works even after page unload)
if (navigator.sendBeacon) {
navigator.sendBeacon(url);
} else {
// Fallback to fetch with keepalive
fetch(url, { method: 'GET', keepalive: true }).catch(function() {});
}
}
// Send height to parent window for iframe resizing (if embedded)
function sendHeightToParent() {
if (window.parent && window.parent !== window) {
var height = Math.max(
document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.clientHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight
);
// Cap maximum height at 250px to prevent iframe from being too tall
var maxHeight = 250;
height = Math.min(height, maxHeight);
window.parent.postMessage({
type: 'recommended-iframe-height',
height: height
}, '*');
}
}
// Send height on load and resize
window.addEventListener('load', function() {
sendHeightToParent();
setTimeout(sendHeightToParent, 500); // Delay for images to load
});
window.addEventListener('resize', function() {
setTimeout(sendHeightToParent, 100);
});
// Also send height when images load
document.addEventListener('DOMContentLoaded', function() {
var images = document.querySelectorAll('img');
images.forEach(function(img) {
img.addEventListener('load', sendHeightToParent);
});
});
</script>