Advertisement
Guest User

xx

a guest
Mar 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "biogrid_datacenter";
  6.  
  7. // Create connection
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9. // Check connection
  10. if (!$conn) {
  11. die("Connection failed: " . mysqli_connect_error());
  12. }
  13.  
  14. $f=fopen("var","a+");
  15.  
  16. //$val="aaa001#ecg#-10#2016#3#27#78075604#492#492#491#1023#491#492#493#1022#492#490#485#481#479#481#490#1022#528#550#566#1023#560#537#508#1023#468#465#470#1022#484#488#491#1022#495#495#496#496#496#496#496#496#497#497#497#497#497#498#498#1022#498#499#499#500#500#500#501#501#502#502#502#1023#503#503#503#";
  17.  
  18. foreach ( $_POST as $key => $val )
  19. {
  20.  
  21.  
  22. $today = date("Y-m-d H:i:s",time());
  23.  
  24.  
  25. $accel;
  26. $heart_rate;
  27. fwrite($f,"$val\n");
  28. $arr=explode('#',$val);
  29. $user=$arr[0];
  30.  
  31. $query="INSERT INTO ";
  32.  
  33. if ($arr[1]=="ecg")
  34. $query = $query . "mp_00_waveforms (device_id, ecg, timestamp) VALUES ('BGP_ECG_002', $arr[7], '$today')";
  35.  
  36.  
  37. if ($arr[1]=="general")
  38. {
  39. //$query_value = $query . "mp_00_values (accel, device_id, heart_rate, timestamp) VALUES ('$arr[11]', 'BGP_ECG_002', '$arr[7]', '$today')";
  40. (float)$accel=$arr[11];
  41. $heart_rate=$arr[7];
  42.  
  43. }
  44.  
  45.  
  46. if ($arr[1]=="rr")
  47. {
  48. //$query_value = $query . "mp_00_values (accel, device_id, heart_rate, timestamp) VALUES ('$arr[11]', 'BGP_ECG_002', '$arr[7]', '$today')";
  49. $query_value="INSERT INTO mp_00_values (accel, device_id, heart_rate, timestamp,r_r_interval) VALUES ($accel, 'BGP_ECG_002', $heart_rate, '$today', $rr_val)";
  50. for ($i=8; $i<count($arr)-2; $i++)
  51. {
  52.  
  53. if ($arr[$i] < 4000)
  54. {$rr_val=$arr[$i];
  55. $query_value =$query_value . ",($accel, 'BGP_ECG_002', $heart_rate, '$today', $rr_val)";
  56. }
  57. }
  58. }
  59.  
  60. for ($i=8; $i<count($arr)-2; $i++)
  61. {
  62. $val=$arr[$i];
  63. if ($val < 1000 && $val > 200)
  64. {
  65. $query =$query . ",('BGP_ECG_002', $val, '$today')";
  66. }
  67. }
  68. mysqli_query($conn, $query);
  69. mysqli_query($conn, $query_value);
  70. //mysqli_query($conn, $query);
  71.  
  72. fwrite($f,"$query\n");
  73.  
  74. }
  75. fclose($f);
  76.  
  77.  
  78.  
  79. mysqli_close($conn);
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement