push.php 711 B

123456789101112131415161718192021222324252627
  1. <?php
  2. $json = json_decode ( $_POST ["record"], true );
  3. $values = array ();
  4. $i = 0;
  5. $line = "(";
  6. foreach ( $json as $key => $value ) {
  7. $line = $line . "'" . $value . "',";
  8. }
  9. $line = substr ( $line, 0, strlen ( $line ) - 1 ) . ")";
  10. $values [$i] = $line;
  11. ++ $i;
  12. $values = implode ( ",", $values );
  13. $username = "hostage";
  14. $password = "hostageDB";
  15. $hostname = "localhost";
  16. $dbhandle = mysql_connect ( $hostname, $username, $password ) or die ( "Unable to connect to MySQL" );
  17. $result = mysql_query ( "INSERT INTO `hostage`.`sync` (`bssid`, `ssid`, `longitude`, `latitude`, `timestamp`, `attacks`, `portscans`) VALUES " . $values );
  18. if (! $result) {
  19. die ( 'Could not insert record: ' . mysql_error () );
  20. }
  21. ?>