<?php
ini_set("display_errors", 0);
error_reporting(0);
$functionsFile = "../includes/functions.php";
include($functionsFile);
$smartersInfo = loadSmartersOptions();
if ($smartersInfo['proxyTraffic'] == 1  || $smartersInfo['proxyTraffic'] == 2) {
	$subfolder = "proxy";
	$dns = $GLOBALS['panelroot'] . $subfolder .  "";
} else {
	$dnsInfo = loadAllDNS(true);
	foreach ($dnsInfo as $thisDns) {
		if($dns)
		{
			$dns .= ',';
		}
		$dns .= $thisDns['portal'];
	}
}
$prefixUrl = $GLOBALS['panelroot'] . "ad-images/";
$aes = "NB!@#12ZKWd";
$key = $_POST['r'];
$sc = md5(str_replace('\\', '', $dns) . '*' . $aes . '*' . $key);
if (isset($_POST['m']) && isset($_POST['k']) && isset($_POST['sc']) && isset($_POST['u']) && isset($_POST['pw']) && isset($_POST['r']) && isset($_POST['av']) && isset($_POST['dt']) && isset($_POST['d']) && isset($_POST['do'])) {
	
	echo '{"ftg":true,"status":true,"su":"' . $dns . '","sc":"' . $sc . '","ndd":""';
	if(isset($_POST['images'])&& $_POST['images'] =="yesplease")	
	{
		$smartersBackgroundInfo = loadSmartersBgOptions();
		$img1url = $prefixUrl . ($smartersBackgroundInfo['img1file'] != "" ? $smartersBackgroundInfo['img1file'] : "b.jpg");
		$img2url = $prefixUrl . ($smartersBackgroundInfo['img2file'] != "" ? $smartersBackgroundInfo['img2file'] : "b.jpg");
		$img3url = $prefixUrl . ($smartersBackgroundInfo['img3file'] != "" ? $smartersBackgroundInfo['img3file'] : "b.jpg");
		$img4url = $prefixUrl . ($smartersBackgroundInfo['img4file'] != "" ? $smartersBackgroundInfo['img4file'] : "b.jpg");
		$img5url = $prefixUrl . ($smartersBackgroundInfo['img5file'] != "" ? $smartersBackgroundInfo['img5file'] : "b.jpg");
		$img6url = $prefixUrl . ($smartersBackgroundInfo['img6file'] != "" ? $smartersBackgroundInfo['img6file'] : "b.jpg");
		$img7url = $prefixUrl . ($smartersBackgroundInfo['img7file'] != "" ? $smartersBackgroundInfo['img7file'] : "b.jpg");

		$img1cap = ($smartersBackgroundInfo['img1caption'] != "" ? $smartersBackgroundInfo['img1caption'] : "");
		$img2cap = ($smartersBackgroundInfo['img2caption'] != "" ? $smartersBackgroundInfo['img2caption'] : "");
		$img3cap = ($smartersBackgroundInfo['img3caption'] != "" ? $smartersBackgroundInfo['img3caption'] : "");
		$img4cap = ($smartersBackgroundInfo['img4caption'] != "" ? $smartersBackgroundInfo['img4caption'] : "");
		$img5cap = ($smartersBackgroundInfo['img5caption'] != "" ? $smartersBackgroundInfo['img5caption'] : "");
		$img6cap = ($smartersBackgroundInfo['img6caption'] != "" ? $smartersBackgroundInfo['img6caption'] : "");
		$img7cap = ($smartersBackgroundInfo['img7caption'] != "" ? $smartersBackgroundInfo['img7caption'] : "");

		echo ',"image1":"' . $img1url .'","caption1":"' . $img1cap . '",';
		echo '"image2":"' . $img2url .'","caption2":"' . $img2cap . '",';
		echo '"image3":"' . $img3url .'","caption3":"' . $img3cap . '",';
		echo '"image4":"' . $img4url .'","caption4":"' . $img4cap . '",';
		echo '"image5":"' . $img5url .'","caption5":"' . $img5cap . '",';
		echo '"image6":"' . $img6url .'","caption6":"' . $img6cap . '",';
		echo '"image7":"' . $img7url .'","caption7":"' . $img7cap . '"';
	}
	echo '}';
} else {
	echo '{"ftg":true,"status":true,"su":"' . $dns . '","sc":"","ndd":""}';
}
