Ejemplo n.º 1
0
 private boolean banExists(Ban ban) {
   DatabaseRow[] rows = getTable().getFilteredRows("name", ban.getSubject());
   if (rows == null || rows.length == 0) {
     return false;
   }
   return true;
 }
Ejemplo n.º 2
0
 /**
  * Update a ban.
  *
  * @param ban
  */
 public void updateBan(Ban ban) {
   Canary.db().prepare();
   DatabaseRow[] rows = getTable().getFilteredRows("name", ban.getSubject());
   // It's only this one
   if (rows != null && rows.length > 0) {
     DatabaseRow row = rows[0];
     row.setStringCell("reason", ban.getReason());
     row.setStringCell("ip", ban.getIp());
     row.setLongCell("timestamp", ban.getTimestamp());
   }
   Canary.db().execute();
 }
Ejemplo n.º 3
0
 /**
  * Add a new Ban to the list of bans.
  *
  * @param ban
  */
 public void addBan(Ban ban) {
   if (banExists(ban)) {
     updateBan(ban);
     return;
   }
   Canary.db().prepare();
   DatabaseRow newData = getTable().addRow();
   newData.setStringCell("name", ban.getSubject());
   newData.setLongCell("timestamp", ban.getTimestamp());
   newData.setStringCell("reason", ban.getReason());
   newData.setStringCell("ip", ban.getIp());
   Canary.db().execute();
 }