| Server IP : 89.108.64.180 / Your IP : 216.73.216.46 Web Server : Apache/2.4.41 (Ubuntu) System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-root ( 1010) PHP Version : 8.0.30 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,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 : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/sadovaya-gelendgik.ru/wp-content/plugins/wp-reset/libs/pCloud/ |
Upload File : |
<?php
namespace pCloud;
use InvalidArgumentException;
class Folder {
private $request;
function __construct() {
$this->request = new Request();
}
public function getMetadata($folderId) {
if (!is_int($folderId)) {
throw new InvalidArgumentException("Invalid folder id");
}
$params = array(
"folderid" => $folderId
);
return $this->request->get("listfolder", $params);
}
public function search(/*string*/ $path) {
$path = pathinfo($path, PATHINFO_DIRNAME);
//$path = str_replace(DIRECTORY_SEPARATOR,"\\",$path);
$params = array(
"nofiles" => 1,
"path" => $path
);
return $this->request->get("listfolder", $params);
}
/**
* list files in folder identified by name
* (start from the root, match directory name, ..)
*
* @param int|string $folder
* @return array|null
*/
public function listFolder($folder = null) {
// first compare with each folder in root
if(is_null($folder)) {
return (array)$this->getContent((int)0);
}
$extension = (string)pathinfo($folder, PATHINFO_EXTENSION);
if(!empty($extension)) {
$folder = (string)pathinfo($folder, PATHINFO_DIRNAME);
}
$path_parts = array_reverse((array)explode(DIRECTORY_SEPARATOR, $folder));
$directory = null;
$currentFolderId = 0;
while(($folderName = array_pop($path_parts))){ /* current directory */
$folderItems = (array)$this->getContent((int)$currentFolderId);
foreach($folderItems as $key => $directory) {
$directory = (array)$directory;
if (isset($directory['isfolder']) && (bool)$directory['isfolder'] === true) {
if (!empty($directory['name']) && strncmp($folderName, $directory['name'], strlen($folderName)) === 0) {
$currentFolderId = $directory['folderid'];
break;
}
}
}
}
return $directory;
}
public function listRoot() {
return $this->getContent(0);
}
public function getContent($folderId) {
if (!is_int($folderId)) {
throw new InvalidArgumentException("Invalid folder id {$folderId}");
}
$folderMetadata = $this->getMetadata($folderId);
return is_object($folderMetadata) ? $folderMetadata->metadata->contents : $folderMetadata;
}
public function create($name = "", $parent = 0) {
if (!is_string($name) || strlen($name) < 1) {
throw new InvalidArgumentException("Invalid folder name");
}
$params = array(
"name" => $name,
"folderid" => $parent
);
$response = $this->request->get("createfolder", $params);
return $response;
}
public function rename($folderId, $name) {
if (!is_int($folderId)) {
throw new InvalidArgumentException("Invalid folder id");
}
if (!is_string($name) || strlen($name) < 1) {
throw new InvalidArgumentException("Invalid folder name");
}
$params = array(
"toname" => $name,
"folderid" => $folderId
);
$response = $this->request->get("renamefolder", $params);
return is_object($response) ? $response->metadata->folderid : $response;
}
public function move($folderId, $newParent) {
if (!is_int($folderId)) {
throw new InvalidArgumentException("Invalid folder id");
}
if (!is_int($newParent)) {
throw new InvalidArgumentException("Invalid new parent id");
}
$params = array(
"tofolderid" => $newParent,
"folderid" => $folderId
);
$response = $this->request->get("renamefolder", $params);
return is_object($response) ? $response->metadata->folderid : $response;
}
public function delete($folderId) {
if (!is_int($folderId)) {
throw new InvalidArgumentException("Invalid folder id");
}
$params = array(
"folderid" => $folderId
);
$response = $this->request->get("deletefolder", $params);
return is_object($response) ? $response->metadata->isdeleted : $response;
}
public function deleteRecursive($folderId) {
if (!is_int($folderId)) {
throw new InvalidArgumentException("Invalid folder id");
}
$params = array(
"folderid" => $folderId
);
return $this->request->get("deletefolderrecursive", $params);
}
}