<?php 
	$path="../../../../";
	include("".$path."deppo/tools/script/cevir.php");
	$path2="config/"; include("".$path."config/map.php");
	include("".$path."deppo/tools/script/fonksiyon".$ver.".php");
	$sql = mysqli_query($conn, "select * from genel where ne='banka' and s1=12"); $rsb = mysqli_fetch_assoc($sql);
?>
<table border="1" cellpadding="0" cellspacing="0" style="display:none">
    <tr>
        <td><b>Parametre İsmi</b></td>
        <td><b>Parametre Değeri</b></td>
    </tr>
<?php 
	$odemeparametreleri = array("AuthCode", "Response", "HostRefNum", "ProcReturnCode", "TransId", "ErrorMessage");
	foreach($_POST as $key => $value){
		if($key=="AuthCode" or $key=="Response" or $key=="HostRefNum" or $key=="ProcReturnCode" or $key=="TransId" or $key=="ErrorMessage")
			echo "<tr><td><span style='font-weight:bold;'>".$key."</span></td><td><span style='font-weight:bold;'>".$value."</span></td></tr>"; 
		else
			echo "<tr><td>".$key."</td><td>".$value."</td></tr>";
	}
?>
</table>
<div style="display:none">
<?php
	if(!isset($_POST["HASHPARAMS"])) //hashparams var mı?
		echo "hashparams set edilmemiş<br />";
	else{	
		$hashparams = $_POST["HASHPARAMS"];   
		$hashparamsval = $_POST["HASHPARAMSVAL"];  
		$storekey = "12345678";
		$paramsval = "";
		$index1 = 0;
		$index2 = 0;
		// hash hesaplamada kullanýlacak deðerler ayrýþtýrýlýp deðerleri birleþtiriliyor. 
		do { 
			$index2 = strpos($hashparams,":",$index1);  
			$a = substr($hashparams, $index1,$index2-$index1); 
			$val = $_POST[$a];
			if(!empty($val))
				$paramsval = $paramsval.$val;
			else
				$paramsval = $paramsval;
			$index1 = $index2 + 1;  
			echo "paramsval deðeri son hali: ".$paramsval."<br/>";
		}while ($index1 < strlen($hashparams)); 
		echo "hashparams="+$hashparams+"<br />";
		echo "hashparamsval="+$hashparamsval+"<br />";
		echo "paramsval="+$paramsval+"<br />";
			
		$hashval = $paramsval.$storekey; //elde edilecek hash deðeri için paramsval e store key ekleniyor. (iþyeri anahtarý)
		echo "<br/>".$hashval."<br/>";
		$hashparam = $_POST["Hash"];
		$hash = base64_encode(pack("H*",sha1($hashval))); 	
		echo "hash: ".$hash."<br />";
		if(!strcmp($paramsval,$hashparamsval) or !strcmp($hash, $hashparam)) //oluþturulan hash ile gelen hash ve hash parametreleri deðerleri ile ayrýþtýrýlýp edilen edilen ayný olmalý.
		{
			echo "<h4>Güvenlik Uyarýsý. Sayýsal Ýmza Geçerli Deðil</h4><br/>";
			echo "<h4>".$paramsval." == ".$hashparamsval."</h4><br/>";
			echo "<h4>".$hash."</h4><br/>";
			echo "<h4>hash, hashparams eþit mi? ".strcmp($hash,$hashparams)."</h4><br/>";
		}
}
	$mdstatus = $_POST["3DStatus"]; // 3d iþlemin sonucu
	if(!strpos($mdstatus, '-')) {
?>   
</div>
<table border="1" style="display:none">
	<tr>
	<td><b>Parametre İsmi</b></td>
	<td><b>Parameter Değeri</b></td>
	</tr>
	<?php
		$ArrLength = count($odemeparametreleri);
		for($i=0;$i<$ArrLength;$i++) { 
			$paramname = $odemeparametreleri[$i];
			if(isset($_POST[$paramname])) {
				$paramval = $_POST[$paramname];
				echo "<tr><td>".$paramname."</td><td>".$paramval."</td></tr>";
			}
		}
	?>
</table> 
<?php
		if(empty($_POST["ErrorMessage"])) {
			echo "<script>window.location.href=\"".$_GET["burl"]."ok\"</script>";
		} else {
			echo "<script>window.location.href=\"".$_GET["burl"]."err/".base64_encode($_POST["ErrorMessage"])."\"</script>";
		}
	} else {
			echo "<script>window.location.href=\"".$_GET["burl"]."err\"</script>";
	}
?>