<?php
function sendSMS($ente_url,$msg,$number){
	
	$ente = get_ente($ente_url);

	 //create array of data to be posted
	$post_data['user'] = $ente['ente_sms_user'];
	$post_data['pass'] = $ente['ente_sms_pass'];
	$post_data['rcpt'] = urlencode($number);
	$post_data['data'] = stripslashes($msg);
	$post_data['sender'] = $ente['ente_sms_name'];; //sender (max 11 caratteri)
	$post_data['qty'] = 'h'; //Qualità del messaggio: (ll, l, a, h, n – bassa, media, automatica, alta, notifica)
	
	//traverse array and prepare data for posting (key1=value1)
	foreach ( $post_data as $key => $value) {
		$post_items[] = $key . '=' . $value;
	}
	 
	//create the final string to be posted using implode()
	$post_string = implode ('&', $post_items);
	 
	//set options
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20100101 Firefox/15.0.1');
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
	curl_setopt($curl, CURLOPT_REFERER, $_SERVER['HTTP_HOST']);
	curl_setopt($curl, CURLOPT_URL, 'http://sms.progettoserver.com/smservice.php?sendsms');
	curl_setopt($curl, CURLOPT_POSTFIELDS, $post_string);
	$smsresult = curl_exec ($curl);
	curl_close ($curl);

	//perform our request
	return $smsresult == 'OK' ? true : false;
}
?>