Skip to content

Instantly share code, notes, and snippets.

@remyperona
Created February 12, 2018 23:39
Show Gist options
  • Save remyperona/45825c774dc21a719990b5ba6505c949 to your computer and use it in GitHub Desktop.
Save remyperona/45825c774dc21a719990b5ba6505c949 to your computer and use it in GitHub Desktop.
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'WP-Rocket' ) === false ) {
if ( strpos( $_SERVER['HTTP_X_ROCKET'], 'WP-Rocket' ) === false ) {
die( 'BAD_UA_XR: ' . ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) : 'not set' ) . ' & ' . ( isset( $_SERVER['HTTP_X_ROCKET'] ) ? htmlspecialchars( $_SERVER['HTTP_X_ROCKET'] ) : 'not set' ) );
}
$user_agent = $_SERVER['HTTP_X_ROCKET'];
}
@list( $_version, $c_key, $c_mail, $_referer ) = array_slice( explode('|', strstr( $user_agent, 'WP-Rocket' ) ), 1, 4 );
@BrianHenryIE
Copy link

Thanks. I see you're one of the WP Rocket developers.

I had problems updating on my local install of WordPress because of this licence check.

First I had queried the production server for the update URL:

wp plugin list --update=available --fields=update_package --format=csv | tail -n +2 | grep wp-rocket

Then locally, where the plugin was disabled:

WP_HOME="https://www.mydomain.com" wp plugin install --force https://wp-rocket.me/12345678/wp-rocket_3.14.2.1.zip

The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature"

And the downloaded zip contained:

BAD_UA_XR: WordPress/6.2.2; https://www.mydomain.com & not set%

I see the header is updated in: \WP_Rocket_Requirements_Check::add_own_ua()

to be: WordPress/6.2.2; https://www.mydomain.com;WP-Rocket|3.13.1|12345678|[email protected]|https://www.mydomain.com|8.1;

So this worked to install the plugin locally:

WP_HOME="https://www.mydomain.com;WP-Rocket|3.13.1|12345678|[email protected]|https://www.mydomain.com|8.1;" wp plugin install --force https://wp-rocket.me/98426592/wp-rocket_3.14.2.1.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment