PluginProbe
The WP Remote WordPress Plugin / 5.68
The WP Remote WordPress Plugin v5.68
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
wpremote / recover.php

recover.php in The WP Remote WordPress Plugin 5.68, at recover.php

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit;
3 if (!class_exists('WPRRecover')) :
4 class WPRRecover {
5 public static $default_secret_key = 'bv_default_secret_key';
6
7 public static function defaultSecret($settings) {
8 $secret = self::getDefaultSecret($settings);
9 if (empty($secret)) {
10 $secret = WPRRecover::refreshDefaultSecret($settings);
11 }
12 return $secret;
13 }
14
15 public static function refreshDefaultSecret($settings) {
16 $key_details = array();
17 $key_details["key"] = WPRAccount::randString(32);
18 $key_details["expires_at"] = time() + (24 * 60 * 60);
19
20 $settings->updateOption(self::$default_secret_key, $key_details);
21
22 return $key_details["key"];
23 }
24
25
26 public static function deleteDefaultSecret($settings) {
27 $settings->deleteOption(self::$default_secret_key);
28 }
29
30 public static function getDefaultSecret($settings) {
31 $key_details = $settings->getOption(self::$default_secret_key);
32
33 if (is_array($key_details) && $key_details["expires_at"] > time()) {
34 return $key_details["key"];
35 }
36
37 return null;
38 }
39
40 public static function getSecretStatus($settings) {
41 $key_details = $settings->getOption(self::$default_secret_key);
42 $status = 'ACTIVE';
43 if (!is_array($key_details)) {
44 $status = 'DELETED';
45 } elseif ($key_details["expires_at"] <= time()) {
46 $status = 'EXPIRED';
47 }
48
49 return $status;
50 }
51
52 public static function validate($key) {
53 return $key && strlen($key) >= 32;
54 }
55
56 public static function find($settings, $pubkey) {
57 if (!self::validate($pubkey)) {
58 return null;
59 }
60
61 $secret = self::getDefaultSecret($settings);
62 if (!self::validate($secret)) {
63 return null;
64 }
65
66 $account = new WPRAccount($settings, $pubkey, $secret);
67 return $account;
68 }
69 }
70 endif;