/**
  * Creates an attempt
  *
  * @access public
  * @return true
  */
 public function addAttempt()
 {
     $timestamp = date("Y-m-d H:i:s");
     $ip = substr(Yii::app()->request->getUserHostAddress(), 0, 40);
     $row = $this->findByAttributes(array('ip' => $ip));
     if ($row !== null) {
         $row->number_attempts = $row->number_attempts + 1;
         $row->last_attempt = $timestamp;
         $row->save();
     } else {
         $record = new FailedLoginAttempt();
         $record->ip = $ip;
         $record->number_attempts = 1;
         $record->last_attempt = $timestamp;
         $record->save();
     }
     return true;
 }