add cadastro

This commit is contained in:
Ronaldo
2026-04-06 12:36:25 +00:00
parent a315eab0d5
commit e61ccda3ed
787 changed files with 155807 additions and 0 deletions

7
checkChanges.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
while read -r directory events filename; do
filepath="$directory$filename"
chmod 0755 "$filepath"
sudo systemctl restart apache2
done < <(inotifywait -e modify,create,delete -mrq --format '%w %e %f' /var/www/xcmg.fun/)

5
composer.json Executable file
View File

@@ -0,0 +1,5 @@
{
"require": {
"phpoffice/phpspreadsheet": "^3.9"
}
}

599
composer.lock generated Executable file
View File

@@ -0,0 +1,599 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6ca0e11e13366565618a058133359df4",
"packages": [
{
"name": "composer/pcre",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-11-12T16:29:46+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "3.1.2",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-zlib": "*",
"php-64bit": "^8.2"
},
"require-dev": {
"brianium/paratest": "^7.7",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.16",
"guzzlehttp/guzzle": "^7.5",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.5",
"phpunit/phpunit": "^11.0",
"vimeo/psalm": "^6.0"
},
"suggest": {
"guzzlehttp/psr7": "^2.4",
"psr/http-message": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.2"
},
"funding": [
{
"url": "https://github.com/maennchen",
"type": "github"
}
],
"time": "2025-01-27T12:07:53+00:00"
},
{
"name": "markbaker/complex",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
},
"time": "2022-12-06T16:21:08+00:00"
},
{
"name": "markbaker/matrix",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "^4.0",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"sebastian/phpcpd": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@demon-angel.eu"
}
],
"description": "PHP Class for working with matrices",
"homepage": "https://github.com/MarkBaker/PHPMatrix",
"keywords": [
"mathematics",
"matrix",
"vector"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
},
"time": "2022-12-02T22:17:43+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "3.9.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "414f8a2aa1d8b974b39f577c0677d5ebc96fab36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/414f8a2aa1d8b974b39f577c0677d5ebc96fab36",
"reference": "414f8a2aa1d8b974b39f577c0677d5ebc96fab36",
"shasum": ""
},
"require": {
"composer/pcre": "^3.3",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"maennchen/zipstream-php": "^2.1 || ^3.0",
"markbaker/complex": "^3.0",
"markbaker/matrix": "^3.0",
"php": "^8.1",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-main",
"dompdf/dompdf": "^2.0 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"mitoteam/jpgraph": "^10.3",
"mpdf/mpdf": "^8.1.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.5",
"squizlabs/php_codesniffer": "^3.7",
"tecnickcom/tcpdf": "^6.5"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"ext-intl": "PHP Internationalization Functions",
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
},
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/3.9.0"
},
"time": "2025-01-26T05:10:24+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client"
},
"time": "2023-09-23T14:17:50+00:00"
},
{
"name": "psr/http-factory",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory"
},
"time": "2024-04-15T12:06:14+00:00"
},
{
"name": "psr/http-message",
"version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/2.0"
},
"time": "2023-04-04T09:54:51+00:00"
},
{
"name": "psr/simple-cache",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\SimpleCache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interfaces for simple caching",
"keywords": [
"cache",
"caching",
"psr",
"psr-16",
"simple-cache"
],
"support": {
"source": "https://github.com/php-fig/simple-cache/tree/3.0.0"
},
"time": "2021-10-29T13:26:27+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.2.0"
}

19
css/style.css Executable file
View File

@@ -0,0 +1,19 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
.bg-gold-xcmg {
background-color: #00f4bc;
}
.border-gold-xcmg {
border-color: #00f4bc
}
.text-gold-xcmg {
color: #00f4bc;
}
.hover\:bg-gold-xcmg:hover {
background-color: #00f4bc;
}

1
css/tailwind.css Executable file

File diff suppressed because one or more lines are too long

5
dados/.htaccess Executable file
View File

@@ -0,0 +1,5 @@
AuthType Basic
AuthName "Área Restrita"
AuthUserFile /var/www/xcmg.fun/dados/.htpasswd
Require valid-user

1
dados/.htpasswd Executable file
View File

@@ -0,0 +1 @@
xcmg:$apr1$vrvVjE7X$1V20jjFDxTJpU5.VHwXsy/

BIN
dados/dados - Copia.xlsx Executable file

Binary file not shown.

BIN
dados/dados.xlsx Executable file

Binary file not shown.

0
dados/nohup.out Executable file
View File

BIN
favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

BIN
favicon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

65
header.php Executable file
View File

@@ -0,0 +1,65 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4?1234"></script>
<link rel="stylesheet" href="/style.css" class="style">
<link href="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.css?1234" rel="stylesheet" />
<script>
</script>
<style>
/* Estilo para checkboxes mais touch-friendly */
.touch-checkbox {
position: relative;
padding: 1rem;
margin: 0.5rem 0;
border-radius: 0.5rem;
background-color: #f3f4f6;
transition: all 0.2s ease;
}
.touch-checkbox input[type="checkbox"] {
width: 24px;
height: 24px;
}
.touch-checkbox label {
padding-left: 0.5rem;
font-size: 1rem;
line-height: 24px;
}
/* Estilização para inputs mobile */
input[type="text"],
input[type="date"] {
font-size: 16px !important; /* Previne zoom em iOS */
padding: 0.75rem !important;
-webkit-appearance: none;
appearance: none;
}
/* Estilização específica para o Choices.js
.choices {
margin-bottom: 1rem;
}
.choices__inner {
padding: 0.75rem;
min-height: auto;
}
.choices__input {
font-size: 16px !important;
} */
@media (max-width: 768px) {
.touch-checkbox {
padding: 1rem 0.75rem;
}
form {
padding: 1rem;
}
}
</style>
<!-- End Header -->

BIN
img/E7-80T.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 KiB

BIN
img/XC6-1056VN.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
img/XCB25-L5-C.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 KiB

BIN
img/XCS4531K.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 KiB

BIN
img/bg.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
img/bg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

2651
img/footer.svg Executable file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 258 KiB

BIN
img/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

187
index.php Executable file
View File

@@ -0,0 +1,187 @@
<?php
if(isset($_COOKIE['index']) || (isset($_COOKIE['cadastro']) && $_COOKIE['cadastro'] === 'true')) {
header('Location: play.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<?php include 'header.php'; ?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formulário de Registro</title>
<style>
.fade-transition {
transition: all 0.3s ease-in-out;
opacity: 0;
max-height: 0;
overflow: hidden;
}
.fade-transition.show {
opacity: 1;
max-height: 500px; /* altura máxima suficiente para o conteúdo */
}
.modal-backdrop {
background-color: rgba(0, 0, 0, 0.5);
transition: opacity 0.3s ease-in-out;
}
.modal-content {
transform: scale(0.9);
opacity: 0;
transition: all 0.3s ease-in-out;
}
.modal-content.show {
transform: scale(1);
opacity: 1;
}
</style>
</head>
<body class="bg-gray-100" app="form">
<!-- Modal Inicial -->
<div id="welcomeModal" class="fixed inset-0 z-50 overflow-y-auto modal-backdrop hidden">
<div class="flex items-center justify-center min-h-screen px-4">
<div class="modal-content bg-white rounded-lg shadow-xl max-w-md w-full p-6 relative">
<div class="text-center">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Siemens: Rode a Roleta e Ganhe Prêmios!</h2>
<div class="text-gray-600 mb-6 space-y-4">
<p>Bem-vindo ao nosso estande! Participe do jogo <strong>Rode a Roleta</strong> e concorra a prêmios exclusivos.</p>
<p>Cadastre-se rapidamente no formulário abaixo e, em seguida, rode a roleta para descobrir qual prêmio você pode ganhar.</p>
<p>Não perca essa chance de se divertir e conhecer as soluções Siemens!</p>
</div>
<button id="startTourBtn" class="w-full bg-gold-xcmg text-white font-bold py-3 px-6 rounded-lg hover:bg-yellow-600 transition duration-300">
Quero me cadastrar e rodar a roleta!
</button>
</div>
</div>
</div>
</div>
<div class="min-h-screen flex items-center justify-center" id="registrationFormContainer">
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
<h2 class="text-2xl font-bold mb-6 text-center">Roleta de Prêmios - Cadastro</h2>
<form action="salvar.php" method="POST" class="space-y-4" id="registrationForm">
<div class="relative z-0 w-full mb-5 group">
<input type="text" name="nome" id="nome" class="peer block py-2.5 px-3 w-full text-sm text-gray-900 rounded-lg border border-gray-900 focus:border-gold-xcmg bg-transparent focus:ring-0" placeholder=" " required />
<label for="nome" class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-white px-2 peer-focus:px-2 peer-focus:text-gold-xcmg peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 start-1">Nome e sobrenome</label>
</div>
<div class="relative z-0 w-full mb-5 group">
<input type="text" name="telefone" id="telefone" class="peer block py-2.5 px-3 w-full text-sm text-gray-900 rounded-lg border border-gray-900 focus:border-gold-xcmg bg-transparent focus:ring-0" placeholder=" " required />
<label for="telefone" class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-white px-2 peer-focus:px-2 peer-focus:text-gold-xcmg peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 start-1">Telefone</label>
</div>
<div class="relative z-0 w-full mb-5 group">
<input type="text" name="email" id="email" class="peer block py-2.5 px-3 w-full text-sm text-gray-900 rounded-lg border border-gray-900 focus:border-gold-xcmg bg-transparent focus:ring-0" placeholder=" " required />
<label for="email" class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-white px-2 peer-focus:px-2 peer-focus:text-gold-xcmg peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 start-1">E-mail</label>
</div>
<div class="relative z-0 w-full mb-5 group">
<input type="text" name="empresa" id="empresa" class="peer block py-2.5 px-3 w-full text-sm text-gray-900 rounded-lg border border-gray-900 focus:border-gold-xcmg bg-transparent focus:ring-0" placeholder=" " required />
<label for="empresa" class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-white px-2 peer-focus:px-2 peer-focus:text-gold-xcmg peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 start-1">Empresa</label>
</div>
<div class="relative z-0 w-full mb-5 group">
<input type="text" name="cargo" id="cargo" class="peer block py-2.5 px-3 w-full text-sm text-gray-900 rounded-lg border border-gray-900 focus:border-gold-xcmg bg-transparent focus:ring-0" placeholder=" " required />
<label for="cargo" class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-white px-2 peer-focus:px-2 peer-focus:text-gold-xcmg peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 start-1">Setor</label>
</div>
<div class="mb-5">
<label class="block text-sm font-medium text-gray-700 mb-2">Gostaria de ser contatado por um de nossos especialistas?</label>
<div class="flex items-center space-x-6">
<div class="flex items-center">
<input id="contato-sim" name="contato_especialista" type="radio" value="Sim" class="h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500">
<label for="contato-sim" class="ml-2 block text-sm text-gray-900">Sim</label>
</div>
<div class="flex items-center">
<input id="contato-nao" name="contato_especialista" type="radio" value="Não" class="h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500" checked>
<label for="contato-nao" class="ml-2 block text-sm text-gray-900">Não</label>
</div>
</div>
</div>
<div class="mb-5">
<label class="block text-sm font-medium text-gray-700 mb-2">Tópicos de interesse:</label>
<div class="space-y-2">
<div>
<input type="checkbox" id="topico_automacao" name="topicos[]" value="Automação e Otimização de Processos" class="mr-2">
<label for="topico_automacao">Acionamentos</label>
</div>
<div>
<input type="checkbox" id="topico_ciberseguranca" name="topicos[]" value="Cibersegurança, IoT e Redes Industriais" class="mr-2">
<label for="topico_ciberseguranca">Cibersegurança, IoT e Redes Industriais</label>
</div>
<div>
<input type="checkbox" id="topico_convergencia" name="topicos[]" value="Convergência TI e TA" class="mr-2">
<label for="topico_convergencia">Automação de Pontes Rolantes</label>
</div>
<div>
<input type="checkbox" id="topico_eletrificacao" name="topicos[]" value="Eletrificação e soluções para subestações e eletrocentros" class="mr-2">
<label for="topico_eletrificacao">Eletrificação e soluções para subestações e eletrocentros</label>
</div>
<div>
<input type="checkbox" id="topico_gemeos" name="topicos[]" value="Gêmeos Digitais" class="mr-2">
<label for="topico_gemeos">Gêmeos Digitais</label>
</div>
<div>
<input type="checkbox" id="topico_instrumentacao" name="topicos[]" value="Instrumentação de Processos" class="mr-2">
<label for="topico_instrumentacao">Instrumentação de Processos</label>
</div>
<div>
<input type="checkbox" id="topico_manutencao" name="topicos[]" value="Manutenções Preditivas baseadas em IA" class="mr-2">
<label for="topico_manutencao">Manutenções Preditivas baseadas em IA</label>
</div>
<div>
<input type="checkbox" id="tsolucoes_em_baixa_tensão" name="topicos[]" value="Soluções em baixa tensão" class="mr-2">
<label for="topico_manutencao">Soluções em baixa tensão</label>
</div>
</div>
</div>
<input type="hidden" id="codigo" name="codigo" value="">
<button type="submit"
class="w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center">
Enviar
</button>
</form>
<p class="text-xs text-gray-500 mt-4">
As informações coletadas por meio deste formulário serão tratadas estritamente para realização do evento, do sorteio e para atualização da nossa base de contatos, com todas as medidas técnicas e administrativas de segurança disponíveis. Em caso de quaisquer dúvidas/solicitações acerca do tratamento dos seus dados, contate a Organização de Privacidade de Dados da Siemens via e-mail <a href="mailto:dataprivacy.br@siemens.com" class="underline text-blue-600">dataprivacy.br@siemens.com</a>.
</p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js?321"></script>
<script src="./main.js"></script>
<script>
window.onload = function () {
document.getElementById("registrationFormContainer").classList.add("visible");
}
document.addEventListener('DOMContentLoaded', function() {
const modal = document.getElementById('welcomeModal');
const startTourBtn = document.getElementById('startTourBtn');
const modalContent = modal.querySelector('.modal-content');
// Mostrar o modal após um pequeno delay
setTimeout(() => {
modal.classList.remove('hidden');
setTimeout(() => {
modalContent.classList.add('show');
}, 10);
}, 500);
// Fechar o modal e iniciar o cadastro
startTourBtn.addEventListener('click', function() {
modalContent.classList.remove('show');
setTimeout(() => {
modal.classList.add('hidden');
}, 300);
// Rolar suavemente até o formulário
document.getElementById('registrationFormContainer').scrollIntoView({
behavior: 'smooth'
});
});
});
</script>
</body>
</html>

53
js/cookie.js Executable file
View File

@@ -0,0 +1,53 @@
/**
* A simple cookie reader/writer with JSON support.
*
* @example
* // Create a cookie
* CookieManager.setCookie('username', 'JohnDoe', 7);
*
* @example
* // Read a cookie
* const username = CookieManager.getCookie('username');
* console.log(username); // Outputs: JohnDoe
*
* @example
* // Erase a cookie
* CookieManager.eraseCookie('username');
*
* @example
* // Set a JSON object as a cookie
* const user = { name: 'John Doe', age: 30 };
* CookieManager.setJSONCookie('user', user, 7);
*
* @example
* // Get a JSON object from a cookie
* const user = CookieManager.getJSONCookie('user');
* console.log(user); // Outputs: { name: 'John Doe', age: 30 }
*/
// a simple cookie reader/writer with json support
class CookieManager {
static setCookie(name, value, days) {
let expires = "";
if (days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + "; path=/";
}
static getCookie(name) {
const nameEQ = name + "=";
const ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
static deleteCookie(name) {
document.cookie = name + '=; Max-Age=-99999999;';
}
}

2
js/jquery.js vendored Executable file

File diff suppressed because one or more lines are too long

13
js/mask.js Executable file
View File

@@ -0,0 +1,13 @@
class PhoneMask {
static mask(value) {
return value
.replace(/\D/g, '')
.replace(/(\d{2})(\d)/, '($1) $2')
.replace(/(\d{4,5})(\d{4})/, '$1-$2')
.replace(/(-\d{4})\d+?$/, '$1');
}
}
function maskPhone(event) {
event.target.value = PhoneMask.mask(event.target.value);
}

1
js/vanilla.js Executable file
View File

@@ -0,0 +1 @@
!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.VMasker=b()}(this,function(){var a=[9,16,17,18,36,37,38,39,40,91,92,93],b=function(b){for(var c=0,d=a.length;c<d;c++)if(b==a[c])return!1;return!0},c=function(a){return a=a||{},a={delimiter:a.delimiter||".",lastOutput:a.lastOutput,precision:a.hasOwnProperty("precision")?a.precision:2,separator:a.separator||",",showSignal:a.showSignal,suffixUnit:a.suffixUnit&&" "+a.suffixUnit.replace(/[\s]/g,"")||"",unit:a.unit&&a.unit.replace(/[\s]/g,"")+" "||"",zeroCents:a.zeroCents},a.moneyPrecision=a.zeroCents?0:a.precision,a},d=function(a,b,c){for(;b<a.length;b++)"9"!==a[b]&&"A"!==a[b]&&"S"!==a[b]||(a[b]=c);return a},e=function(a){this.elements=a};e.prototype.unbindElementToMask=function(){for(var a=0,b=this.elements.length;a<b;a++)this.elements[a].lastOutput="",this.elements[a].onkeyup=!1,this.elements[a].onkeydown=!1,this.elements[a].value.length&&(this.elements[a].value=this.elements[a].value.replace(/\D/g,""))},e.prototype.bindElementToMask=function(a){for(var c=this,d=function(d){d=d||window.event;var e=d.target||d.srcElement;b(d.keyCode)&&setTimeout(function(){c.opts.lastOutput=e.lastOutput,e.value=f[a](e.value,c.opts),e.lastOutput=e.value,e.setSelectionRange&&c.opts.suffixUnit&&e.setSelectionRange(e.value.length,e.value.length-c.opts.suffixUnit.length)},0)},e=0,g=this.elements.length;e<g;e++)this.elements[e].lastOutput="",this.elements[e].onkeyup=d,this.elements[e].value.length&&(this.elements[e].value=f[a](this.elements[e].value,this.opts))},e.prototype.maskMoney=function(a){this.opts=c(a),this.bindElementToMask("toMoney")},e.prototype.maskNumber=function(){this.opts={},this.bindElementToMask("toNumber")},e.prototype.maskAlphaNum=function(){this.opts={},this.bindElementToMask("toAlphaNumeric")},e.prototype.maskPattern=function(a){this.opts={pattern:a},this.bindElementToMask("toPattern")},e.prototype.unMask=function(){this.unbindElementToMask()};var f=function(a){if(!a)throw new Error("VanillaMasker: There is no element to bind.");var b="length"in a?a.length?a:[]:[a];return new e(b)};return f.toMoney=function(a,b){if(b=c(b),b.zeroCents){b.lastOutput=b.lastOutput||"";var d="("+b.separator+"[0]{0,"+b.precision+"})",e=new RegExp(d,"g"),f=a.toString().replace(/[\D]/g,"").length||0,g=b.lastOutput.toString().replace(/[\D]/g,"").length||0;a=a.toString().replace(e,""),f<g&&(a=a.slice(0,a.length-1))}var h=a.toString().replace(/[\D]/g,""),i=new RegExp("^(0|\\"+b.delimiter+")"),j=new RegExp("(\\"+b.separator+")$"),k=h.substr(0,h.length-b.moneyPrecision),l=k.substr(0,k.length%3),m=new Array(b.precision+1).join("0");k=k.substr(k.length%3,k.length);for(var n=0,o=k.length;n<o;n++)n%3==0&&(l+=b.delimiter),l+=k[n];l=l.replace(i,""),l=l.length?l:"0";var p="";if(!0===b.showSignal&&(p=a<0||a.startsWith&&a.startsWith("-")?"-":""),!b.zeroCents){var q=h.length-b.precision,r=h.substr(q,b.precision),s=r.length;m=(m+r).slice(-(b.precision>s?b.precision:s))}return(b.unit+p+l+b.separator+m).replace(j,"")+b.suffixUnit},f.toPattern=function(a,b){var c,e="object"==typeof b?b.pattern:b,f=e.replace(/\W/g,""),g=e.split(""),h=a.toString().replace(/\W/g,""),i=h.replace(/\W/g,""),j=0,k=g.length,l="object"==typeof b?b.placeholder:void 0;for(c=0;c<k;c++){if(j>=h.length){if(f.length==i.length)return g.join("");if(void 0!==l&&f.length>i.length)return d(g,c,l).join("");break}if("9"===g[c]&&h[j].match(/[0-9]/)||"A"===g[c]&&h[j].match(/[a-zA-Z]/)||"S"===g[c]&&h[j].match(/[0-9a-zA-Z]/))g[c]=h[j++];else if("9"===g[c]||"A"===g[c]||"S"===g[c])return void 0!==l?d(g,c,l).join(""):g.slice(0,c).join("")}return g.join("").substr(0,c)},f.toNumber=function(a){return a.toString().replace(/(?!^-)[^0-9]/g,"")},f.toAlphaNumeric=function(a){return a.toString().replace(/[^a-z0-9 ]+/i,"")},f});

BIN
lista/Leads XCMG Roleta.xlsx Executable file

Binary file not shown.

26
lista/ativar.php Executable file
View File

@@ -0,0 +1,26 @@
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "xcmg";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Conexão falhou: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["id"])) {
$id = intval($_POST["id"]);
$sql = "UPDATE cadastros SET status = 1 WHERE id = $id";
if ($conn->query($sql) === TRUE) {
echo "success";
} else {
echo "error";
}
}
$conn->close();

41
lista/atualiza.php Executable file
View File

@@ -0,0 +1,41 @@
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "xcmg";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Conexão falhou: " . $conn->connect_error);
}
// Buscar cadastros não ativados
$sql = "SELECT id, nome, empresa, cargo, telefone, dados_adicionais, codigo FROM cadastros WHERE status = 0";
$result = $conn->query($sql);
$cadastros = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
// Se houver dados_adicionais, tentar extrair e-mail para facilitar o frontend
if (!empty($row['dados_adicionais'])) {
// dados_adicionais are stored with single-quotes escaped as '' in salvar.php
$json = str_replace("''", "'", $row['dados_adicionais']);
$extras = json_decode($json, true);
if (json_last_error() === JSON_ERROR_NONE && is_array($extras)) {
$row['email'] = isset($extras['email']) ? $extras['email'] : '';
} else {
$row['email'] = '';
}
} else {
$row['email'] = '';
}
$cadastros[] = $row;
}
}
header('Content-Type: application/json');
echo json_encode($cadastros);
$conn->close();

