<?php
date_default_timezone_set('Asia/Jakarta');
$waktu=date('d-m-Y H:i:s');


	$sql_satker = $pdo->prepare("SELECT * FROM satker where no='1'");
	$sql_satker->execute();
	$data = $sql_satker->fetch();
		$sekolah=$data['sekolah'];
		$alamat=$data['alamat'];
		$emailsek=$data['email'];
		$passwordsek=$data['password'];
		$urlheader=$data['email_urlheader'];
		$urlheader2=$data['email_urlheader2'];
		$apiwa_fitur=$data['apiwa_fitur'];
		$apiwa_passkey=$data['apiwa_passkey'];
	
	$ceknohp=strlen($hp);
	
	$cekkey=strlen($apiwa_passkey);
	$cektoken=strlen($apiwa_token);
	if($tkn_sts=="AKTIF"){$keyapi=$idkeyapi;}else{$keyapi=$apiwa_passkey;};


	if($ceknohp>7 and $apiwa_fitur=="ya"){
		//Kirim WA Notifikasi
		$message = $tekswa;
		$phone_no = $hp; 
		$message = preg_replace("/(\n)/", "<ENTER>", $message);
		$message = preg_replace("/(\r)/", "<ENTER>", $message);

		$phone_no = preg_replace("/(\n)/", ",", $phone_no);
		$phone_no = preg_replace("/(\r)/", "", $phone_no);

		$data = array("phone_no" => $phone_no, "key" => $keyapi, "message" => $message);
		$data_string = json_encode($data);
		$ch = curl_init('http://116.203.92.59/api/send_message');
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_VERBOSE, 0);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
		curl_setopt($ch, CURLOPT_TIMEOUT, 15);
		curl_setopt(
			$ch,
			CURLOPT_HTTPHEADER,
			array(
				'Content-Type: application/json',
				'Content-Length: ' . strlen($data_string)
			)
		);
		$result = curl_exec($ch);
		// akhir WA
	}else{echo "";};	


?>
	
