コード例 #1
0
 /**
  * Delete cache entries older than TTL
  *
  * @param string $ttl  Lifetime of message cache entries
  */
 function expunge($ttl)
 {
     // get expiration timestamp
     $ts = get_offset_time($ttl, -1);
     $this->db->query("DELETE FROM " . $this->db->table_name('cache_messages') . " WHERE changed < " . $this->db->fromunixtime($ts));
     $this->db->query("DELETE FROM " . $this->db->table_name('cache_index') . " WHERE changed < " . $this->db->fromunixtime($ts));
     $this->db->query("DELETE FROM " . $this->db->table_name('cache_thread') . " WHERE changed < " . $this->db->fromunixtime($ts));
 }
コード例 #2
0
ファイル: rcube_user.php プロジェクト: jimjag/roundcubemail
 /**
  * Update user's failed_login timestamp and counter
  */
 function failed_login()
 {
     if ($this->ID && ($rate = (int) $this->rc->config->get('login_rate_limit', 3))) {
         if (empty($this->data['failed_login'])) {
             $failed_login = new DateTime('now');
             $counter = 1;
         } else {
             $failed_login = new DateTime($this->data['failed_login']);
             $threshold = new DateTime('- 60 seconds');
             if ($failed_login < $threshold) {
                 $failed_login = new DateTime('now');
                 $counter = 1;
             }
         }
         $this->db->query("UPDATE " . $this->db->table_name('users', true) . " SET `failed_login` = " . $this->db->fromunixtime($failed_login->format('U')) . ", `failed_login_counter` = " . ($counter ?: "`failed_login_counter` + 1") . " WHERE `user_id` = ?", $this->ID);
     }
 }