summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2013-03-19 14:49:34 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2013-03-21 22:26:46 +0100
commit5660816ea079585c70583a9e470e22c4cf66c022 (patch)
tree298c188eeef5d53a2dcd266eab4607f11bb8c63d
parentde39a712b040d4ce51dc4eb2f4e2ef74a7a9013c (diff)
downloadaur-5660816ea079585c70583a9e470e22c4cf66c022.tar.gz
aur-5660816ea079585c70583a9e470e22c4cf66c022.tar.xz
Save last login IP address
Save the IP address used for the last login in the "Users" table. This makes it a bit easier to create IP ban lists for spammers without looking at web server logs. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r--UPGRADING10
-rw-r--r--support/schema/aur-schema.sql1
-rw-r--r--web/lib/acctfuncs.inc.php3
3 files changed, 13 insertions, 1 deletions
diff --git a/UPGRADING b/UPGRADING
index c39330b2..9c054672 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -1,6 +1,16 @@
Upgrading
=========
+From 2.1.0 to 2.2.0
+-------------------
+
+1. Add new "Users" table login IP address column:
+
+----
+ALTER TABLE Users
+ ADD COLUMN LastLoginIPAddress INTEGER UNSIGNED NOT NULL DEFAULT 0;
+----
+
From 2.0.0 to 2.1.0
-------------------
diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index d55cf1af..fab40d63 100644
--- a/support/schema/aur-schema.sql
+++ b/support/schema/aur-schema.sql
@@ -34,6 +34,7 @@ CREATE TABLE Users (
PGPKey VARCHAR(40) NULL DEFAULT NULL,
LastVoted BIGINT UNSIGNED NOT NULL DEFAULT 0,
LastLogin BIGINT UNSIGNED NOT NULL DEFAULT 0,
+ LastLoginIPAddress INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (ID),
UNIQUE (Username),
UNIQUE (Email),
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index b94c4c3e..21cc6c21 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -444,7 +444,8 @@ function try_login() {
}
if ($logged_in) {
- $q = "UPDATE Users SET LastLogin = UNIX_TIMESTAMP() ";
+ $q = "UPDATE Users SET LastLogin = UNIX_TIMESTAMP(), ";
+ $q.= "LastLoginIPAddress = " . $dbh->quote(ip2long($_SERVER['REMOTE_ADDR'])) . " ";
$q.= "WHERE ID = '$userID'";
$dbh->exec($q);