Initial commit: apps.supersam24.ru

This commit is contained in:
root committed 2026-10-22 00:04:27 +03:00
commit e955e1da36
6566 files changed
+1271095

No files matched your search

+1
View File
@@ -0,0 +1 @@
/vendor/
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2015 Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+39
View File
@@ -0,0 +1,39 @@
PHAR Utils
==========
PHAR file format utilities, for when PHP phars you up.
Installation
------------
`composer require seld/phar-utils`
API
---
### `Seld\PharUtils\Timestamps`
- `__construct($pharFile)`
> Load a phar file in memory.
- `updateTimestamps($timestamp = null)`
> Updates each file's unix timestamps in the PHAR so the PHAR signature
> can be produced in a reproducible manner.
- `save($path, $signatureAlgo = '')`
> Saves the updated phar file with an updated signature.
> Algo must be one of `Phar::MD5`, `Phar::SHA1`, `Phar::SHA256`
> or `Phar::SHA512`
Requirements
------------
PHP 5.3 and above
License
-------
PHAR Utils is licensed under the MIT License - see the LICENSE file for details
+26
View File
@@ -0,0 +1,26 @@
{
"name": "seld/phar-utils",
"description": "PHAR file format utilities, for when PHP phars you up",
"type": "library",
"keywords": ["phra"],
"license": "MIT",
"require": {
"php": ">=5.3"
},
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be"
}
],
"autoload": {
"psr-4": {
"Seld\\PharUtils\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "e5afe72073d9266712c8e1ddc1648513",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3"
},
"platform-dev": []
}
+192
View File
@@ -0,0 +1,192 @@
<?php
/*
* This file is part of PHAR Utils.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Seld\PharUtils;
class Timestamps
{
private $contents;
/**
* @param string $file path to the phar file to use
*/
public function __construct($file)
{
$this->contents = file_get_contents($file);
}
/**
* Updates each file's unix timestamps in the PHAR
*
* The PHAR signature can then be produced in a reproducible manner.
*
* @param int|DateTime|string $timestamp Date string or DateTime or unix timestamp to use
*/
public function updateTimestamps($timestamp = null)
{
if ($timestamp instanceof \DateTime) {
$timestamp = $timestamp->getTimestamp();
} elseif (is_string($timestamp)) {
$timestamp = strtotime($timestamp);
} elseif (!is_int($timestamp)) {
$timestamp = strtotime('1984-12-24T00:00:00Z');
}
// detect manifest offset / end of stub
if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
throw new \RuntimeException('Could not detect the stub\'s end in the phar');
}
// set starting position and skip past manifest length
$pos = $match[0][1] + strlen($match[0][0]);
$stubEnd = $pos + $this->readUint($pos, 4);
$pos += 4;
$numFiles = $this->readUint($pos, 4);
$pos += 4;
// skip API version (YOLO)
$pos += 2;
// skip PHAR flags
$pos += 4;
$aliasLength = $this->readUint($pos, 4);
$pos += 4 + $aliasLength;
$metadataLength = $this->readUint($pos, 4);
$pos += 4 + $metadataLength;
while ($pos < $stubEnd) {
$filenameLength = $this->readUint($pos, 4);
$pos += 4 + $filenameLength;
// skip filesize
$pos += 4;
// update timestamp to a fixed value
$this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
// skip timestamp, compressed file size, crc32 checksum and file flags
$pos += 4*4;
$metadataLength = $this->readUint($pos, 4);
$pos += 4 + $metadataLength;
$numFiles--;
}
if ($numFiles !== 0) {
throw new \LogicException('All files were not processed, something must have gone wrong');
}
}
/**
* Saves the updated phar file, optionally with an updated signature.
*
* @param string $path
* @param int $signatureAlgo One of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512
* @return bool
*/
public function save($path, $signatureAlgo)
{
$pos = $this->determineSignatureBegin();
$algos = array(
\Phar::MD5 => 'md5',
\Phar::SHA1 => 'sha1',
\Phar::SHA256 => 'sha256',
\Phar::SHA512 => 'sha512',
);
if (!isset($algos[$signatureAlgo])) {
throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
}
$algo = $algos[$signatureAlgo];
// re-sign phar
// signature
$signature = hash($algo, substr($this->contents, 0, $pos), true)
// sig type
. pack('L', $signatureAlgo)
// ohai Greg & Marcus
. 'GBMB';
$this->contents = substr($this->contents, 0, $pos) . $signature;
return file_put_contents($path, $this->contents);
}
private function readUint($pos, $bytes)
{
$res = unpack('V', substr($this->contents, $pos, $bytes));
return $res[1];
}
/**
* Determine the beginning of the signature.
*
* @return int
*/
private function determineSignatureBegin()
{
// detect signature position
if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
throw new \RuntimeException('Could not detect the stub\'s end in the phar');
}
// set starting position and skip past manifest length
$pos = $match[0][1] + strlen($match[0][0]);
$manifestEnd = $pos + 4 + $this->readUint($pos, 4);
$pos += 4;
$numFiles = $this->readUint($pos, 4);
$pos += 4;
// skip API version (YOLO)
$pos += 2;
// skip PHAR flags
$pos += 4;
$aliasLength = $this->readUint($pos, 4);
$pos += 4 + $aliasLength;
$metadataLength = $this->readUint($pos, 4);
$pos += 4 + $metadataLength;
$compressedSizes = 0;
while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
$filenameLength = $this->readUint($pos, 4);
$pos += 4 + $filenameLength;
// skip filesize and timestamp
$pos += 2*4;
$compressedSizes += $this->readUint($pos, 4);
// skip compressed file size, crc32 checksum and file flags
$pos += 3*4;
$metadataLength = $this->readUint($pos, 4);
$pos += 4 + $metadataLength;
$numFiles--;
}
if ($numFiles !== 0) {
throw new \LogicException('All files were not processed, something must have gone wrong');
}
return $manifestEnd + $compressedSizes;
}
}