-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cli multisite #690
Open
timotei-litespeed
wants to merge
9
commits into
litespeedtech:master
Choose a base branch
from
timotei-litespeed:cli-multisite
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Cli multisite #690
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9384187
CLI - purge url fix
Tymotey 80d87e4
Merge branch 'v6.3' into cli-multisite
Tymotey 336eec5
Revert changes to Router class
Tymotey 3a14a3a
Revert "Revert changes to Router class"
Tymotey 9b8b343
Use is_ssl()
Tymotey 7a89f12
Revert changes
Tymotey 5358608
CLI - purge link, add validation parameter
Tymotey ccf2ac9
Multiple changes to purge url
Tymotey 145352c
Review changes
Tymotey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -268,18 +269,35 @@ public function is_role_simulation() | |
/** | ||
* Get a security hash | ||
* | ||
* @since 6.3 - Added parameters $item_name and $blog_id. | ||
* @since 3.3 | ||
*/ | ||
public static function get_hash() | ||
public static function get_hash($item_name = null, $blog_id = null) | ||
{ | ||
$save_blog = get_current_blog_id(); | ||
// Switch to blog if sent. | ||
if($blog_id && $save_blog != $blog_id ){ | ||
switch_to_blog($blog_id); | ||
} | ||
|
||
// Change item name if sent. | ||
if(!$item_name){ | ||
$item_name = self::ITEM_HASH; | ||
} | ||
|
||
// Reuse previous hash if existed | ||
$hash = self::get_option(self::ITEM_HASH); | ||
$hash = self::get_option($item_name); | ||
if ($hash) { | ||
return $hash; | ||
} | ||
|
||
$hash = Str::rrand(6); | ||
self::update_option(self::ITEM_HASH, $hash); | ||
self::update_option($item_name, $hash); | ||
// If needed shitch back to the saved blog. | ||
if($blog_id && $save_blog != $blog_id ){ | ||
switch_to_blog($save_blog); | ||
} | ||
|
||
return $hash; | ||
} | ||
|
||
|
@@ -501,12 +519,20 @@ 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; | ||
} | ||
|
||
$hash = Router::get_hash(self::VALIDATE_PURGE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be under the cond |
||
|
||
// 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] != $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( | ||
|
@@ -518,7 +544,7 @@ private function verify_action() | |
Core::ACTION_QS_PURGE_EMPTYCACHE, | ||
)) | ||
) { | ||
Debug2::debug('[Router] LSCWP_CTRL query string - did not match admin IP Actions: ' . $action); | ||
Debug2::debug('[Router] LSCWP_CTRL query string - did not match public action: ' . $action); | ||
return; | ||
} | ||
|
||
|
@@ -764,4 +790,4 @@ public function handler($cls) | |
|
||
return $this->cls($cls)->handler(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
if
can be moved to be under line 187's elseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used for test if subdomain install has the domain url sent