Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Security
File: HashNonce.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class MWP_Security_HashNonce implements MWP_Security_NonceInterface
[10] Fix | Delete
{
[11] Fix | Delete
/**
[12] Fix | Delete
* How much is this nonce valid for use
[13] Fix | Delete
*/
[14] Fix | Delete
const NONCE_LIFETIME = 43200;
[15] Fix | Delete
/**
[16] Fix | Delete
* Blacklist time of nonce. The minimum value is NONCE_LIFETIME +1
[17] Fix | Delete
*/
[18] Fix | Delete
const NONCE_BLACKLIST_TIME = 86400;
[19] Fix | Delete
/**
[20] Fix | Delete
* @var string
[21] Fix | Delete
*/
[22] Fix | Delete
protected $nonce;
[23] Fix | Delete
/**
[24] Fix | Delete
* @var int
[25] Fix | Delete
*/
[26] Fix | Delete
protected $issueAt;
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* {@inherits}
[30] Fix | Delete
*/
[31] Fix | Delete
public function setValue($value)
[32] Fix | Delete
{
[33] Fix | Delete
$parts = explode("_", $value);
[34] Fix | Delete
if (count($parts) == 2) {
[35] Fix | Delete
list($this->nonce, $this->issueAt) = $parts;
[36] Fix | Delete
}
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* {@inherits}
[41] Fix | Delete
*/
[42] Fix | Delete
public function verify()
[43] Fix | Delete
{
[44] Fix | Delete
if (empty($this->nonce) || (int) $this->issueAt == 0) {
[45] Fix | Delete
return false;
[46] Fix | Delete
}
[47] Fix | Delete
if ($this->issueAt + self::NONCE_LIFETIME < time()) {
[48] Fix | Delete
return false;
[49] Fix | Delete
}
[50] Fix | Delete
/** @handled function */
[51] Fix | Delete
$nonceUsed = get_transient('n_'.$this->nonce);
[52] Fix | Delete
[53] Fix | Delete
if ($nonceUsed !== false) {
[54] Fix | Delete
return false;
[55] Fix | Delete
}
[56] Fix | Delete
/** @handled function */
[57] Fix | Delete
set_transient('n_'.$this->nonce, $this->issueAt, self::NONCE_BLACKLIST_TIME); //need shorter name, because of 64 char limit
[58] Fix | Delete
[59] Fix | Delete
return true;
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function