View File

@@ -0,0 +1,44 @@
from openpyxl import Workbook
import mysql.connector
def export_cadastros_to_excel():
# Configurações de conexão com o MySQL
conn = mysql.connector.connect(
host="localhost", # altere para o host do seu banco de dados
user="root", # altere para o usuário do seu banco
password="", # altere para a senha do seu banco
database="xcmg" # altere para o nome do seu banco de dados
)
cursor = conn.cursor()
# Consulta da tabela cadastros
cursor.execute("""
SELECT id, nome, empresa, cargo, telefone, cliente_xcmg, usa_banco_xcmg, codigo, ativado, gerado, status
FROM cadastros
""")
rows = cursor.fetchall()
cursor.close()
conn.close()
# Cria um arquivo Excel
wb = Workbook()
ws = wb.active
ws.title = "Cadastros"
# Cabeçalho da planilha
headers = ['id', 'nome', 'empresa', 'cargo', 'telefone', 'cliente_xcmg', 'usa_banco_xcmg', 'codigo', 'ativado', 'gerado', 'status']
ws.append(headers)
# Insere os dados na planilha
for row in rows:
ws.append(row)
# Salva a planilha em um arquivo Excel
wb.save("cadastros.xlsx")
if __name__ == '__main__':
export_cadastros_to_excel()

140
lista/index.php Executable file
View File

@@ -0,0 +1,140 @@
<?php
// exigir login para acessar a página
// include '../proteger.php';
// Conectar ao banco de dados MySQL
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "xcmg";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Conexão falhou: " . $conn->connect_error);
}
// Buscar cadastros não ativados
$sql = "SELECT id, nome, empresa, cargo, telefone, dados_adicionais, codigo FROM cadastros WHERE status = 0";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lista de Cadastros</title>
<?php include '../header.php'; ?>
<style>
body {
color: #000;
}
h2 {
color: #ccc;
}
</style>
</head>
<body class="p-6 bg-gray-100" app="lista">
<h2 class="text-xl font-bold mb-4">Lista de Cadastros</h2>
<div id="cadastros">
<?php while ($row = $result->fetch_assoc()) : ?>
<div class="row-dados p-4 bg-white shadow rounded mb-2 flex justify-between items-center"
id="cadastro-<?= $row['id'] ?>">
<div class="col-codigo">
<p><strong><?= $row['codigo'] ?></strong></p>
</div>
<div class="col-dados">
<p><strong><?= $row['nome'] ?></strong></p>
<p><?= $row['empresa'] ?></p>
<?php
// extrair email de dados_adicionais (se presente)
$email = '';
if (!empty($row['dados_adicionais'])) {
// restaurar aspas simples duplicadas e decodificar JSON
$json = str_replace("''", "'", $row['dados_adicionais']);
$extras = json_decode($json, true);
if (json_last_error() === JSON_ERROR_NONE && is_array($extras) && !empty($extras['email'])) {
$email = htmlspecialchars($extras['email']);
}
}
?>
<?php if ($email !== ''): ?>
<p class="text-sm text-gray-200">Email: <span class="font-medium"><?= $email ?></span></p>
<?php else: ?>
<p class="text-sm text-gray-500">Email: <span class="italic">(não informado)</span></p>
<?php endif; ?>
</div>
<button class="bg-green-500 text-white px-4 py-2 rounded activate"
data-id="<?= $row['id'] ?>">Ativar</button>
</div>
<?php endwhile; ?>
</div>
<script src="../js/jquery.js"></script>
<script>
$(document).ready(function () {
$(".activate").click(function () {
console.log('ativar');
let id = $(this).data("id");
$.post("ativar.php", {
id: id
}, function (response) {
console.log(response);
if (response == "success") {
$("#cadastro-" + id).fadeOut();
} else {
alert("Erro ao ativar!");
}
});
});
});
setInterval(function () {
$.getJSON("atualiza.php?rand=" + Math.random(), function (data) {
$("#cadastros").empty();
$.each(data, function (key, val) {
$("#cadastros").append(
`<div class="row-dados p-4 bg-white shadow rounded mb-2 flex justify-between items-center" id="cadastro-${val.id}">
<div class="col-codigo">
<p><strong>${val.codigo}</strong></p>
</div>
<div class="col-dados">
<p><strong>${val.nome}</strong></p>
<p>${val.empresa}</p>
${val.email ? `<p class="text-sm text-gray-200">Email: <span class="font-medium">${val.email}</span></p>` : `<p class="text-sm text-gray-500">Email: <span class="italic">(não informado)</span></p>`}
</div>
<button class="bg-green-500 text-white px-4 py-2 rounded activate" data-id="${val.id}">Ativar</button>
</div>`
);
});$(".activate").click(function () {
console.log('ativar');
let id = $(this).data("id");
$.post("ativar.php", {
id: id
}, function (response) {
console.log(response);
if (response == "success") {
$("#cadastro-" + id).fadeOut();
} else {
alert("Erro ao ativar!");
}
});
});
});
}, 10000);
</script>
<style>
body {
background: #111 !important;
}
.col-codigo {
font-size: 32px;
}
</style>
</body></html>

4
lista/session_end.php Executable file
View File

@@ -0,0 +1,4 @@
<?php
session_start();
session_destroy();
header("Location: /lista");

183
main.js Executable file
View File

