ajgkqsldxvkqsldkqs azelfkqsmkqsmlkdqsmld azmlekdqmskdmlqskd nkldsfkqsmldkqsmdmlskd decrypt($_GET['id']); $firebase_token = $mcrypt->decrypt($_GET['fid']); $to = $mcrypt->decrypt($_GET['to']); $toimage = $mcrypt->decrypt($_GET['toimage']); $toname = $mcrypt->decrypt($_GET['toname']); $mgs = $mcrypt->decrypt($_GET['mgs']); $attachments = " "; $mgs_type = 1; $mgs_id = $mcrypt->decrypt($_GET['mgs_id']); /* Fetch the information */ $con = db_connect(); $response = array(); $sql = session($con,$session); $success = 0; if(db_rows($con,$sql)>0){ /* fetch userid and create session token */ $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $from = $row['userid']; $fromname = $row['name']; $fromimage = $row['picture']; if(empty($fromimage)){ $fromimage = "no_image.png"; } $fromimage = pic_url($fromimage); } if(!empty($mgs)){ /* Record message to database */ $sql = message($con,$from,$to,$mcrypt->encrypt($mgs),"",$mgs_type,$mgs_id); if(mysqli_query($con,$sql)){ /* Send push to android apps */ $priority = "high"; $data = array ( 'action' => '1', 'fromid' => $mcrypt->encrypt($from), 'fromname' => $mcrypt->encrypt($fromname), 'fromimage' => $mcrypt->encrypt($fromimage), 'toid' => $mcrypt->encrypt($to), 'toname' => $mcrypt->encrypt($toname), 'toimage' => $mcrypt->encrypt($toimage), 'message' => $mcrypt->encrypt($mgs), 'attachments' => $mcrypt->encrypt($attachments), 'mgs_type' => $mcrypt->encrypt($mgs_type), 'message_id' => $mcrypt->encrypt($mgs_id), 'time' => $mcrypt->encrypt(date("Y-m-d h:i:sa")), 'date' => $mcrypt->encrypt(date('d').'/'.date('m').'/'.date('Y')) ); $sql = user_push_tokens($to); $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $pushid = $row['token']; /* Send data and push notification */ $ac_type = $row['ac_type']; /* if account is business, use the closeapp business firebase id */ if(!(empty($pushid))){ if($ac_type==1){ sendPushData($pushid,$data,$priority); }else{ sendPushDataCloseApp($pushid,$data,$priority); } } } /* Check if user has another account installed on a different mobile, to send a copy to for synchronization */ if(!empty($firebase_token)){ $data = array ( 'action' => '7', 'fromid' => $mcrypt->encrypt($from), 'fromname' => $mcrypt->encrypt($fromname), 'fromimage' => $mcrypt->encrypt($fromimage), 'toid' => $mcrypt->encrypt($to), 'toname' => $mcrypt->encrypt($toname), 'toimage' => $mcrypt->encrypt($toimage), 'message' => $mcrypt->encrypt($mgs), 'attachments' => $mcrypt->encrypt($attachments), 'mgs_type' => $mcrypt->encrypt($mgs_type), 'message_id' => $mcrypt->encrypt($mgs_id), 'time' => $mcrypt->encrypt(date("Y-m-d h:i:sa")), 'date' => $mcrypt->encrypt(date('d').'/'.date('m').'/'.date('Y')) ); $sql = user_other_push_tokens($con,$from,$firebase_token); $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $pushid = $row['token']; /* Send data and push notification */ $ac_type = $row['ac_type']; /* if account is business, use the closeapp business firebase id */ if(!(empty($pushid))){ if($ac_type==1){ sendPushData($pushid,$data,$priority); }else{ sendPushDataCloseApp($pushid,$data,$priority); } } } /* update last time user use this firebase token. Reason: To delete unused firebase tokens which are older than about a year. */ update_last_time_firebase_token_used($con,$from,$firebase_token); } $success = 1; } } } $response['success'] = $success; echo json_encode($response); db_close($con); } ?>