
<?php 

require_once "vt.php";

$sms_setting = $dbh -> prepare("SELECT * FROM sms_setting WHERE id = ?");
$sms_setting-> execute(array(1));
$sms_setting = $sms_setting->fetch(PDO::FETCH_OBJ);


function XMLPOST($PostAddress,$xmlData){
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$PostAddress);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,2);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
	$result = curl_exec($ch);
	return $result;
}


function smsyollas($tel,$mesaj){
	global $sms_setting;
	
	if($sms_setting->saglayici=="1sms"){

		$xml='<sms>
		<username>'.$sms_setting->username.'</username>
		<password>'.$sms_setting->password.'</password>
		<header>'.$sms_setting->header.'</header>
		<validity>2880</validity>
		<sendDateTime>2015.7.23.9.30.0</sendDateTime>
		<message>
		<gsm>
		<no>'.$tel.'</no>
		</gsm>
		<msg><![CDATA['.$mesaj.']]></msg>
		</message>
		</sms>
		';

		$yolla  = XMLPOST('http://panel.1sms.com.tr:8080/api/smspost/v1',$xml);
		$sonuc  =   explode('|',$yolla);

	}

	if($sms_setting->saglayici=="netgsm"){

		$xml='<?xml version="1.0" encoding="UTF-8"?>
		<mainbody>
		<header>
		<company dil="TR">Netgsm</company>        
		<usercode>'.$sms_setting->username.'</usercode>
		<password>'.$sms_setting->password.'</password>
		<type>1:n</type>
		<msgheader>'.$sms_setting->header.'</msgheader>
		</header>
		<body>
		<msg>
		<![CDATA['.$mesaj.']]>
		</msg>
		<no>'.$tel.'</no>
		</body>
		</mainbody>';


		$yolla  = XMLPOST('https://api.netgsm.com.tr/sms/send/xml',$xml);
		$sonuc  =   explode('|',$yolla);
		
	}

}

//smsyollas("905385018784","Deneme Mesajı");





?>