<?php

@session_start();

if($_SERVER["SERVER_NAME"]=="localhost")  //Local Host

{
  $host = "localhost";
  $username = "root";
  $password = "";
  $db = "satsang";
}

elseif($_SERVER["SERVER_NAME"]=="192.168.0.100")  //Local Host

{
  $host = "localhost";
  $username = "root";
  $password = "";
  $db = "satsang";
}

else  //Server

{
  $host = "localhost";
  $username = "debashis_admin";
  $password = "debashis*123";
  $db = "debashis_satsang";
}

@mysql_connect($host,$username,$password);
mysql_select_db($db);
mysql_query('SET CHARACTER SET utf8');
mysql_query("SET SESSION collation_connection ='utf8_general_ci'");


function sms_send($recipient_no, $sms_text) {
	$url = "http://bulksmsbd.net/api/smsapi";
	$api_key = "Y838JafREH4hd4Tx3yI5";
	$senderid = "8809617611063";
	$number = $recipient_no;
	$message = $sms_text;

	$data = [
		"api_key" => $api_key,
		"senderid" => $senderid,
		"number" => $number,
		"message" => $message
	];
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	$response = curl_exec($ch);
	curl_close($ch);
	return $response;
}

function sms_char_len($input_char, $char_type){
		if($char_type=="ASCII"){
			if(mb_strlen($input_char)<=160){
				$sms_len=1;
			}
			else if(mb_strlen($input_char)>160 and mb_strlen($input_char)<=306){
				$sms_len=2;
			}
			else if(mb_strlen($input_char)>306 and mb_strlen($input_char)<=459){
				$sms_len=3;
			}
			else if(mb_strlen($input_char)>459 and mb_strlen($input_char)<=612){
				$sms_len=4;
			}
			else if(mb_strlen($input_char)>612 and mb_strlen($input_char)<=765){
				$sms_len=5;
			}
			else if(mb_strlen($input_char)>765 and mb_strlen($input_char)<=918){
				$sms_len=6;
			}
			else if(mb_strlen($input_char)>918 and mb_strlen($input_char)<=1071){
				$sms_len=7;
			}
			else{
				$sms_len=0;
			}
		}
		else{
			if(mb_strlen($input_char)<=70){
				$sms_len=1;
			}
			else if(mb_strlen($input_char)>70 and mb_strlen($input_char)<=134){
				$sms_len=2;
			}
			else if(mb_strlen($input_char)>134 and mb_strlen($input_char)<=201){
				$sms_len=3;
			}
			else if(mb_strlen($input_char)>201 and mb_strlen($input_char)<=268){
				$sms_len=4;
			}
			else if(mb_strlen($input_char)>268 and mb_strlen($input_char)<=335){
				$sms_len=5;
			}
			else if(mb_strlen($input_char)>335 and mb_strlen($input_char)<=402){
				$sms_len=6;
			}
			else if(mb_strlen($input_char)>402 and mb_strlen($input_char)<=469){
				$sms_len=7;
			}
			else if(mb_strlen($input_char)>469 and mb_strlen($input_char)<=536){
				$sms_len=8;
			}
			else if(mb_strlen($input_char)>536 and mb_strlen($input_char)<=603){
				$sms_len=9;
			}
			else{
				$sms_len=0;
			}
		}
		return $sms_len;
	}

?>