nonce-timeout.php
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
class WPFC_NONCE_TIMEOUT{
private $file_path = "";
private $file_name = "nonce_datas.txt";
private $prev_nonce = false;
private $current_nonce = false;
public function __construct($cache_path){
$this->file_path = $cache_path;
$this->set_current_nonce();
$this->set_prev_nonce();
}
public function verify_nonce(){
$verified = false;
if($this->prev_nonce){
if(wp_verify_nonce($this->prev_nonce, 'wpfc')){
$verified = true;
}else{
$this->write();
}
}else{
$verified = true;
$this->write();
}
return $verified;
}
public function write(){
if(is_dir($this->file_path)){
@file_put_contents($this->file_path."/".$this->file_name, $this->current_nonce);
}
}
public function set_current_nonce(){
$this->current_nonce = wp_create_nonce("wpfc");
}
public function set_prev_nonce(){
if(file_exists($this->file_path."/".$this->file_name)){
if($data = @file_get_contents($this->file_path."/".$this->file_name)){
$this->prev_nonce = $data;
}
}
}
}
?>