| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/duplicator/lib/fileops/ |
Upload File : |
<?php
if (!defined("ABSPATH") && !defined("DUPXABSPATH"))
die("");
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class FileOpsState
{
public static $instance = null;
private $workerTime;
private $directories;
private $throttleDelay;
private $excludedDirectories;
private $excludedFiles;
private $working = false;
const StateFilename = 'state.json';
public static function getInstance($reset = false)
{
if ((self::$instance == null) && (!$reset)) {
$stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
self::$instance = new FileOpsState();
if (file_exists($stateFilepath)) {
$stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'rb');
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
$stateString = fread($stateHandle, filesize($stateFilepath));
$data = json_decode($stateString);
self::$instance->setFromData($data);
// self::$instance->fileRenames = (array)(self::$instance->fileRenames);
DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
DupLiteSnapLibIOU::fclose($stateHandle);
} else {
$reset = true;
}
}
if ($reset) {
self::$instance = new FileOpsState();
self::$instance->reset();
}
return self::$instance;
}
private function setFromData($data)
{
// $this->currentFileHeader = $data->currentFileHeader;
}
public function reset()
{
$stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
$stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
$this->initMembers();
DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
DupLiteSnapLibIOU::fclose($stateHandle);
}
public function save()
{
$stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
$stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
DupArchiveUtil::tlog("saving state");
DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
DupLiteSnapLibIOU::fclose($stateHandle);
}
private function initMembers()
{
// $this->currentFileHeader = null;
}
}