ajgkqsldxvkqsldkqs azelfkqsmkqsmlkdqsmld azmlekdqmskdmlqskd nkldsfkqsmldkqsmdmlskd decrypt($_POST['id']); $mgs_id = $mcrypt->decrypt($_POST['mgs_id']); $to = $mcrypt->decrypt($_POST['toid']); $toname = $mcrypt->decrypt($_POST['toname']); $toimage = $mcrypt->decrypt($_POST['toimage']); /* Fetch the information */ $con = db_connect(); $sql = session($con,$session); $success = 0; $message = ""; 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 = logo_url($fromimage); } /* Validate image */ $target_folder = "../im_files/"; if (isset($_FILES['file']['name'])) { if(!empty($_FILES['file']['name'])){ $ext = strtolower(pathinfo($_FILES['file']['name'],PATHINFO_EXTENSION)); $allowed_file = array('jpg', 'jpeg','png','gif','pdf','docx','xls','xlsx','txt'); /* give the file a new name */ $original_name = $_FILES['file']['name']; $filename = md5($from.$to.$_FILES['file']['name'].time()).".".$ext; $target_path = $target_folder.$filename; if(!in_array($ext,$allowed_file)){ echo $mcrypt->encrypt('Only images,pdf,word and excel files allowed!'); }else{ $size = $_FILES['image']["size"]; if($size>1000000){ echo $mcrypt->encrypt('Maximum allowed file size is 1MB.'); }else{ /* Save the image file and update company account */ if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { /* Record message to database and send a push notification to the recipient */ $mgs = $original_name; $attachment = $filename; $mgs_type = 2; $sql = message($con,$from,$to,$mcrypt->encrypt($mgs),$mcrypt->encrypt($attachment),$mgs_type,$mgs_id); if(mysqli_query($con,$sql)){ /* Send push to android apps */ $sql = user_push_tokens($to); $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $pushid = $row['token']; $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($attachment), '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')) ); /* Send data and push notification */ $priority = "high"; $ac_type = $row['ac_type']; /* if account is business, use the closeapp business firebase id */ if($ac_type==1){ sendPushData($pushid,$data,$priority); }else{ sendPushDataCloseApp($pushid,$data,$priority); } } echo $mcrypt->encrypt('1'); } }else{ echo $mcrypt->encrypt('Server error.Please try again later.'); } } } }else{ echo $mcrypt->encrypt("File doesn't exist."); } }else{ echo $mcrypt->encrypt("File doesn't exist."); } } db_close($con); }