PluginProbe
The WP Remote WordPress Plugin / 4.79
The WP Remote WordPress Plugin v4.79
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
← All changes | account.php +30 -4 5.164.79 View file →
@@ -5,11 +5,12 @@
5 5 class WPRAccount {
6 6 public $settings;
7 7 public $public;
8 8 public $secret;
9 + public $sig_match;
9 10 public static $api_public_key = 'bvApiPublic';
10 11 public static $accounts_list = 'bvAccountsList';
11 -
12 +
12 13 public function __construct($settings, $public, $secret) {
13 14 $this->settings = $settings;
14 15 $this->public = $public;
15 16 $this->secret = $secret;
@@ -108,10 +109,9 @@
108 109 public static function accountsByPattern($settings, $search_key, $search_pattern) {
109 110 $accounts = self::allAccounts($settings);
110 111 $accounts_by_pattern = array();
111 112 foreach ($accounts as $pubkey => $value) {
112 - if (array_key_exists($search_key, $value) &&
113 - WPRHelper::safePregMatch($search_pattern, $value[$search_key]) == 1) {
113 + if (array_key_exists($search_key, $value) && preg_match($search_pattern, $value[$search_key]) == 1) {
114 114 $accounts_by_pattern[$pubkey] = $value;
115 115 }
116 116 }
117 117 return $accounts_by_pattern;
@@ -158,10 +158,36 @@
158 158 }
159 159
160 160 public function info() {
161 161 return array(
162 - "public" => substr($this->public, 0, 6)
162 + "public" => substr($this->public, 0, 6),
163 + "sigmatch" => substr($this->sig_match, 0, 6)
163 164 );
165 + }
166 +
167 + public static function getSigMatch($request, $secret) {
168 + $method = $request->method;
169 + $time = $request->time;
170 + $version = $request->version;
171 + if ($request->is_sha1) {
172 + $sig_match = sha1($method.$secret.$time.$version);
173 + } else {
174 + $sig_match = md5($method.$secret.$time.$version);
175 + }
176 + return $sig_match;
177 + }
178 +
179 + public function authenticate($request) {
180 + $time = $request->time;
181 + if ($time < intval($this->settings->getOption('bvLastRecvTime')) - 300) {
182 + return false;
183 + }
184 + $this->sig_match = self::getSigMatch($request, $this->secret);
185 + if ($this->sig_match !== $request->sig) {
186 + return false;
187 + }
188 + $this->settings->updateOption('bvLastRecvTime', $time);
189 + return 1;
164 190 }
165 191
166 192 public function updateInfo($info) {
167 193 $accounts = self::allAccounts($this->settings);