Пример #1
0
function Baza_Radnje($opis, $email, $tip)
{
    $baza = new baza();
    $baza->spojiDB();
    $vrime = vratiVrime();
    $upit = "Insert into Radnje_baza (id_baza,id_kor,datum_rada,opis,tip)  values ('default','{$email}','{$vrime}','{$opis}','{$tip}' )";
    $baza->ostaliUpiti($upit);
}
Пример #2
0
 private function sendNotification()
 {
     include_once 'baza.class.php';
     $baza = new baza();
     $baza->spojiDB();
     $registatoin_ids = array();
     $sql = "SELECT * FROM Air";
     $result = $baza->selectUpit($sql);
     while ($row = mysqli_fetch_assoc($result)) {
         array_push($registatoin_ids, $row['registration_id']);
     }
     // Set POST variables
     $url = 'https://android.googleapis.com/gcm/send';
     $json_data = file_get_contents('simulations.json');
     $json = json_decode($json_data, true);
     $message = array();
     //$message = array("Notice" => $_POST['message']);
     $i = 0;
     foreach ($json as $key => $value) {
         $message["name" . $i] = "" . $value['name'] . ";" . $value['percentage'] . ";" . $value['longitude'] . ";" . $value['latitude'] . ";";
         $i += 1;
     }
     $fields = array('registration_ids' => $registatoin_ids, 'data' => $message);
     //echo $fields['data'];
     $headers = array('Authorization: key=AIzaSyDw1dJ7G9c03mxM3qGsrEfBtOK1jCy9f_M', 'Content-Type: application/json');
     //echo $message;
     // Open connection
     $ch = curl_init();
     // Set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // Disabling SSL Certificate support temporarly
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
     // Execute post
     $result = curl_exec($ch);
     if ($result === FALSE) {
         die('Curl failed: ' . curl_error($ch));
     }
     // Close connection
     curl_close($ch);
 }
Пример #3
0
<?php

include_once 'baza.class.php';
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
if (isset($_GET['regId'])) {
    $baza = new baza();
    $baza->spojiDB();
    $regId = $_GET['regId'];
    $sql = "INSERT INTO Air (registration_id) values ('{$regId}')";
    $baza->ostaliUpiti($sql);
}