//$logger = loggerFactory::createLogger(); //$logger->debug("PushNotification: OperationId: $orderId, RequestKey: $requestKey, EventType: $eventType, EventKey: $eventKey, EventDateTime: $eventDateTime, EventData: $eventData"); header("Content-Type: text/json", true); require_once 'includes/modules/payment/todopagoplugin/includes/TodopagoTransaccion.php'; $transaction = new TodopagoTransaccion(); if ($transaction->_getStep($orderId) == TodopagoTransaccion::TRANSACTION_FINISHED && $requestKey == $transaction->getRequestKey($orderId)) { $newOrderStatus = getNewOrderStatus($eventType); updateOrder($orderId, $newOrderStatus, $comment = 'Actualizado por TodoPago - PushNotificationService', true); $statusCode = -1; } else { $statusCode = 1; //$logger->info("Fallo el update de la orden por push. OperationId: $orderId, RequestKey: $requestKey, EventKey: $eventKey"); } $rta = json_encode(array('StatusCode' => $statusCode, 'EventKey' => $eventKey)); //$logger->debug("Rta PushNotification: $rta"); echo $rta; } function getNewOrderStatus($eventType) { $statusByEvent = array('aprobar' => 1, 'cancelar' => 2); return $statusByEvent[$eventType]; } function updateOrder($orderId, $orderStatusId, $comment, $notify) { $order_status_history_data_array = array('orders_id' => $orderId, 'orders_status_id' => $orderStatusId, 'comments' => $comment, 'customer_notified' => '0', 'date_added' => 'now()'); tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $order_status_history_data_array); $order_data_array = array('orders_id' => $orderId, 'orders_status' => $orderStatusId); tep_db_perform(TABLE_ORDERS, array('orders_status' => $orderStatusId), 'update', "orders_id = {$orderId}"); } pushNotification();
$sound = "default"; if (isset($_POST['sound'])) { $sound = $_POST['sound']; } $color = "FFFFFF"; if (isset($_POST['color'])) { $color = $_POST['color']; } $url = "ssl://gateway.sandbox.push.apple.com:2195"; $certFile = "/Library/WebServer/aps_developer.pem"; $context = stream_context_create(); stream_context_set_option($context, 'ssl', 'local_cert', $certFile); $stream = stream_socket_client($url, $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $context); if ($stream != FALSE) { $apsDict = array("alert" => $msg, "sound" => $sound); $payloadDict = array("aps" => $apsDict, "color" => $color); $payload = json_encode($payloadDict); $db = connectToDB(); if ($db) { $query = "SELECT token FROM device"; $resource = mysql_query($query); if ($resource) { while ($row = mysql_fetch_assoc($resource)) { pushNotification($stream, $row['token'], $payload); } } mysql_close($db); } fclose($stream); } require_once "./push.html";
function distribusiSurat($db, $token, $id_surat, $subject, $tu, $tembusan, $nama_institusi) { $tujuan = explode("@+id/", $tu); // explode dulu tujuannya $registration_ids = array(); for ($i = 0; $i < count($tujuan); $i++) { if (!empty($tujuan[$i])) { // echo $id_surat . " - " . $tujuan[$i] . " - " . $tembusan . " <br/>"; kirimSurat($db, $id_surat, $tujuan[$i], $tembusan); if (!empty(pushNotification($db, $tujuan[$i]))) { $registration_ids = pushNotification($db, $tujuan[$i]); } } } if (count($registration_ids) > 0) { $gcm = new GCM(); $pesan = array("message" => $subject, "title" => "Surat baru dari {$nama_institusi}", "msgcnt" => 1, "sound" => "beep.wav"); $result = $gcm->send_notification($registration_ids, $pesan); } else { $result = '"Not a GCM User"'; } echo '{"isUnreads": ' . countUnreads($token) . ', "isFavorites": ' . countFavorites($token) . ', "isUnsigned": ' . countUnsigned($token) . ', "result": ' . $result . '}'; // echo $result; }
if (isset($_POST['AddAppointment'])) { $caregiver = $db->quote($_POST['caregiver']); $patient = $db->quote($_POST['patients']); $aptdate = date("Y-m-d H:i:s", strtotime($db->quote($_POST['aptdate']))); $aptdate = str_replace(" ", "T", $aptdate); $db->query("INSERT INTO " . $configValues['AP'] . " (P_ID, A_Date, AssignedTo) values('" . $patient . "', '" . $aptdate . "', '" . $caregiver . "')"); $aptid = $db->insert_id(); $db->query("UPDATE " . $configValues['AP'] . " SET A_ID = " . $aptid . " where ID = " . $aptid); if (isset($_POST['tasks'])) { $tasks = $_POST['tasks']; foreach ($tasks as $key => $value) { $valuesplit = explode("|", $value); $db->query("INSERT INTO " . $configValues['TL'] . " (A_ID, TaskID, Task, Status) values('" . $aptid . "', '" . $valuesplit[0] . "', '" . $valuesplit[1] . "', 0)"); } } pushNotification($caregiver, $db, 'add'); header("Location:appointments.php"); exit; } $caregivers = $db->select("SELECT * from " . $configValues['CG'] . ""); $patients = $db->select("SELECT * from " . $configValues['PT'] . ""); $tasks = $db->select("SELECT * from " . $configValues['TK'] . ""); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Remote Patient Cate - Admin Panel</title> <!-- CSS Reset --> <link rel="stylesheet" type="text/css" href="reset.css" media="screen" />
if (isset($_POST['UpdateAppointment'])) { $caregiver = $db->quote($_POST['caregiver']); $patient = $db->quote($_POST['patients']); $aptdate = date("Y-m-d H:i:s", strtotime($db->quote($_POST['aptdate']))); $aptdate = str_replace(" ", "T", $aptdate); $db->query("UPDATE " . $configValues['AP'] . " SET P_ID = '" . $patient . "', A_Date = '" . $aptdate . "', AssignedTo = '" . $caregiver . "' WHERE A_ID = " . $_GET['aptid']); $aptid = $_GET['aptid']; $db->query("DELETE FROM " . $configValues['TL'] . " WHERE A_ID = " . $aptid); if (isset($_POST['tasks'])) { $tasks = $_POST['tasks']; foreach ($tasks as $key => $value) { $valuesplit = explode("|", $value); $db->query("INSERT INTO " . $configValues['TL'] . " (A_ID, TaskID, Task, Status) values('" . $aptid . "', '" . $valuesplit[0] . "', '" . $valuesplit[1] . "', 0)"); } } pushNotification($caregiver, $db, 'edit'); header("Location:appointments.php"); exit; } $caregivers = $db->select("SELECT * from " . $configValues['CG'] . " WHERE role = 'CG'"); $patients = $db->select("SELECT * from " . $configValues['PT'] . ""); $tasks = $db->select("SELECT * from " . $configValues['TK'] . ""); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Remote Patient Cate - Admin Panel</title> <!-- CSS Reset --> <link rel="stylesheet" type="text/css" href="reset.css" media="screen" />
<?php require 'push.php'; // this is used to read POST parameters because the server I am using has issues $rest_json = file_get_contents("php://input"); $_POST = json_decode($rest_json, true); // make sure the parameter is there if ($_POST["status"] == NULL) { die(''); } $status = $_POST["status"]; $message = "has changed to {$status}"; $myToken = ""; // put your device token here pushNotification($myToken, $message);