Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Tools/BanPrivateID.php

From BrandMeister Wiki

Concept

Latest releases of BrandMaster has some logic to temporary ban Private IDs. Real-time logic placed at Script/Modules/Filter.lua

The idea is very simple: Memcached has functionality for timed storage. We need to put any value to cache with following syntax:

Ban-<private ID>

BanPrivateID.php

<?php

  unset($number);
  unset($interval);

  if (isset($_SERVER) &&
      array_key_exists("number", $_GET) &&
      array_key_exists("interval", $_GET))
  {
    $number = intval($_GET["number"]);
    $interval = intval($_GET["interval"]);
  }

  if ((php_sapi_name() == "cli") &&
      ($argc >= 3))
  {
    $number = intval($argv[1]);
    $interval = intval($argv[2]);
  }

  if (isset($number))
  {
    $cache = new Memcache();
    $cache->connect("localhost", 11211);
    $cache->set("Ban-$number", 1, 0, $interval);
  }

?>