Add session IP address logging

This commit is contained in:
Skylar Ittner 2017-06-09 13:26:54 -06:00
parent 8cc0315cf7
commit f0101aaea2
3 changed files with 4 additions and 2 deletions

View File

@ -28,7 +28,7 @@ switch ($VARS['action']) {
$scrambled["real"][] = $a['aid']; $scrambled["real"][] = $a['aid'];
$scrambled["fake"][] = substr(hash("md5", mt_rand()), 0, 20); $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(); $sid = $database->id();
$scrambled_insert = []; $scrambled_insert = [];
for ($i = 0; $i < count($scrambled['real']); $i++) { for ($i = 0; $i < count($scrambled['real']); $i++) {

Binary file not shown.

View File

@ -1,5 +1,5 @@
-- MySQL Script generated by MySQL Workbench -- MySQL Script generated by MySQL Workbench
-- Fri 09 Jun 2017 03:48:51 AM MDT -- Fri 09 Jun 2017 01:26:04 PM MDT
-- Model: New Model Version: 1.0 -- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering -- MySQL Workbench Forward Engineering
@ -38,6 +38,7 @@ CREATE TABLE IF NOT EXISTS `captcheck`.`sessions` (
`aid` INT NOT NULL, `aid` INT NOT NULL,
`expired` TINYINT(1) NOT NULL DEFAULT 0, `expired` TINYINT(1) NOT NULL DEFAULT 0,
`timestamp` DATETIME NOT NULL, `timestamp` DATETIME NOT NULL,
`ipaddr` VARCHAR(45) NULL,
PRIMARY KEY (`sid`), PRIMARY KEY (`sid`),
UNIQUE INDEX `sid_UNIQUE` (`sid` ASC), UNIQUE INDEX `sid_UNIQUE` (`sid` ASC),
INDEX `fk_sessions_answers1_idx` (`aid` 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'); INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (30, 'gear', 'cog');
COMMIT; COMMIT;