Skip to content

Commit

Permalink
Fix clear for all cli actions + change hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymotey committed Jun 28, 2024
1 parent 7a89f12 commit 657b8bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions cli/purge.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public function url($args)
{
$data = array(
Router::ACTION => Core::ACTION_QS_PURGE,
Router::VALIDATE_PURGE => Router::get_hash(),
);
$url = $args[0];
$deconstructed = wp_parse_url($url);
Expand Down
11 changes: 9 additions & 2 deletions src/router.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Router extends Base
{
const NONCE = 'LSCWP_NONCE';
const ACTION = 'LSCWP_CTRL';
const VALIDATE_PURGE = 'VALIDATE_PURGE';

const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network';
const ACTION_DB_OPTM = 'db_optm';
Expand Down Expand Up @@ -501,12 +502,18 @@ private function verify_action()
// Each action must have a valid nonce unless its from admin ip and is public action
// Validate requests nonce (from admin logged in page or cli)
if (!$this->verify_nonce($action)) {
// check if it is from admin ip
if (!$this->is_admin_ip()) {
// check if action is from admin ip. skip test for action Core::ACTION_QS_PURGE.
if ( $action != Core::ACTION_QS_PURGE && !$this->is_admin_ip()) {
Debug2::debug('[Router] LSCWP_CTRL query string - did not match admin IP: ' . $action);
return;
}

// Validate request for action Core::ACTION_QS_PURGE. test if request parameter isset and is correct.
if( $action == Core::ACTION_QS_PURGE && ( !isset($_REQUEST[Router::VALIDATE_PURGE]) || $_REQUEST[Router::VALIDATE_PURGE] != Router::get_hash() ) ){
Debug2::debug('[Router] LSCWP_CTRL query string - could not validate request for: ' . $action);
return;
}

// check if it is public action
if (
!in_array($action, array(
Expand Down

0 comments on commit 657b8bb

Please sign in to comment.