"; $localip = $_POST['localip']; echo "localip: $localip
"; if(!isset($_POST['wifiboxid'])) echo "missing wifiboxid
"; $wifiboxid = $_POST['wifiboxid']; echo "wifiboxid: $wifiboxid
"; $remoteip = getenv('REMOTE_ADDR'); echo "remoteip: $remoteip
"; $timestamp = time(); echo "timestamp: $timestamp
"; $id = $remoteip.'/'.$wifiboxid; echo "id: $id
"; /*$statement = $db->prepare("INSERT INTO $table(remoteip, localip, wifiboxid, date) VALUES(:remoteip, :localip, :wifiboxid, FROM_UNIXTIME(:timestamp))"); $statement->execute(array( ':remoteip' => $remoteip, ':localip' => $localip, ':wifiboxid' => $wifiboxid, ':timestamp' => $timestamp ));*/ /*$statement = $db->prepare( "UPDATE $table " . "SET localip = :localip, " . " date = FROM_UNIXTIME(:timestamp)" . "WHERE remoteip=:remoteip AND " . " wifiboxid=:wifiboxid"); $statement->execute(array( ':remoteip' => $remoteip, ':localip' => $localip, ':wifiboxid' => $wifiboxid, ':timestamp' => $timestamp ));*/ /*$statement = $db->prepare("INSERT INTO $table(id,remoteip, localip, wifiboxid, date) VALUES(:id,:remoteip, :localip, :wifiboxid, FROM_UNIXTIME(:timestamp))"); $statement->execute(array( ':id' => $id, ':remoteip' => $remoteip, ':localip' => $localip, ':wifiboxid' => $wifiboxid, ':timestamp' => $timestamp ));*/ $statement = $db->prepare( "REPLACE INTO $table " . "SET id = :id, " . " remoteip = :remoteip, " . " localip = :localip, " . " wifiboxid = :wifiboxid, " . " date = FROM_UNIXTIME(:timestamp)"); $statement->execute(array( ':id' => $id, ':remoteip' => $remoteip, ':localip' => $localip, ':wifiboxid' => $wifiboxid, ':timestamp' => $timestamp)); // Remove old signins $hourago = time() - 60*60; echo "hourago: $hourago (time: ".time().")
"; $statement = $db->prepare("DELETE FROM $table WHERE date < FROM_UNIXTIME(:hourago)"); $statement->execute(array( ':hourago' => $hourago)); ?>