PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 2.0.3
JetBackup – Backup, Restore & Migrate v2.0.3
3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / com / lib / BackupGuard / Core / SGBGReloader.php
backup / com / lib / BackupGuard / Core Last commit date
ISGArchiveDelegate.php 3 years ago SGBGArchive.php 3 years ago SGBGArchiveCdr.php 3 years ago SGBGArchiveHelper.php 3 years ago SGBGCache.php 3 years ago SGBGCacheableFile.php 3 years ago SGBGDirectoryTreeFile.php 3 years ago SGBGFile.php 3 years ago SGBGFileHelper.php 3 years ago SGBGJsonFile.php 3 years ago SGBGLog.php 3 years ago SGBGReloader.php 3 years ago SGBGStateFile.php 3 years ago SGBGTask.php 3 years ago
SGBGReloader.php
110 lines
1 <?php
2
3 class SGBGReloader
4 {
5 private static $instance = null;
6 protected $interval = 60; //seconds
7 protected $lastReloadTs = 0;
8
9 private function __construct()
10 {
11
12 }
13
14 private function __clone()
15 {
16
17 }
18
19 public static function getInstance()
20 {
21 if (!self::$instance) {
22 self::$instance = new self();
23 }
24
25 return self::$instance;
26 }
27
28 public function getInterval()
29 {
30 return $this->interval;
31 }
32
33 public function setInterval($interval)
34 {
35 $this->interval = $interval;
36 }
37
38 public function getLastReloadTs()
39 {
40 return $this->lastReloadTs;
41 }
42
43 public function setLastReloadTs($lastReloadTs)
44 {
45 $this->lastReloadTs = $lastReloadTs;
46 }
47
48 public function shouldReload()
49 {
50 return (time() - $this->getLastReloadTs() >= $this->getInterval());
51 }
52
53 protected function getCurrentUrl()
54 {
55 $scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')?'https':'http';
56 return ($scheme.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
57 }
58
59
60 private function doCurl ($url, $key, $action) {
61
62 // Set post values
63 $postfields = array(
64 'k' => $key,
65 'action' => $action,
66 );
67
68 // Call the API
69 $ch = curl_init();
70 curl_setopt($ch, CURLOPT_URL, $url);
71 curl_setopt($ch, CURLOPT_POST, 1);
72 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
73 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
74 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
75 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
76 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
77 curl_exec($ch);
78 curl_close($ch);
79
80 }
81
82 public function reload() {
83
84
85 if (defined('BG_EXTERNAL_RESTORE_RUNNING') && BG_EXTERNAL_RESTORE_RUNNING) {
86
87 $external = SGExternalRestore::getInstance()->getDestinationFileUrlArray();
88 $action = "awake";
89 $this->doCurl($external['url'].$external['restore_file'], $external['key'], $action);
90
91 } else {
92
93 $url = get_admin_url() . "admin-ajax.php?action=backup_guard_awake";
94 $args = array(
95 'timeout' => 2,
96 'sslverify' => false,
97 'headers' => [
98 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
99 ]
100 );
101
102 wp_remote_get($url, $args);
103
104 }
105
106
107 die;
108 }
109 }
110