kohjhjhصثقصثقصثقgdfgdg
Ele57885fddfgdfgfghgقفغفغفقhfg555434536
/
home
/
u402332945
/
domains
/
simmar.co.in
/
public_html
/
Admin-Panel
/
Upload FileeE
HOME
<?php function send_notification ($tokens, $message, $message1) { $msg = array ( 'body' => "$message", 'title' => "$message1", 'sound' => 'sample.mp3', 'android_channel_id' => '9192', ); $fields = array ( 'registration_ids' => $tokens, 'notification' => $msg ); $headers = array( 'Authorization:key = AAAAiNxuy6w:APA91bGgsw8MM_1V5WjkkfVt-RPayq9UN9KzqwaBd13tcbgF7ca5cRRuzXKnfeg4Wpy_Ezpibn2FuquZuJ7hFIcUFKXma5UC7mQC7QTn-5B3MAFUVePYys_1ssiy7aHZj4krZnQY1MC6', 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,CURLOPT_IPRESOLVE,CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } $conn = mysqli_connect("localhost","swhsalem_123","swhsalem_123","swhsalem_123") or die("Error connecting"); date_default_timezone_set("Asia/Calcutta"); $sql = " Select * From devices"; $result = mysqli_query($conn,$sql); $tokens = array(); if(mysqli_num_rows($result) > 0 ){ while ($row = mysqli_fetch_assoc($result)) { $tokens[] = $row["Token"]; } } mysqli_close($conn); //Checking post request include 'db.php'; if($_SERVER['REQUEST_METHOD']=='POST'){ //Geting email and message from the request $message = $_POST['message']; $message1 = $_POST['message1']; $dantime = date("d-m-Y h:i:sa"); } $insert = $db->query("INSERT into p80(name1,name2,dantime) VALUES ('".$message."','".$message1."','".$dantime."')"); $message_status = send_notification($tokens,$message,$message1); $result = json_decode($message_status); if($result->success){ header("Location:sendNotification1.php"); }else{ echo "<pre>";print_r($result);die; } ?>