Exemple #1
0
 public static function checkPhoneNumber($number)
 {
     if (!isphone($number)) {
         return false;
     }
     return true;
 }
Exemple #2
0
function sendsms2 ($type,$phone,$param1='',$param2='',$param3='',$param4='') {
	
	global $arraytextsms,$sender_idsms,$loginsms,$passwordsms,$transactionsms;
	
	$transactionId = "12345667a";
	
	if ($param1 == '' || !$phone)
		return false;
	
	$ttt = isphone($phone);
	
	if ($ttt === false)
		return false;
	
	if ($type==0)
		$sms_text = $param1;
	elseif ($arraytextsms[$type]) {
	
		$sms_text = str_replace("___1___",$param1,$arraytextsms[$type]);
		$sms_text = str_replace("___2___",$param2,$sms_text);
		$sms_text = str_replace("___3___",$param3,$sms_text);
		$sms_text = str_replace("___4___",$param4,$sms_text);
		
	}
	else
		return false;
		
	$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>".
		"<message>".
			"<login>" . $loginsms . "</login>".
			"<pwd>" . $passwordsms . "</pwd>".
			"<id>" . $transactionsms . "</id>".
			"<sender>" . $sender_idsms . "</sender>".
			"<text>" . strtolower_rusms($sms_text) . "</text>".
			// "<time>20101118214600</time>".		// Можно указать время отправки этого сообщения
			"<phones>".
			"<phone>" . $ttt . "</phone>".
			// "<phone>79091234567</phone>".		// Можно указать дополнительные номера телефонов
			"</phones>".
//			"<test>1</test>".					// Если раскомментировать эту строку, то СМС не будет отправлено фактически и не будет протарифицированно 
		"</message>";
	
	//echo htmlspecialchars($xml);
		
	try {
		$url = "http://2kengu.ru/api/message";
	
		$result = post_content( $url, $xml );
		$html = $result['content'];
		
		$patern="#<[\s]*status[\s]*>([^<]*)<[\s]*/status[\s]*>#i";
		preg_match($patern, $html, $matches);
		$status = $matches[1];
		//echo htmlspecialchars($html);
		if ($status == '0' || $status == '11')
			return array(0=>$status,1=>$ttt,2=>strtolower_rusms($sms_text));
		else
			return $status; 
				
	} catch(Exception $e) {
		return false;
	}	
	
}