-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAllergies.php
44 lines (37 loc) · 1.26 KB
/
Allergies.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require "conn.php";
set_include_path('.;C:\wamp\bin\php\php5.5.12\pear');
include('Crypt/AES.php');
include('Crypt/RSA.php');
include('Crypt/Random.php');
include('Math/BigInteger.php');
$tag_id = $_POST["tag_id"];
//Extract Data Required from database and package it
//---------------------------------------------------------------
$mysql_qry1 = "SELECT `patient_id` FROM `patient` WHERE tag_id='$tag_id'";
if ($result1=mysqli_query($conn,$mysql_qry1))
{
while($row1=mysqli_fetch_row($result1))
{
$patient_id = $row1[0];
}
}
$mysql_qry2 = "SELECT `type` FROM `allergies` WHERE patient_id='$patient_id'";
$response = array();
if ($result2=mysqli_query($conn,$mysql_qry2))
{
while($row2=mysqli_fetch_row($result2))
{
array_push($response, array("type"=>$row2[0]));
}
}
//---------------------------------------------------------------
//Encrypt Outgoing Data
//---------------------------------------------------------------
$cipher = new Crypt_AES(CRYPT_AES_MODE_ECB);
$symmetricKey = file_get_contents('C:\wamp\www\symmetric.txt');
$cipher->setKey($symmetricKey);
echo base64_encode($cipher->encrypt(json_encode(array("server_response"=>$response))));
//---------------------------------------------------------------
mysqli_close($conn);
?>