summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-05-19 21:24:17 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-05-19 21:24:17 +1000
commitae06722d3f8153ea6d3fb5d3f1b2a1e329686ae1 (patch)
tree3ff1e17a689347c03bb0e5849ac7b5433d58da40 /inc
parent5ccddb2e63d8f715e82b685e23b545c44899df84 (diff)
cache mutes with memcached
Diffstat (limited to 'inc')
-rw-r--r--inc/functions.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 5424683c..d9bd681e 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -727,14 +727,6 @@
}
function checkRobot($body) {
- /* CREATE TABLE `robot` (
-`hash` VARCHAR( 40 ) NOT NULL COMMENT 'SHA1'
-) ENGINE = INNODB; */
- /* CREATE TABLE `mutes` (
-`ip` VARCHAR( 15 ) NOT NULL ,
-`time` INT NOT NULL
-) ENGINE = MYISAM ; */
-
$body = makerobot($body);
$query = prepare("SELECT 1 FROM `robot` WHERE `hash` = :hash LIMIT 1");
$query->bindValue(':hash', $body);
@@ -786,7 +778,14 @@
}
function checkMute() {
- global $config;
+ global $config, $memcached;
+
+ if($config['memcached']['enabled']) {
+ // Cached mute?
+ if(($mute = $memcached->get("mute_${_SERVER['REMOTE_ADDR']}")) && ($mutetime = $memcached->get("mutetime_${_SERVER['REMOTE_ADDR']}"))) {
+ error(sprintf($config['error']['youaremuted'], $mute['time'] + $mutetime - time()));
+ }
+ }
$mutetime = muteTime();
if($mutetime > 0) {
@@ -801,6 +800,10 @@
}
if($mute['time'] + $mutetime > time()) {
+ if($config['memcached']['enabled']) {
+ $memcached->set("mute_${_SERVER['REMOTE_ADDR']}", $mute, $mute['time'] + $mutetime);
+ $memcached->set("mutetime_${_SERVER['REMOTE_ADDR']}", $mutetime, $mute['time'] + $mutetime);
+ }
// Not expired yet
error(sprintf($config['error']['youaremuted'], $mute['time'] + $mutetime - time()));
} else {