Added some protection from bot registrations.
authorNik Okuntseff <support@anuko.com>
Sat, 24 Mar 2018 11:22:56 +0000 (11:22 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 24 Mar 2018 11:22:56 +0000 (11:22 +0000)
WEB-INF/lib/ttRegistrator.class.php
WEB-INF/templates/footer.tpl

index 7082e6b..3c424f4 100644 (file)
@@ -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;
+  }
 }
index 223a757..4beb895 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.17.68.4151 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.69.4152 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>