Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data = json_decode($_POST['data'], true);
- $dbhost = "localhost";
- $dbname = "scrapi";
- $dbusername = "root";
- // $dbpassword = "";
- $dbpassword = "run3scap3";
- $link = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbusername,$dbpassword);
- foreach ($data['stations'] as $key => $st) {
- if(empty($st['Station MAC'])){
- echo "failed, no MAC\n";
- break;
- }
- if(empty($st['BSSID'])){
- $st['BSSID'] = "";
- }
- if(empty($st['Probed ESSIDs'])){
- $st['Probed ESSIDs'] = "";
- }
- $statement = $link->prepare("INSERT INTO stations(MAC,firstseen,lastseen,BSSID,ESSID)
- VALUES(:MAC,:firstseen,:lastseen,:BSSID,:ESSID)");
- $statement->execute(array(
- "MAC" => $st['Station MAC'],
- "firstseen" => $st['First time seen'],
- "lastseen" => $st['Last time seen'],
- "BSSID" => $st['BSSID'],
- "ESSID" => $st['Probed ESSIDs'],
- ));
- echo "inserted: " . $st['Station MAC'] . "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement