hello
Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : chryzalihi ( 621211) PHP Version : 8.3.31 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl Directory : /home/chryzalihi/www/wp-content/languages/themes/the/ |
UploadSync.php 0000604 00000005672 15244446726 0007362 0 ustar 00 <?php
/**
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace Aws\S3\Sync;
use Aws\Common\Exception\RuntimeException;
use Aws\S3\Model\MultipartUpload\UploadBuilder;
use Aws\S3\Model\MultipartUpload\AbstractTransfer;
use Guzzle\Http\EntityBody;
/**
* Uploads a local directory tree to Amazon S3
*/
class UploadSync extends AbstractSync
{
const BEFORE_MULTIPART_BUILD = 's3.sync.before_multipart_build';
protected function init()
{
if (null == $this->options['multipart_upload_size']) {
$this->options['multipart_upload_size'] = AbstractTransfer::MIN_PART_SIZE;
}
}
protected function createTransferAction(\SplFileInfo $file)
{
// Open the file for reading
$filename = $file->getRealPath() ?: $file->getPathName();
if (!($resource = fopen($filename, 'r'))) {
// @codeCoverageIgnoreStart
throw new RuntimeException('Could not open ' . $file->getPathname() . ' for reading');
// @codeCoverageIgnoreEnd
}
$key = $this->options['source_converter']->convert($filename);
$body = EntityBody::factory($resource);
// Determine how the ACL should be applied
if ($acl = $this->options['acl']) {
$aclType = is_string($this->options['acl']) ? 'ACL' : 'ACP';
} else {
$acl = 'private';
$aclType = 'ACL';
}
// Use a multi-part upload if the file is larger than the cutoff size and is a regular file
if ($body->getWrapper() == 'plainfile' && $file->getSize() >= $this->options['multipart_upload_size']) {
$builder = UploadBuilder::newInstance()
->setBucket($this->options['bucket'])
->setKey($key)
->setMinPartSize($this->options['multipart_upload_size'])
->setOption($aclType, $acl)
->setClient($this->options['client'])
->setSource($body)
->setConcurrency($this->options['concurrency']);
$this->dispatch(
self::BEFORE_MULTIPART_BUILD,
array('builder' => $builder, 'file' => $file)
);
return $builder->build();
}
return $this->options['client']->getCommand('PutObject', array(
'Bucket' => $this->options['bucket'],
'Key' => $key,
'Body' => $body,
$aclType => $acl
));
}
}
DownloadSync.php 0000604 00000006472 15244446726 0007704 0 ustar 00 <?php
/**
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace Aws\S3\Sync;
use Aws\Common\Exception\RuntimeException;
use Aws\S3\ResumableDownload;
/**
* Downloads and Amazon S3 bucket to a local directory
*/
class DownloadSync extends AbstractSync
{
protected function createTransferAction(\SplFileInfo $file)
{
$sourceFilename = $file->getPathname();
list($bucket, $key) = explode('/', substr($sourceFilename, 5), 2);
$filename = $this->options['source_converter']->convert($sourceFilename);
$this->createDirectory($filename);
// Some S3 buckets contains nested files under the same name as a directory
if (is_dir($filename)) {
return false;
}
// Allow a previously interrupted download to resume
if (file_exists($filename) && $this->options['resumable']) {
return new ResumableDownload($this->options['client'], $bucket, $key, $filename);
}
return $this->options['client']->getCommand('GetObject', array(
'Bucket' => $bucket,
'Key' => $key,
'SaveAs' => $filename
));
}
/**
* @codeCoverageIgnore
*/
protected function createDirectory($filename)
{
$directory = dirname($filename);
// Some S3 clients create empty files to denote directories. Remove these so that we can create the directory.
if (is_file($directory) && filesize($directory) == 0) {
unlink($directory);
}
// Create the directory if it does not exist
if (!is_dir($directory) && !mkdir($directory, 0777, true)) {
$errors = error_get_last();
throw new RuntimeException('Could not create directory: ' . $directory . ' - ' . $errors['message']);
}
}
protected function filterCommands(array $commands)
{
// Build a list of all of the directories in each command so that we don't attempt to create an empty dir in
// the same parallel transfer as attempting to create a file in that dir
$dirs = array();
foreach ($commands as $command) {
$parts = array_values(array_filter(explode('/', $command['SaveAs'])));
for ($i = 0, $total = count($parts); $i < $total; $i++) {
$dir = '';
for ($j = 0; $j < $i; $j++) {
$dir .= '/' . $parts[$j];
}
if ($dir && !in_array($dir, $dirs)) {
$dirs[] = $dir;
}
}
}
return array_filter($commands, function ($command) use ($dirs) {
return !in_array($command['SaveAs'], $dirs);
});
}
protected function transferCommands(array $commands)
{
parent::transferCommands($this->filterCommands($commands));
}
}
UploadSyncBuilder.php 0000604 00000013221 15244446726 0010656 0 ustar 00 <?php
/**
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace Aws\S3\Sync;
use FilesystemIterator as FI;
use Aws\Common\Model\MultipartUpload\AbstractTransfer;
use Aws\S3\Model\Acp;
use Guzzle\Common\HasDispatcherInterface;
use Guzzle\Common\Event;
use Guzzle\Service\Command\CommandInterface;
class UploadSyncBuilder extends AbstractSyncBuilder
{
/** @var string|Acp Access control policy to set on each object */
protected $acp = 'private';
/** @var int */
protected $multipartUploadSize;
/**
* Set the path that contains files to recursively upload to Amazon S3
*
* @param string $path Path that contains files to upload
*
* @return $this
*/
public function uploadFromDirectory($path)
{
$this->baseDir = realpath($path);
$this->sourceIterator = $this->filterIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(
$path,
FI::SKIP_DOTS | FI::UNIX_PATHS | FI::FOLLOW_SYMLINKS
)));
return $this;
}
/**
* Set a glob expression that will match files to upload to Amazon S3
*
* @param string $glob Glob expression
*
* @return $this
* @link http://www.php.net/manual/en/function.glob.php
*/
public function uploadFromGlob($glob)
{
$this->sourceIterator = $this->filterIterator(
new \GlobIterator($glob, FI::SKIP_DOTS | FI::UNIX_PATHS | FI::FOLLOW_SYMLINKS)
);
return $this;
}
/**
* Set a canned ACL to apply to each uploaded object
*
* @param string $acl Canned ACL for each upload
*
* @return $this
*/
public function setAcl($acl)
{
$this->acp = $acl;
return $this;
}
/**
* Set an Access Control Policy to apply to each uploaded object
*
* @param Acp $acp Access control policy
*
* @return $this
*/
public function setAcp(Acp $acp)
{
$this->acp = $acp;
return $this;
}
/**
* Set the multipart upload size threshold. When the size of a file exceeds this value, the file will be uploaded
* using a multipart upload.
*
* @param int $size Size threshold
*
* @return $this
*/
public function setMultipartUploadSize($size)
{
$this->multipartUploadSize = $size;
return $this;
}
protected function specificBuild()
{
$sync = new UploadSync(array(
'client' => $this->client,
'bucket' => $this->bucket,
'iterator' => $this->sourceIterator,
'source_converter' => $this->sourceConverter,
'target_converter' => $this->targetConverter,
'concurrency' => $this->concurrency,
'multipart_upload_size' => $this->multipartUploadSize,
'acl' => $this->acp
));
return $sync;
}
protected function addCustomParamListener(HasDispatcherInterface $sync)
{
// Handle the special multi-part upload event
parent::addCustomParamListener($sync);
$params = $this->params;
$sync->getEventDispatcher()->addListener(
UploadSync::BEFORE_MULTIPART_BUILD,
function (Event $e) use ($params) {
foreach ($params as $k => $v) {
$e['builder']->setOption($k, $v);
}
}
);
}
protected function getTargetIterator()
{
return $this->createS3Iterator();
}
protected function getDefaultSourceConverter()
{
return new KeyConverter($this->baseDir, $this->keyPrefix . $this->delimiter, $this->delimiter);
}
protected function getDefaultTargetConverter()
{
return new KeyConverter('s3://' . $this->bucket . '/', '', DIRECTORY_SEPARATOR);
}
protected function addDebugListener(AbstractSync $sync, $resource)
{
$sync->getEventDispatcher()->addListener(UploadSync::BEFORE_TRANSFER, function (Event $e) use ($resource) {
$c = $e['command'];
if ($c instanceof CommandInterface) {
$uri = $c['Body']->getUri();
$size = $c['Body']->getSize();
fwrite($resource, "Uploading {$uri} -> {$c['Key']} ({$size} bytes)\n");
return;
}
// Multipart upload
$body = $c->getSource();
$totalSize = $body->getSize();
$progress = 0;
fwrite($resource, "Beginning multipart upload: " . $body->getUri() . ' -> ');
fwrite($resource, $c->getState()->getFromId('Key') . " ({$totalSize} bytes)\n");
$c->getEventDispatcher()->addListener(
AbstractTransfer::BEFORE_PART_UPLOAD,
function ($e) use (&$progress, $totalSize, $resource) {
$command = $e['command'];
$size = $command['Body']->getContentLength();
$percentage = number_format(($progress / $totalSize) * 100, 2);
fwrite($resource, "- Part {$command['PartNumber']} ({$size} bytes, {$percentage}%)\n");
$progress += $size;
}
);
});
}
}
AbstractSync.php 0000604 00000007745 15244446726 0007704 0 ustar 00 <?php
/**
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace Aws\S3\Sync;
use Aws\S3\S3Client;
use Guzzle\Common\AbstractHasDispatcher;
use Guzzle\Common\Collection;
use Guzzle\Iterator\ChunkedIterator;
use Guzzle\Service\Command\CommandInterface;
abstract class AbstractSync extends AbstractHasDispatcher
{
const BEFORE_TRANSFER = 's3.sync.before_transfer';
const AFTER_TRANSFER = 's3.sync.after_transfer';
/** @var Collection */
protected $options;
/**
* @param array $options Associative array of options:
* - client: (S3Client) used to transfer requests
* - bucket: (string) Amazon S3 bucket
* - iterator: (\Iterator) Iterator that yields SplFileInfo objects to transfer
* - source_converter: (FilenameConverterInterface) Converter used to convert filenames
* - *: Any other options required by subclasses
*/
public function __construct(array $options)
{
$this->options = Collection::fromConfig(
$options,
array('concurrency' => 10),
array('client', 'bucket', 'iterator', 'source_converter')
);
$this->init();
}
public static function getAllEvents()
{
return array(self::BEFORE_TRANSFER, self::AFTER_TRANSFER);
}
/**
* Begin transferring files
*/
public function transfer()
{
// Pull out chunks of uploads to upload in parallel
$iterator = new ChunkedIterator($this->options['iterator'], $this->options['concurrency']);
foreach ($iterator as $files) {
$this->transferFiles($files);
}
}
/**
* Create a command or special transfer action for the
*
* @param \SplFileInfo $file File used to build the transfer
*
* @return CommandInterface|callable
*/
abstract protected function createTransferAction(\SplFileInfo $file);
/**
* Hook to initialize subclasses
* @codeCoverageIgnore
*/
protected function init() {}
/**
* Process and transfer a group of files
*
* @param array $files Files to transfer
*/
protected function transferFiles(array $files)
{
// Create the base event data object
$event = array('sync' => $this, 'client' => $this->options['client']);
$commands = array();
foreach ($files as $file) {
if ($action = $this->createTransferAction($file)) {
$event = array('command' => $action, 'file' => $file) + $event;
$this->dispatch(self::BEFORE_TRANSFER, $event);
if ($action instanceof CommandInterface) {
$commands[] = $action;
} elseif (is_callable($action)) {
$action();
$this->dispatch(self::AFTER_TRANSFER, $event);
}
}
}
$this->transferCommands($commands);
}
/**
* Transfer an array of commands in parallel
*
* @param array $commands Commands to transfer
*/
protected function transferCommands(array $commands)
{
if ($commands) {
$this->options['client']->execute($commands);
// Notify listeners that each command finished
$event = array('sync' => $this, 'client' => $this->options['client']);
foreach ($commands as $command) {
$event['command'] = $command;
$this->dispatch(self::AFTER_TRANSFER, $event);
}
}
}
}
KeyConverter.php 0000604 00000004421 15244446726 0007710 0 ustar 00 <?php
/**
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace Aws\S3\Sync;
/**
* Converts filenames from one system to another
*/
class KeyConverter implements FilenameConverterInterface
{
/** @var string Directory separator for Amazon S3 keys */
protected $delimiter;
/** @var string Prefix to prepend to each Amazon S3 object key */
protected $prefix;
/** @var string Base directory to remove from each file path before converting to an object key */
protected $baseDir;
/**
* @param string $baseDir Base directory to remove from each converted name
* @param string $prefix Amazon S3 prefix
* @param string $delimiter Directory separator used with generated names
*/
public function __construct($baseDir = '', $prefix = '', $delimiter = '/')
{
$this->baseDir = (string) $baseDir;
$this->prefix = $prefix;
$this->delimiter = $delimiter;
}
public function convert($filename)
{
$key = $filename;
// Remove base directory from the key (only the first occurrence)
if ($this->baseDir && (false !== $pos = strpos($filename, $this->baseDir))) {
$key = substr_replace($key, '', $pos, strlen($this->baseDir));
}
// Replace Windows directory separators to become Unix style, and convert that to the custom dir separator
$key = str_replace('/', $this->delimiter, str_replace('\\', '/', $key));
// Add the key prefix and remove double slashes that are not in the protocol (e.g. prefixed with ":")
$delim = preg_quote($this->delimiter);
$key = preg_replace(
"#(?<!:){$delim}{$delim}#",
$this->delimiter,
$this->prefix . $key
);
return $key;
}
}
.htaccess 0000444 00000000424 15244446726 0006356 0 ustar 00 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>