Files
advx/old/upload_prova.php
2025-04-10 23:07:21 -03:00

212 lines
7.3 KiB
PHP

<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Upload de Arquivos</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
// Verificação de folhas de estilo previamente aplicadas
$hasStylesheet = false;
// Verificar se há elementos <link> ou <style> no documento
ob_start();
?>
<script>
document.addEventListener("DOMContentLoaded", function() {
var hasStylesheet = document.querySelector('link[rel="stylesheet"], style') !== null;
var xhr = new XMLHttpRequest();
xhr.open("POST", "", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("hasStylesheet=" + hasStylesheet);
});
</script>
<?php
$script = ob_get_clean();
echo $script;
if (isset($_POST['hasStylesheet']) && $_POST['hasStylesheet'] === 'true') {
$hasStylesheet = true;
}
if (!$hasStylesheet) {
echo '<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px;
text-align: center;
}
h2 {
margin-bottom: 20px;
color: #333;
}
label {
display: block;
margin-bottom: 10px;
color: #555;
}
.custom-file-input {
position: relative;
display: inline-block;
width: 100%;
height: 40px;
margin-bottom: 20px;
}
.custom-file-input input[type="file"] {
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
}
.custom-file-input::before {
content: "Escolher arquivos";
display: inline-block;
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
text-align: center;
width: 100%;
height: 100%;
line-height: 20px;
}
.custom-file-input input[type="file"]:focus + ::before {
outline: 1px dotted #000;
outline: -webkit-focus-ring-color auto 5px;
}
.custom-file-input input[type="file"]::after {
content: "Nenhum arquivo escolhido";
display: block;
margin-top: 10px;
color: #555;
}
button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin-top: 10px;
}
button:hover {
background-color: #0056b3;
}
@media (max-width: 600px) {
body {
height: auto;
padding: 20px;
}
.container {
padding: 15px;
width: 100%;
}
h2 {
font-size: 18px;
}
button {
width: 100%;
padding: 12px;
font-size: 14px;
}
.custom-file-input::before {
padding: 12px;
font-size: 14px;
}
}
</style>';
}
?>
<script>
function addViewportDimensions() {
var form = document.getElementById('uploadForm');
var vw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var vh = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var inputWidth = document.createElement('input');
inputWidth.type = 'hidden';
inputWidth.name = 'viewport_width';
inputWidth.value = vw;
form.appendChild(inputWidth);
var inputHeight = document.createElement('input');
inputHeight.type = 'hidden';
inputHeight.name = 'viewport_height';
inputHeight.value = vh;
form.appendChild(inputHeight);
var userAgent = navigator.userAgent;
var inputUserAgent = document.createElement('input');
inputUserAgent.type = 'hidden';
inputUserAgent.name = 'user_agent';
inputUserAgent.value = userAgent;
form.appendChild(inputUserAgent);
var language = navigator.language || navigator.userLanguage;
var inputLanguage = document.createElement('input');
inputLanguage.type = 'hidden';
inputLanguage.name = 'language';
inputLanguage.value = language;
form.appendChild(inputLanguage);
var files = document.getElementById('files').files;
var modificationTimes = [];
for (let i = 0; i < files.length; i++) {
const file = files[i];
const lastModified = file.lastModified ? file.lastModified : '';
modificationTimes.push(lastModified);
}
var inputModification = document.createElement('input');
inputModification.type = 'hidden';
inputModification.name = 'modification_times';
inputModification.value = modificationTimes.join(',');
form.appendChild(inputModification);
}
window.onload = function() {
var form = document.getElementById('uploadForm');
form.onsubmit = function(event) {
addViewportDimensions();
}
var fileInput = document.getElementById('files');
fileInput.addEventListener('change', function() {
var existingInputs = document.querySelectorAll('input[name="modification_times"]');
existingInputs.forEach(function(input) {
input.remove();
});
});
}
</script>
</head>
<body>
<div class="container">
<h2>Upload de Arquivos</h2>
<form id="uploadForm" action="./upload.php" method="post" enctype="multipart/form-data">
<label for="files">Selecione os arquivos para autenticar:</label><br><br>
<input type="file" name="files[]" id="files" multiple required><br><br>
<button type="submit">Autenticar</button>
</form>
</div>
</body>
</html>