<?php
include("ust.php");
date_default_timezone_set('Europe/Istanbul');

$verino = g("verino");
$icerik_getir=mysql_query("SELECT * FROM urunler WHERE seo_url='$verino'"); 
$getir=mysql_fetch_array($icerik_getir); 
$id = $getir['id'];
$urun_id = $getir['id'];
$urun_baslik = $getir['baslik'];
$urun_resim = $getir['resim'];
$urun_fiyat = $getir['m4'];
$tl_formati = number_format($urun_fiyat, 2, ',', '.');
$urun_fiyat_yaz = "$tl_formati " . $dil_v_getir["dil_para"]; 

## ÜRÜNLER MODÜLÜ 
$m_kontrol=mysql_query("SELECT * FROM moduller WHERE modul_adi='urunler'"); 
$getir=mysql_fetch_array($m_kontrol); 
$modul_v6 = $getir['modul_v6'];
$modul_v8 = $getir['modul_v8'];
$modul_v9 = $getir['modul_v9'];
if($modul_v6 == "evet"){
?>
	
	<section class="contact-us" style="margin-top:-40px;">
	<div class="container">
			
	
	<?php
	$islem = g("islem");


	if($islem == "buy"){

		

	
	$type = g("type");
	$icerik_getir=mysql_query("SELECT * FROM urunler WHERE id='$type'"); 
	$getir=mysql_fetch_array($icerik_getir); 
	$urun_fiyat = $getir['m4'];
	$urun_id = $getir['id'];

	##-> İp Adresi Alma
	function getRealIpAddr()  
	{if (!empty($_SERVER['HTTP_CLIENT_IP']))  
	{$ip=$_SERVER['HTTP_CLIENT_IP']; }  
	elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //Proxy den bağlanıyorsa gerçek IP yi alır.
	{ $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];}  
	else { $ip=$_SERVER['REMOTE_ADDR']; }  
	return $ip; }  


  	$siparis_adsoyad = p("siparis_adsoyad");
	$siparis_telefon = p("siparis_telefon");
	$siparis_mail = p("siparis_mail");
	$siparis_tarih = date('d.m.Y');
	$siparis_saat = date('H:i');
	$siparis_kargo = p("siparis_kargo");
	$siparis_not = p("siparis_not");
	$siparis_tutar = $urun_fiyat;
	$siparis_ip = getRealIpAddr();
	$siparis_odeme_durum = "bekliyor";
	$siparis_durum = "bekliyor";
	$siparis_tur = "urun";
	$siparis_veri = $urun_id;
	
	$ekle = mysql_query("INSERT INTO siparisler (siparis_kargo,siparis_not,siparis_tur,siparis_veri,siparis_odeme_durum,siparis_durum,siparis_adsoyad,siparis_telefon,siparis_mail,siparis_tutar,siparis_tarih,siparis_saat,siparis_ip)VALUES('$siparis_kargo','$siparis_not','$siparis_tur','$siparis_veri','$siparis_odeme_durum','$siparis_durum','$siparis_adsoyad','$siparis_telefon','$siparis_mail','$siparis_tutar','$siparis_tarih','$siparis_saat','$siparis_ip')");


	$isimle = explode(" ","$siparis_adsoyad");
	$isim_ad = $isimle[0];
	$isim_soyad = $isimle[1];
	


	## Api Ayarları
	$genel_getir=mysql_query("SELECT * FROM genelayarlar WHERE id='1'"); 
	$getir=mysql_fetch_array($genel_getir); 
	$geayar_shopier_key = $getir['geayar_shopier_key'];
	$geayar_shopier_pass = $getir['geayar_shopier_pass'];
	
	include 'core/shopier/shopierAPI.php'; 
		
	$shopier = new Shopier(''.$geayar_shopier_key.'', ''.$geayar_shopier_pass.''); 
	$shopier->setBuyer([ 
	'id' => ''.$urun_baslik.'', 
	'paket' => ''.$urun_baslik.'', 
	'first_name' => ''.$isim_ad.'',
	'last_name' => ''.$isim_soyad.'',
	'email' => ''.$siparis_mail.'',
	'phone' => ''.$siparis_telefon.'']); 
	$shopier->setOrderBilling([
	'billing_address' => 'Dijital Ürün', 
	'billing_city' => 'İstanbul',
	'billing_country' => 'Türkiye',
	'billing_postcode' => '34000', 
	]);
	$shopier->setOrderShipping([
	'shipping_address' => 'Dijital Ürün', 
	'shipping_city' => 'İstanbul',
	'shipping_country' => 'Türkiye',
	'shipping_postcode' => '34000', 
	]);
	die($shopier->run('544546545', ''.$urun_fiyat.'', ''.$geayar_siteadresi.'/order/')); 

	}
	?>
	
	<div class="row">
	
	<div class="col-md-6">
	<h3><?php echo $dil_v_getir["m70"];?> </h3>
	<?php echo $dil_v_getir["m71"];?>
	<hr>
	
	<form action="buy/<?php echo $verino;?>/?islem=buy&type=<?php echo $id;?>" method="post">
	
	<div class="row">
	
	
	<div class="form-group col-md-6">
	<label><?php echo $dil_v_getir["m72"];?></label>
    <input type="text" name="siparis_adsoyad" class="form-control" required="required">
	</div>
	
	<div class="form-group col-md-6">
	<label><?php echo $dil_v_getir["m73"];?></label>
    <input type="text" name="siparis_telefon" class="form-control" required="required">
	</div>
	
	<div class="form-group col-md-12">
	<label><?php echo $dil_v_getir["m74"];?></label>
    <input type="email" name="siparis_mail" class="form-control" required="required">
	</div>
	
	<?php if($modul_v9 == "evet"){?>
	<div class="form-group col-md-12">
	<label><?php echo $dil_v_getir["m75"];?></label>
    <input type="text" name="siparis_not" class="form-control" required="required">
	</div>
	<?php } ?>
	
	<?php if($modul_v8 == "evet"){?>
	<div class="form-group col-md-12">
	<label><?php echo $dil_v_getir["m76"];?></label>
	<textarea class="form-control" name="siparis_kargo"></textarea>
	</div>
	<?php } ?>
	</div>

	
	<button type="submit" class="btn btn-primary"><?php echo $dil_v_getir["m79"]; ?></button><br><br>
	</form>
	</div>
	
	
	
	<div class="col-md-6">
	
	

	<h3><?php echo $urun_baslik;?> </h3>
	<font color="#f3a712"><?php echo $urun_fiyat_yaz; ?></font>
	<hr>
	<img src="<?php echo $urun_resim;?>">

	

	

	</div>
	
	
	</div>
	
	
	
	</div>
	
	
	</section>	
	

		
<?php
include("alt.php"); }else{echo '<meta http-equiv="refresh" content="0;URL=anasayfa/">';}
?>		