| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/i/n/f/infrafs/INFRABIKEIT/wp-content/plugins/ |
Upload File : |
class.fileops.u.delete.php 0000644 00000002221 15133536101 0011521 0 ustar 00 <?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 FileOpsDeleteConfig
{
public $workerTime;
public $directories;
public $throttleDelayInUs;
public $excludedDirectories;
public $excludedFiles;
public $fileLock;
}
class FileOpsDeleteU
{
// Move $directories, $files, $excludedFiles to $destination directory. Throws exception if it can't do something and $exceptionOnFaiure is true
// $exludedFiles can include * wildcard
// returns: array with list of failures
public static function delete($currentDirectory, &$deleteConfig)
{
$timedOut = false;
if (is_dir($currentDirectory)) {
$objects = scandir($currentDirectory);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($currentDirectory."/".$object)) {
self::delete($currentDirectory."/".$object, $deleteConfig);
}
else {
@unlink($currentDirectory."/".$object);
}
}
}
@rmdir($currentDirectory);
}
}
} class.fileops.u.move.php 0000644 00000002436 15133536101 0011235 0 ustar 00 <?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 FileOpsMoveU
{
// Move $directories, $files, $excludedFiles to $destination directory. Throws exception if it can't do something and $exceptionOnFaiure is true
// $exludedFiles can include * wildcard
// returns: array with list of failures
public static function move($directories, $files, $excludedFiles, $destination)
{
DupLiteSnapLibLogger::logObject('directories', $directories);
DupLiteSnapLibLogger::logObject('files', $files);
DupLiteSnapLibLogger::logObject('excludedFiles', $excludedFiles);
DupLiteSnapLibLogger::logObject('destination', $destination);
$failures = array();
$directoryFailures = DupLiteSnapLibIOU::massMove($directories, $destination, null, false);
DupLiteSnapLibLogger::log('done directories');
$fileFailures = DupLiteSnapLibIOU::massMove($files, $destination, $excludedFiles, false);
DupLiteSnapLibLogger::log('done files');
return array_merge($directoryFailures, $fileFailures);
}
} class.fileops.state.php 0000644 00000005211 15133536101 0011136 0 ustar 00 <?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;
}
} class.fileops.constants.php 0000644 00000001745 15133536101 0012042 0 ustar 00 <?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 FileOpsConstants
{
public static $FILEOPS_ROOT;
public static $DEFAULT_WORKER_TIME = 18;
public static $LIB_DIR;
public static $PROCESS_LOCK_FILEPATH;
public static $PROCESS_CANCEL_FILEPATH;
public static $KEY_FILEPATH;
public static $LOG_FILEPATH;
public static function init() {
self::$FILEOPS_ROOT = dirname(__FILE__);
self::$LIB_DIR = self::$FILEOPS_ROOT.'/..';
self::$PROCESS_LOCK_FILEPATH = self::$FILEOPS_ROOT.'/fileops_lock.bin';
self::$PROCESS_CANCEL_FILEPATH = self::$FILEOPS_ROOT.'/fileops_cancel.bin';
self::$LOG_FILEPATH = dirname(__FILE__).'/fileops.log';
}
}
FileOpsConstants::init(); index.php 0000644 00000000017 15133536101 0006360 0 ustar 00 <?php
//silent fileops.php 0000644 00000013305 15133536101 0006716 0 ustar 00 <?php
/** Absolute path to the DAWS directory. - necessary for php protection */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('display_errors'))
@ini_set('display_errors', 1);
error_reporting(E_ALL);
set_error_handler("terminate_missing_variables");
require_once(dirname(__FILE__) . '/class.fileops.constants.php');
require_once(dirname(__FILE__) . '/class.fileops.u.move.php');
require_once(FileOpsConstants::$LIB_DIR . '/snaplib/snaplib.all.php');
class FileOps
{
private $lock_handle = null;
function __construct()
{
date_default_timezone_set('UTC'); // Some machines don’t have this set so just do it here.
DupLiteSnapLibLogger::init(FileOpsConstants::$LOG_FILEPATH);
}
public function processRequest()
{
try {
DupLiteSnapLibLogger::clearLog();
/* @var $state FileOpsState */
DupLiteSnapLibLogger::log('process request');
$retVal = new StdClass();
$retVal->pass = false;
if (isset($_REQUEST['action'])) {
//$params = $_REQUEST;
$params = array();
DupLiteSnapLibLogger::logObject('REQUEST', $_REQUEST);
foreach($_REQUEST as $key => $value)
{
$params[$key] = json_decode($value, true);
}
} else {
$json = file_get_contents('php://input');
DupLiteSnapLibLogger::logObject('json1', $json);
$params = json_decode($json, true);
DupLiteSnapLibLogger::logObject('json2', $json);
}
DupLiteSnapLibLogger::logObject('params', $params);
DupLiteSnapLibLogger::logObject('keys', array_keys($params));
$action = $params['action'];
if ($action == 'deltree') {
DupLiteSnapLibLogger::log('deltree');
$config = DeleteConfig();
$config->workerTime = DupLiteSnapLibUtil::GetArrayValue($params, 'worker_time');
$config->directories = DupLiteSnapLibUtil::getArrayValue($params, 'directories');
$config->throttleDelayInUs = DupLiteSnapLibUtil::getArrayValue($params, 'throttleDelay', false, 0) * 1000000;
$config->excludedDirectories = DupLiteSnapLibUtil::getArrayValue($params, 'excluded_directories', false, array());
$config->excludedFiles = DupLiteSnapLibUtil::getArrayValue($params, 'excluded_files', false, array());
$config->fileLock = DupLiteSnapLibUtil::GetArrayValue($params, 'fileLock');
DupLiteSnapLibLogger::logObject('Config', $config);
// TODO use appropriate lock type
DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_EX);
$this->lock_handle = DupLiteSnapLibIOU::fopen(FileOpsConstants::$PROCESS_LOCK_FILEPATH, 'c+');
DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_UN);
$retVal->pass = true;
$retVal->status = new stdClass;
//todo $retVal->status->errors = $moveErrors; // RSR TODO ensure putting right thing in here
} else if($action === 'move_files') {
$directories = DupLiteSnapLibUtil::getArrayValue($params, 'directories', false, array());
$files = DupLiteSnapLibUtil::getArrayValue($params, 'files', false, array());
$excludedFiles = DupLiteSnapLibUtil::getArrayValue($params, 'excluded_files', false, array());
$destination = DupLiteSnapLibUtil::getArrayValue($params, 'destination');
DupLiteSnapLibLogger::log('before move');
$moveErrors = FileOpsMoveU::move($directories, $files, $excludedFiles, $destination);
DupLiteSnapLibLogger::log('after move');
$retVal->pass = true;
$retVal->status = new stdClass();
$retVal->status->errors = $moveErrors; // RSR TODO ensure putting right thing in here
}
else {
throw new Exception('Unknown command.');
}
session_write_close();
} catch (Exception $ex) {
$error_message = "Error Encountered:" . $ex->getMessage() . '<br/>' . $ex->getTraceAsString();
DupLiteSnapLibLogger::log($error_message);
$retVal->pass = false;
$retVal->error = $error_message;
}
DupLiteSnapLibLogger::logObject("before json encode retval", $retVal);
$jsonRetVal = json_encode($retVal);
DupLiteSnapLibLogger::logObject("json encoded retval", $jsonRetVal);
echo $jsonRetVal;
}
}
function generateCallTrace()
{
$e = new Exception();
$trace = explode("\n", $e->getTraceAsString());
// reverse array to make steps line up chronologically
$trace = array_reverse($trace);
array_shift($trace); // remove {main}
array_pop($trace); // remove call to this method
$length = count($trace);
$result = array();
for ($i = 0; $i < $length; $i++) {
$result[] = ($i + 1) . ')' . substr($trace[$i], strpos($trace[$i], ' ')); // replace '#someNum' with '$i)', set the right ordering
}
return "\t" . implode("\n\t", $result);
}
function terminate_missing_variables($errno, $errstr, $errfile, $errline)
{
// echo "<br/>ERROR: $errstr $errfile $errline<br/>";
// if (($errno == E_NOTICE) and ( strstr($errstr, "Undefined variable"))) die("$errstr in $errfile line $errline");
DupLiteSnapLibLogger::log("ERROR $errno, $errstr, {$errfile}:{$errline}");
DupLiteSnapLibLogger::log(generateCallTrace());
// DaTesterLogging::clearLog();
// exit(1);
//return false; // Let the PHP error handler handle all the rest
}
$fileOps = new FileOps();
$fileOps->processRequest();