55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
$ini = parse_ini_file("conf.ini", true);
|
|
mysql_connect($ini['db']['host'],$ini['db']['user'],$ini['db']['pass']);
|
|
mysql_select_db($ini['db']['db']);
|
|
|
|
|
|
$datetime = date('Y-m-d H:i:s');
|
|
$a=44.647;
|
|
$b=9.6;
|
|
$c=44.647;
|
|
$d=9.6;
|
|
$intensity=0;
|
|
|
|
$dataArray = array('latitude'=>number_format((float)$a, 2, '.', ''),
|
|
'longitude'=>number_format((float)$b, 2, '.', ''),
|
|
'detection_latitude'=>number_format((float)$c, 2, '.', ''),
|
|
'detection_longitude'=>number_format((float)$d, 2, '.', ''),
|
|
'wave_speed'=>8,
|
|
'counter'=>43,
|
|
'datetime'=>$datetime,
|
|
'intensity'=>$intensity,
|
|
'type'=>'eqn');
|
|
|
|
//extract users for notifications
|
|
$sql2=mysql_query("select reg_id from gcm where user_id=-3433561141690823682");
|
|
$counter=0;
|
|
$num_rows2 = mysql_num_rows($sql2);
|
|
for ($i = 0; $i < $num_rows2; $i++)
|
|
{
|
|
$regidArray[$counter]=mysql_result($sql2,$i,"reg_id");
|
|
$counter=$counter+1;
|
|
if ($counter==999 or $i==($num_rows2-1))
|
|
{
|
|
$headers = array(
|
|
'Authorization: key=AIzaSyAYaXDEapyd-mF9V9LNW1dmuoS-ea9GwWI',
|
|
'Content-Type: application/json');
|
|
$fields = array(
|
|
'registration_ids' => $regidArray,
|
|
'data' => $dataArray);
|
|
|
|
$context = stream_context_create(array(
|
|
'http' => array(
|
|
'method' => 'POST',
|
|
'header' => $headers,
|
|
'content' => json_encode($fields))));
|
|
$response = file_get_contents('https://android.googleapis.com/gcm/send', FALSE, $context);
|
|
var_dump($response);
|
|
$counter=0;
|
|
$regidArray=array();
|
|
}
|
|
}
|
|
|
|
mysql_close();
|
|
?>
|