//echo "Response:".$response."\n"; } function response($IDNumber, $pid) { $response['STATUS'] = array('Success' => TRUE, 'NIK' => $IDNumber, 'PID' => $pid); return json_encode($response); } //reveice post message //var_dump($_POST); $data = json_decode(file_get_contents('php://input'), true); $AppID = $data["META"]["AppID"]; $IDNumber = $data["KTP"]["NIK"]; //cek META field, apakah data lengkap //process message if (cariapp($AppID) >= 0) { $encode = json_encode($data['KTP']); $encode = preg_replace('/\\s+/', '', $encode); $data["META"]["signature"] = hitunghashdata($encode); $daftar = daftarpid($AppID, $data); if ($daftar[0] == 1) { //mengirim pesan ke device (Pesan + AppID + PID + OTP + CallbackAddr) kirimGCM($data, $AppID, $daftar[1], $daftar[2], $SIcallbackaddr); //tampilkan response header('Content-type: application/json'); echo response($IDNumber, $daftar[1]); } else { echo "daftar[0] ngga 1"; } } else { echo "App ID tidak terdaftar"; }
$data["otp"] = $otp; $data["pid"] = $pid; unset($data["CAwebsigncallback"]); $gcpm = new GCMPushMessage($data["regid"]); $gcpm->fillDataDocSign($data, $callbackaddr); $response = $gcpm->sendGoogleCloudMessage(); //echo "Response:".$response."\n"; } function response($IDNumber, $PID, $id) { $response['STATUS'] = array('Success' => TRUE, 'NIK' => $IDNumber, 'PID' => $PID, 'TableID' => $id); return json_encode($response); } $uploaddir = realpath('./') . '/documents/signature/'; if (!file_exists($uploaddir)) { mkdir($uploaddir, 0755, true); } $uploadfile = $uploaddir . basename($_FILES['file_contents']['name']); if (move_uploaded_file($_FILES['file_contents']['tmp_name'], $uploadfile)) { $retarray = daftarpid($_POST); $otp = $retarray["otp"]; $pid = $retarray["pid"]; if ($retarray["result"] != 0) { kirimGCM($_POST, $otp, $pid, $SIdocsigncallbackaddr); echo response($_POST["userid"], $pid, $_POST["id"]); } else { echo "Ada Kesalahan"; } } else { echo "Possible file upload attack!\n"; }
<?php require_once './lib/GCMPushMessage.php'; include './addr-path.php'; function kirimGCM($data) { //mengirim pesan ke device (Pesan + AppID + PID + OTP) $devices = $data["regid"]; $message = $data["content"]; $gcpm = new GCMPushMessage($devices); $gcpm->notification($message); $response = $gcpm->sendGoogleCloudMessage(); return json_decode($response, true); } $kirim = kirimGCM($_POST); if ($kirim["success"]) { echo json_encode($kirim); } else { "Gagal kirim pesan"; }