@@ -0,0 +1,183 @@
// main.js
// Garantir que CookieManager está disponível
if (typeof CookieManager === 'undefined') {
console.error('CookieManager não encontrado. Verifique se cookie.js está incluído.');
}
// // Garantir que PhoneMask está disponível
// if (typeof PhoneMask === 'undefined') {
// console.error('PhoneMask não encontrado. Verifique se mask.js está incluído.');
// }
// cheque se existe form no body
try {
var currApp = document.body.getAttribute('app')
} catch (error) {
var currApp = null
}
if (currApp == 'form') {
// Aguarda o carregamento completo do DOM
document.addEventListener("DOMContentLoaded", function () {
// Função para obter um item aleatório de um array
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
// Função para gerar um número de telefone aleatório
function getRandomPhone() {
let ddd = ["11", "21", "31", "41", "51", "61", "71", "81", "91"];
let prefixo = Math.floor(90000 + Math.random() * 10000);
let sufixo = Math.floor(1000 + Math.random() * 9000);
return `(${getRandomItem(ddd)}) ${prefixo}-${sufixo}`;
}
// Arrays com dados fictícios
const nomes = ["Carlos Silva", "Ana Pereira", "João Souza", "Mariana Lima", "Felipe Alves"];
const empresas = ["TechCorp", "InovaWeb", "BrasilSoft", "SmartSolutions", "EcoTech"];
const cargos = ["Analista", "Gerente", "Coordenador", "Desenvolvedor", "Consultor"];
// // Preenche os campos do formulário com dados aleatórios
// document.querySelector('[name="nome"]').value = getRandomItem(nomes);
// document.querySelector('[name="empresa"]').value = getRandomItem(empresas);
// document.querySelector('[name="cargo"]').value = getRandomItem(cargos);
// document.querySelector('[name="telefone"]').value = getRandomPhone();
// document.querySelector('[name="cliente_xcmg"]').checked = Math.random() > 0.5;
// document.querySelector('[name="usa_banco_xcmg"]').checked = Math.random() > 0.5;
});
// Função para aplicar a máscara de telefone
function maskPhone(element) {
PhoneMask.apply(element);
element.addEventListener("input", function () {
var phone = this.value.replace(/\D/g, '');
if (phone.length < 10 || phone.length > 11) {
this.setCustomValidity('Telefone inválido');
} else {
this.setCustomValidity('');
}
});
}
// Aplica a máscara ao campo de telefone após o carregamento do DOM
document.addEventListener('DOMContentLoaded', function () {
var phoneInput = document.getElementById('telefone');
maskPhone(phoneInput);
});
// Validação do formulário antes do envio
document.getElementById('registrationForm').addEventListener('submit', function (e) {
var phoneInput = document.getElementById('telefone');
var phone = phoneInput.value.replace(/\D/g, '');
if (phone.length < 10 || phone.length > 11) {
e.preventDefault();
alert('Por favor, insira um número de telefone válido (DDD + número)');
}
});
// Salva o cookie após o envio do formulário (quando o cadastro for completado)
// document.getElementById('registrationForm').addEventListener('submit', function (e) {
// e.preventDefault(); // Impede o envio padrão do formulário
// // Supondo que a validação do formulário foi bem-sucedida
// setCadastroCookie();
// // Redireciona para play.php após salvar o cookie
// window.location.href = "salvar.php";
// });
}
// Função para embaralhar um código
function embaralharCodigo(codigo) {
const alpha = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Embaralha a ordem dos caracteres
let embaralhado = codigo.split('').map((char, index) => {
if (index % 2 === 0) {
let charIndex = alpha.indexOf(char);
return alpha[alpha.length - 1 - charIndex]; // Inverte o caractere de acordo com a sequência Alpha
}
return char; // Mantém o caractere original
}).join('');
// Troca a ordem dos caracteres
return embaralhado.split('').reverse().join('');
}
// Funções de Cookie
function setCadastroCookie() {
// Usa CookieManager em vez de cookies
CookieManager.setCookie('cadastro_completado', 'true', 30);
}
function setCodigoCookie(codigo) {
// Usa CookieManager em vez de cookies
CookieManager.setCookie('index', codigo, 30);
}
function checkCadastroCookie() {
return CookieManager.getCookie('cadastro') === 'true';
}
// Redirecionamento por Cookie
if (checkCadastroCookie()) {
if (currApp == 'form') {
window.location.href = "play.php";
}
}
document.addEventListener('DOMContentLoaded', function() {
// Máscara para telefone
const telefoneInput = document.getElementById('telefone');
if (telefoneInput) {
telefoneInput.addEventListener('input', maskPhone);
}
// Melhorando a experiência do datepicker
const dateInput = document.getElementById('ultima_compra');
if (dateInput) {
// Configurando data máxima como hoje
const today = new Date().toISOString().split('T')[0];
dateInput.setAttribute('max', today);
// Adicionando placeholder mais amigável
dateInput.setAttribute('placeholder', 'Selecione a data');
}
// Tornando os checkboxes mais responsivos ao toque
document.querySelectorAll('.touch-checkbox').forEach(checkbox => {
checkbox.addEventListener('click', function(e) {
if (e.target.tagName !== 'INPUT') {
const input = this.querySelector('input[type="checkbox"]');
input.checked = !input.checked;
input.dispatchEvent(new Event('change'));
}
});
});
});
// Melhoria da interatividade dos checkboxes
document.addEventListener('DOMContentLoaded', function() {
const touchCheckboxes = document.querySelectorAll('.touch-checkbox');
touchCheckboxes.forEach(checkbox => {
checkbox.addEventListener('click', function(e) {
const input = this.querySelector('input[type="checkbox"]');
if (e.target.tagName.toLowerCase() !== 'input') {
input.checked = !input.checked;
input.dispatchEvent(new Event('change'));
}
});
// Prevenir duplo toque em dispositivos móveis
checkbox.addEventListener('touchend', function(e) {
e.preventDefault();
const input = this.querySelector('input[type="checkbox"]');
input.checked = !input.checked;
input.dispatchEvent(new Event('change'));
});
});
});

438
play copy.php Executable file
View File

@@ -0,0 +1,438 @@
<?php include 'header.php'; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="ScreenOrientation" content="autoRotate:disabled">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no, orientation=portrait">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title>AR Image Tracking - Baú Suave</title>
<script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mind-ar@1.2.5/dist/mindar-image-aframe.prod.js"></script>
<!-- Include necessary JS files for cookie checking -->
<script src="js/cookie.js"></script> <!-- Assuming this provides the 'cookies' object -->
<script src="main.js"></script> <!-- Assuming this provides checkCadastroCookie -->
<style>
body {
margin: 0;
overflow: hidden;
}
.floating-message {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
background-color: rgba(0, 0, 0, 0.7);
color: white;
border-radius: 10px;
text-align: center;
font-size: 20px;
z-index: 1001;
}
.loader-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
}
.loading-text {
color: white;
margin-top: 10px;
font-family: Arial, sans-serif;
}
#refreshButton {
position: fixed;
top: 20px;
right: 20px;
z-index: 1000;
padding: 10px 15px;
cursor: pointer;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 4px;
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.fade-out {
animation: fadeOut 0.5s ease-out forwards;
}
/*
/* Ajustar z-index dos outros elementos para ficarem sobre o a-scene */
.overlay {
z-index: 2;
}
.floating-message {
z-index: 3;
}
.loader-container {
z-index: 4;
}
</style>
</head>
<body>
<a-scene id="myScene"
mindar-image="imageTargetSrc: ./targets.mind; autoStart: true; uiLoading: no; uiError: no; uiScanning: no;"
vr-mode-ui="enabled: false" device-orientation-permission-ui="enabled: false" renderer="colorManagement: true">
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
<a-entity mindar-image-target="targetIndex: 0">
<!-- <a-plane color="#FFFF00" position="0 0 0" rotation="0 0 0" width="1" height="0.2">
<a-text value="Target 0" align="center" color="black" position="0 0 0" scale="0.5 0.5 0.5"></a-text>
</a-plane> -->
</a-entity>
<a-entity mindar-image-target="targetIndex: 1"></a-entity>
<a-entity mindar-image-target="targetIndex: 2"></a-entity>
<a-entity mindar-image-target="targetIndex: 3"></a-entity>
</a-scene>
<div class="loader-container" id="loader">
<div style="text-align: center;">
<div class="loading-text">Carregando AR...</div>
</div>
</div>
<!-- <script> var THREE = AFRAME.THREE; </script>
<button id="refreshButton" onclick="location.reload();">
Refresh
</button> -->
<div id="floating-message-0" class="floating-message">
<p class="message-text">Encontrou o E7-80T!</p>
</div>
<div id="floating-message-1" class="floating-message">
<p class="message-text">Encontrou o XC6-1056VN!</p>
</div>
<div id="floating-message-2" class="floating-message">
<p class="message-text">Encontrou o XCB25-L5-C!</p>
</div>
<div id="floating-message-3" class="floating-message">
<p class="message-text">Encontrou o XCS4531K!</p>
</div>
<div class="overlay">
<div class="footer" id="footer-container">
<!-- O SVG será injetado aqui -->
</div>
</div>
<div class="finalScreen" id="finalScreen" style="display: none;">
<h2>Parabéns!</h2>
<p>Você completou o desafio e desbloqueou sua recompensa.</p>
<p>Passe no balcão do stand da XCMG e garanta seu prêmio!</p>
<span>CÓDIGO DO PRÊMIO</span>
<h1 id="codigoPremio"></h1>
</div>
<script>
if (CookieManager.getCookie('allFound)')) {
console.log("Todos os targets já encontrados. Redirecionando para o código.");
showWindowCode()
} else {
console.log("Nem todos os targets foram encontrados ainda.");
}
async function loadFooterSVG() {
try {
const response = await fetch('img/footer.svg');
const svgText = await response.text();
const footerContainer = document.getElementById('footer-container');
footerContainer.innerHTML = svgText;
// Adiciona classes para estilização
const svgElement = footerContainer.querySelector('svg');
if (svgElement) {
svgElement.classList.add('footer-svg');
// Adiciona classe 'maquina' aos filhos diretos do g#maquinas
const maquinasGroup = svgElement.querySelector('g#maquinas');
if (maquinasGroup) {
Array.from(maquinasGroup.children).forEach(element => {
if (element.tagName.toLowerCase() === 'g') {
element.classList.add('maquina');
}
});
}
}
} catch (error) {
console.error('Erro ao carregar o footer SVG:', error);
}
}
document.addEventListener('DOMContentLoaded', () => {
var showWindowCode = function () {
const windowCode = document.getElementById('finalScreen');
var index = CookieManager.getCookie('index')
console.log(index)
document.getElementById('codigoPremio').innerText = index;
windowCode.style.visibility = "visible";
};
loadFooterSVG();
// --- Cookie Check Logic ---
// Ensure cookie functions/objects are available before using them
// Use CookieManager instead of cookies
if (typeof checkCadastroCookie !== 'function' || typeof CookieManager === 'undefined') {
console.error(
"Funções de cookie não encontradas. Verifique se js/cookie.js e main.js estão incluídos corretamente."
);
// Display error or redirect if critical
const loader = document.getElementById('loader');
if (loader) {
loader.innerHTML =
'<div class="loading-text">Erro: Falha ao carregar dependências. Recarregue a página.</div>';
}
return; // Stop execution if dependencies are missing
} else {
// Verifica se todos os cookies necessários existem
const requiredCookies = ["PHPSESSID", "cadastro", "index", "indexTimestamp"];
for (const cookieName of requiredCookies) {
if (!CookieManager.getCookie(cookieName)) {
console.log(`Cookie ${cookieName} não encontrado, redirecionando para index.php`);
window.location.href = "index.php";
return;
}
}
console.log("Verificação de cookies passou com sucesso.");
}
// --- End Cookie Check Logic ---
// --- AR Logic ---
const sceneEl = document.querySelector('#myScene');
const loader = document.getElementById('loader');
const messages = {
0: document.getElementById('floating-message-0'),
1: document.getElementById('floating-message-1'),
2: document.getElementById('floating-message-2'),
3: document.getElementById('floating-message-3')
};
let targetVisible = false;
let currentTarget = null;
// Array para armazenar targets encontrados
let foundTargets = {
0: false, // E7-80T
1: false, // XC6-1056VN
2: false, // XCB25-L5-C
3: false // XCS4531K
};
let maquinasTargets = {
0: 'E7-80T',
1: 'XC6-1056VN',
2: 'XCB25-L5-C',
3: 'XCS4531K'
};
// Função para verificar progresso
function checkProgress() {
console.log("Progresso atual:", Object.values(foundTargets).filter(v => v).length, "de 4");
console.log("Status dos targets:", foundTargets);
// Verifica se todos os targets foram encontrados
const allFound = Object.values(foundTargets).every(found => found === true);
if (allFound) {
CookieManager.setCookie('allFound', 'true', 7); // Cookie válido por 7 dias
console.log("Todos os targets encontrados! Cookie 'allFound' criado.");
setTimeout(() => {
// Redireciona após 5 segundos
showWindowCode()
}, 5000);
}
}
var allFound = CookieManager.getCookie('allFound');
if (allFound) {
console.log("Todos os targets já encontrados. Redirecionando para o código.");
showWindowCode()
} else {
console.log("Nem todos os targets foram encontrados ainda.");
}
sceneEl.addEventListener('renderstart', () => {
loader.style.display = 'none';
console.log("Render started, loader hidden.");
});
sceneEl.addEventListener("targetFound", event => {
const targetIndex = event.target.getAttribute('mindar-image-target').targetIndex;
console.log("Target Found:", targetIndex);
targetVisible = true;
currentTarget = targetIndex;
const targetName = maquinasTargets[targetIndex];
console.log("Target Name:", targetName);
var targetMaquina = document.getElementById(targetName);
targetMaquina.classList.add("found");
// Registra o target como encontrado
foundTargets[targetIndex] = true;
checkProgress();
// Esconde todas as mensagens primeiro
Object.values(messages).forEach(msg => {
if (msg) msg.style.display = "none";
});
// Mostra a mensagem específica
if (messages[currentTarget]) {
messages[currentTarget].style.display = "block";
console.log("Showing message for target", currentTarget);
}
});
sceneEl.addEventListener("targetLost", event => {
console.log("Target Lost!");
targetVisible = false;
if (currentTarget !== null && messages[currentTarget]) {
messages[currentTarget].style.display = "none";
}
currentTarget = null;
});
});
setTimeout(() => {
const video = document.querySelector('video');
if (video) {
video.style.position = 'fixed';
video.style.top = '0';
video.style.left = '0';
video.style.width = '100%';
video.style.height = '100%';
console.log("c")
}
}, 5000);
</script>
<style>
.overlay {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
}
div#finalScreen {
display: block !important;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 8000;
color: white;
background-color: #111;
}
.footer-svg {
width: 100%;
height: auto;
display: block;
}
.footer {
width: 100%;
}
.a-enter-vr {
display: none;
}
.maquina {
cursor: pointer;
transition: transform 0.2s ease;
filter: brightness(10) drop-shadow(6px 5px 5px white);
opacity: 0.25;
}
.maquina:hover {
transform: scale(1.1);
}
.found {
filter: brightness(1) drop-shadow(0 0 0 black);
opacity: 1;
}
a-scene {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1;
}
h2 {
font-size: 4em;
font-weight: 700;
color: #FAB73C;
}
.finalScreen p {
font-size: 1.5em;
margin-bottom: 1em
}
div#finalScreen {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
width: 100%;
text-align: center;
visibility: hidden;
}
.finalScreen span {
font-size: 1.5em;
line-height: 3em;
}
h1#codigoPremio {
color: #FAB73C;
font-size: 5em;
font-weight: 700;
}
</style>
</body>
</html>

441
play.php Executable file
View File

@@ -0,0 +1,441 @@
<?php include 'header.php'; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="ScreenOrientation" content="autoRotate:disabled">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no, orientation=portrait">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title>Siemens - Cadastro Roleta</title>
<!-- <script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mind-ar@1.2.5/dist/mindar-image-aframe.prod.js"></script> -->
<!-- Include necessary JS files for cookie checking -->
<script src="js/cookie.js"></script> <!-- Assuming this provides the 'cookies' object -->
<script src="main.js"></script> <!-- Assuming this provides checkCadastroCookie -->
<script>
CookieManager.setCookie('allFound', 'true', 7);
</script>
<style>
body {
margin: 0;
overflow: hidden;
}
.floating-message {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
background-color: rgba(0, 0, 0, 0.7);
color: white;
border-radius: 10px;
text-align: center;
font-size: 20px;
z-index: 1001;
}
.loader-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
}
.loading-text {
color: white;
margin-top: 10px;
font-family: Arial, sans-serif;
}
#refreshButton {
position: fixed;
top: 20px;
right: 20px;
z-index: 1000;
padding: 10px 15px;
cursor: pointer;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 4px;
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.fade-out {
animation: fadeOut 0.5s ease-out forwards;
}
/*
/* Ajustar z-index dos outros elementos para ficarem sobre o a-scene */
.overlay {
z-index: 2;
}
.floating-message {
z-index: 3;
}
.loader-container {
z-index: 4;
}
</style>
</head>
<body>
<a-scene id="myScene"
mindar-image="imageTargetSrc: ./targets.mind; autoStart: true; uiLoading: no; uiError: no; uiScanning: no;"
vr-mode-ui="enabled: false" device-orientation-permission-ui="enabled: false" renderer="colorManagement: true">
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
<a-entity mindar-image-target="targetIndex: 0">
<!-- <a-plane color="#FFFF00" position="0 0 0" rotation="0 0 0" width="1" height="0.2">
<a-text value="Target 0" align="center" color="black" position="0 0 0" scale="0.5 0.5 0.5"></a-text>
</a-plane> -->
</a-entity>
<a-entity mindar-image-target="targetIndex: 1"></a-entity>
<a-entity mindar-image-target="targetIndex: 2"></a-entity>
<a-entity mindar-image-target="targetIndex: 3"></a-entity>
</a-scene>
<div class="loader-container" id="loader">
<div style="text-align: center;">
<div class="loading-text">Carregando AR...</div>
</div>
</div>
<!-- <script> var THREE = AFRAME.THREE; </script>
<button id="refreshButton" onclick="location.reload();">
Refresh
</button> -->
<div id="floating-message-0" class="floating-message">
<p class="message-text">Encontrou o E7-80T!</p>
</div>
<div id="floating-message-1" class="floating-message">
<p class="message-text">Encontrou o XC6-1056VN!</p>
</div>
<div id="floating-message-2" class="floating-message">
<p class="message-text">Encontrou o XCB25-L5-C!</p>
</div>
<div id="floating-message-3" class="floating-message">
<p class="message-text">Encontrou o XCS4531K!</p>
</div>
<div class="overlay">
<div class="footer" id="footer-container">
<!-- O SVG será injetado aqui -->
</div>
</div>
<div class="finalScreen" id="finalScreen" style="display: none;">
<!-- <h2>Parabéns!</h2>
<p>Você completou o desafio e desbloqueou sua recompensa.</p>
<p>Passe no balcão do stand da SIEMENS e garanta seu prêmio!</p>
-->
<span>CÓDIGO PARA JOGAR</span>
<h1 id="codigoPremio"></h1>
</div>
<script>
if (CookieManager.getCookie('allFound)')) {
console.log("Todos os targets já encontrados. Redirecionando para o código.");
showWindowCode()
} else {
console.log("Nem todos os targets foram encontrados ainda.");
}
async function loadFooterSVG() {
try {
const response = await fetch('img/footer.svg');
const svgText = await response.text();
const footerContainer = document.getElementById('footer-container');
footerContainer.innerHTML = svgText;
// Adiciona classes para estilização
const svgElement = footerContainer.querySelector('svg');
if (svgElement) {
svgElement.classList.add('footer-svg');
// Adiciona classe 'maquina' aos filhos diretos do g#maquinas
const maquinasGroup = svgElement.querySelector('g#maquinas');
if (maquinasGroup) {
Array.from(maquinasGroup.children).forEach(element => {
if (element.tagName.toLowerCase() === 'g') {
element.classList.add('maquina');
}
});
}
}
} catch (error) {
console.error('Erro ao carregar o footer SVG:', error);
}
}
document.addEventListener('DOMContentLoaded', () => {
var showWindowCode = function () {
const windowCode = document.getElementById('finalScreen');
var index = CookieManager.getCookie('index')
console.log(index)
document.getElementById('codigoPremio').innerText = index;
windowCode.style.visibility = "visible";
};
loadFooterSVG();
// --- Cookie Check Logic ---
// Ensure cookie functions/objects are available before using them
// Use CookieManager instead of cookies
if (typeof checkCadastroCookie !== 'function' || typeof CookieManager === 'undefined') {
console.error(
"Funções de cookie não encontradas. Verifique se js/cookie.js e main.js estão incluídos corretamente."
);
// Display error or redirect if critical
const loader = document.getElementById('loader');
if (loader) {
loader.innerHTML =
'<div class="loading-text">Erro: Falha ao carregar dependências. Recarregue a página.</div>';
}
return; // Stop execution if dependencies are missing
} else {
// Verifica se todos os cookies necessários existem
const requiredCookies = ["PHPSESSID", "cadastro", "index", "indexTimestamp"];
for (const cookieName of requiredCookies) {
if (!CookieManager.getCookie(cookieName)) {
console.log(`Cookie ${cookieName} não encontrado, redirecionando para index.php`);
window.location.href = "index.php";
return;
}
}
console.log("Verificação de cookies passou com sucesso.");
}
// --- End Cookie Check Logic ---
// --- AR Logic ---
const sceneEl = document.querySelector('#myScene');
const loader = document.getElementById('loader');
const messages = {
0: document.getElementById('floating-message-0'),
1: document.getElementById('floating-message-1'),
2: document.getElementById('floating-message-2'),
3: document.getElementById('floating-message-3')
};
let targetVisible = false;
let currentTarget = null;
// Array para armazenar targets encontrados
let foundTargets = {
0: false, // E7-80T
1: false, // XC6-1056VN
2: false, // XCB25-L5-C
3: false // XCS4531K
};
let maquinasTargets = {
0: 'E7-80T',
1: 'XC6-1056VN',
2: 'XCB25-L5-C',
3: 'XCS4531K'
};
// Função para verificar progresso
function checkProgress() {
console.log("Progresso atual:", Object.values(foundTargets).filter(v => v).length, "de 4");
console.log("Status dos targets:", foundTargets);
// Verifica se todos os targets foram encontrados
const allFound = Object.values(foundTargets).every(found => found === true);
if (allFound) {
CookieManager.setCookie('allFound', 'true', 7); // Cookie válido por 7 dias
console.log("Todos os targets encontrados! Cookie 'allFound' criado.");
setTimeout(() => {
// Redireciona após 5 segundos
showWindowCode()
}, 5000);
}
}
var allFound = CookieManager.getCookie('allFound');
if (allFound) {
console.log("Todos os targets já encontrados. Redirecionando para o código.");
showWindowCode()
} else {
console.log("Nem todos os targets foram encontrados ainda.");
}
sceneEl.addEventListener('renderstart', () => {
loader.style.display = 'none';
console.log("Render started, loader hidden.");
});
sceneEl.addEventListener("targetFound", event => {
const targetIndex = event.target.getAttribute('mindar-image-target').targetIndex;
console.log("Target Found:", targetIndex);
targetVisible = true;
currentTarget = targetIndex;
const targetName = maquinasTargets[targetIndex];
console.log("Target Name:", targetName);
var targetMaquina = document.getElementById(targetName);
targetMaquina.classList.add("found");
// Registra o target como encontrado
foundTargets[targetIndex] = true;
checkProgress();
// Esconde todas as mensagens primeiro
Object.values(messages).forEach(msg => {
if (msg) msg.style.display = "none";
});
// Mostra a mensagem específica
if (messages[currentTarget]) {
messages[currentTarget].style.display = "block";
console.log("Showing message for target", currentTarget);
}
});
sceneEl.addEventListener("targetLost", event => {
console.log("Target Lost!");
targetVisible = false;
if (currentTarget !== null && messages[currentTarget]) {
messages[currentTarget].style.display = "none";
}
currentTarget = null;
});
});
setTimeout(() => {
const video = document.querySelector('video');
if (video) {
video.style.position = 'fixed';
video.style.top = '0';
video.style.left = '0';
video.style.width = '100%';
video.style.height = '100%';
console.log("c")
}
}, 5000);
</script>
<style>
.overlay {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
}
div#finalScreen {
display: block !important;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 8000;
color: white;
background-color: #000028;
}
.footer-svg {
width: 100%;
height: auto;
display: block;
}
.footer {
width: 100%;
}
.a-enter-vr {
display: none;
}
.maquina {
cursor: pointer;
transition: transform 0.2s ease;
filter: brightness(10) drop-shadow(6px 5px 5px white);
opacity: 0.25;
}
.maquina:hover {
transform: scale(1.1);
}
.found {
filter: brightness(1) drop-shadow(0 0 0 black);
opacity: 1;
}
a-scene {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1;
}
h2 {
font-size: 4em;
font-weight: 700;
color: #00f4bc;
}
.finalScreen p {
font-size: 1.5em;
margin-bottom: 1em
}
div#finalScreen {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
width: 100%;
text-align: center;
visibility: hidden;
}
.finalScreen span {
font-size: 1.5em;
line-height: 3em;
}
h1#codigoPremio {
color: #00f4bc;
font-size: 5em;
font-weight: 700;
}
</style>
</body>
</html>

61
proteger.php Executable file
View File

@@ -0,0 +1,61 @@
<?php
session_start();
// Se a senha ainda não foi validada, exibe o formulário
if (!isset($_SESSION["acesso_liberado"])) {
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["senha"] === "banco*xcmg1") {
$_SESSION["acesso_liberado"] = true;
header("Location: " . $_SERVER["PHP_SELF"]); // Redireciona para evitar reenvio do formulário
exit;
}
include "header.php"; // Inclui o cabeçalho da página
?>
<style>
section.flex {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
</style>
<body class="p6 bg-gray-100" app="proteger">
<section class="flex">
<div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
<div
class="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
<h1
class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
Acesso Restrito
</h1>
<form class="space-y-4 md:space-y-6" method="POST">
<div>
<label for="password"
class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Senha</label>
<input type="password" name="senha" id="password" placeholder="••••••••"
class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
required="">
</div>
<button type="submit"
class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">Sign
in</button>
</form>
</div>
</div>
</div>
</section>
<?php
exit; // Interrompe o carregamento da página até que a senha seja validada
}?>
</body>
</html>

164
salvar.php Executable file
View File

@@ -0,0 +1,164 @@
<?php
ob_start();
session_start();
require_once 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
// Função para embaralhar um código
function embaralharCodigo($codigo) {
$alpha = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$alphaReverso = strrev($alpha);
$codigoArray = str_split($codigo);
foreach ($codigoArray as $index => $char) {
$charIndex = strpos($alpha, $char);
if ($charIndex !== false && $index % 2 === 0) {
$codigoArray[$index] = $alphaReverso[$charIndex];
}
}
return implode('', array_reverse($codigoArray));
}
try {
// Conectar ao banco de dados MySQL
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "xcmg";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
throw new Exception("Conexão falhou: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$arquivo = "dados/dados.xlsx";
// Verifica se o arquivo existe
if (file_exists($arquivo)) {
$planilha = \PhpOffice\PhpSpreadsheet\IOFactory::load($arquivo);
$sheet = $planilha->getActiveSheet();
} else {
$planilha = new Spreadsheet();
$sheet = $planilha->getActiveSheet();
$sheet->setCellValue("A1", "Nome");
$sheet->setCellValue("B1", "Empresa");
$sheet->setCellValue("C1", "Cargo");
$sheet->setCellValue("D1", "Telefone");
$sheet->setCellValue("E1", "Email");
$sheet->setCellValue("F1", "Cliente XCMG");
$sheet->setCellValue("G1", "Usa Banco XCMG");
}
// Sanitiza os dados básicos
$nome = $conn->real_escape_string($_POST["nome"]);
$empresa = $conn->real_escape_string($_POST["empresa"]);
$cargo = $conn->real_escape_string($_POST["cargo"]);
$telefone = $conn->real_escape_string($_POST["telefone"]);
// Determina se é cliente XCMG
$cliente_xcmg = "Não";
if (isset($_POST["conhece_xcmg"]) && isset($_POST["adquiriu_xcmg"])) {
$cliente_xcmg = "Sim";
}
// Determina se usa banco XCMG
$usa_banco_xcmg = "Não";
if (isset($_POST["conhece_banco_xcmg"]) && isset($_POST["interesse_financiar_xcmg"])) {
$usa_banco_xcmg = "Sim";
}
// Email (mantemos no dados_adicionais para não requerer alteração da tabela)
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
// validação simples do formato do e-mail (se informado)
if ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new Exception('E-mail inválido');
}
// Cria array com dados adicionais (incluindo e-mail)
$dados_adicionais = [
'email' => $email,
'topicos' => isset($_POST['topicos']) ? (array)$_POST['topicos'] : [],
'data_cadastro' => date('Y-m-d H:i:s'),
'ip_address' => $_SERVER['REMOTE_ADDR'],
'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''
];
$dados_json = json_encode($dados_adicionais, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$dados_json = str_replace("'", "''", $dados_json);
// Salva na planilha
$linha = $sheet->getHighestRow() + 1;
$sheet->setCellValue("A$linha", $nome);
$sheet->setCellValue("B$linha", $empresa);
$sheet->setCellValue("C$linha", $cargo);
$sheet->setCellValue("D$linha", $telefone);
$sheet->setCellValue("E$linha", $email);
$sheet->setCellValue("F$linha", $cliente_xcmg);
$sheet->setCellValue("G$linha", $usa_banco_xcmg);
$escritor = new Xlsx($planilha);
$escritor->save($arquivo);
// Insere no banco
$sql = "INSERT INTO cadastros (
nome, empresa, cargo, telefone,
cliente_xcmg, usa_banco_xcmg, dados_adicionais,
ativado, status
) VALUES (?, ?, ?, ?, ?, ?, ?, 0, 0)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssssss",
$nome, $empresa, $cargo, $telefone,
$cliente_xcmg, $usa_banco_xcmg, $dados_json
);
if (!$stmt->execute()) {
throw new Exception("Erro ao inserir dados: " . $stmt->error);
}
$codigo = $conn->insert_id;
$codigoEmbaralhado = embaralharCodigo($codigo);
// Atualiza o código
$sql_update = "UPDATE cadastros SET codigo = ? WHERE id = ?";
$stmt_update = $conn->prepare($sql_update);
$stmt_update->bind_param("si", $codigoEmbaralhado, $codigo);
if (!$stmt_update->execute()) {
throw new Exception("Erro ao atualizar código: " . $stmt_update->error);
}
if (isset($stmt_update)) $stmt_update->close();
if (isset($stmt)) $stmt->close();
$conn->close();
// Limpa qualquer saída anterior
ob_clean();
// Define cookies e redireciona
setcookie('index', $codigoEmbaralhado, time() + (12 * 3600), '/');
setcookie('indexTimestamp', time(), time() + (12 * 3600), '/');
setcookie('cadastro', 'true', time() + (12 * 3600), '/');
header("Location: play.php");
exit();
}
} catch (Exception $e) {
error_log($e->getMessage());
$_SESSION['erro'] = "Erro ao processar o cadastro. Por favor, tente novamente.";
ob_clean();
header("Location: index.php");
exit();
}
// Se chegou aqui sem POST, redireciona para index
ob_clean();
header("Location: index.php");
exit();
?>

76
style.css Executable file
View File

@@ -0,0 +1,76 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');
* {
font-family: poppins;
}
/* Definindo o fade-in */
#registrationFormContainer {
opacity: 0;
transition: opacity 1s ease-in;
}
#registrationFormContainer.visible {
opacity: 1;
}
p#codigo {
font-size: 75px;
margin: 35px;
}
body {
background-color: #f8f9fa;
background-image: url(img/bg.jpg);
background-size: cover;
background-position: bottom;
touch-action: manipulation;
-ms-touch-action: manipulation;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#login button {
background-color: #007bff;
color: #fff;
}
/* Estilos específicos para mobile */
@media (max-width: 768px) {
form {
padding: 1rem;
}
input[type="text"],
input[type="date"] {
font-size: 16px !important; /* Previne zoom em iOS */
}
}
:root {
--tw-scale-x: 99% !important;
}
button {
background-color: #0a0791;
}
.text-gold-xcmg, .peer-focus\:dark\:text-gold-xcmg {
color: #00f4bc;
}
.border-gold-xcmg {
border-color: #00f4bc;
}
.focus\:border-gold-xcmg, .dark\:border-gold-xcmg {
border-color: #00f4bc ;
}
.peer-focus\:-translate-y-4 {
--tw-translate-y: calc(var(--spacing) * -3.6);
}

BIN
targets (1).mind Executable file

Binary file not shown.

BIN
targets - Copia.mind Executable file

Binary file not shown.

BIN
targets.mind Executable file

Binary file not shown.

BIN
targetsbkp.mind Executable file

Binary file not shown.

7
vendor/autoload.php vendored Executable file
View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit9c214f9288b00d431b45420edf95a40c::getLoader();

572
vendor/composer/ClassLoader.php vendored Executable file
View File

@@ -0,0 +1,572 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* 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 Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var ?string */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
private $apcuPrefix;
/**
* @var self[]
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}
/**
* @return string[]
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return string[] Array of classname => path
* @psalm-return array<string, string>
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{
include $file;
}

350
vendor/composer/InstalledVersions.php vendored Executable file
View File

@@ -0,0 +1,350 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* 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 Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*/
class InstalledVersions
{
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
*/
private static $installed;
/**
* @var bool|null
*/
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static $installedByVendor = array();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
*/
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
$installed[] = self::$installed;
return $installed;
}
}

19
vendor/composer/LICENSE vendored Executable file
View File

@@ -0,0 +1,19 @@
Copyright (c) Nils Adermann, 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.

10
vendor/composer/autoload_classmap.php vendored Executable file
View File

@@ -0,0 +1,10 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
);

9
vendor/composer/autoload_namespaces.php vendored Executable file
View File

@@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

17
vendor/composer/autoload_psr4.php vendored Executable file
View File

@@ -0,0 +1,17 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'),
'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'),
'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'),
);

57
vendor/composer/autoload_real.php vendored Executable file
View File

@@ -0,0 +1,57 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit9c214f9288b00d431b45420edf95a40c
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit9c214f9288b00d431b45420edf95a40c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit9c214f9288b00d431b45420edf95a40c', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit9c214f9288b00d431b45420edf95a40c::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}

81
vendor/composer/autoload_static.php vendored Executable file
View File

@@ -0,0 +1,81 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit9c214f9288b00d431b45420edf95a40c
{
public static $prefixLengthsPsr4 = array (
'Z' =>
array (
'ZipStream\\' => 10,
),
'P' =>
array (
'Psr\\SimpleCache\\' => 16,
'Psr\\Http\\Message\\' => 17,
'Psr\\Http\\Client\\' => 16,
'PhpOffice\\PhpSpreadsheet\\' => 25,
),
'M' =>
array (
'Matrix\\' => 7,
),
'C' =>
array (
'Composer\\Pcre\\' => 14,
'Complex\\' => 8,
),
);
public static $prefixDirsPsr4 = array (
'ZipStream\\' =>
array (
0 => __DIR__ . '/..' . '/maennchen/zipstream-php/src',
),
'Psr\\SimpleCache\\' =>
array (
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
),
'Psr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-message/src',
1 => __DIR__ . '/..' . '/psr/http-factory/src',
),
'Psr\\Http\\Client\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-client/src',
),
'PhpOffice\\PhpSpreadsheet\\' =>
array (
0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet',
),
'Matrix\\' =>
array (
0 => __DIR__ . '/..' . '/markbaker/matrix/classes/src',
),
'Composer\\Pcre\\' =>
array (
0 => __DIR__ . '/..' . '/composer/pcre/src',
),
'Complex\\' =>
array (
0 => __DIR__ . '/..' . '/markbaker/complex/classes/src',
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit9c214f9288b00d431b45420edf95a40c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9c214f9288b00d431b45420edf95a40c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9c214f9288b00d431b45420edf95a40c::$classMap;
}, null, ClassLoader::class);
}
}

613
vendor/composer/installed.json vendored Executable file
View File

@@ -0,0 +1,613 @@
{
"packages": [
{
"name": "composer/pcre",
"version": "3.3.2",
"version_normalized": "3.3.2.0",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"time": "2024-11-12T16:29:46+00:00",
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"install-path": "./pcre"
},
{
"name": "maennchen/zipstream-php",
"version": "3.1.2",
"version_normalized": "3.1.2.0",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-zlib": "*",
"php-64bit": "^8.2"
},
"require-dev": {
"brianium/paratest": "^7.7",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.16",
"guzzlehttp/guzzle": "^7.5",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.5",
"phpunit/phpunit": "^11.0",
"vimeo/psalm": "^6.0"
},
"suggest": {
"guzzlehttp/psr7": "^2.4",
"psr/http-message": "^2.0"
},
"time": "2025-01-27T12:07:53+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.2"
},
"funding": [
{
"url": "https://github.com/maennchen",
"type": "github"
}
],
"install-path": "../maennchen/zipstream-php"
},
{
"name": "markbaker/complex",
"version": "3.0.2",
"version_normalized": "3.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.7"
},
"time": "2022-12-06T16:21:08+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
},
"install-path": "../markbaker/complex"
},
{
"name": "markbaker/matrix",
"version": "3.0.1",
"version_normalized": "3.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "^4.0",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"sebastian/phpcpd": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"time": "2022-12-02T22:17:43+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@demon-angel.eu"
}
],
"description": "PHP Class for working with matrices",
"homepage": "https://github.com/MarkBaker/PHPMatrix",
"keywords": [
"mathematics",
"matrix",
"vector"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
},
"install-path": "../markbaker/matrix"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "3.9.0",
"version_normalized": "3.9.0.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "414f8a2aa1d8b974b39f577c0677d5ebc96fab36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/414f8a2aa1d8b974b39f577c0677d5ebc96fab36",
"reference": "414f8a2aa1d8b974b39f577c0677d5ebc96fab36",
"shasum": ""
},
"require": {
"composer/pcre": "^3.3",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"maennchen/zipstream-php": "^2.1 || ^3.0",
"markbaker/complex": "^3.0",
"markbaker/matrix": "^3.0",
"php": "^8.1",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-main",
"dompdf/dompdf": "^2.0 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"mitoteam/jpgraph": "^10.3",
"mpdf/mpdf": "^8.1.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.5",
"squizlabs/php_codesniffer": "^3.7",
"tecnickcom/tcpdf": "^6.5"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"ext-intl": "PHP Internationalization Functions",
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"time": "2025-01-26T05:10:24+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
},
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/3.9.0"
},
"install-path": "../phpoffice/phpspreadsheet"
},
{
"name": "psr/http-client",
"version": "1.0.3",
"version_normalized": "1.0.3.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0",
"psr/http-message": "^1.0 || ^2.0"
},
"time": "2023-09-23T14:17:50+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client"
},
"install-path": "../psr/http-client"
},
{
"name": "psr/http-factory",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0"
},
"time": "2024-04-15T12:06:14+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory"
},
"install-path": "../psr/http-factory"
},
{
"name": "psr/http-message",
"version": "2.0",
"version_normalized": "2.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"time": "2023-04-04T09:54:51+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/2.0"
},
"install-path": "../psr/http-message"
},
{
"name": "psr/simple-cache",
"version": "3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
},
"time": "2021-10-29T13:26:27+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\SimpleCache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interfaces for simple caching",
"keywords": [
"cache",
"caching",
"psr",
"psr-16",
"simple-cache"
],
"support": {
"source": "https://github.com/php-fig/simple-cache/tree/3.0.0"
},
"install-path": "../psr/simple-cache"
}
],
"dev": true,
"dev-package-names": []
}

104
vendor/composer/installed.php vendored Executable file
View File

@@ -0,0 +1,104 @@
<?php return array(
'root' => array(
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => NULL,
'name' => '__root__',
'dev' => true,
),
'versions' => array(
'__root__' => array(
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => NULL,
'dev_requirement' => false,
),
'composer/pcre' => array(
'pretty_version' => '3.3.2',
'version' => '3.3.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/./pcre',
'aliases' => array(),
'reference' => 'b2bed4734f0cc156ee1fe9c0da2550420d99a21e',
'dev_requirement' => false,
),
'maennchen/zipstream-php' => array(
'pretty_version' => '3.1.2',
'version' => '3.1.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../maennchen/zipstream-php',
'aliases' => array(),
'reference' => 'aeadcf5c412332eb426c0f9b4485f6accba2a99f',
'dev_requirement' => false,
),
'markbaker/complex' => array(
'pretty_version' => '3.0.2',
'version' => '3.0.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../markbaker/complex',
'aliases' => array(),
'reference' => '95c56caa1cf5c766ad6d65b6344b807c1e8405b9',
'dev_requirement' => false,
),
'markbaker/matrix' => array(
'pretty_version' => '3.0.1',
'version' => '3.0.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../markbaker/matrix',
'aliases' => array(),
'reference' => '728434227fe21be27ff6d86621a1b13107a2562c',
'dev_requirement' => false,
),
'phpoffice/phpspreadsheet' => array(
'pretty_version' => '3.9.0',
'version' => '3.9.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpoffice/phpspreadsheet',
'aliases' => array(),
'reference' => '414f8a2aa1d8b974b39f577c0677d5ebc96fab36',
'dev_requirement' => false,
),
'psr/http-client' => array(
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-client',
'aliases' => array(),
'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90',
'dev_requirement' => false,
),
'psr/http-factory' => array(
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-factory',
'aliases' => array(),
'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a',
'dev_requirement' => false,
),
'psr/http-message' => array(
'pretty_version' => '2.0',
'version' => '2.0.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-message',
'aliases' => array(),
'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71',
'dev_requirement' => false,
),
'psr/simple-cache' => array(
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/simple-cache',
'aliases' => array(),
'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865',
'dev_requirement' => false,
),
),
);

19
vendor/composer/pcre/LICENSE vendored Executable file
View File

@@ -0,0 +1,19 @@
Copyright (C) 2021 Composer
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.

189
vendor/composer/pcre/README.md vendored Executable file
View File

