<?php 
if($_GET['debug']==1){
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING);
}

//error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING);
//error_reporting(E_ALL);
session_start();
ini_set('memory_limit','2048M');
require_once('./includes/config.php');
require_once('./includes/skins.php');
require_once('./includes/global-functions.php');
require_once('./includes/classes.php');
require_once('./includes/webhook.php');
require_once('info.php');
require_once(getLanguage(null, (!empty($_GET['lang']) ? $_GET['lang'] : $_COOKIE['lang']), null));
$link = mysqli_connect($CONF['host'], $CONF['user'], $CONF['pass'], $CONF['name']);
$db = new mysqli($CONF['host'], $CONF['user'], $CONF['pass'], $CONF['name']);
if ($db->connect_errno) {
    echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error;
}
$db->set_charset("utf8mb4");
$action = getSocialConfig();
$shopConfig = getShopConfig();
$resultSettings = $db->query(getSettings());
//include_once('./includes/analytics_store.php');// for the analytics dashboard

// Verify whether the user imported the database or not
if($resultSettings) {
	$settings = $resultSettings->fetch_assoc();
} else {
	echo "Error: ".$db->error;
}
date_default_timezone_set($settings['timezone']);
//redirectToHTTPS();
regenerateIcart();
setIcart();
appConfig();
//$thisFile = str_replace('\\', '/', __FILE__);
$thisFile = '/var/www/x28_html/index.php';
//$docRoot = $_SERVER['DOCUMENT_ROOT'];
$docRoot = '/var/www/x28_html';
//$docRoot = '/home/content/60/11067260/html'; //manually set for GoDaddy Servers
$webRoot  = str_replace(array($docRoot, 'index.php'), '', $thisFile);

if(isset($_GET['a']) && isset($action[$_GET['a']])) {
$page_name = $action[$_GET['a']];
} else {
	$page_name = 'home';
}

$TMPL['cachebuster'] = date('mdyHis');

$TMPL['token_id'] = generateToken();

// Extra class for the content [main and sidebar]
$TMPL['content_class'] = ' content-'.$page_name;


/*if($shopConfig['suspend']){
	include('suspend.php');
	exit;
}*/
if($shopConfig['offline']){
	if($_GET['preview']){
		
	}else{
		include('offline.php');
		exit;
	}
}
if(isset($_POST['authlogin'])) {
	$ckey = $db->real_escape_string($_POST['authtoken']);
	$user_id = $db->real_escape_string($_POST['user']);
	$result = $db->query("SELECT idu FROM users WHERE ckey = '$ckey' AND level >= 1");
	if($result->num_rows){
		$result2 = $db->query("SELECT username, idu, level, password FROM users WHERE idu = '$user_id'");
		if($result2->num_rows){
			$row = $result2->fetch_assoc();
			$_SESSION['username'] = $row['username'];
			$_SESSION['user_id'] = $row['idu'];
			$_SESSION['user_level'] = $row['level'];
			$_SESSION['password'] = $row['password'];
			header("Location: ".$CONF['url']."/index.php?a=subscription");
		}else{
			header("Location: ".$CONF['url']."/index.php?a=page&e=99999999");
		}
	}else{
		header("Location: ".$CONF['url']."/index.php?a=page&e=99999999");
	}
	
	return;
}
require_once("./sources/{$page_name}.php");

// Store the theme path and theme name into the CONF and TMPL
$TMPL['theme_path'] = $CONF['theme_path'];
$TMPL['theme_name'] = $CONF['theme_name'] = $settings['theme'];
$TMPL['theme_url'] = $CONF['theme_url'] = $CONF['theme_path'].'/'.$CONF['theme_name'];

$TMPL['template'] = $CONF['template'] = $settings['template'];

if(isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
	$loggedIn = new loggedIn();
	$loggedIn->db = $db;
	$loggedIn->url = $CONF['url'];
	//$loggedIn->username = (isset($_SESSION['username'])) ? $_SESSION['username'] : $_COOKIE['username'];
	//$loggedIn->password = (isset($_SESSION['password'])) ? $_SESSION['password'] : $_COOKIE['password'];
	$loggedIn->username = $_SESSION['username'];
	$loggedIn->password = $_SESSION['password'];
	$verify = $loggedIn->verify();
	
	// If the user is a moderator
	if($verify['user_group'] == 1) {
		$_SESSION['usernameAdmin'] = $loggedIn->username;
		$_SESSION['passwordAdmin'] = $loggedIn->password;
	}
}

$plugins = loadPlugins($db);


// Load the head plugins
foreach($plugins as $plugin) {
	if(array_intersect(array("8"), str_split($plugin['type']))) {
		$TMPL['styles'] .= "\n<link href=\"".$CONF['url']."/plugins/".$plugin['name']."/".$plugin['name'].".css\" rel=\"stylesheet\" type=\"text/css\">";
	}
}

foreach($plugins as $plugin) {
	if(array_intersect(array("9"), str_split($plugin['type']))) {
		$TMPL['scripts'] .= "\n<script type=\"text/javascript\" src=\"".$CONF['url']."/plugins/".$plugin['name']."/".$plugin['name'].".js\"></script>";
	}
}
if($_COOKIE['env'] == "mobileapp"){
	$TMPL['scripts'] .= '<script>$(function(){$("body").addClass("mobileapp");});</script>';
}
if($_GET['a'] == 'settings' || $_GET['a'] == 'order' || $_GET['a'] == 'subscription' || $_GET['a'] == 'accountbilling' || $_GET['a'] == 'security' || $_GET['a'] == 'achievements'){

	if($_GET['a'] == 'settings'){
		$settings_active = !$_GET['b'] ? ' class="active"': '';
		$security_active = $_GET['b']== 'security' ? ' class="active"': '';
		$settings_profile = $_GET['b']== 'avatar' ? ' class="active"': '';
	}
	if($_GET['a'] == 'order'){
		$settings_order = ' class="active"';
	}
	if($_GET['a'] == 'subscription'){
		$settings_subs = ' class="active"';
	}
	if($_GET['a'] == 'accountbilling'){
		$settings_billing = ' class="active"';
	}
	if($_GET['a'] == 'achievements'){
		$settings_achievements = ' class="active"';
	}
	
	$TMPL["tabs"] = '<div class="type-profile-top-e">
						<ul>
							<li'.$settings_subs.'>
								<a href="'.$CONF['url'].'/index.php?a=subscription">Subscriptions</a>
							</li>
							<li'.$settings_achievements.'>
								<a href="'.$CONF['url'].'/index.php?a=achievements">Fit Rewards</a> 
							</li>
							<li'.$settings_active.'>
								<a href="'.$CONF['url'].'/index.php?a=settings">Settings</a>
							</li>
							
							<li'.$settings_billing.'>
								<a href="'.$CONF['url'].'/index.php?a=accountbilling">Billing</a>
							</li>
						</ul>
					</div>';
}
$TMPL['meta_description'] = $shopConfig['meta_description'];
$TMPL['keywords'] = $shopConfig['keywords'];
//Klaviyo
$klaviyo_public_key = '';
//$klaviyo_public_key2 = '';
$queryk       = "SELECT username, username2 FROM integrations WHERE slug='klaviyo' AND username <>''";
$reusltk      = $db->query($queryk);
if($reusltk->num_rows){
	$rowk = $reusltk->fetch_assoc();
	$klaviyo_public_key = $rowk['username'];
	//$klaviyo_public_key2 = $rowk['username2'];
}
//$TMPL['mainmenu'] = getMainMenu('mainmenu');
$TMPL['content'] = PageMain();

$TMPL['mainmenu'] = getMainMenu('mainmenu');

$feed = new content();
$feed->db = $db;
$TMPL['fpcss'] = $feed->getFrontpageCss();

if(!empty($verify['username'])) { 
	$TMPL['menu'] = menu($verify);
	$TMPL['url_logo'] = $CONF['url'].'/index.php?a=home';
} else {
	$TMPL['menu'] = menu(false);
	$TMPL['url_logo'] = $CONF['url'].'/index.php?a=home';
}
$TMPL['url'] = $CONF['url'];
$TMPL['footer'] = $settings['title'];
$TMPL['meta_description'] = $shopConfig['meta_description'];
$TMPL['keywords'] = $shopConfig['keywords'];
$TMPL['logo'] = $shopConfig['logo'] ? '<div class="logo" style="background-image:url('.$shopConfig['logo'].');"></div>'  : '<div class="logo" style="font-weight:bold;font-size:40px;align-items:center;display:flex;color:black;">'.$shopConfig['name'].'</div>';
if($page_name == 'page'){
	$ogimage = getogimage();
	$TMPL['logourl'] = $ogimage;
}else{
	$TMPL['logourl'] = $shopConfig['logo'];
}
$TMPL['year'] = date('Y');
$TMPL['powered_by'] = '<p class="powered-by-fp">Powered by <a href="http://fitnessplane.com" target="_blank" style="font-weight:bold; color: #4183C4;">Fitness Plane</a></p>';
$TMPL['language'] = getLanguage($CONF['url'], null, 1);
$TMPL['tracking_code'] = $settings['tracking_code'];
$TMPL['favicon'] =$shopConfig['favicon'] ? '<link rel="shortcut icon" type="image/png" href="images/favicon/'.$shopConfig['favicon'].'"/>':'';
if(!empty($settings['facebookpixel'])){
	$facebookpixel = "<!-- Facebook Pixel Code -->
	<script>
	  !function(f,b,e,v,n,t,s)
	  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
	  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
	  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
	  n.queue=[];t=b.createElement(e);t.async=!0;
	  t.src=v;s=b.getElementsByTagName(e)[0];
	  s.parentNode.insertBefore(t,s)}(window, document,'script',
	  'https://connect.facebook.net/en_US/fbevents.js');
	  fbq('init', '".$settings['facebookpixel']."');
	  fbq('track', 'PageView');
	</script>
	<noscript><img height='1' width='1' style='display:none'
	  src='https://www.facebook.com/tr?id=".$settings['facebookpixel']."&ev=PageView&noscript=1'
	/></noscript>
	<!-- End Facebook Pixel Code -->";
	$facebookpixel .= '<script>';
	$facebookpixel .= 'if (typeof fbq === "function") {'; 
	if($_GET['cart'] == 'confirmation'){
		$facebookpixel .= "fbq('track', 'Purchase', {value: document.getElementById('totalamount').value, currency: 'USD'});";
	}
	if($_GET['cart'] == 'basket'){
		$facebookpixel .= "fbq('track', 'AddToCart');";
	}
	if($_GET['cart'] == 'checkout'){
		$facebookpixel .= "fbq('track', 'InitiateCheckout');";
	}
	if($_GET['product'] > 0 ||  $_GET['challenge'] > 0 ||  $_GET['subscribe'] > 0 || $_GET['a'] == 'subscribe'){
		$facebookpixel .= "fbq('track', 'ViewContent');";
	}
	$facebookpixel .= '}';
	$facebookpixel .= '</script>';
	$TMPL['facebookpixel'] = $facebookpixel;
}else{
	$TMPL['facebookpixel'] = '';
}

if(!empty($settings['refersionurl']) && !empty($settings['refersionpublickey']) && !empty($settings['refersionsecretkey'])){
	$refersiontrackingcode = '<!-- REFERSION TRACKING: BEGIN -->
<script src="//'.$settings['refersionurl'].'/tracker/v3/'.$settings['refersionpublickey'].'.js"></script>
<script>_refersion();</script>
<!-- REFERSION TRACKING: END -->';
	$TMPL['refersiontrackingcode'] = $refersiontrackingcode;
}else{
	$TMPL['refersiontrackingcode'] = '';
}

/* Newsletter code */
$TMPL['newsletter'] = getNewsletterModule();

function getNewsletterModule() {
	global $db;
	$html = '';
	if(isset($_SESSION['user_id'])){
		$loggedin = true;
		//return $html;
	}
	$page        = $_GET['a'] == 'page' ? filter($_GET['e']) : "null";
	$category    = $_GET['a'] == 'shop' ? filter($_GET['category']) : "null";
	$myaccount   = isset($_SESSION['user_id']) ? 1 : 0;
	$content_cat = $_GET['a'] == 'page' && isset($_GET['b']) && !isset($_GET['e']) ? filter($_GET['b']) : "null";
	$cart        = isset($_GET['cart']) ? filter($_GET['cart']) : "null";
	$ishome 	 = count($_GET) < 1 ? true : false;
	$query_n       = "SELECT * FROM modules WHERE position='bottom' AND publish=1 AND id=2";
	$result_n      = $db->query($query_n);	
	if($result_n->num_rows){
		$row_n = $result_n->fetch_assoc();
		$pagelist     = explode(',', $row_n['pagelist']);
		$categorylist = explode(',', $row_n['categorylist']);
		$pagecatlist  = explode(',', $row_n['pagecatlist']);
		$cartlist     = explode(',', $row_n['cartlist']);
		$html .= '<div id="newsletter">';
		if($row_n['title']){
			$html .=	'<h2>'.$row_n['title'].'</h2>';
		}
		if($row_n['content']){
			$html .=	'<p>'.$row_n['content'].' </p>';
		}
		$html .=	'<form id="newsletterform" name="newsletterform">';
		$html .=	'<div class="input-group mb-3">
								  <input type="text" class="form-control" placeholder="Enter your email" aria-label="Enter your email" aria-describedby="newsletter-submit" name="newsletter-email">
								  <div class="input-group-append">
									<button type="submit" class="btn button" id="newsletter-submit" data-loading-text="<i class=\'fa fa-circle-notch fa-spin\'></i> Sending">Submit</button>
								  </div>
								  
								</div>
								<div class="newsletter-msg"></div>';
		$html .=	'</form>';
		$html .= '</div>';
		if($row_n['pageassign'] == 1){
			$nl = $html;
		}
		if($row_n['pageassign'] == 2){
			//if (in_array($page, $pagelist) || in_array($category, $categorylist) || in_array($content_cat, $pagecatlist) || in_array($cart, $cartlist) || ($myaccount && $row_n['accountpage'])) {
			if (in_array($page, $pagelist) || in_array($category, $categorylist) || in_array($content_cat, $pagecatlist) || in_array($cart, $cartlist) || ($ishome && $row_n['homepage'])) {
				$nl = $html;
			}
		}
		if($row_n['pageassign'] == 3){
			$nl = '';
		}
		if($row_n['pageassign'] == 4){
			if (in_array($page, $pagelist) || in_array($category, $categorylist) || in_array($content_cat, $pagecatlist) || in_array($cart, $cartlist) || ($ishome && $row_n['homepage'])) {
				//Do Nothing
			}else{
				$nl = $html;
			}
		}
	}
	return $nl;
}
$social = '';
if($settings['socialfacebook']){
	$social .= ' <a href="https://facebook.com/'.$settings['socialfacebook'].'" title="facebook" target="_blank"><i class="fab fa-facebook-f"></i></a> ';
}
if($settings['socialinstagram']){
	$social .= ' <a href="https://instagram.com/'.$settings['socialinstagram'].'" title="instagram" target="_blank"><i class="fab fa-instagram"></i></a> ';
}
if($settings['socialtwitter']){
	$social .= ' <a href="https://twitter.com/'.$settings['socialtwitter'].'" title="twitter" target="_blank"><i class="fab fa-twitter"></i></a> ';
}
if($settings['socialyoutube']){
	$social .= ' <a href="https://youtube.com/'.$settings['socialyoutube'].'" title="youtube" target="_blank"><i class="fab fa-youtube"></i></a> ';
}
if($settings['socialpinterest']){
	$social .= ' <a href="https://pinterest.com/'.$settings['socialpinterest'].'" title="pinterest" target="_blank"><i class="fab fa-pinterest-p"></i></a> ';
}
$queryLink       = "SELECT * FROM modules WHERE position='bottom' AND publish=1 AND id <> 2 order by ordering";//Not id 2 -hiding newsletter module for now;
$resultlink      = $db->query($queryLink);
if($resultlink->num_rows){
	$TMPL['footermodules']='<div id="footer-modules" class="footer-modules row">';
	while($rowLink = $resultlink->fetch_assoc()){
		if ($rowLink['moduletype'] == 'menu') {
			$queryLink2  = "SELECT menutype FROM menu_type WHERE id=" . $rowLink['menutype_id'];
			$resultlink2 = $db->query($queryLink2);
			$rowLink2    = $resultlink2->fetch_assoc();
			$TMPL['footermodules'] .= '<div class="footer-module col">';
			$TMPL['footermodules'] .= '<h3>' . $rowLink['title'] . '</h3>';
			$TMPL['footermodules'] .= getModuleMenu($rowLink2['menutype']);
			$TMPL['footermodules'] .= '</div>';
		} else
		if ($rowLink['moduletype'] == 'content') {
			$TMPL['footermodules'] .= '<div class="footer-module col">'; 
			$TMPL['footermodules'] .= '<h3>' . $rowLink['title'] . '</h3>';
			if($rowLink['id'] == 1){
				$TMPL['footermodules'] .= '<div><div class="social-links">'.$social.'</div></div>';
			}else{
				$TMPL['footermodules'] .= '<div>'.$rowLink['content'].'</div>';
			}
			
			$TMPL['footermodules'] .= '</div>';
		}else
		if ($rowLink['moduletype'] == 'emailform') {
			$TMPL['footermodules'] .= '<div class="footer-module col">';
			$TMPL['footermodules'] .= '<h3>Email Sign Up</h3>';
			$TMPL['footermodules'] .= '<div class="email-signup-form"><form><input type="text" name="email-signup" class="email-signup"/> <button class="btn btn-primary btn-sm">Submit</button></form></div>';
			$TMPL['footermodules'] .= '</div>';
		}
		
	}
	$TMPL['footermodules'] .= '</div>';
}

