| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Handles interactions with the database for quarantined files. | |
| 3 | + * Model for the unlock out table. | |
| 4 | 4 | * |
| 5 | 5 | * @package WP_Defender\Model |
| 6 | 6 | */ |
| 7 | 7 | |
| @@ -90,8 +90,26 @@ | ||
| 90 | 90 | return $this->save(); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | + * Checks whether a pending unlock request already exists. | |
| 95 | + * | |
| 96 | + * @param string $ip The IP address to check. | |
| 97 | + * @param string $email The email address to check. | |
| 98 | + * | |
| 99 | + * @return bool | |
| 100 | + */ | |
| 101 | + public static function has_pending_request( $ip, $email ): bool { | |
| 102 | + $model = self::get_orm()->get_repository( self::class ) | |
| 103 | + ->where( 'ip', $ip ) | |
| 104 | + ->where( 'email', $email ) | |
| 105 | + ->where( 'status', self::STATUS_PENDING ) | |
| 106 | + ->first(); | |
| 107 | + | |
| 108 | + return is_object( $model ); | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 94 | 112 | * Remove data by given data. |
| 95 | 113 | * |
| 96 | 114 | * @param int $timestamp The timestamp to compare against. |
| 97 | 115 | * @param int $limit The maximum number of records to delete. |
| @@ -131,8 +149,9 @@ | ||
| 131 | 149 | |
| 132 | 150 | $model = $orm->get_repository( self::class ) |
| 133 | 151 | ->where( 'id', $id ) |
| 134 | 152 | ->where( 'email', $email ) |
| 153 | + ->where( 'status', self::STATUS_PENDING ) | |
| 135 | 154 | ->first(); |
| 136 | 155 | |
| 137 | 156 | if ( ! is_object( $model ) ) { |
| 138 | 157 | return ''; |