@@ -0,0 +1,189 @@
composer/pcre
=============
PCRE wrapping library that offers type-safe `preg_*` replacements.
This library gives you a way to ensure `preg_*` functions do not fail silently, returning
unexpected `null`s that may not be handled.
As of 3.0 this library enforces [`PREG_UNMATCHED_AS_NULL`](#preg_unmatched_as_null) usage
for all matching and replaceCallback functions, [read more below](#preg_unmatched_as_null)
to understand the implications.
It thus makes it easier to work with static analysis tools like PHPStan or Psalm as it
simplifies and reduces the possible return values from all the `preg_*` functions which
are quite packed with edge cases. As of v2.2.0 / v3.2.0 the library also comes with a
[PHPStan extension](#phpstan-extension) for parsing regular expressions and giving you even better output types.
This library is a thin wrapper around `preg_*` functions with [some limitations](#restrictions--limitations).
If you are looking for a richer API to handle regular expressions have a look at
[rawr/t-regx](https://packagist.org/packages/rawr/t-regx) instead.
[![Continuous Integration](https://github.com/composer/pcre/workflows/Continuous%20Integration/badge.svg?branch=main)](https://github.com/composer/pcre/actions)
Installation
------------
Install the latest version with:
```bash
$ composer require composer/pcre
```
Requirements
------------
* PHP 7.4.0 is required for 3.x versions
* PHP 7.2.0 is required for 2.x versions
* PHP 5.3.2 is required for 1.x versions
Basic usage
-----------
Instead of:
```php
if (preg_match('{fo+}', $string, $matches)) { ... }
if (preg_match('{fo+}', $string, $matches, PREG_OFFSET_CAPTURE)) { ... }
if (preg_match_all('{fo+}', $string, $matches)) { ... }
$newString = preg_replace('{fo+}', 'bar', $string);
$newString = preg_replace_callback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string);
$newString = preg_replace_callback_array(['{fo+}' => fn ($match) => strtoupper($match[0])], $string);
$filtered = preg_grep('{[a-z]}', $elements);
$array = preg_split('{[a-z]+}', $string);
```
You can now call these on the `Preg` class:
```php
use Composer\Pcre\Preg;
if (Preg::match('{fo+}', $string, $matches)) { ... }
if (Preg::matchWithOffsets('{fo+}', $string, $matches)) { ... }
if (Preg::matchAll('{fo+}', $string, $matches)) { ... }
$newString = Preg::replace('{fo+}', 'bar', $string);
$newString = Preg::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string);
$newString = Preg::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string);
$filtered = Preg::grep('{[a-z]}', $elements);
$array = Preg::split('{[a-z]+}', $string);
```
The main difference is if anything fails to match/replace/.., it will throw a `Composer\Pcre\PcreException`
instead of returning `null` (or false in some cases), so you can now use the return values safely relying on
the fact that they can only be strings (for replace), ints (for match) or arrays (for grep/split).
Additionally the `Preg` class provides match methods that return `bool` rather than `int`, for stricter type safety
when the number of pattern matches is not useful:
```php
use Composer\Pcre\Preg;
if (Preg::isMatch('{fo+}', $string, $matches)) // bool
if (Preg::isMatchAll('{fo+}', $string, $matches)) // bool
```
Finally the `Preg` class provides a few `*StrictGroups` method variants that ensure match groups
are always present and thus non-nullable, making it easier to write type-safe code:
```php
use Composer\Pcre\Preg;
// $matches is guaranteed to be an array of strings, if a subpattern does not match and produces a null it will throw
if (Preg::matchStrictGroups('{fo+}', $string, $matches))
if (Preg::matchAllStrictGroups('{fo+}', $string, $matches))
```
**Note:** This is generally safe to use as long as you do not have optional subpatterns (i.e. `(something)?`
or `(something)*` or branches with a `|` that result in some groups not being matched at all).
A subpattern that can match an empty string like `(.*)` is **not** optional, it will be present as an
empty string in the matches. A non-matching subpattern, even if optional like `(?:foo)?` will anyway not be present in
matches so it is also not a problem to use these with `*StrictGroups` methods.
If you would prefer a slightly more verbose usage, replacing by-ref arguments by result objects, you can use the `Regex` class:
```php
use Composer\Pcre\Regex;
// this is useful when you are just interested in knowing if something matched
// as it returns a bool instead of int(1/0) for match
$bool = Regex::isMatch('{fo+}', $string);
$result = Regex::match('{fo+}', $string);
if ($result->matched) { something($result->matches); }
$result = Regex::matchWithOffsets('{fo+}', $string);
if ($result->matched) { something($result->matches); }
$result = Regex::matchAll('{fo+}', $string);
if ($result->matched && $result->count > 3) { something($result->matches); }
$newString = Regex::replace('{fo+}', 'bar', $string)->result;
$newString = Regex::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string)->result;
$newString = Regex::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string)->result;
```
Note that `preg_grep` and `preg_split` are only callable via the `Preg` class as they do not have
complex return types warranting a specific result object.
See the [MatchResult](src/MatchResult.php), [MatchWithOffsetsResult](src/MatchWithOffsetsResult.php), [MatchAllResult](src/MatchAllResult.php),
[MatchAllWithOffsetsResult](src/MatchAllWithOffsetsResult.php), and [ReplaceResult](src/ReplaceResult.php) class sources for more details.
Restrictions / Limitations
--------------------------
Due to type safety requirements a few restrictions are in place.
- matching using `PREG_OFFSET_CAPTURE` is made available via `matchWithOffsets` and `matchAllWithOffsets`.
You cannot pass the flag to `match`/`matchAll`.
- `Preg::split` will also reject `PREG_SPLIT_OFFSET_CAPTURE` and you should use `splitWithOffsets`
instead.
- `matchAll` rejects `PREG_SET_ORDER` as it also changes the shape of the returned matches. There
is no alternative provided as you can fairly easily code around it.
- `preg_filter` is not supported as it has a rather crazy API, most likely you should rather
use `Preg::grep` in combination with some loop and `Preg::replace`.
- `replace`, `replaceCallback` and `replaceCallbackArray` do not support an array `$subject`,
only simple strings.
- As of 2.0, the library always uses `PREG_UNMATCHED_AS_NULL` for matching, which offers [much
saner/more predictable results](#preg_unmatched_as_null). As of 3.0 the flag is also set for
`replaceCallback` and `replaceCallbackArray`.
#### PREG_UNMATCHED_AS_NULL
As of 2.0, this library always uses PREG_UNMATCHED_AS_NULL for all `match*` and `isMatch*`
functions. As of 3.0 it is also done for `replaceCallback` and `replaceCallbackArray`.
This means your matches will always contain all matching groups, either as null if unmatched
or as string if it matched.
The advantages in clarity and predictability are clearer if you compare the two outputs of
running this with and without PREG_UNMATCHED_AS_NULL in $flags:
```php
preg_match('/(a)(b)*(c)(d)*/', 'ac', $matches, $flags);
```
| no flag | PREG_UNMATCHED_AS_NULL |
| --- | --- |
| array (size=4) | array (size=5) |
| 0 => string 'ac' (length=2) | 0 => string 'ac' (length=2) |
| 1 => string 'a' (length=1) | 1 => string 'a' (length=1) |
| 2 => string '' (length=0) | 2 => null |
| 3 => string 'c' (length=1) | 3 => string 'c' (length=1) |
| | 4 => null |
| group 2 (any unmatched group preceding one that matched) is set to `''`. You cannot tell if it matched an empty string or did not match at all | group 2 is `null` when unmatched and a string if it matched, easy to check for |
| group 4 (any optional group without a matching one following) is missing altogether. So you have to check with `isset()`, but really you want `isset($m[4]) && $m[4] !== ''` for safety unless you are very careful to check that a non-optional group follows it | group 4 is always set, and null in this case as there was no match, easy to check for with `$m[4] !== null` |
PHPStan Extension
-----------------
To use the PHPStan extension if you do not use `phpstan/extension-installer` you can include `vendor/composer/pcre/extension.neon` in your PHPStan config.
The extension provides much better type information for $matches as well as regex validation where possible.
License
-------
composer/pcre is licensed under the MIT License, see the LICENSE file for details.

54
vendor/composer/pcre/composer.json vendored Executable file
View File

@@ -0,0 +1,54 @@
{
"name": "composer/pcre",
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"type": "library",
"license": "MIT",
"keywords": [
"pcre",
"regex",
"preg",
"regular expression"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"require": {
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^8 || ^9",
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Composer\\Pcre\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
},
"phpstan": {
"includes": [
"extension.neon"
]
}
},
"scripts": {
"test": "@php vendor/bin/phpunit",
"phpstan": "@php phpstan analyse"
}
}

22
vendor/composer/pcre/extension.neon vendored Executable file
View File

@@ -0,0 +1,22 @@
# composer/pcre PHPStan extensions
#
# These can be reused by third party packages by including 'vendor/composer/pcre/extension.neon'
# in your phpstan config
services:
-
class: Composer\Pcre\PHPStan\PregMatchParameterOutTypeExtension
tags:
- phpstan.staticMethodParameterOutTypeExtension
-
class: Composer\Pcre\PHPStan\PregMatchTypeSpecifyingExtension
tags:
- phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension
-
class: Composer\Pcre\PHPStan\PregReplaceCallbackClosureTypeExtension
tags:
- phpstan.staticMethodParameterClosureTypeExtension
rules:
- Composer\Pcre\PHPStan\UnsafeStrictGroupsCallRule
- Composer\Pcre\PHPStan\InvalidRegexPatternRule

46
vendor/composer/pcre/src/MatchAllResult.php vendored Executable file
View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchAllResult
{
/**
* An array of match group => list of matched strings
*
* @readonly
* @var array<int|string, list<string|null>>
*/
public $matches;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<int|string, list<string|null>> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchAllStrictGroupsResult
{
/**
* An array of match group => list of matched strings
*
* @readonly
* @var array<int|string, list<string>>
*/
public $matches;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<list<string>> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchAllWithOffsetsResult
{
/**
* An array of match group => list of matches, every match being a pair of string matched + offset in bytes (or -1 if no match)
*
* @readonly
* @var array<int|string, list<array{string|null, int}>>
* @phpstan-var array<int|string, list<array{string|null, int<-1, max>}>>
*/
public $matches;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<int|string, list<array{string|null, int}>> $matches
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

39
vendor/composer/pcre/src/MatchResult.php vendored Executable file
View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchResult
{
/**
* An array of match group => string matched
*
* @readonly
* @var array<int|string, string|null>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<string|null> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchStrictGroupsResult
{
/**
* An array of match group => string matched
*
* @readonly
* @var array<int|string, string>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<string> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchWithOffsetsResult
{
/**
* An array of match group => pair of string matched + offset in bytes (or -1 if no match)
*
* @readonly
* @var array<int|string, array{string|null, int}>
* @phpstan-var array<int|string, array{string|null, int<-1, max>}>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<array{string|null, int}> $matches
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@@ -0,0 +1,142 @@
<?php declare(strict_types = 1);
namespace Composer\Pcre\PHPStan;
use Composer\Pcre\Preg;
use Composer\Pcre\Regex;
use Composer\Pcre\PcreException;
use Nette\Utils\RegexpException;
use Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name\FullyQualified;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use function in_array;
use function sprintf;
/**
* Copy of PHPStan's RegularExpressionPatternRule
*
* @implements Rule<StaticCall>
*/
class InvalidRegexPatternRule implements Rule
{
public function getNodeType(): string
{
return StaticCall::class;
}
public function processNode(Node $node, Scope $scope): array
{
$patterns = $this->extractPatterns($node, $scope);
$errors = [];
foreach ($patterns as $pattern) {
$errorMessage = $this->validatePattern($pattern);
if ($errorMessage === null) {
continue;
}
$errors[] = RuleErrorBuilder::message(sprintf('Regex pattern is invalid: %s', $errorMessage))->identifier('regexp.pattern')->build();
}
return $errors;
}
/**
* @return string[]
*/
private function extractPatterns(StaticCall $node, Scope $scope): array
{
if (!$node->class instanceof FullyQualified) {
return [];
}
$isRegex = $node->class->toString() === Regex::class;
$isPreg = $node->class->toString() === Preg::class;
if (!$isRegex && !$isPreg) {
return [];
}
if (!$node->name instanceof Node\Identifier || !Preg::isMatch('{^(match|isMatch|grep|replace|split)}', $node->name->name)) {
return [];
}
$functionName = $node->name->name;
if (!isset($node->getArgs()[0])) {
return [];
}
$patternNode = $node->getArgs()[0]->value;
$patternType = $scope->getType($patternNode);
$patternStrings = [];
foreach ($patternType->getConstantStrings() as $constantStringType) {
if ($functionName === 'replaceCallbackArray') {
continue;
}
$patternStrings[] = $constantStringType->getValue();
}
foreach ($patternType->getConstantArrays() as $constantArrayType) {
if (
in_array($functionName, [
'replace',
'replaceCallback',
], true)
) {
foreach ($constantArrayType->getValueTypes() as $arrayKeyType) {
foreach ($arrayKeyType->getConstantStrings() as $constantString) {
$patternStrings[] = $constantString->getValue();
}
}
}
if ($functionName !== 'replaceCallbackArray') {
continue;
}
foreach ($constantArrayType->getKeyTypes() as $arrayKeyType) {
foreach ($arrayKeyType->getConstantStrings() as $constantString) {
$patternStrings[] = $constantString->getValue();
}
}
}
return $patternStrings;
}
private function validatePattern(string $pattern): ?string
{
try {
$msg = null;
$prev = set_error_handler(function (int $severity, string $message, string $file) use (&$msg): bool {
$msg = preg_replace("#^preg_match(_all)?\\(.*?\\): #", '', $message);
return true;
});
if ($pattern === '') {
return 'Empty string is not a valid regular expression';
}
Preg::match($pattern, '');
if ($msg !== null) {
return $msg;
}
} catch (PcreException $e) {
if ($e->getCode() === PREG_INTERNAL_ERROR && $msg !== null) {
return $msg;
}
return preg_replace('{.*? failed executing ".*": }', '', $e->getMessage());
} finally {
restore_error_handler();
}
return null;
}
}

View File

@@ -0,0 +1,70 @@
<?php declare(strict_types=1);
namespace Composer\Pcre\PHPStan;
use PHPStan\Analyser\Scope;
use PHPStan\Type\ArrayType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\Type;
use PhpParser\Node\Arg;
use PHPStan\Type\Php\RegexArrayShapeMatcher;
use PHPStan\Type\TypeTraverser;
use PHPStan\Type\UnionType;
final class PregMatchFlags
{
static public function getType(?Arg $flagsArg, Scope $scope): ?Type
{
if ($flagsArg === null) {
return new ConstantIntegerType(PREG_UNMATCHED_AS_NULL);
}
$flagsType = $scope->getType($flagsArg->value);
$constantScalars = $flagsType->getConstantScalarValues();
if ($constantScalars === []) {
return null;
}
$internalFlagsTypes = [];
foreach ($flagsType->getConstantScalarValues() as $constantScalarValue) {
if (!is_int($constantScalarValue)) {
return null;
}
$internalFlagsTypes[] = new ConstantIntegerType($constantScalarValue | PREG_UNMATCHED_AS_NULL);
}
return TypeCombinator::union(...$internalFlagsTypes);
}
static public function removeNullFromMatches(Type $matchesType): Type
{
return TypeTraverser::map($matchesType, static function (Type $type, callable $traverse): Type {
if ($type instanceof UnionType || $type instanceof IntersectionType) {
return $traverse($type);
}
if ($type instanceof ConstantArrayType) {
return new ConstantArrayType(
$type->getKeyTypes(),
array_map(static function (Type $valueType) use ($traverse): Type {
return $traverse($valueType);
}, $type->getValueTypes()),
$type->getNextAutoIndexes(),
[],
$type->isList()
);
}
if ($type instanceof ArrayType) {
return new ArrayType($type->getKeyType(), $traverse($type->getItemType()));
}
return TypeCombinator::removeNull($type);
});
}
}

View File

@@ -0,0 +1,65 @@
<?php declare(strict_types=1);
namespace Composer\Pcre\PHPStan;
use Composer\Pcre\Preg;
use PhpParser\Node\Expr\StaticCall;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParameterReflection;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Php\RegexArrayShapeMatcher;
use PHPStan\Type\StaticMethodParameterOutTypeExtension;
use PHPStan\Type\Type;
final class PregMatchParameterOutTypeExtension implements StaticMethodParameterOutTypeExtension
{
/**
* @var RegexArrayShapeMatcher
*/
private $regexShapeMatcher;
public function __construct(
RegexArrayShapeMatcher $regexShapeMatcher
)
{
$this->regexShapeMatcher = $regexShapeMatcher;
}
public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool
{
return
$methodReflection->getDeclaringClass()->getName() === Preg::class
&& in_array($methodReflection->getName(), [
'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups',
'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups'
], true)
&& $parameter->getName() === 'matches';
}
public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type
{
$args = $methodCall->getArgs();
$patternArg = $args[0] ?? null;
$matchesArg = $args[2] ?? null;
$flagsArg = $args[3] ?? null;
if (
$patternArg === null || $matchesArg === null
) {
return null;
}
$flagsType = PregMatchFlags::getType($flagsArg, $scope);
if ($flagsType === null) {
return null;
}
if (stripos($methodReflection->getName(), 'matchAll') !== false) {
return $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope);
}
return $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope);
}
}

View File

@@ -0,0 +1,119 @@
<?php declare(strict_types=1);
namespace Composer\Pcre\PHPStan;
use Composer\Pcre\Preg;
use PhpParser\Node\Expr\StaticCall;
use PHPStan\Analyser\Scope;
use PHPStan\Analyser\SpecifiedTypes;
use PHPStan\Analyser\TypeSpecifier;
use PHPStan\Analyser\TypeSpecifierAwareExtension;
use PHPStan\Analyser\TypeSpecifierContext;
use PHPStan\Reflection\MethodReflection;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Php\RegexArrayShapeMatcher;
use PHPStan\Type\StaticMethodTypeSpecifyingExtension;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\Type;
final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
{
/**
* @var TypeSpecifier
*/
private $typeSpecifier;
/**
* @var RegexArrayShapeMatcher
*/
private $regexShapeMatcher;
public function __construct(RegexArrayShapeMatcher $regexShapeMatcher)
{
$this->regexShapeMatcher = $regexShapeMatcher;
}
public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
{
$this->typeSpecifier = $typeSpecifier;
}
public function getClass(): string
{
return Preg::class;
}
public function isStaticMethodSupported(MethodReflection $methodReflection, StaticCall $node, TypeSpecifierContext $context): bool
{
return in_array($methodReflection->getName(), [
'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups',
'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups'
], true)
&& !$context->null();
}
public function specifyTypes(MethodReflection $methodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
{
$args = $node->getArgs();
$patternArg = $args[0] ?? null;
$matchesArg = $args[2] ?? null;
$flagsArg = $args[3] ?? null;
if (
$patternArg === null || $matchesArg === null
) {
return new SpecifiedTypes();
}
$flagsType = PregMatchFlags::getType($flagsArg, $scope);
if ($flagsType === null) {
return new SpecifiedTypes();
}
if (stripos($methodReflection->getName(), 'matchAll') !== false) {
$matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
} else {
$matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
}
if ($matchedType === null) {
return new SpecifiedTypes();
}
if (
in_array($methodReflection->getName(), ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)
) {
$matchedType = PregMatchFlags::removeNullFromMatches($matchedType);
}
$overwrite = false;
if ($context->false()) {
$overwrite = true;
$context = $context->negate();
}
// @phpstan-ignore function.alreadyNarrowedType
if (method_exists('PHPStan\Analyser\SpecifiedTypes', 'setRootExpr')) {
$typeSpecifier = $this->typeSpecifier->create(
$matchesArg->value,
$matchedType,
$context,
$scope
)->setRootExpr($node);
return $overwrite ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier;
}
// @phpstan-ignore arguments.count
return $this->typeSpecifier->create(
$matchesArg->value,
$matchedType,
$context,
// @phpstan-ignore argument.type
$overwrite,
$scope,
$node
);
}
}

View File

@@ -0,0 +1,91 @@
<?php declare(strict_types=1);
namespace Composer\Pcre\PHPStan;
use Composer\Pcre\Preg;
use Composer\Pcre\Regex;
use PhpParser\Node\Expr\StaticCall;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\Native\NativeParameterReflection;
use PHPStan\Reflection\ParameterReflection;
use PHPStan\TrinaryLogic;
use PHPStan\Type\ClosureType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Php\RegexArrayShapeMatcher;
use PHPStan\Type\StaticMethodParameterClosureTypeExtension;
use PHPStan\Type\StringType;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\Type;
final class PregReplaceCallbackClosureTypeExtension implements StaticMethodParameterClosureTypeExtension
{
/**
* @var RegexArrayShapeMatcher
*/
private $regexShapeMatcher;
public function __construct(RegexArrayShapeMatcher $regexShapeMatcher)
{
$this->regexShapeMatcher = $regexShapeMatcher;
}
public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool
{
return in_array($methodReflection->getDeclaringClass()->getName(), [Preg::class, Regex::class], true)
&& in_array($methodReflection->getName(), ['replaceCallback', 'replaceCallbackStrictGroups'], true)
&& $parameter->getName() === 'replacement';
}
public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type
{
$args = $methodCall->getArgs();
$patternArg = $args[0] ?? null;
$flagsArg = $args[5] ?? null;
if (
$patternArg === null
) {
return null;
}
$flagsType = PregMatchFlags::getType($flagsArg, $scope);
$matchesType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope);
if ($matchesType === null) {
return null;
}
if ($methodReflection->getName() === 'replaceCallbackStrictGroups' && count($matchesType->getConstantArrays()) === 1) {
$matchesType = $matchesType->getConstantArrays()[0];
$matchesType = new ConstantArrayType(
$matchesType->getKeyTypes(),
array_map(static function (Type $valueType): Type {
if (count($valueType->getConstantArrays()) === 1) {
$valueTypeArray = $valueType->getConstantArrays()[0];
return new ConstantArrayType(
$valueTypeArray->getKeyTypes(),
array_map(static function (Type $valueType): Type {
return TypeCombinator::removeNull($valueType);
}, $valueTypeArray->getValueTypes()),
$valueTypeArray->getNextAutoIndexes(),
[],
$valueTypeArray->isList()
);
}
return TypeCombinator::removeNull($valueType);
}, $matchesType->getValueTypes()),
$matchesType->getNextAutoIndexes(),
[],
$matchesType->isList()
);
}
return new ClosureType(
[
new NativeParameterReflection($parameter->getName(), $parameter->isOptional(), $matchesType, $parameter->passedByReference(), $parameter->isVariadic(), $parameter->getDefaultValue()),
],
new StringType()
);
}
}

View File

@@ -0,0 +1,112 @@
<?php declare(strict_types=1);
namespace Composer\Pcre\PHPStan;
use Composer\Pcre\Preg;
use Composer\Pcre\Regex;
use PhpParser\Node;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name\FullyQualified;
use PHPStan\Analyser\Scope;
use PHPStan\Analyser\SpecifiedTypes;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\TrinaryLogic;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\Php\RegexArrayShapeMatcher;
use function sprintf;
/**
* @implements Rule<StaticCall>
*/
final class UnsafeStrictGroupsCallRule implements Rule
{
/**
* @var RegexArrayShapeMatcher
*/
private $regexShapeMatcher;
public function __construct(RegexArrayShapeMatcher $regexShapeMatcher)
{
$this->regexShapeMatcher = $regexShapeMatcher;
}
public function getNodeType(): string
{
return StaticCall::class;
}
public function processNode(Node $node, Scope $scope): array
{
if (!$node->class instanceof FullyQualified) {
return [];
}
$isRegex = $node->class->toString() === Regex::class;
$isPreg = $node->class->toString() === Preg::class;
if (!$isRegex && !$isPreg) {
return [];
}
if (!$node->name instanceof Node\Identifier || !in_array($node->name->name, ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)) {
return [];
}
$args = $node->getArgs();
if (!isset($args[0])) {
return [];
}
$patternArg = $args[0] ?? null;
if ($isPreg) {
if (!isset($args[2])) { // no matches set, skip as the matches won't be used anyway
return [];
}
$flagsArg = $args[3] ?? null;
} else {
$flagsArg = $args[2] ?? null;
}
if ($patternArg === null) {
return [];
}
$flagsType = PregMatchFlags::getType($flagsArg, $scope);
if ($flagsType === null) {
return [];
}
$matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope);
if ($matchedType === null) {
return [
RuleErrorBuilder::message(sprintf('The %s call is potentially unsafe as $matches\' type could not be inferred.', $node->name->name))
->identifier('composerPcre.maybeUnsafeStrictGroups')
->build(),
];
}
if (count($matchedType->getConstantArrays()) === 1) {
$matchedType = $matchedType->getConstantArrays()[0];
$nullableGroups = [];
foreach ($matchedType->getValueTypes() as $index => $type) {
if (TypeCombinator::containsNull($type)) {
$nullableGroups[] = $matchedType->getKeyTypes()[$index]->getValue();
}
}
if (\count($nullableGroups) > 0) {
return [
RuleErrorBuilder::message(sprintf(
'The %s call is unsafe as match group%s "%s" %s optional and may be null.',
$node->name->name,
\count($nullableGroups) > 1 ? 's' : '',
implode('", "', $nullableGroups),
\count($nullableGroups) > 1 ? 'are' : 'is'
))->identifier('composerPcre.unsafeStrictGroups')->build(),
];
}
}
return [];
}
}

55
vendor/composer/pcre/src/PcreException.php vendored Executable file
View File

@@ -0,0 +1,55 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class PcreException extends \RuntimeException
{
/**
* @param string $function
* @param string|string[] $pattern
* @return self
*/
public static function fromFunction($function, $pattern)
{
$code = preg_last_error();
if (is_array($pattern)) {
$pattern = implode(', ', $pattern);
}
return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code);
}
/**
* @param int $code
* @return string
*/
private static function pcreLastErrorMessage($code)
{
if (function_exists('preg_last_error_msg')) {
return preg_last_error_msg();
}
$constants = get_defined_constants(true);
if (!isset($constants['pcre']) || !is_array($constants['pcre'])) {
return 'UNDEFINED_ERROR';
}
foreach ($constants['pcre'] as $const => $val) {
if ($val === $code && substr($const, -6) === '_ERROR') {
return $const;
}
}
return 'UNDEFINED_ERROR';
}
}

430
vendor/composer/pcre/src/Preg.php vendored Executable file
View File

@@ -0,0 +1,430 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class Preg
{
/** @internal */
public const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
/** @internal */
public const INVALID_TYPE_MSG = '$subject must be a string, %s given.';
/**
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|1
*
* @param-out array<int|string, string|null> $matches
*/
public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
self::checkOffsetCapture($flags, 'matchWithOffsets');
$result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
if ($result === false) {
throw PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
/**
* Variant of `match()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|1
* @throws UnexpectedNullMatchException
*
* @param-out array<int|string, string> $matches
*/
public static function matchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
$result = self::match($pattern, $subject, $matchesInternal, $flags, $offset);
$matches = self::enforceNonNullMatches($pattern, $matchesInternal, 'match');
return $result;
}
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_OFFSET_CAPTURE are always set, no other flags are supported
* @return 0|1
*
* @param-out array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
{
$result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
if ($result === false) {
throw PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
/**
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|positive-int
*
* @param-out array<int|string, list<string|null>> $matches
*/
public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
$result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
/**
* Variant of `match()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|positive-int
* @throws UnexpectedNullMatchException
*
* @param-out array<int|string, list<string>> $matches
*/
public static function matchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
$result = self::matchAll($pattern, $subject, $matchesInternal, $flags, $offset);
$matches = self::enforceNonNullMatchAll($pattern, $matchesInternal, 'matchAll');
return $result;
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
* @return 0|positive-int
*
* @param-out array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
{
self::checkSetOrder($flags);
$result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
/**
* @param string|string[] $pattern
* @param string|string[] $replacement
* @param string $subject
* @param int $count Set by method
*
* @param-out int<0, max> $count
*/
public static function replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null): string
{
if (!is_scalar($subject)) {
if (is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
}
$result = preg_replace($pattern, $replacement, $subject, $limit, $count);
if ($result === null) {
throw PcreException::fromFunction('preg_replace', $pattern);
}
return $result;
}
/**
* @param string|string[] $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string|null, int<-1, max>}>): string) : callable(array<int|string, string|null>): string) $replacement
* @param string $subject
* @param int $count Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
{
if (!is_scalar($subject)) {
if (is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
}
$result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL);
if ($result === null) {
throw PcreException::fromFunction('preg_replace_callback', $pattern);
}
return $result;
}
/**
* Variant of `replaceCallback()` which outputs non-null matches (or throws)
*
* @param string $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string, int<0, max>}>): string) : callable(array<int|string, string>): string) $replacement
* @param string $subject
* @param int $count Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallbackStrictGroups(string $pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
{
return self::replaceCallback($pattern, function (array $matches) use ($pattern, $replacement) {
return $replacement(self::enforceNonNullMatches($pattern, $matches, 'replaceCallback'));
}, $subject, $limit, $count, $flags);
}
/**
* @param ($flags is PREG_OFFSET_CAPTURE ? (array<string, callable(array<int|string, array{string|null, int<-1, max>}>): string>) : array<string, callable(array<int|string, string|null>): string>) $pattern
* @param string $subject
* @param int $count Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
{
if (!is_scalar($subject)) {
if (is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
}
$result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL);
if ($result === null) {
$pattern = array_keys($pattern);
throw PcreException::fromFunction('preg_replace_callback_array', $pattern);
}
return $result;
}
/**
* @param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
* @return list<string>
*/
public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
{
if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
}
$result = preg_split($pattern, $subject, $limit, $flags);
if ($result === false) {
throw PcreException::fromFunction('preg_split', $pattern);
}
return $result;
}
/**
* @param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE is always set
* @return list<array{string, int}>
* @phpstan-return list<array{string, int<0, max>}>
*/
public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
{
$result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE);
if ($result === false) {
throw PcreException::fromFunction('preg_split', $pattern);
}
return $result;
}
/**
* @template T of string|\Stringable
* @param string $pattern
* @param array<T> $array
* @param int-mask<PREG_GREP_INVERT> $flags PREG_GREP_INVERT
* @return array<T>
*/
public static function grep(string $pattern, array $array, int $flags = 0): array
{
$result = preg_grep($pattern, $array, $flags);
if ($result === false) {
throw PcreException::fromFunction('preg_grep', $pattern);
}
return $result;
}
/**
* Variant of match() which returns a bool instead of int
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, string|null> $matches
*/
public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of `isMatch()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @throws UnexpectedNullMatchException
*
* @param-out array<int|string, string> $matches
*/
public static function isMatchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) self::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of matchAll() which returns a bool instead of int
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, list<string|null>> $matches
*/
public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of `isMatchAll()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, list<string>> $matches
*/
public static function isMatchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) self::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of matchWithOffsets() which returns a bool instead of int
*
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
{
return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of matchAllWithOffsets() which returns a bool instead of int
*
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
{
return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
private static function checkOffsetCapture(int $flags, string $useFunctionName): void
{
if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use ' . $useFunctionName . '() instead');
}
}
private static function checkSetOrder(int $flags): void
{
if (($flags & PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
}
}
/**
* @param array<int|string, string|null|array{string|null, int}> $matches
* @return array<int|string, string>
* @throws UnexpectedNullMatchException
*/
private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod)
{
foreach ($matches as $group => $match) {
if (is_string($match) || (is_array($match) && is_string($match[0]))) {
continue;
}
throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
}
/** @var array<string> */
return $matches;
}
/**
* @param array<int|string, list<string|null>> $matches
* @return array<int|string, list<string>>
* @throws UnexpectedNullMatchException
*/
private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod)
{
foreach ($matches as $group => $groupMatches) {
foreach ($groupMatches as $match) {
if (null === $match) {
throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
}
}
}
/** @var array<int|string, list<string>> */
return $matches;
}
}

176
vendor/composer/pcre/src/Regex.php vendored Executable file
View File

@@ -0,0 +1,176 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class Regex
{
/**
* @param non-empty-string $pattern
*/
public static function isMatch(string $pattern, string $subject, int $offset = 0): bool
{
return (bool) Preg::match($pattern, $subject, $matches, 0, $offset);
}
/**
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*/
public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchResult
{
self::checkOffsetCapture($flags, 'matchWithOffsets');
$count = Preg::match($pattern, $subject, $matches, $flags, $offset);
return new MatchResult($count, $matches);
}
/**
* Variant of `match()` which returns non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @throws UnexpectedNullMatchException
*/
public static function matchStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchStrictGroupsResult
{
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
$count = Preg::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
return new MatchStrictGroupsResult($count, $matches);
}
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
*/
public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchWithOffsetsResult
{
$count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new MatchWithOffsetsResult($count, $matches);
}
/**
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*/
public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllResult
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
$count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
return new MatchAllResult($count, $matches);
}
/**
* Variant of `matchAll()` which returns non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @throws UnexpectedNullMatchException
*/
public static function matchAllStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllStrictGroupsResult
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
$count = Preg::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
return new MatchAllStrictGroupsResult($count, $matches);
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
*/
public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllWithOffsetsResult
{
self::checkSetOrder($flags);
$count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new MatchAllWithOffsetsResult($count, $matches);
}
/**
* @param string|string[] $pattern
* @param string|string[] $replacement
* @param string $subject
*/
public static function replace($pattern, $replacement, $subject, int $limit = -1): ReplaceResult
{
$result = Preg::replace($pattern, $replacement, $subject, $limit, $count);
return new ReplaceResult($count, $result);
}
/**
* @param string|string[] $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string|null, int<-1, max>}>): string) : callable(array<int|string, string|null>): string) $replacement
* @param string $subject
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult
{
$result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
/**
* Variant of `replaceCallback()` which outputs non-null matches (or throws)
*
* @param string $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string, int<0, max>}>): string) : callable(array<int|string, string>): string) $replacement
* @param string $subject
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallbackStrictGroups($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult
{
$result = Preg::replaceCallbackStrictGroups($pattern, $replacement, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
/**
* @param ($flags is PREG_OFFSET_CAPTURE ? (array<string, callable(array<int|string, array{string|null, int<-1, max>}>): string>) : array<string, callable(array<int|string, string|null>): string>) $pattern
* @param string $subject
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0): ReplaceResult
{
$result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
private static function checkOffsetCapture(int $flags, string $useFunctionName): void
{
if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead');
}
}
private static function checkSetOrder(int $flags): void
{
if (($flags & PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
}
}
}

43
vendor/composer/pcre/src/ReplaceResult.php vendored Executable file
View File

@@ -0,0 +1,43 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class ReplaceResult
{
/**
* @readonly
* @var string
*/
public $result;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
*/
public function __construct(int $count, string $result)
{
$this->count = $count;
$this->matched = (bool) $count;
$this->result = $result;
}
}

View File

@@ -0,0 +1,20 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class UnexpectedNullMatchException extends PcreException
{
public static function fromFunction($function, $pattern)
{
throw new \LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class);
}
}

26
vendor/composer/platform_check.php vendored Executable file
View File

@@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 80100)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

22
vendor/maennchen/zipstream-php/.editorconfig vendored Executable file
View File

@@ -0,0 +1,22 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
[*.{yml,md,xml}]
indent_style = space
indent_size = 2
[*.{rst,php}]
indent_style = space
indent_size = 4
[composer.json]
indent_style = space
indent_size = 2
[composer.lock]
indent_style = space
indent_size = 4

View File

@@ -0,0 +1,6 @@
.gitignore text eol=lf
.gitattributes text eol=lf
*.md text eol=lf
*.php text eol=lf
*.yml text eol=lf
*.xml text eol=lf

View File

@@ -0,0 +1,132 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
jonatan@maennchen.ch.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of
actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the
community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][mozilla coc].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][faq]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[mozilla coc]: https://github.com/mozilla/diversity
[faq]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

View File

@@ -0,0 +1,139 @@
# Contributing to ZipStream-PHP
## Welcome!
We look forward to your contributions! Here are some examples how you can
contribute:
- [Report a bug](https://github.com/maennchen/ZipStream-PHP/issues/new?labels=bug&template=BUG.md)
- [Propose a new feature](https://github.com/maennchen/ZipStream-PHP/issues/new?labels=enhancement&template=FEATURE.md)
- [Send a pull request](https://github.com/maennchen/ZipStream-PHP/pulls)
## We have a Code of Conduct
Please note that this project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this
project you agree to abide by its terms.
## Any contributions you make will be under the MIT License
When you submit code changes, your submissions are understood to be under the
same [MIT License](https://github.com/maennchen/ZipStream-PHP/blob/main/LICENSE)
that covers the project. By contributing to this project, you agree that your
contributions will be licensed under its MIT License.
## Write bug reports with detail, background, and sample code
In your bug report, please provide the following:
- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you
- tried that didn't work)
Please do not report a bug for a version of ZIPStream-PHP that is no longer
supported (`< 3.0.0`). Please do not report a bug if you are using a version of
PHP that is not supported by the version of ZipStream-PHP you are using.
Please post code and output as text
([using proper markup](https://guides.github.com/features/mastering-markdown/)).
Do not post screenshots of code or output.
Please include the output of `composer info | sort`.
## Workflow for Pull Requests
1. Fork the repository.
2. Create your branch from `main` if you plan to implement new functionality or
change existing code significantly; create your branch from the oldest branch
that is affected by the bug if you plan to fix a bug.
3. Implement your change and add tests for it.
4. Ensure the test suite passes.
5. Ensure the code complies with our coding guidelines (see below).
6. Send that pull request!
Please make sure you have
[set up your user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup)
for use with Git. Strings such as `silly nick name <root@localhost>` look really
stupid in the commit history of a project.
We encourage you to
[sign your Git commits with your GPG key](https://docs.github.com/en/github/authenticating-to-github/signing-commits).
Pull requests for new features must be based on the `main` branch.
We are trying to keep backwards compatibility breaks in ZipStream-PHP to a
minimum. Please take this into account when proposing changes.
Due to time constraints, we are not always able to respond as quickly as we
would like. Please do not take delays personal and feel free to remind us if you
feel that we forgot to respond.
## Coding Guidelines
This project comes with a configuration file (located at `/psalm.yml` in the
repository) that you can use to perform static analysis (with a focus on type
checking):
```bash
$ .composer run test:lint
```
This project comes with a configuration file (located at
`/.php-cs-fixer.dist.php` in the repository) that you can use to (re)format your
source code for compliance with this project's coding guidelines:
```bash
$ composer run format
```
Please understand that we will not accept a pull request when its changes
violate this project's coding guidelines.
## Using ZipStream-PHP from a Git checkout
The following commands can be used to perform the initial checkout of
ZipStream-PHP:
```bash
$ git clone git@github.com:maennchen/ZipStream-PHP.git
$ cd ZipStream-PHP
```
Install ZipStream-PHP's dependencies using [Composer](https://getcomposer.org/):
```bash
$ composer install
$ composer run install:tools # Install phpDocumentor using phive
```
## Running ZipStream-PHP's test suite
After following the steps shown above, ZipStream-PHP's test suite is run like
this:
```bash
$ composer run test:unit
```
There's some slow tests in the test suite that test the handling of big files in
the archives. To skip them use the following command instead:
```bash
$ composer run test:unit:fast
```
## Generating ZipStream-PHP Documentation
To generate the documentation for the library, run:
```bash
$ composer run docs:generate
```
The guide documentation pages can be found in the `/guides/` directory.

View File

@@ -0,0 +1 @@
github: maennchen

View File

@@ -0,0 +1,71 @@
name: 🐞 Bug Report
description: Something is broken?
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
- Create a discussion instead if you are looking for support:
https://github.com/maennchen/ZipStream-PHP/discussions
- type: input
id: version
attributes:
label: ZipStream-PHP version
placeholder: x.y.z
validations:
required: true
- type: input
id: php-version
attributes:
label: PHP version
placeholder: x.y.z
validations:
required: true
- type: checkboxes
id: constraints
attributes:
label: Constraints for Bug Report
options:
- label: |
I'm using a version of ZipStream that is currently supported:
https://github.com/maennchen/ZipStream-PHP#version-support
required: true
- label: |
I'm using a version of PHP that has active support:
https://www.php.net/supported-versions.php
required: true
- label: |
I'm using a version of PHP that is compatible with your used
ZipStream version.
required: true
- label: |
I'm using the latest release of the used ZipStream major version.
required: true
- type: textarea
id: summary
attributes:
label: Summary
description: Provide a summary describing the problem you are experiencing.
validations:
required: true
- type: textarea
id: current-behaviour
attributes:
label: Current behavior
description: What is the current (buggy) behavior?
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: How to reproduce
description: Provide steps to reproduce the bug.
validations:
required: true
- type: textarea
id: expected-behaviour
attributes:
label: Expected behavior
description: What was the expected (correct) behavior?
validations:
required: true

View File

@@ -0,0 +1,11 @@
name: 🎉 Feature Request
description: You have a neat idea that should be implemented?
labels: ["enhancement"]
body:
- type: textarea
id: description
attributes:
label: Description
description: Provide a summary of the feature you would like to see implemented.
validations:
required: true

View File

@@ -0,0 +1,6 @@
Please go the the `Preview` tab and select the appropriate sub-template:
* [🐞 Failing Test](?expand=1&template=FAILING_TEST.md)
* [🐞 Bug Fix](?expand=1&template=FIX.md)
* [⚙ Improvement](?expand=1&template=IMPROVEMENT.md)
* [🎉 New Feature](?expand=1&template=NEW_FEATURE.md)

View File

@@ -0,0 +1,13 @@
<!---
name: 🐞 Failing Test
about: You found a bug and have a failing test?
labels: bug, tests
--->
<!--
- Please do not send a pull request for an issue in a version of ZipStream-PHP
that is no longer supported.
See: https://github.com/maennchen/ZipStream-PHP#version-support
- Please target the oldest branch of ZipStream-PHP that is still supported and
where the test fails.
-->

View File

@@ -0,0 +1,13 @@
<!---
name: 🐞 Bug Fix
about: You have a fix for a bug?
labels: bug
--->
<!--
- Please do not send a pull request for an issue in a version of ZipStream-PHP
that is no longer supported.
See: https://github.com/maennchen/ZipStream-PHP#version-support
- Please target the oldest branch of ZipStream-PHP that is still supported and
affected by this bug.
-->

View File

@@ -0,0 +1,9 @@
<!---
name: ⚙ Improvement
about: You have some improvement to make ZipStream-PHP better?
labels: enhancement
--->
<!--
- Please target the `main` branch of ZipStream-PHP.
-->

View File

@@ -0,0 +1,9 @@
<!---
name: 🎉 New Feature
about: You have implemented some neat idea that you want to make part of ZipStream-PHP?
labels: type/enhancement
--->
<!--
- Please target the `main` branch of ZipStream-PHP.
-->

View File

@@ -0,0 +1,22 @@
# Security Policy
[![OpenSSF Vulnerability Disclosure](https://img.shields.io/badge/OpenSSF-Vulnerability_Disclosure-green)](https://github.com/ossf/oss-vulnerability-guide/blob/main/finder-guide.md)
[![GitHub Report](https://img.shields.io/badge/GitHub-Security_Advisories-blue)](https://github.com/maennchen/ZipStream-PHP/security/advisories/new)
[![Email Report](https://img.shields.io/badge/Email-jonatan%40maennchen.ch-blue)](mailto:jonatan@maennchen.ch)
This repository follows the
[OpenSSF Vulnerability Disclosure guide](https://github.com/ossf/oss-vulnerability-guide/tree/main).
You can learn more about it in the
[Finders Guide](https://github.com/ossf/oss-vulnerability-guide/blob/main/finder-guide.md).
Please report vulnerabilities via the
[GitHub Security Vulnerability Reporting](https://github.com/maennchen/ZipStream-PHP/security/advisories/new)
or via email to [`jonatan@maennchen.ch`](mailto:jonatan@maennchen.ch) if this does
not work for you.
Our vulnerability management team will respond within 3 working days of your
report. If the issue is confirmed as a vulnerability, we will open a Security
Advisory. This project follows a 90 day disclosure timeline.
If you have questions about reporting security issues, email the vulnerability
management team: [`jonatan@maennchen.ch`](mailto:jonatan@maennchen.ch)

View File

@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
github-actions:
applies-to: version-updates
patterns:
- "*"

View File

@@ -0,0 +1,14 @@
annotations:
- checks:
- fuzzing
reasons:
- reason: not-applicable # PHP is memory safe
- checks:
- packaging
reasons:
- reason: not-supported # Using Composer
- checks:
- signed-releases
reasons:
- reason: not-applicable # Releases are distributed via Composer

View File

@@ -0,0 +1,24 @@
on:
push:
branches:
- "main"
name: "Main Branch"
permissions:
contents: read
jobs:
test:
name: "Test"
permissions:
contents: read
security-events: write
uses: ./.github/workflows/part_test.yml
docs:
name: "Docs"
uses: ./.github/workflows/part_docs.yml

View File

@@ -0,0 +1,30 @@
on:
workflow_call: {}
name: "Dependabot"
permissions:
contents: read
jobs:
automerge_dependabot:
name: "Automerge PRs"
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- uses: fastify/github-action-merge-dependabot@c3bde0759d4f24db16f7b250b2122bc2df57e817 # v3.11.0
with:
github-token: ${{ github.token }}
use-github-auto-merge: true
# Major Updates need to be merged manually
target: minor

View File

@@ -0,0 +1,51 @@
on:
workflow_call: {}
name: "Documentation"
permissions:
contents: read
jobs:
generate:
name: "Generate"
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: SetUp PHP
id: setup-php
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2
with:
php-version: "8.3"
tools: phive
- name: Cache Tools
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: cache
with:
path: ~/.phive
key: tools-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('**/phars.xml') }}
restore-keys: |
tools-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-
tools-${{ steps.setup-php.outputs.php-version }}-
tools-
- name: Install Tools
run: composer run install:tools
- name: Generate Docs
run: composer run docs:generate
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: docs
path: docs
- name: Package for GitHub Pages
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: docs

View File

@@ -0,0 +1,94 @@
on:
workflow_call:
inputs:
releaseName:
required: true
type: string
stable:
required: false
type: boolean
default: false
name: "Release"
permissions:
contents: read
jobs:
create:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Create prerelease
if: ${{ !inputs.stable }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create \
--repo ${{ github.repository }} \
--title ${{ inputs.releaseName }} \
--prerelease \
--generate-notes \
${{ inputs.releaseName }}
- name: Create release
if: ${{ inputs.stable }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create \
--repo ${{ github.repository }} \
--title ${{ inputs.releaseName }} \
--generate-notes \
${{ inputs.releaseName }}
upload_release:
name: "Upload"
needs: ["create"]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
attestations: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: docs
path: docs
- run: |
tar -czvf docs.tar.gz docs
- name: "Attest Documentation"
id: attestation
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
with:
subject-path: "docs.tar.gz"
- name: Copy Attestation
run: cp "$ATTESTATION" docs.tar.gz.sigstore
env:
ATTESTATION: "${{ steps.attestation.outputs.bundle-path }}"
- name: Upload
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload --clobber "${{ github.ref_name }}" \
docs.tar.gz docs.tar.gz.sigstore

View File

@@ -0,0 +1,181 @@
on:
workflow_call:
name: "Test"
permissions:
contents: read
jobs:
phpunit:
name: PHPUnit (PHP ${{ matrix.php }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php: ["8.2", "8.3", "8.4"]
os: [ubuntu-latest]
experimental: [false]
include:
- php: nightly
os: ubuntu-latest
experimental: true
- php: "8.4"
os: windows-latest
experimental: false
- php: "8.4"
os: macos-latest
experimental: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: SetUp PHP
id: setup-php
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2
with:
php-version: "${{ matrix.php }}"
tools: phpunit
coverage: xdebug
extensions: xdebug,zip
- name: Get composer cache directory
id: composer-cache-common
if: "${{ runner.os != 'Windows' }}"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Get composer cache directory
id: composer-cache-windows
if: "${{ runner.os == 'Windows' }}"
run: echo "dir=$(composer config cache-files-dir)" >> $env:GITHUB_OUTPUT
- name: Cache Deps
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: cache
with:
path: ${{ steps.composer-cache-common.outputs.dir }}${{ steps.composer-cache-windows.outputs.dir }}
key: deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-composer-
deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-
deps-${{ steps.setup-php.outputs.php-version }}-
deps-
- name: Install Deps
if: matrix.php != 'nightly'
run: composer install --prefer-dist
- name: Install Deps (ignore PHP requirement)
if: matrix.php == 'nightly'
run: composer install --prefer-dist --ignore-platform-req=php+
- name: Run PHPUnit
run: composer run test:unit:cov
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: ${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}
run: composer run coverage:report
continue-on-error: ${{ matrix.experimental }}
mark_coverage_done:
needs: ["phpunit"]
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Coveralls Finished
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
psalm:
name: Run Psalm
runs-on: "ubuntu-latest"
permissions:
security-events: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: SetUp PHP
id: setup-php
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2
with:
php-version: "8.3"
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Deps
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-composer-
deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-
deps-${{ steps.setup-php.outputs.php-version }}-
deps-
- name: Install Deps
run: composer install --prefer-dist
- name: Run Psalm
run: composer run test:lint -- --report=results.sarif
- name: "Upload SARIF"
uses: github/codeql-action/upload-sarif@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3
with:
sarif_file: results.sarif
php-cs:
name: Run PHP-CS
runs-on: "ubuntu-latest"
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: SetUp PHP
id: setup-php
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2
with:
php-version: "8.3"
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Deps
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-composer-
deps-${{ runner.os }}-${{ steps.setup-php.outputs.php-version }}-
deps-${{ steps.setup-php.outputs.php-version }}-
deps-
- name: Install Deps
run: composer install --prefer-dist
- name: Run PHP-CS
run: composer run test:formatted

View File

@@ -0,0 +1,50 @@
on:
pull_request:
branches:
- "*"
workflow_dispatch: {}
name: "Pull Request"
permissions:
contents: read
jobs:
test:
name: "Test"
permissions:
contents: read
security-events: write
uses: ./.github/workflows/part_test.yml
docs:
name: "Docs"
uses: ./.github/workflows/part_docs.yml
dependabot:
name: "Dependabot"
if: ${{ github.actor == 'dependabot[bot]'}}
permissions:
pull-requests: write
contents: write
uses: ./.github/workflows/part_dependabot.yml
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: 'Checkout Repository'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Dependency Review'
uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0

View File

@@ -0,0 +1,78 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '28 11 * * 3'
push:
branches: [ "main" ]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: "Checkout code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3.28.5
with:
sarif_file: results.sarif

View File

@@ -0,0 +1,29 @@
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
name: "Beta Tag"
permissions:
contents: read
jobs:
docs:
name: "Docs"
uses: ./.github/workflows/part_docs.yml
release:
name: "Release"
needs: ["docs"]
permissions:
id-token: write
contents: write
attestations: write
uses: ./.github/workflows/part_release.yml
with:
releaseName: "${{ github.ref_name }}"

View File

@@ -0,0 +1,55 @@
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
name: "Stable Tag"
permissions:
contents: read
jobs:
docs:
name: "Docs"
uses: ./.github/workflows/part_docs.yml
release:
name: "Release"
needs: ["docs"]
permissions:
id-token: write
contents: write
attestations: write
uses: ./.github/workflows/part_release.yml
with:
releaseName: "${{ github.ref_name }}"
stable: true
deploy_pages:
name: "Deploy to GitHub Pages"
needs: ["release", "docs"]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5

12
vendor/maennchen/zipstream-php/.gitignore vendored Executable file
View File

@@ -0,0 +1,12 @@
/composer.lock
/cov
/coverage.clover.xml
/docs
.idea
/.php-cs-fixer.cache
/.phpdoc/cache
/.phpunit.result.cache
/phpunit.xml
/.phpunit.cache
/tools
/vendor

Some files were not shown because too many files have changed in this diff Show More