PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 2.2
Vimeography: Vimeo Video Gallery WordPress Plugin v2.2
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
← All changes | lib/update.php +24 -129 trunk2.2 View file →
@@ -70,12 +70,8 @@
70 70
71 71 // Add activation key message for plugins with missing keys
72 72 add_action( 'load-plugins.php', array( $this, 'vimeography_check_for_missing_activation_keys' ) );
73 73
74 - // Force EDD Software Licensing to ignore the X-Accel-Redirect header
75 - // (évite les problèmes de téléchargement de mises à jour derrière certains serveurs).
76 - add_filter( 'edd_ignore_x_accel_redirect', '__return_true' );
77 -
78 74 }
79 75
80 76 /**
81 77 * Activate the license key
@@ -91,117 +87,56 @@
91 87 if ( $this->vimeography_check_if_activation_key_exists( $key ) ) {
92 88 return;
93 89 }
94 90
95 - // Lookup the product name associated with this license key before
96 - // attempting activation. This allows activate_license to succeed even on
97 - // EDD servers that require item_name (i.e. without EDD_BYPASS_NAME_CHECK).
98 - $item_name = $this->_vimeography_lookup_item_name( $key );
99 -
100 91 // Data to send to the API
101 92 $api_params = array(
102 93 'edd_action' => 'activate_license',
103 94 'license' => $key,
95 + //'item_name' => urlencode( $this->item_name ), // the name of our product in EDD **IMPORTANT need to set EDD_BYPASS_NAME_CHECK on vimeography.com to true if omitting
104 96 'url' => urlencode( home_url() ),
105 97 );
106 98
107 - if ( ! empty( $item_name ) ) {
108 - $api_params['item_name'] = urlencode( $item_name );
109 - }
110 -
111 99 // Call the API
112 100 $response = wp_remote_get(
113 101 add_query_arg( $api_params, $this->_endpoint),
114 102 array(
115 103 'timeout' => 15,
116 - 'sslverify' => true
104 + 'sslverify' => false
117 105 )
118 106 );
119 107
120 108 // Make sure there are no errors
121 109 if ( is_wp_error( $response ) ) {
122 - throw new Exception( wp_kses_post(__('The HTTP Request failed: ' . $response->get_error_message(), 'vimeography') ));
110 + throw new Exception( __('The HTTP Request failed: ' . $response->get_error_message(), 'vimeography') );
123 111 }
124 112
125 113 // Decode license data
126 114 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
127 115
128 - if ( ! is_object( $license_data ) ) {
129 - throw new Exception( wp_kses_post(__('The license server returned an invalid response.', 'vimeography') ));
130 - }
131 -
132 - if ( ! empty( $license_data->success ) AND isset( $license_data->license ) AND $license_data->license === 'valid' ) {
116 + if ( $license_data->success AND $license_data->license == 'valid' ) {
133 117 $this->_vimeography_add_activation_key( $key, $license_data );
134 118 return TRUE;
135 119 } else {
136 - $error = isset( $license_data->error ) ? $license_data->error : '';
137 120 // Add failed message
138 - switch ($error) {
121 + switch ($license_data->error) {
139 122 case 'missing': case 'revoked':
140 - throw new Exception( wp_kses_post(__('That license key could not be found in our system.', 'vimeography') ));
123 + throw new Exception( __('That license key could not be found in our system.', 'vimeography') );
141 124 case 'no_activations_left':
142 - throw new Exception( wp_kses_post(__('You have reached the max number of sites that this license can be used on.', 'vimeography') ));
125 + throw new Exception( __('You have reached the max number of sites that this license can be used on.', 'vimeography') );
143 126 case 'expired':
144 - throw new Exception( wp_kses_post(__('The license key you entered has expired. Please visit http://vimeography.com to renew it.', 'vimeography') ));
127 + throw new Exception( __('The license key you entered has expired. Please visit http://vimeography.com to renew it.', 'vimeography') );
145 128 case 'key_mismatch':
146 - throw new Exception( wp_kses_post(__('The license key you entered does not match the one we have on file.', 'vimeography') ));
129 + throw new Exception( __('The license key you entered does not match the one we have on file.', 'vimeography') );
147 130 case 'license_not_activable':
148 - throw new Exception( wp_kses_post(__('Looks like you are trying to activate your bundle license. Please activate each of the products in your bundle separately by using their respective individual licenses.', 'vimeography') ));
131 + throw new Exception( __('Looks like you are trying to activate your bundle license. Please activate each of the products in your bundle separately by using their respective individual licenses.', 'vimeography') );
149 132 default:
150 - throw new Exception( wp_kses_post(__('Unknown error: ' . $error, 'vimeography') ));
133 + throw new Exception( __('Unknown error: ' . $license_data->error, 'vimeography') );
151 134 }
152 135 }
153 136 }
154 137
155 138 /**
156 - * Ask the Vimeography EDD endpoint which product is associated with a given
157 - * license key.
158 - *
159 - * Implementation note: the `check_license` endpoint does not return the
160 - * product name on Vimeography's server (item_name is empty). However, calling
161 - * `activate_license` *without* the `url` parameter triggers a `missing_url`
162 - * error response that includes both `item_name` and `vimeography_product_name`
163 - * in its payload — and does NOT consume an activation, since the request
164 - * aborts on the server before the site count is incremented.
165 - *
166 - * @access protected
167 - * @param string $key Normalized license key.
168 - * @return string Product name, or empty string if it could not be resolved.
169 - */
170 - protected function _vimeography_lookup_item_name( $key ) {
171 - $response = wp_remote_get(
172 - add_query_arg( array(
173 - 'edd_action' => 'activate_license',
174 - 'license' => $key,
175 - ), $this->_endpoint ),
176 - array(
177 - 'timeout' => 15,
178 - 'sslverify' => true,
179 - )
180 - );
181 -
182 - if ( is_wp_error( $response ) ) {
183 - return '';
184 - }
185 -
186 - $data = json_decode( wp_remote_retrieve_body( $response ) );
187 -
188 - if ( ! is_object( $data ) ) {
189 - return '';
190 - }
191 -
192 - if ( ! empty( $data->item_name ) ) {
193 - return $data->item_name;
194 - }
195 -
196 - if ( ! empty( $data->vimeography_product_name ) ) {
197 - return $data->vimeography_product_name;
198 - }
199 -
200 - return '';
201 - }
202 -
203 - /**
204 139 * Deactivate the license key
205 140 *
206 141 * @access public
207 142 * @return void
@@ -221,9 +156,9 @@
221 156 $response = wp_remote_get(
222 157 add_query_arg( $api_params, $this->_endpoint ),
223 158 array(
224 159 'timeout' => 15,
225 - 'sslverify' => true
160 + 'sslverify' => false
226 161 )
227 162 );
228 163
229 164 // Make sure there are no errors
@@ -236,10 +171,10 @@
236 171
237 172 // Remove the key even if deactivation fails
238 173 $this->_vimeography_remove_activation_key( $key );
239 174
240 - if ( ! is_object( $license_data ) || empty( $license_data->success ) ) {
241 - throw new Exception( wp_kses_post(__('That license key has been removed from your site, but could not be deactivated in our system.', 'vimeography')) );
175 + if ( ! $license_data->success ) {
176 + throw new Exception( __('That license key has been removed from your site, but could not be deactivated in our system.', 'vimeography') );
242 177 }
243 178 }
244 179
245 180 /**
@@ -260,9 +195,9 @@
260 195 $response = wp_remote_get(
261 196 add_query_arg( $api_params, $this->_endpoint ),
262 197 array(
263 198 'timeout' => 15,
264 - 'sslverify' => true
199 + 'sslverify' => false
265 200 )
266 201 );
267 202
268 203 // Make sure there are no errors
@@ -345,38 +280,16 @@
345 280 * @var $license_data array
346 281 * @return bool TRUE if successful, FALSE if failed
347 282 */
348 283 protected function _vimeography_add_activation_key( $key, $license_data ) {
349 - if ( ! is_object( $license_data ) ) {
350 - return FALSE;
351 - }
352 -
353 - $plugin_slug = isset( $license_data->vimeography_plugin_slug )
354 - ? sanitize_key( (string) $license_data->vimeography_plugin_slug )
355 - : '';
356 -
357 - if ( empty( $plugin_slug ) ) {
358 - return FALSE;
359 - }
360 -
361 284 $entry = new stdClass();
362 - $entry->activation_key = sanitize_text_field( (string) $key );
363 - $entry->plugin_name = $plugin_slug;
364 - $entry->product_name = isset( $license_data->vimeography_product_name )
365 - ? sanitize_text_field( (string) $license_data->vimeography_product_name )
366 - : '';
367 - $entry->expires = isset( $license_data->expires )
368 - ? sanitize_text_field( (string) $license_data->expires )
369 - : '';
370 - $entry->status = isset( $license_data->license )
371 - ? sanitize_key( (string) $license_data->license )
372 - : '';
373 - $entry->limit = isset( $license_data->license_limit )
374 - ? intval( $license_data->license_limit )
375 - : 0;
376 - $entry->activations_left = isset( $license_data->activations_left )
377 - ? intval( $license_data->activations_left )
378 - : 0;
285 + $entry->activation_key = $key;
286 + $entry->plugin_name = $license_data->vimeography_plugin_slug;
287 + $entry->product_name = $license_data->vimeography_product_name;
288 + $entry->expires = $license_data->expires;
289 + $entry->status = $license_data->license;
290 + $entry->limit = $license_data->license_limit;
291 + $entry->activations_left = $license_data->activations_left;
379 292
380 293 $this->_activation_keys[] = $entry;
381 294 return update_site_option('vimeography_activation_keys', array_values( $this->_activation_keys ) );
382 295 }
@@ -420,18 +333,9 @@
420 333 }
421 334
422 335 echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message notice inline notice-warning notice-alt">';
423 336 echo '<span style="display: block; padding: 5px;">';
424 - printf(
425 - wp_kses_post(
426 - __(
427 - 'Hey! Don\'t forget to <a title="Activate my Vimeography Addon" href="%1$sadmin.php?page=vimeography-manage-activations">enter your activation key</a> to receive the latest updates for the %2$s plugin.',
428 - 'vimeography'
429 - )
430 - ),
431 - esc_url(get_admin_url()), // Premier argument %1$s
432 - esc_html($plugin_data['Name']) // Deuxième argument %2$s
433 - );
337 + printf( __('Hey! Don\'t forget to <a title="Activate my Vimeography Addon" href="%1$sadmin.php?page=vimeography-manage-activations">enter your activation key</a> to receive the latest updates for the %2$s plugin.', 'vimeography'), get_admin_url(), $plugin_data['Name'] );
434 338 echo '</span>';
435 339 echo '</div></td></tr>';
436 340 }
437 341
@@ -475,18 +379,9 @@
475 379 * @access protected
476 380 * @return string
477 381 */
478 382 protected function _vimeography_get_plugin_path( $plugin_name ) {
479 - // Defense in depth: even though $plugin_name is stored via sanitize_key()
480 - // in _vimeography_add_activation_key(), reject anything that isn't a
481 - // strict plugin slug here to prevent any form of path traversal on the
482 - // WPMU_PLUGIN_DIR / WP_PLUGIN_DIR concatenation below.
483 - $plugin_name = (string) $plugin_name;
484 -
485 - if ( ! preg_match( '/^[a-z0-9][a-z0-9_-]*$/', $plugin_name ) ) {
486 - return FALSE;
487 - }
488 -
383 + //return str_replace('vimeography/', trailingslashit($plugin_name), VIMEOGRAPHY_PATH);
489 384 $basename = '/' . trailingslashit( $plugin_name ) . $plugin_name . '.php';
490 385
491 386 if ( ! is_file( $dir = WPMU_PLUGIN_DIR . $basename ) ) {
492 387 if ( ! is_file( $dir = WP_PLUGIN_DIR . $basename ) ) {