File: /home2/yenicep/public_html/functions-development.php
<?
date_default_timezone_set('Europe/Minsk');
class myFunctions
{
//public $path = "https://www.ekspar.com.tr/onarim/";
//var $dbHost = "localhost";
//var $dbName = "garantili";
//var $dbUserName = "root";
//var $dbPassword = "";
//var $dbCharSet = "utf8";
public $path = "https://www.garantili.com.tr/";
var $dbHost = "localhost";
var $dbName = "garantil_garantili2021";
var $dbUserName = "garantil_usR443AA";
var $dbPassword = "hXtYu_]FQLxi";
var $dbCharSet = "utf8";
public function __construct($session = false)
{
try
{
$this->db = new PDO("mysql:host=".$this->dbHost.";dbname=".$this->dbName.";charset=".$this->dbCharSet, $this->dbUserName, $this->dbPassword);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
}
catch (PDOException $e)
{
die("Veri tabanı bağlantı hatası:<br /><br />" . $e->getMessage());
}
}
public function query($sql, $params = null){
try {
$query = $this->db->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$query->execute($params);
return $query;
} catch (PDOException $e) {
die("Hatalı:<br /><br />" . $e->getMessage());
}
}
public function markagetir($markagetir)
{
if (!$markagetir){$markagetir=0;}
$s = "select * from markalar where id=$markagetir";
$q = $this->query($s);
$b = $q->fetch();
return $b->marka;
}
public function GetAllmarkagetir()
{
$s = "select * from markalar where aktif=1";
$q = $this->query($s);
$b = $q->fetchAll();
return $b;
}
public function hafizagetir($hafizagetir)
{
if (!$hafizagetir){$hafizagetir=0;}
$s = "select * from hafiza where id=$hafizagetir";
$q = $this->query($s);
$b = $q->fetch();
return $b->hafiza;
}
public function hafizaturgetir($hafizagetir)
{
if (!$hafizagetir){$hafizagetir=0;}
$s = "select * from hafiza where id=$hafizagetir";
$q = $this->query($s);
$b = $q->fetch();
return $b->tip;
}
public function modelgetir($modelgetir)
{
if (!$modelgetir){$modelgetir=0;}
$s = "select model from modeller where id=$modelgetir";
$q = $this->query($s);
$b = $q->fetch();
return $b->model;
}
public function policebayigetir($bayi)
{
if (!$modelgetir){$modelgetir=0;}
$s = "select bayi from kasko_police_bayiler where id='$bayi'";
$q = $this->query($s);
$b = $q->fetch();
return $b->bayi;
}
public function tarihsaat2($tarihsaat)
{
$ay=substr($tarihsaat, 5, 2);
$yil=substr($tarihsaat, 0, 4);
$gun=substr($tarihsaat, 8, 2);
$saat=substr($tarihsaat, 11, 2);
$dakika=substr($tarihsaat, 14, 2);
$tarihitekraryaz=$gun."/".$ay."/".$yil." ".$saat.":".$dakika;
return $tarihitekraryaz;
}
public function sadecetarih($tarihsaat)
{
$ay=substr($tarihsaat, 5, 2);
$yil=substr($tarihsaat, 0, 4);
$gun=substr($tarihsaat, 8, 2);
$saat=substr($tarihsaat, 11, 2);
$dakika=substr($tarihsaat, 14, 2);
$tarihitekraryaz=$gun."/".$ay."/".$yil;
return $tarihitekraryaz;
}
public function sadecesaat($tarihsaat)
{
$saat=substr($tarihsaat, 11, 2);
$dakika=substr($tarihsaat, 14, 2);
$tarihitekraryaz=$saat.":".$dakika;
return $tarihitekraryaz;
}
public function takip_no()
{
$length = 5;
$b = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'),1,$length);
$ekle=date("Ymdhi");
$a="GRN".$ekle.$b;
return $a;
}
public function select($tablo_adi,$yazilacak_alan,$sorgu,$secili)
{
// <?=$func->select("uyeler","adi soyadi uye_no email","where yetki=5",5)
//harika kullanım..........
$dizi = explode (" ",$yazilacak_alan);
$s = "select * from $tablo_adi $sorgu order by $dizi[0] desc";
$q = $this->query($s);
$b = $q->fetchAll();
$dizi1=$dizi[0];
$dizi2=$dizi[1];
$dizi3=$dizi[2];
$dizi4=$dizi[3];
foreach($b as $rs){
if ($dizi[0]){$t1=$rs->$dizi1;}
if ($dizi[1]){$t2=" ".$rs->$dizi2;}
if ($dizi[2]){$t3=" ".$rs->$dizi3;}
if ($dizi[3]){$t4=" ".$rs->$dizi4;}
if ($secili==$rs->id){$sec=" selected";}else{$sec="";}
$textle="<option value=".$rs->id.$sec.">".$t1.$t2.$t3.$t4."</option>".$textle;
}
return $textle;
}
public function hdi_get_onay($kasko_id){
$user="WS97630000";
$pwd="fGHj71YH";
$s = "select * from kaskolu_cihazlar where id='$kasko_id' ";
$q = $this->query($s);
$row=$q->fetch();
if($row->id){
$curl = curl_init();
$dizi = explode('-',$row->MSDogYL);
$dogum_yili=$dizi[0];
$bastar = date_format(date_create($row->basTar), 'dmY');
$bitTar = date_format(date_create($row->bitTar), 'dmY');
$dogumtarihi = str_replace('-','',$row->MSDogYL);
$teminat_tipi=$this->teminat_tipi_bul($kasko_id);
$tutar_hesapla = "select * from a_satis_fiyatlandirma_sabitleri where marka='".$row->marka."' and model='".$row->model."' and hafiza='".$row->hafiza."' and aktif=1";
$tutar_hesapla = $this->query($tutar_hesapla);
$tutar_hesapla= $tutar_hesapla->fetch();
$tutar= $tutar_hesapla->satis_tutari;
$tutar=$tutar/$this->gunceldolarkurgetir('dolar');
$xml = 'http://srv.hdisigorta.com.tr:1080/cgi-bin/SYLON.pgm?xmlData=<HDISIGORTA><user>'.$user.'</user><pwd>'.$pwd.'</pwd><IstekTip>O</IstekTip><basTar>'.$bastar.'</basTar><Uygulama>PRMU701</Uygulama><OzelTuzel>'.$row->OzelTuzel.'</OzelTuzel><TcKimlikNo>'.$row->m_tc.$row->m_pasaportno.$dogumtarihi.'</TcKimlikNo><VergiKimlikNo></VergiKimlikNo><Uyruk>'.$row->Uyruk.'</Uyruk><adresBilgi><Cadde>'.$row->Cadde.'</Cadde><Semt>'.$row->Sokak.'</Semt><KoyMahalle>'.$row->KoyMahalle.'</KoyMahalle><BinaNo>'.$row->Daire.'</BinaNo><HanApartmanAd>'.$row->HanApartmanAd.'</HanApartmanAd><Daire>'.$row->Daire.'</Daire><Ilce>MERKEZ</Ilce><IlKod>'.$row->IlKod.'</IlKod></adresBilgi><satTemsilci></satTemsilci><odemeTipi>1</odemeTipi><taksitSekli>1</taksitSekli><TckR>'.$row->TransactionId.'</TckR><teminatTipi>'.$teminat_tipi.'</teminatTipi><imeiNo>'.$row->imei.'</imeiNo><teminatTutar>'.$row->teminatTutar.'</teminatTutar><telefon>'.$row->m_gsm.'</telefon><kimlikNo>'.$row->m_tc.'</kimlikNo><cepMarka>'.$this->markagetir($row->marka).'</cepMarka><cepModel>'.$this->modelgetir($row->model) .'</cepModel><projeKod>5</projeKod></HDISIGORTA>';
$xml=str_replace(" ", "%20", $xml);
$this->query("insert into kasko_response(`tarih`,`sorgu`,`aciklama`) values('".gunceltarihsaat()."','$xml','hdi get request')");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $xml,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
$this->query("insert into kasko_response(`tarih`,`sorgu`,`aciklama`) values('".gunceltarihsaat()."','$response','hdi get response')");
$response = simplexml_load_string($response);
$response = json_encode($response, JSON_PRETTY_PRINT);
$response = json_decode($response, true);
// echo var_dump($response);
curl_close($curl);
$gunceltarihsaat=gunceltarihsaat();
$hdi_policeNo=$response[POLICE][policeNo];
if($response['Durum']=='00'){
$url="http://web.hdisigorta.com.tr/cgi-bin/SYLON-PDF.php?user=WS97630000&pwd=fGHj71YH&Uygulama=551&PoliceNumarasi=".$hdi_policeNo."&TecditNumarasi=0&ZeyilNumarasi=0";
$this->query("update kaskolu_cihazlar set police_pdf='".$url."',policeno_aktiflik=1,policeno_aktiflik_tarih='$gunceltarihsaat',police_onay=1,police_onay_tarih='$gunceltarihsaat',hdi_policeNo='$hdi_policeNo',odeme_return='".$response['DurumAciklama']."' where id='$kasko_id'");
$resut=1;
}else{
$this->query("update kaskolu_cihazlar set police_onay=3,police_onay_tarih='$gunceltarihsaat',odeme_return='".$response['DurumAciklama']."' where id='$kasko_id'");
$resut=3;
}
}
return $resut;
}
public function teminat_tipi_bul($kasko_id){
$s = "select * from kaskolu_cihazlar where id='$kasko_id' ";
$q = $this->query($s);
$row=$q->fetch();
$s = "select * from a_satis_fiyatlandirma_sabitleri where marka='".$row->marka."' and model='".$row->model."' and hafiza='".$row->hafiza."' and aktif=1";
$q = $this->query($s);
$rs= $q->fetch();
$tutar= $rs->satis_tutari;
$tutar=$tutar/$this->gunceldolarkurgetir('dolar');
if($tutar<=499){
$tip=1;
}elseif($tutar>=500 and $tutar<=999){
$tip=2;
}elseif($tutar>=1000 and $tutar<=1499){
$tip=3;
}elseif($tutar>=1500 and $tutar<=2000){
$tip=4;
}elseif($tutar>=2001 and $tutar<=2500){
$tip=5;
}elseif($tutar>=2501 and $tutar<=3000){
$tip=6;
}elseif($tutar>=3001 and $tutar<=3500){
$tip=7;
}
return 1;
}
public function hdi_insert($kasko_id){
$user="WS97630000";
$pwd="fGHj71YH";
$s = "select * from kaskolu_cihazlar where id='$kasko_id' ";
$q = $this->query($s);
$row=$q->fetch();
if($row->id){
$curl = curl_init();
$dizi = explode('-',$row->MSDogYL);
$dogum_yili=$dizi[0];
$bastar = date_format(date_create($row->basTar), 'dmY');
$bitTar = date_format(date_create($row->bitTar), 'dmY');
$dogumtarihi = str_replace('-','',$row->MSDogYL);
$teminat_tipi=$this->teminat_tipi_bul($kasko_id);
$tutar= $row->teminatTutar;
$xml = 'http://srv.hdisigorta.com.tr:1080/cgi-bin/SYLON.pgm?xmlData=<HDISIGORTA><user>'.$user.'</user><pwd>'.$pwd.'</pwd><IstekTip>P</IstekTip><basTar>'.$bastar.'</basTar><Uygulama>PRMU701</Uygulama><OzelTuzel>'.$row->OzelTuzel.'</OzelTuzel><TcKimlikNo>'.$row->m_tc.$row->m_pasaportno.$dogumtarihi.'</TcKimlikNo><VergiKimlikNo></VergiKimlikNo><Uyruk>'.$row->Uyruk.'</Uyruk><adresBilgi><Cadde>'.$row->Cadde.'</Cadde><Semt>'.$row->Sokak.'</Semt><KoyMahalle>'.$row->KoyMahalle.'</KoyMahalle><BinaNo>'.$row->Daire.'</BinaNo><HanApartmanAd>'.$row->HanApartmanAd.'</HanApartmanAd><Daire>'.$row->Daire.'</Daire><Ilce>MERKEZ</Ilce><IlKod>'.$row->IlKod.'</IlKod></adresBilgi><satTemsilci></satTemsilci><odemeTipi>1</odemeTipi><taksitSekli>1</taksitSekli><TckR>'.$row->m_tc.$row->m_pasaportno.'</TckR><teminatTipi>'.$teminat_tipi.'</teminatTipi><imeiNo>'.$row->imei.'</imeiNo><teminatTutar>'.$tutar.'</teminatTutar><telefon>'.$row->m_gsm.'</telefon><kimlikNo>12251620548</kimlikNo><cepMarka>'.$this->markagetir($row->marka).'</cepMarka><cepModel>'.$this->modelgetir($row->model) .'</cepModel><projeKod>5</projeKod></HDISIGORTA>';
$xml=str_replace(" ", "%20", $xml);
$this->query("insert into kasko_response(`tarih`,`sorgu`,`aciklama`) values('".gunceltarihsaat()."','".str_replace("'", "",$xml)."','hdi insert request')");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $xml,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
$this->query("insert into kasko_response(`tarih`,`sorgu`,`aciklama`) values('".gunceltarihsaat()."','".str_replace("'", "",$response)."','hdi insert response')");
$xmlObject = simplexml_load_string($response);
$json = json_encode($xmlObject, JSON_PRETTY_PRINT);
$response = json_decode($json, true);
curl_close($curl);
$Durum = $response['Durum'];
if($Durum==00){
// echo " UPDATE `kaskolu_cihazlar` SET `hdi_ReqAddr`='".$response['ReqAddr']."',`hdi_ReferansNo`='".$response['ReferansNo']."',`Durum`='".$response['Durum']."',`hdi_DurumAciklama`='".$response['DurumAciklama']."',`hdi_urunNo`='".$response['POLICE']['urunNo']."',`hdi_urunAdi`='".$response['POLICE']['urunAdi']."',`hdi_policeNo`='".$response['POLICE']['policeNo']."',`hdi_acenteNo`='".$response['POLICE']['acenteNo']."',`hdi_acenteUnvan`='".$response['POLICE']['acenteUnvan']."',`hdi_musteriNo`='".$response['POLICE']['musteriNo']."',`hdi_musteriAdSoy`='".$response['POLICE']['musteriAdSoy']."',`hdi_tanTar`='".$response['POLICE']['tanTar']."',`hdi_basTar`='".$response['POLICE']['basTar']."',`hdi_bitTar`='".$response['POLICE']['bitTar']."',`hdi_temTutar`='".$response['POLICE']['temTutar']."',`hdi_temFiyat`='".$response['POLICE']['temFiyat']."',`hdi_temNetPrim`='".$response['POLICE']['temNetPrim']."',`hdi_temVerg`='".$response['POLICE']['temVerg']."',`hdi_temBrut`='".$response['POLICE']['temBrut']."',`hdi_temKomisyon`='".$response['POLICE']['temKomisyon']."',hdi_tarih='".date('Y-m-d H:i:s')."' WHERE id='$kasko_id'";
$this->query("UPDATE `kaskolu_cihazlar` SET dovizKuru='".$response['POLICE']['dovizKuru']."', `dovizTLBrut`='".$response['POLICE']['dovizTLBrut']."', `hdi_ReqAddr`='".$response['ReqAddr']."',`hdi_ReferansNo`='".$response['ReferansNo']."',`Durum`='".$response['Durum']."',`hdi_DurumAciklama`='".str_replace("'", "",$response['DurumAciklama'])."',`hdi_urunNo`='".$response['POLICE']['urunNo']."',`hdi_urunAdi`='".$response['POLICE']['urunAdi']."',`hdi_policeNo`='".$response['POLICE']['policeNo']."',`hdi_acenteNo`='".$response['POLICE']['acenteNo']."',`hdi_acenteUnvan`='".$response['POLICE']['acenteUnvan']."',`hdi_musteriNo`='".$response['POLICE']['musteriNo']."',`hdi_musteriAdSoy`='".$response['POLICE']['musteriAdSoy']."',`hdi_tanTar`='".$response['POLICE']['tanTar']."',`hdi_basTar`='".$response['POLICE']['basTar']."',`hdi_bitTar`='".$response['POLICE']['bitTar']."',`hdi_temTutar`='".$response['POLICE']['temTutar']."',`hdi_temFiyat`='".$response['POLICE']['temFiyat']."',`hdi_temNetPrim`='".$response['POLICE']['temNetPrim']."',`hdi_temVerg`='".$response['POLICE']['temVerg']."',`hdi_temBrut`='".$response['POLICE']['temBrut']."',`hdi_temKomisyon`='".$response['POLICE']['temKomisyon']."',hdi_tarih='".date('Y-m-d H:i:s')."' WHERE id='$kasko_id'");
$result=1;
}else{
// echo "UPDATE `kaskolu_cihazlar` SET `dovizTLBrut`='".$response['POLICE']['dovizTLBrut']."', `hdi_ReqAddr`='".$response['ReqAddr']."',`hdi_ReferansNo`='".$response['ReferansNo']."',`Durum`='".$response['Durum']."',`hdi_DurumAciklama`='".$response['DurumAciklama']."',`hdi_urunNo`='".$response['POLICE']['urunNo']."',`hdi_urunAdi`='".$response['POLICE']['urunAdi']."',`hdi_policeNo`='".$response['POLICE']['policeNo']."',`hdi_acenteNo`='".$response['POLICE']['acenteNo']."',`hdi_acenteUnvan`='".$response['POLICE']['acenteUnvan']."',`hdi_musteriNo`='".$response['POLICE']['musteriNo']."',`hdi_musteriAdSoy`='".$response['POLICE']['musteriAdSoy']."',`hdi_tanTar`='".$response['POLICE']['tanTar']."',`hdi_basTar`='".$response['POLICE']['basTar']."',`hdi_bitTar`='".$response['POLICE']['bitTar']."',`hdi_temTutar`='".$response['POLICE']['temTutar']."',`hdi_temFiyat`='".$response['POLICE']['temFiyat']."',`hdi_temNetPrim`='".$response['POLICE']['temNetPrim']."',`hdi_temVerg`='".$response['POLICE']['temVerg']."',`hdi_temBrut`='".$response['POLICE']['temBrut']."',`hdi_temKomisyon`='".$response['POLICE']['temKomisyon']."',hdi_tarih='".date('Y-m-d H:i:s')."' WHERE id='$kasko_id'";
$this->query("UPDATE `kaskolu_cihazlar` SET dovizKuru='".$response['POLICE']['dovizKuru']."',`dovizTLBrut`='".$response['POLICE']['dovizTLBrut']."', `hdi_ReqAddr`='".$response['ReqAddr']."',`hdi_ReferansNo`='".$response['ReferansNo']."',`Durum`='".$response['Durum']."',`hdi_DurumAciklama`='".str_replace("'", "",$response['DurumAciklama'])."',`hdi_urunNo`='".$response['POLICE']['urunNo']."',`hdi_urunAdi`='".$response['POLICE']['urunAdi']."',`hdi_policeNo`='".$response['POLICE']['policeNo']."',`hdi_acenteNo`='".$response['POLICE']['acenteNo']."',`hdi_acenteUnvan`='".$response['POLICE']['acenteUnvan']."',`hdi_musteriNo`='".$response['POLICE']['musteriNo']."',`hdi_musteriAdSoy`='".$response['POLICE']['musteriAdSoy']."',`hdi_tanTar`='".$response['POLICE']['tanTar']."',`hdi_basTar`='".$response['POLICE']['basTar']."',`hdi_bitTar`='".$response['POLICE']['bitTar']."',`hdi_temTutar`='".$response['POLICE']['temTutar']."',`hdi_temFiyat`='".$response['POLICE']['temFiyat']."',`hdi_temNetPrim`='".$response['POLICE']['temNetPrim']."',`hdi_temVerg`='".$response['POLICE']['temVerg']."',`hdi_temBrut`='".$response['POLICE']['temBrut']."',`hdi_temKomisyon`='".$response['POLICE']['temKomisyon']."',hdi_tarih='".date('Y-m-d H:i:s')."' WHERE id='$kasko_id'");
$result=2;
}
}else{
$result=3;
}
// echo "<br>result : ".$result;
return $result;
}
public function mobilexpressodeme($kasko_id){
$s = "select * from kaskolu_cihazlar where id='$kasko_id' ";
$q = $this->query($s);
$row=$q->fetch();
if($row->id){
$curl = curl_init();
$dizi = explode('-',$row->MSDogYL);
$dogum_yili=$dizi[0];
$url = "https://kasko.garantili.com.tr/sigorta/odeme/go";
$payload = [
'totalAmount' => $row->teminatTutar,
'taksitAdet' => 1,
'secure3d' => 'evet',
'customerId' => '9763100001',
'customerName' => 'ekspar',
'email' => $row->m_gsm,
'phone' => $row->m_eposta
];
// echo var_dump($payload);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
$output = curl_exec($ch);
curl_close($ch);
$this->query("insert into kasko_response(`tarih`,`sorgu`,`aciklama`) values('".gunceltarihsaat()."','$output','mobilexpressodeme')");
$response = json_decode($output, TRUE);
// echo var_dump($response);
$Durum = $response['Durum'];
}
return $response;
}
public function gunceldolarkurgetir($kur)
{
$s = "select * from kasko where kasko_id='2' ";
$q = $this->query($s);
$row=$q->fetch();
return $row->kur;
}
public function __destruct(){
$this->db = null;
}
}
$func= new myFunctions;
function p($request) {
return str_replace("'","\'",strip_tags(trim($_REQUEST[$request])));
}
function trfiyat($trfiyat){
$trfiyat=money_format('%i', $trfiyat);
$trfiyat=number_format($trfiyat, 2, ',', '.');
return $trfiyat." <span style='font-family: Helvetica Neue, Helvetica, Arial, sans-serif'>₺</span>";
}
function dolarfiyat($trfiyat){
$trfiyat=money_format('%i', $trfiyat);
$trfiyat=number_format($trfiyat, 2, ',', '.');
return $trfiyat." $";
}
function gunceltarihsaat()
{
return date("Y-m-d"." "."H:i:s");
}
?>