Skip to content

Commit

Permalink
bug \#1119 : prevent mass manual spam from single client
Browse files Browse the repository at this point in the history
  • Loading branch information
ihptru committed Oct 6, 2011
1 parent 8b73d05 commit 0e2336f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion create.php
Expand Up @@ -7,7 +7,7 @@
$schema = 'CREATE TABLE IF NOT EXISTS servers (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255),
address varchar(255) UNIQUE, players integer, state integer, ts integer, map varchar(255), mods varchar(255))';
$db->query($schema);
echo "Connection to DB closed.\n";
echo "Connection to DB closed.\n";
$db = null;
}
catch (PDOException $e)
Expand Down
15 changes: 13 additions & 2 deletions ping.php
Expand Up @@ -21,8 +21,19 @@ function check_port($ip, $port)
header( 'Content-type: text/plain' );
try
{
$db = new PDO('sqlite:db/openra.db');
$ip = $_SERVER['REMOTE_ADDR'];
$ip = $_SERVER['REMOTE_ADDR'];

$db = new PDO('sqlite:db/openra.db');

$select = $db->prepare("SELECT COUNT(address) FROM servers WHERE address LIKE '".$ip.":%'");

$select->execute();
$count = (int)$select->fetchColumn();
if ( $count > 10 )
{
exit();
}

$port = $_REQUEST['port'];
$addr = $ip . ':' . $port;
$name = urldecode( $_REQUEST['name'] );
Expand Down

0 comments on commit 0e2336f

Please sign in to comment.