Add identity table #11
3 changed files with 14 additions and 14 deletions
|
@ -76,7 +76,7 @@ function lockAction($action) {
|
|||
$replace_id = -1;
|
||||
|
||||
//first find records with ip/action
|
||||
$result = databaseQuery("SELECT id, time, num FROM gpgmw_locks WHERE ip = ? AND action = ?", array($ip, $action), true);
|
||||
$result = databaseQuery("SELECT id, time, num FROM lacre_locks WHERE ip = ? AND action = ?", array($ip, $action), true);
|
||||
if($row = $result->fetch()) {
|
||||
$id = $row['id'];
|
||||
$time = $row['time'];
|
||||
|
@ -92,10 +92,10 @@ function lockAction($action) {
|
|||
//increase the count; maybe initiate an OVERLOAD
|
||||
$count = $count + 1;
|
||||
if($count >= $lock_count_overload[$action]) {
|
||||
databaseQuery("UPDATE gpgmw_locks SET num = '-1', time = ? WHERE ip = ?", array(time(), $ip));
|
||||
databaseQuery("UPDATE lacre_locks SET num = '-1', time = ? WHERE ip = ?", array(time(), $ip));
|
||||
return false;
|
||||
} else {
|
||||
databaseQuery("UPDATE gpgmw_locks SET num = ?, time = ? WHERE ip = ?", array($count, time(), $ip));
|
||||
databaseQuery("UPDATE lacre_locks SET num = ?, time = ? WHERE ip = ?", array($count, time(), $ip));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -107,16 +107,16 @@ function lockAction($action) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
databaseQuery("INSERT INTO gpgmw_locks (ip, time, action, num) VALUES (?, ?, ?, '1')", array($ip, time(), $action));
|
||||
databaseQuery("INSERT INTO lacre_locks (ip, time, action, num) VALUES (?, ?, ?, '1')", array($ip, time(), $action));
|
||||
}
|
||||
|
||||
if($replace_id != -1) {
|
||||
databaseQuery("UPDATE gpgmw_locks SET num = '1', time = ? WHERE id = ?", array(time(), $replace_id));
|
||||
databaseQuery("UPDATE lacre_locks SET num = '1', time = ? WHERE id = ?", array(time(), $replace_id));
|
||||
}
|
||||
|
||||
//some housekeeping
|
||||
$delete_time = time() - $lock_time_max;
|
||||
databaseQuery("DELETE FROM gpgmw_locks WHERE time <= ?", array($delete_time));
|
||||
databaseQuery("DELETE FROM lacre_locks WHERE time <= ?", array($delete_time));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,17 +42,17 @@ function requestPGP($email, $key) {
|
|||
}
|
||||
|
||||
//housekeeping
|
||||
databaseQuery("DELETE FROM gpgmw_keys WHERE time < DATE_SUB(NOW(), INTERVAL 48 HOUR) AND confirm != '' AND status = 0");
|
||||
databaseQuery("DELETE FROM lacre_keys WHERE time < DATE_SUB(NOW(), INTERVAL 48 HOUR) AND confirm != '' AND status = 0");
|
||||
|
||||
//if we already have an unaccepted key for this user, only replace if one day has elapsed since the last request
|
||||
// this may prevent spam
|
||||
$result = databaseQuery("SELECT HOUR(TIMEDIFF(time, NOW())), id FROM gpgmw_keys WHERE email = ? AND status = 0", array($email));
|
||||
$result = databaseQuery("SELECT HOUR(TIMEDIFF(time, NOW())), id FROM lacre_keys WHERE email = ? AND status = 0", array($email));
|
||||
|
||||
if($row = $result->fetch()) {
|
||||
if($row[0] < 24) {
|
||||
return $lang['submit_error_alreadyqueue'];
|
||||
} else {
|
||||
databaseQuery('DELETE FROM gpgmw_keys WHERE id = ?', array($row[1]));
|
||||
databaseQuery('DELETE FROM lacre_keys WHERE id = ?', array($row[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ function requestPGP($email, $key) {
|
|||
return $lang['submit_error_emailfail'];
|
||||
}
|
||||
|
||||
databaseQuery("INSERT INTO gpgmw_keys (email, publickey, confirm) VALUES (?, ?, ?)", array($email, $key, $confirm));
|
||||
databaseQuery("INSERT INTO lacre_keys (email, publickey, confirm) VALUES (?, ?, ?)", array($email, $key, $confirm));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,10 @@ function confirmPGP($email, $confirm) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$result = databaseQuery("SELECT id FROM gpgmw_keys WHERE confirm = ? AND email = ?", array($confirm, $email));
|
||||
$result = databaseQuery("SELECT id FROM lacre_keys WHERE confirm = ? AND email = ?", array($confirm, $email));
|
||||
|
||||
if($row = $result->fetch()) {
|
||||
databaseQuery("UPDATE gpgmw_keys SET confirm = '' WHERE id = ?", array($row[0]));
|
||||
databaseQuery("UPDATE lacre_keys SET confirm = '' WHERE id = ?", array($row[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
-- is set to 1 after a public key with (confirm='', status=0) has been imported
|
||||
-- is set to 2 if a key should be deleted (will be deleted based on email address)
|
||||
-- publickey is the ASCII-armored PGP public key; can be cleared to save space if status > 0
|
||||
CREATE TABLE gpgmw_keys (
|
||||
CREATE TABLE lacre_keys (
|
||||
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
email VARCHAR(256),
|
||||
publickey TEXT,
|
||||
|
@ -14,7 +14,7 @@ CREATE TABLE gpgmw_keys (
|
|||
);
|
||||
|
||||
-- see include/lock.php for documentation
|
||||
CREATE TABLE gpgmw_locks (
|
||||
CREATE TABLE lacre_locks (
|
||||
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
ip VARCHAR(16),
|
||||
time INT,
|
||||
|
|
Loading…
Reference in a new issue