<?
error_reporting(0);
@error_reporting(E_ALL ^ E_NOTICE);
@ini_set('display_errors', false);
@ini_set('html_errors', false);
@ini_set('error_reporting', E_ALL ^ E_NOTICE);
Include_once("curl_http_client.php");
$curl = new Curl_HTTP_Client();
$useragent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36';
$curl->set_user_agent($useragent);
$cookies_file = 'cookie.txt';
$curl->store_cookies($cookies_file);
$curl->set_referrer("http://sms.ums.uz/sms.php");
if (isset($_GET['captcha'])){
$url = 'http://sms.ums.uz/sms.php';
$curls = curl_init();
curl_setopt($curls, CURLOPT_URL, $url);
curl_setopt($curls,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36');
curl_setopt($curls, CURLOPT_REFERER, "'.$url.'");
curl_setopt($curls, CURLOPT_COOKIEJAR, 'cookie.txt'); 
curl_setopt($curls, CURLOPT_COOKIEFILE, 'cookie.txt'); 
curl_setopt($curls, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curls, CURLOPT_TIMEOUT,620);
$files = curl_exec($curls);
curl_close($curls); 
$files = preg_replace('#\n#sU',' ',$files);
if(@preg_match_all('#<div class="bl-corner"><div class="br-corner"><div class="b-side"></div>(.*)</div>(.*)<img src="(.*)" alt="captcha" />(.*)<div class="error">#sU',$files,$get)){
for($q=0; $q<count($get[0]); $q++){
include_once("curl_http_client.php");
$curl = new Curl_HTTP_Client();
$useragent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36';
$curl->set_user_agent($useragent);
$cookies_file = 'cookie.txt';
$curl->store_cookies($cookies_file);
$curl->set_referrer("http://sms.ums.uz/sms.php");
$ca=$get[3][$q];
$captchas = 'http://sms.ums.uz'.$ca.'';
$captcha = $curl->fetch_url("".$captchas."");	
//	echo $captcha;	
echo $captcha;	
exit();
}
}
}
define('_IN_JOHNCMS', 1);

$textl = 'Bepul SMS (UMS)';
$rootpath='../../';

include_once('../../incfiles/core.php');
include_once('../../incfiles/head.php');
if (isset($_POST['ok'])){
$number = trim($_POST['daddr']);
$captcha = $_POST['bod'];
$message = $_POST['sms_text'];
#captcha filterlash
if (empty($captcha)){
$error .= 'Xatolik! Rasm dagi himoya kodini kiritmadingiz!.';
}
# Raqamni filterlash
if (empty($number))
	{
		$error .= 'Xatolik! Raqamingiz kiritilmadi.';
	}
	elseif ( !preg_match("/^[0-9]*$/", $number) )
	{
		$error .= 'Telefon raqamida faqat sonlar qatnashishi va raqamlar orasida bo\'sh joy bo\'lmasligi kerak.';
	}
	elseif (!(strlen($number) == 7))
	{
		$error .= 'Telefon raqami uzunligi 7 ta belgidan iborat bo\'lishi lozim.';
	}
	
	# Xabarni filterlash
	if ( empty($message) )
	{
		$error .= 'Xatolik! Xabar matni kiritilmadi.';
	}
	elseif( !preg_match("#^([A-zА-я0-9\'\`\,\(\)\.\:\!\?\$\%\&\*\@\~\-\_\n\r ])+$#ui", $message) )
	{
		$error .= 'Xatolik! Xabar matnida taqiqlangan belgilar mavjud yoki kril alifbosi belgilari ishlatilgan.';
	}
	elseif ( strlen($message) > 150 || strlen($message) < 2 )
	{
		$error .= 'Xabar matni uzunligi 2-150 ta belgidan iborat bo\'lishi lozim.';
	}

	if ( isset($error) )
	{
		echo $error."\n:: <a href=\"./ums\">Qayta urinib ko'rish</a>";
	}

$message = $message."\n--\nQaqnus.Ru";
	
	$post_data = array('branch' => '99897', 'entity' => 'sms', 'sms_text' => $message, 
	'daddr' => $number, 'bod' => $captcha);
	
	$html_data = $curl->send_post_data("http://sms.ums.uz/sms.php", $post_data);
	
	include('simple_html_dom.php');
	$html = str_get_html($html_data);
	$result_1 = $html->find('div[class=error', 0) -> innertext;
	$result_2 = $html->find('div[class=error"]', 0) -> innertext;
	$result_3 = $html->find('div[class=error', 0) -> innertext;
	if ($result_1 != null)
	{
		if ($result_1 == 'Не указан номер')
			$message = 'Raqam kiritilmadi';
		else
			$message = 'Xatolik! Bir necha daqiqalardan keyin urinib ko\'ring!';
	}
	elseif ($result_2 = 'Не введен код')
		$message = '+99897<b>'.$number.'</b> raqamiga SMS muvaffaqiyatli jo\'natildi!';
		
	elseif ($result_3 != null)
	{

		$message = '+99897<b>'.$number.'</b> raqamiga SMS muvaffaqiyatli jo\'natildi!';
	}
	else
	{
		$message = 'Xatolik! Bir necha daqiqalardan keyin urinib ko\'ring!';
	}
	
echo '<div class="tmn">'.$message.'</div>';
}

echo '
<script type="text/javascript" language="javascript"  src="text_count.js"></script>
		<div class="phdr">'.$textl.'</div>';
echo '
	<div class="menu">  
	<form action="index.php" method="POST" accept-charset="utf-8" enctype="application/x-www-form-urlencoded" > 
	Raqam:<br/>
	<input type="text" size="7" maxlength="7" name="daddr" value="" {CLASS}/><br>
	Xabar matni:<br/>
	<textarea id="smsarea" name="sms_text"></textarea><br/>
	<input id="symleft" type="text" size="3" maxlength="3" readonly="true"/></span> - belgi qoldi<br/>
';
?>
Ruhsat etilgan belgilar: <span class="p_t">- _ , . ) ( ' ` ! : ? $ % & * @ ~</span>
<?
Echo '
	</div>
	<div class="list1">
	Tekshiruv kodi:<br/>
	<img src="?captcha" alt="Captcha"><br/>
	Rasmdagi kodni yozing: <br/>
	<input type="text" name="bod" size="7" maxlength="7" value=""/><br>
	<input type="submit" name="ok" value="Yuborish">  
	</form> 
	</div>
	<div class="sdsfd">
	</div>
	<div class="menu"> 
<span style="color: red">Eslatma!</span><br/>
';
?>
1. SMS xabar qabul qiluvchidan hech qanday maxsus sozlamalar talab qilinmaydi, SMS'lar odatdagidek tartibda yuboriladi.<br/>
	2. Jo'natilgan SMS'lar har <b>2-3soniyadayoq</b> qabul qiluvchiga yetkaziladi!<br/>
	3. Agar qabul qiluvchi aloqadan tashqarida (o'chirilgan) bo'lsa. SMS aloqaga chiqqan paytda albatta yetkaziladi.<br/>
	4. Ushbu xizmatdan foydalanish ba'zi cheklovlardan tashqari, mutlaqo bepul hisoblanadi. <br/>
	<span style="color: red">Qat'iyan taqiqlanadi:</span><br/>
	1. Xabar matnida haqoratli so'zlar ishlatish.<br/>
	2. Xabar matnida O'zb. Res. Qonunchiligiga zid so'zlar ishlatish.<br/>
	3. Katta miqdorda SMS spam'lar tarqatish.<br/>
	4. Har turdagi reklamalar tarqatishda foydalanish.<br/>
	* Xizmatdan foydalangan har-bir foydalanuvchi haqidagi ma'lumotlar bazamizda saqlanib qoladi. Ushbu shartlar amal qilinmagan taqdirda qoidabuzarni topish biz uchun muammo bo'lmaydi. Qoidabuzar topilgach esa kechirilmaydi va qattiq qarshi chora ko'riladi!   
<?
Echo '</div>';
include_once('../../incfiles/end.php');
?>