Ignore:
Timestamp:
May 28, 2014, 11:00:26 PM (10 years ago)
Author:
chronos
Message:
  • Added: Better handling of repeater false referrer links. Now use manual BlackList table for checking which IP source is blocked.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Referrer/Referrer.php

    r805 r811  
    4141      {
    4242        $IP = GetRemoteAddress();
    43        
    44         // Check if client IP is not blocked as spam source
    45         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Referrer` WHERE `LastIP` = "'.$IP.'" AND (`Visible` = 0)');
     43
     44        // Check if client IP is not blaclisted as spam source. If yes then add new referrer as invisible
     45        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `BlackList` WHERE `IP` = "'.$IP.'"');
    4646        $DbRow = $DbResult->fetch_row();
    47         if($DbRow[0] == 0) $Visible = '1';
    48           else $Visible = '0';
     47        if($DbRow[0] == 0)
     48        {
     49          $Visible = '1';
     50          $Description = '';
     51        } else
     52        {
     53          $Visible = '0';
     54          $Description = 'Spam';
     55        }
    4956
    5057        // Check if host name is already stored and need just to update hit counter
     
    5562          $this->System->Database->query('UPDATE `Referrer` SET `Hits` = `Hits` + 1, `DateLast` = NOW(), `LastURL` = "'.
    5663           addslashes($Referrer).'", `LastIP` = "'.$IP.'" WHERE `Id` = '.$DbRow['Id']);
    57         } else $this->System->Database->query('INSERT INTO `Referrer` (`Web`, `DateFirst`, `DateLast`, `LastURL`, `Hits`, `LastIP`, `Visible`) '.
    58                   'VALUES ("'.$HostName.'", NOW(), NOW( ), "'.addslashes($Referrer).'", 1, "'.$IP.'", '.$Visible.')');
     64        } else
     65        {
     66          $this->System->Database->query('INSERT INTO `Referrer` (`Web`, `DateFirst`, `DateLast`, `LastURL`, `Hits`, `LastIP`, `Visible`, `Description`) '.
     67                  'VALUES ("'.$HostName.'", NOW(), NOW( ), "'.addslashes($Referrer).'", 1, "'.$IP.'", '.$Visible.', "'.$Description.'")');
     68        }
    5969      }
    6070    }
     
    177187          $Item = $DbResult->fetch_assoc();
    178188          $this->Database->update('Referrer', 'Id='.$_GET['id'], array('Visible' => 0, 'Description' => 'Spam'));
     189          $DbResult2 = $this->Database->select('BlackList', '*', 'IP="'.$Item['LastIP'].'"');
     190          if($DbResult2->num_rows == 0)
     191          {
     192            $this->Database->insert('BlackList', array('Time' => 'NOW()', 'IP' => $Item['LastIP']));
     193          }
    179194          $Output = ShowMessage(T('Set as spam'), MESSAGE_CRITICAL);
    180195          $Output .= $this->ShowList();
Note: See TracChangeset for help on using the changeset viewer.