<?php
$path="../../";
include("../../map.php");
include("../../secure.php");
if($_POST['position']<>""){
	$i=1;
	foreach($_POST['position'] as $k=>$v){
		if($v<>""){
			$Rsq = mysqli_query($conn, "update t1 set s10='".$i."' Where id=".$v."");
			$i++;
		}
	}
}

if($_GET["durum"]=="extra"){
	$xiarr = array();
	foreach ($_POST as $key => $value){
		if(substr($key,0,2)=="xi"){
			$xiarr = $xiarr + array($key => $value);
		}
	}
	$xrjsi = json_encode($xiarr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	$xarr = array();
	foreach ($_POST as $key => $value){
		if(substr($key,0,2)=="xs" or substr($key,0,2)=="xc" or substr($key,0,2)=="xt"){
			$xarr = $xarr + array($key => $value);
		}
	}
	$xjs = json_encode($xarr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	if($_POST["xs2"]==""){$xs2=0;}else{$xs2=$_POST["xs2"];}
	if($_POST["xs7"]==""){$xs7=0;}else{$xs7=$_POST["xs7"];}
	if($_POST["xs10"]==""){$xs10=0;}else{$xs10=$_POST["xs10"];}
	if($_POST["xs13"]==""){$xs13=0;}else{$xs13=$_POST["xs13"];}
	if(!empty($_GET["extra_id"])){
		$Rsq = mysqli_query($conn, "update t1 set t2='".$_POST["xt2"]."', t3='".$_POST["xt3"]."', n1='".addslashes(stripslashes($_POST["xn1"]))."', n2='".addslashes(stripslashes($_POST["xn2"]))."', n12='".addslashes(stripslashes($xjs))."', n17='".addslashes(stripslashes($xrjsi))."', s7='".$xs7."', s10='".$xs10."', s13='".$xs13."' Where t1='".$_GET["ne"]."' and id='".$_GET["extra_id"]."' ");
		echo ctranslate("Kayıt Güncellendi");
	}else{
		$conn->query("insert INTO t1(t1,t2,t3,ne,n1,n2,n12,n17,s1,s2,s7,s10,s13) VALUES ('".$_GET["ne"]."', '".$_POST["xt2"]."', '".$_POST["xt3"]."', 'extra', '".addslashes(stripslashes($_POST["xn1"]))."', '".addslashes(stripslashes($_POST["xn2"]))."', '".addslashes(stripslashes($xjs))."', '".addslashes(stripslashes($xrjsi))."', '".$_GET["id"]."', '".$xs2."', '".$xs7."', '".$xs10."', '".$xs13."');");
		echo "url:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok&iq=".$_POST["xs2"]."";
	}

}elseif($_GET["durum"]=="extra_s"){
	$sql = mysqli_query($conn, "delete from t1 where id=".$_GET["extra_id"]);
	echo "url:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok&iq=".$_POST["sx2"]."";
}
?>