2 include("includes.php");
4 $myFile = "testFile.txt";
5 $fh = fopen($myFile, 'w') or die("can't open file");
7 $inputJSON = file_get_contents('php://input');
8 $input= json_decode( $inputJSON, TRUE ); //convert JSON into array
10 #fwrite($fh, var_export($input, true));
12 #foreach ($input as $index => $element) {
13 #fwrite($fh, "Param: $index; Value: $element\n");
14 #foreach ($element as $item => $value) {
15 #fwrite($fh, "Param: $item; Value: $value\n");
16 #if ($item == "type" ) {
17 #fwrite($fh, "$value\n");
22 for($i=0; $i<sizeof($input); $i++) {
23 #fwrite($fh, $input[$i][type]."\n");
24 switch ($input[$i][type]) {
26 #fwrite($fh, "ssid: ".$input[$i][ssid]."\n");
27 $query=open_database("localhost","kismet","asdfqwerty","wireless","select LASTSEEN from beacon where SSID='".$input[$i][ssid]."' and BSSID='".$input[$i][bssid]."'");
28 #write($fh, "select LASTSEEN from beacon where SSID='".$input[$i][ssid]."' and BSSID='".$input[$i][bssid]."'");
29 if (mysql_numrows($query) > 0) {
30 open_database("localhost","kismet","asdfqwerty","wireless","update beacon set CHANNEL='".$input[$i][channel]."', RSSI='".$input[$i][rssi]."', LASTSEEN=UNIX_TIMESTAMP(NOW()) where SSID='".$input[$i][ssid]."' and BSSID='".$input[$i][bssid]."'");
32 open_database("localhost","kismet","asdfqwerty","wireless","insert into beacon set SSID='".$input[$i][ssid]."', BSSID='".$input[$i][bssid]."', LASTSEEN=UNIX_TIMESTAMP(NOW()), CHANNEL='".$input[$i][channel]."', RSSI='".$input[$i][rssi]."'");
37 $query=open_database("localhost","kismet","asdfqwerty","wireless","select LASTSEEN from probe where BSSID='".$input[$i][bssid_mac]."' and MAC='".$input[$i][client_mac]."'");
38 if (mysql_numrows($query) > 0) {
39 open_database("localhost","kismet","asdfqwerty","wireless","update probe set CHANNEL='".$input[$i][channel]."', RSSI='".$input[$i][rssi]."', LASTSEEN=UNIX_TIMESTAMP(NOW()) where BSSID='".$input[$i][bssid_mac]."' and MAC='".$input[$i][client_mac]."'");
41 open_database("localhost","kismet","asdfqwerty","wireless","insert into probe set BSSID='".$input[$i][bssid_mac]."', MAC='".$input[$i][client_mac]."', LASTSEEN=UNIX_TIMESTAMP(NOW()), CHANNEL='".$input[$i][channel]."', RSSI='".$input[$i][rssi]."'");
46 $query=open_database("localhost","kismet","asdfqwerty","wireless","select LASTSEEN from probe where BSSID='".$input[$i][bssid_mac]."' and MAC='".$input[$i][client_mac]."'");
47 if (mysql_numrows($query) > 0) {
48 open_database("localhost","kismet","asdfqwerty","wireless","update probe set CHANNEL='".$input[$i][channel]."', RSSI='".$input[$i][rssi]."', LASTSEEN=UNIX_TIMESTAMP(NOW()) where BSSID='".$input[$i][bssid_mac]."' and MAC='".$input[$i][client_mac]."'");
50 open_database("localhost","kismet","asdfqwerty","wireless","insert into probe set BSSID='".$input[$i][bssid_mac]."', MAC='".$input[$i][client_mac]."', LASTSEEN=UNIX_TIMESTAMP(NOW()), CHANNEL='".$input[$i][channel]."', RSSI='".$input[$i][rssi]."'");