X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttRegistrator.class.php;h=3c424f4864b22f31d7356dcba874d51d0b20ae47;hb=e0ec0364d761e2dff5a7c0032f04ec1dbae50980;hp=7082e6bc2412cec3623873f6d57a0d3b2622bfdd;hpb=75b65e92b21d45e2b09fb12daef169fb214a7acd;p=timetracker.git diff --git a/WEB-INF/lib/ttRegistrator.class.php b/WEB-INF/lib/ttRegistrator.class.php index 7082e6bc..3c424f48 100644 --- a/WEB-INF/lib/ttRegistrator.class.php +++ b/WEB-INF/lib/ttRegistrator.class.php @@ -85,6 +85,12 @@ class ttRegistrator { global $i18n; + // Protection fom too many recent bot registrations from user IP. + if ($this->registeredRecently()) { + $this->err->add($i18n->get('error.access_denied')); + return false; + } + import('ttUserHelper'); if (ttUserHelper::getUserByLogin($this->login)) { // User login already exists. @@ -185,4 +191,22 @@ class ttRegistrator { return true; } + + // registeredRecently determines if we already have a successful recent registration from user IP. + // "recent" means "within the last minute" and is set in a query by the following condition: + // "and created > now() - interval 1 minute". Change if necessary. + function registeredRecently() { + $mdb2 = getConnection(); + + $ip_part = ' created_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']); + $sql = 'select created from tt_teams where '.$ip_part.' and created > now() - interval 1 minute'; + $res = $mdb2->query($sql); + if (is_a($res, 'PEAR_Error')) + return false; + $val = $res->fetchRow(); + if ($val) + return true; + + return false; + } }