$headerConfig = $feed->getHeaderConfig();
$hc = json_decode($headerConfig, true);
if($hc['rmenubackground']){
	$mmenubg = 'background: '.$hc['rmenubackground'].'!important;';
}
if($hc['rmenubuttoncolor']){
	$mmenucolor = 'color: '.$hc['rmenubuttoncolor'].'!important;';
}
if($hc['backgroundcolor']){
	$abg = 'background: '.$hc['backgroundcolor'].'!important;';
}
if($hc['textcolor']){
	$afc = 'color: '.$hc['textcolor'].'!important;';
}

if($hc['showannouncement']){
	$an = '<div id="announcement"><div class="container">'.$hc['announcement'].'</div></div>';
	if($hc['announcementhomepageonly']){
		if($page_name == 'home'){
			$TMPL['announcement'] = $an;
		}
	}else{
		$TMPL['announcement'] = $an;
	}
}
function showZendesk(){
	$html = '';
	if($_GET['a'] != 'feed' && $_GET['a'] != 'profile' && $_GET['a'] != 'shop' && $_GET['a'] != 'tracker' && $_GET['a'] != 'broadcasts' && $_GET['a'] != 'viewlive' && $_GET['a'] != 'golive'){
		$html.= '<!-- Start of x28 Zendesk Widget script -->
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=2947e7ad-789a-4bb7-9a5b-9db2ebba5e4a"> </script>
<!-- End of x28 Zendesk Widget script -->';
	}
	//return $html;
}
function showChatbox(){
	$html = '';
	if($_GET['a'] != 'feed' && $_GET['a'] != 'profile' && $_GET['a'] != 'shop' && $_GET['a'] != 'tracker' && $_GET['a'] != 'broadcasts' && $_GET['a'] != 'viewlive' && $_GET['a'] != 'golive'){
		$html.= '<!-- Start of x28 Kustomer Widget script --><script
		src="https://cdn.kustomerapp.com/chat-web/widget.js"
		data-kustomer-api-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxNzA1YTE3ODlhMzhiMDVlZDUxMTI4NSIsInVzZXIiOiI2MTcwNWExNmI5OWFiZWMzNmYzZmE2MTkiLCJvcmciOiI2MTY0OTdhZWI1M2UyNTc4NDA5ZTMxYjMiLCJvcmdOYW1lIjoieDI4Zml0bmVzcyIsInVzZXJUeXBlIjoibWFjaGluZSIsInBvZCI6InByb2QxIiwicm9sZXMiOlsib3JnLnRyYWNraW5nIl0sImF1ZCI6InVybjpjb25zdW1lciIsImlzcyI6InVybjphcGkiLCJzdWIiOiI2MTcwNWExNmI5OWFiZWMzNmYzZmE2MTkifQ.8_uXflkJA4rpPoTEfHbt-bD1q4W9cr2qvrAAgHF4d_o"
	  ></script>
	  <script>
		Kustomer.start({
		  brandId: "616497b6574c0a743ab9f2ac"
		});
	  </script><!-- End of x28 Kustomer Widget script -->';
	}
	return $html;
}
$TMPL['zendesk'] = showChatbox();

if($hc['contactbarbackgroundcolor']){
	$cbg = 'background: '.$hc['contactbarbackgroundcolor'].'!important;';
}
if($hc['contactbartextcolor']){
	$cfc = 'color: '.$hc['contactbartextcolor'].'!important;';
}

if($hc['showcontactbar']){
	if($shopConfig['email']){
		$siteemail = '<i class="far fa-envelope"></i> <span>' .$shopConfig['email'].'</span> ';
	}
	if($shopConfig['email']){
		$sitephone = '<i class="fas fa-phone"></i> <span><a href="tel:' .$shopConfig['phone'].'">' .$shopConfig['phone'].'</a></span> ';
	}	
	$cb = '<div id="contactbar">
								<div class="container">
								<div class="site-contacts">'.$siteemail.$sitephone.'</div>
								<div class="social-links">'.$social.'</div>
								</div>
							  </div>';
	if($hc['contactbarhomepageonly']){
		if($page_name == 'home'){
			$TMPL['contactbar'] = $cb;
		}
	}else{
		$TMPL['contactbar'] = $cb;
	}
}

$TMPL['headerstyles']  = '<style>';
$TMPL['headerstyles'] .= '.navbtn.topbar-button, .navbtn.topbar-button:hover {'.$mmenubg.$mmenucolor.'}';
$TMPL['headerstyles'] .= '#announcement {'.$abg.$afc.'}';
$TMPL['headerstyles'] .= '#contactbar {'.$cbg.$cfc.'}';
$TMPL['headerstyles'] .= '#contactbar a{'.$cfc.'}';
$TMPL['headerstyles'] .= '</style>';
$TMPL['menustyle'] = $hc['menutype'] == 'compact' ? ' compact ' : '';
if($hc['stickyheader']){
	$TMPL['headerstyles'] .= '<script>$(function(){stickyHeader();});</script>';
}

//Klaviyo
$TMPL['klaviyo'] ='';
if(!empty($klaviyo_public_key)){
	$TMPL['klaviyo'] .= '<!-- Klaviyo Track --><script type="application/javascript" async src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id='.$klaviyo_public_key.'"></script>';
	$TMPL['klaviyo'] .= '<script type="text/javascript">var _learnq = _learnq || [];';
	if(!empty($verify['username']) && !empty($verify['idu'])) {
	$TMPL['klaviyo'] .= '_learnq.push(["identify", {
		"$email": "'.$verify["email"].'",
		"$first_name": "'.$verify["first_name"].'",
		"$last_name": "'.$verify["last_name"].'" 
	  }]);';
	}
	if($_GET['cart'] == 'confirmation'){
	}
	if($_GET['cart'] == 'basket'){
	}
	if($_GET['product'] > 0 ){
		$TMPL['klaviyo'] .= 'var item = {
							 "ProductName": "'.getProductDetail('product_name').'",
							 "ProductID": "'.$_GET['product'].'",
							 "SKU": "'.getProductDetail('product_sku').'",
							 "ImageURL": "'.getProductListImage($_GET['product'], true).'",
							 "URL": "'. $CONF["url"] .'/index.php?a=shop&category=' . $_GET['category'] . '&product=' . $_GET['product'] . '",
							 "Price": '.getProductPrice(true).'
						   };
						 
						   _learnq.push(["track", "Viewed Product", item]);';
	}
	if($_GET['cart'] == 'checkout'){
		//$TMPL['klaviyo'] .= getAbandonCart();//Front End API Klaviyo
	}
	if($_GET['cart'] == 'basket'){
		$TMPL['klaviyo'] .= klaviyoAddToCart();
	}
	
	$TMPL['klaviyo'] .= '</script>';
}
/*if(!empty($klaviyo_public_key2)){
	$TMPL['klaviyo'] .= '<!-- Klaviyo Track 2 --><script type="application/javascript" async src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id='.$klaviyo_public_key2.'"></script>';
	$TMPL['klaviyo'] .= '<script type="text/javascript">var _learnq = _learnq || [];';
	if(!empty($verify['username']) && !empty($verify['idu'])) {
	$TMPL['klaviyo'] .= '_learnq.push(["identify", {
		"$email": "'.$verify["email"].'",
		"$first_name": "'.$verify["first_name"].'",
		"$last_name": "'.$verify["last_name"].'" 
	  }]);';
	}
	if($_GET['cart'] == 'confirmation'){
	}
	if($_GET['cart'] == 'basket'){
	}
	if($_GET['product'] > 0 ){
		$TMPL['klaviyo'] .= 'var item = {
							 "ProductName": "'.getProductDetail('product_name').'",
							 "ProductID": "'.$_GET['product'].'",
							 "SKU": "'.getProductDetail('product_sku').'",
							 "ImageURL": "'.getProductListImage($_GET['product'], true).'",
							 "URL": "'. $CONF["url"] .'/index.php?a=shop&category=' . $_GET['category'] . '&product=' . $_GET['product'] . '",
							 "Price": '.getProductPrice(true).'
						   };
						 
						   _learnq.push(["track", "Viewed Product", item]);';
	}
	if($_GET['cart'] == 'checkout'){
		//$TMPL['klaviyo'] .= getAbandonCart();//Front End API Klaviyo
	}
	if($_GET['cart'] == 'basket'){
		$TMPL['klaviyo'] .= klaviyoAddToCart();
	}
	
	$TMPL['klaviyo'] .= '</script>';
}*/

$skin = new skin('wrapper');

echo $skin->make();

mysqli_close($db);
?>