<?php

$settingsArray = array();
$xml = simplexml_load_file("public/cache/settings.xml");		
foreach($xml->children() as $settingsGrp => $settingsGroupVal)
{					
	  foreach($settingsGroupVal->children() as $settingsKey => $settingsVal)
	  {
		$settingsArray[$settingsGrp][$settingsKey] = (string)$settingsVal;
	  }		  				
}

if($settingsArray['site_settings']['enable_ssl_checkout']=='Enable')
{
	$siteUrl = 	rtrim($settingsArray['site_settings']['global_https_url'],"/")."/";			
}
else
{
	$siteUrl = 	rtrim($settingsArray['site_settings']['global_http_url'],"/")."/";		
}

$reDirectIndex = rtrim($settingsArray['site_settings']['global_http_url'],"/")."/";
$reDirectUrl = $siteUrl;
//echo '<pre>';print_r($_GET);exit;
if($_GET['COMPLUS']!='')
{	
	$chkParam = $_GET['COMPLUS'];
	
	if($chkParam=='CART'  || $chkParam=='GIFTCOUPON')
	{						
		$paymentStatus = $_GET['STATUS'];		
		$orderID 	   = $_GET['orderID'];
		$paymentResponse = '';
		foreach($_GET as $key => $val)
		{
			if($key == 'TRXDATE' && $val != '')
			{
				$val = explode("/",$val);
				$val = implode("-",$val);						
			}
			$paymentResponse .=$key."~~".urlencode($val)."||"; 	
		}
		$orderID = base64_encode($orderID);
		$paymentResponse = base64_encode($paymentResponse);
		$controller = "";
		if($chkParam=='CART')
		{
			$controller = "cart/expresscheckout/source/";					
		}
		elseif($chkParam=='GIFTCOUPON')
		{
			$controller = "giftcoupon/";					
		}
		if($controller!='')
		{			
			$reDirectUrl .= $controller."Ogone/orderID/".$orderID."/checksum/".$paymentResponse."/"; 
			header("Location:$reDirectUrl");
			exit;
		}
	}		
}
header("Location:$reDirectIndex");
?>