]> git.mjollnir.org Git - s9y.git/commitdiff
Fix spamblock table generation, thanks to boris
authorgarvinhicking <garvinhicking>
Mon, 13 Aug 2007 07:59:46 +0000 (07:59 +0000)
committergarvinhicking <garvinhicking>
Mon, 13 Aug 2007 07:59:46 +0000 (07:59 +0000)
plugins/serendipity_event_spamblock/serendipity_event_spamblock.php

index 5d8194905f6a4c253911fbd90a45987f96e27347..57b1768cb6deacdd7228e26830122b5537cde80c 100644 (file)
@@ -546,17 +546,12 @@ var $filter_defaults;
         return $ret;
     }
 
-    function checkScheme($maxVersion) {
+    function checkScheme() {
         global $serendipity;
 
-        $version = $this->get_config('version', '1.1');
-
-        if ($version != '1.0') {
-            $q   = "CREATE TABLE {$serendipity['dbPrefix']}spamblock_htaccess (
-                          timestamp int(10) {UNSIGNED} default null,
-                          ip varchar(15))";
-            $sql = serendipity_db_schema_import($q);
-        } elseif ($version != $maxVersion) {
+        $dbversion = $this->get_config('dbversion', '1');
+        
+        if ($dbversion == '1') {
             $q   = "CREATE TABLE {$serendipity['dbPrefix']}spamblocklog (
                           timestamp int(10) {UNSIGNED} default null,
                           type varchar(255),
@@ -585,7 +580,10 @@ var $filter_defaults;
                           ip varchar(15))";
             $sql = serendipity_db_schema_import($q);
 
-            $this->set_config('version', $maxVersion);
+            $q   = "CREATE INDEX kshtaidx ON {$serendipity['dbPrefix']}spamblock_htaccess (timestamp);";
+            $sql = serendipity_db_schema_import($q);
+
+            $this->set_config('dbversion', '2');
         }
 
         return true;
@@ -718,9 +716,7 @@ var $filter_defaults;
 
                 case 'frontend_saveComment':
                     if (!is_array($eventData) || serendipity_db_bool($eventData['allow_comments'])) {
-                        if ($this->get_config('logtype', 'db') == 'db' && $this->get_config('version') != $bag->get('version')) {
-                            $this->checkScheme($bag->get('version'));
-                        }
+                        $this->checkScheme();
 
                         $serendipity['csuccess'] = 'true';
                         $logfile = $this->logfile = $this->get_config('logfile', $serendipity['serendipityPath'] . 'spamblock.log');