Browse Source

Add session IP address logging

tags/v0.2
Skylar Ittner 2 years ago
parent
commit
f0101aaea2
3 changed files with 4 additions and 1 deletions
  1. 1
    1
      api.php
  2. BIN
      database.mwb
  3. 3
    0
      database.sql

+ 1
- 1
api.php View File

@@ -28,7 +28,7 @@ switch ($VARS['action']) {
$scrambled["real"][] = $a['aid'];
$scrambled["fake"][] = substr(hash("md5", mt_rand()), 0, 20);
}
$database->insert("sessions", ["skey" => $skey, "aid" => $correct_answer['aid'], "expired" => 0, "#timestamp" => "NOW()"]);
$database->insert("sessions", ["skey" => $skey, "aid" => $correct_answer['aid'], "expired" => 0, "#timestamp" => "NOW()", "ipaddr" => getUserIP()]);
$sid = $database->id();
$scrambled_insert = [];
for ($i = 0; $i < count($scrambled['real']); $i++) {

BIN
database.mwb View File


+ 3
- 0
database.sql View File

@@ -1,5 +1,5 @@
-- MySQL Script generated by MySQL Workbench
-- Fri 09 Jun 2017 01:26:04 PM MDT
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering

@@ -38,6 +38,7 @@ CREATE TABLE IF NOT EXISTS `captcheck`.`sessions` (
`aid` INT NOT NULL,
`expired` TINYINT(1) NOT NULL DEFAULT 0,
`timestamp` DATETIME NOT NULL,
`ipaddr` VARCHAR(45) NULL,
PRIMARY KEY (`sid`),
UNIQUE INDEX `sid_UNIQUE` (`sid` ASC),
INDEX `fk_sessions_answers1_idx` (`aid` ASC),
@@ -112,3 +113,4 @@ INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (29, 'truck',
INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (30, 'gear', 'cog');

COMMIT;


Loading…
Cancel
Save