PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.4.9
JetBackup – Backup, Restore & Migrate v1.4.9
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 / SGReloader.php
backup / com / lib Last commit date
BackupGuard 5 years ago Dropbox 5 years ago Request 5 years ago SGArchive.php 5 years ago SGAuthClient.php 5 years ago SGCallback.php 5 years ago SGCdrEntry.php 5 years ago SGCharsetHandler.php 5 years ago SGDBState.php 5 years ago SGEntry.php 5 years ago SGFileEntry.php 5 years ago SGFileState.php 5 years ago SGMigrateState.php 5 years ago SGMysqldump.php 5 years ago SGReloadHandler.php 5 years ago SGReloader.php 5 years ago SGReloaderState.php 5 years ago SGReviewManager.php 5 years ago SGState.php 5 years ago SGStatsRequests.php 5 years ago SGUploadHandler.php 5 years ago SGUploadState.php 5 years ago
SGReloader.php
87 lines
1 <?php
2
3 require_once(SG_BACKUP_PATH.'SGBackup.php');
4 require_once(SG_LIB_PATH.'SGReloaderState.php');
5 require_once(SG_LIB_PATH.'SGReloadHandler.php');
6 require_once(SG_LIB_PATH.'SGCallback.php');
7
8 class SGReloader
9 {
10 public static function awake($method = null)
11 {
12 $reloaderState = SGReloaderState::loadState();
13 if ($reloaderState['callback'] != "" && $reloaderState['state'] == SG_RELOADER_STATUS_IDLE) {
14
15 $callbackJson = json_decode($reloaderState['callback']);
16 $callbackJson->params['method'] = $method;
17 $callback = new SGCallback($callbackJson->class, $callbackJson->method, $callbackJson->params);
18
19 if ($callback->canPerform()) {
20 self::saveState('', SG_RELOADER_STATUS_RUNNING);
21 $callback->perform();
22 }
23 }
24
25 return;
26 }
27
28 private static function saveState($callback, $state = SG_RELOADER_STATUS_IDLE)
29 {
30 $sgReloaderState = new SGReloaderState();
31 $sgReloaderState->setCallback($callback);
32 $sgReloaderState->setState($state);
33 $sgReloaderState->update();
34 }
35
36 public static function didCompleteCallback()
37 {
38 self::saveState('', SG_RELOADER_STATUS_IDLE);
39 }
40
41 public static function registerCallback(SGCallback $callback)
42 {
43 self::saveState((string)$callback);
44 }
45
46 public static function reset()
47 {
48 SGReloaderState::reset();
49 }
50
51 public static function reloadWithAjaxUrl($awakeURL)
52 {
53 //external restore works only with ajax requests
54 if (defined('BG_EXTERNAL_RESTORE_RUNNING') && BG_EXTERNAL_RESTORE_RUNNING) {
55 return;
56 }
57
58 // awake frequency in miliseconds
59 $sgAwakeFrequency = SGConfig::get('SG_AJAX_REQUEST_FREQUENCY')?SGConfig::get('SG_AJAX_REQUEST_FREQUENCY'):SG_AJAX_DEFAULT_REQUEST_FREQUENCY;
60 $sgAwakeFrequency = $sgAwakeFrequency/1000; // awake frequency in seconds
61
62 // add 3 seconds to awake frequency
63 $timeout = $sgAwakeFrequency + 3;
64 while ($timeout) {
65
66 $reloaderState = SGReloaderState::loadState();
67 $state = $reloaderState['state'];
68
69 if ($state == SG_RELOADER_STATUS_RUNNING) {
70 return;
71 }
72
73 sleep(1);
74 $timeout--;
75 }
76
77 self::reload($awakeURL);
78 }
79
80 private static function reload($awakeURL)
81 {
82 $sgReloadHandler = new SGReloadHandler($awakeURL);
83 $sgReloadHandler->reload();
84 return;
85 }
86 }
87