Skip to content

Instantly share code, notes, and snippets.

@ConnorMcF
Created November 25, 2015 21:57
Show Gist options
  • Save ConnorMcF/fc5d3a789125a2909fd0 to your computer and use it in GitHub Desktop.
Save ConnorMcF/fc5d3a789125a2909fd0 to your computer and use it in GitHub Desktop.
<?php
require('../class/ratelimiter.php');
$rateLimiter = new RateLimiter(new Memcached(), $_SERVER["REMOTE_ADDR"],"registration");
try {
// allow a maximum of 100 requests for the IP in 5 minutes
$rateLimiter->limitRequestsInMinutes(1, 1);
} catch (RateExceededException $e) {
header("HTTP/1.0 529 Too Many Requests");
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment