Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolução do mapa #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions atualizar_imagem.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
<?php
if (isset($_POST)) {
// script para atualizar imagem...
if(isset($_FILES['imagem'])) {

$largura_permitida = 800;
$altura_permitida = 600;

list($largura, $altura) = getimagesize($_FILES['imagem']['tmp_name']);

$extensao = substr($_FILES['imagem']['name'],-4);

if(strtolower($extensao) == '.jpg' || strtolower($extensao) == 'jpeg') {
if($largura == $largura_permitida && $altura == $altura_permitida) {
move_uploaded_file($_FILES['imagem']['tmp_name'], 'quebracabeca.jpg');
include 'gerar_quebracabeca.php';
header('Location: mostrar.php');
}
else {
echo '<h3>Erro: O tamanho da imagem precisa ser 800x600</h3>';
}
}
else {
echo '<h3>Erro: A extensão da imagem precisa ser .jpg</h3>';
}
}
}
?>
<html>
<head>
<title>Atualizar Imagem</title>
</head>
<body>
<form action="atualizar_imagem_quebra_cabeca.php" action="POST">
<form action="atualizar_imagem.php" method="POST" enctype="multipart/form-data">
Enviar nova imagem para atualizar (Tamanho válido 800x600):
<br />
<input name="imagem" type="file" />
Expand Down
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
header('Location: mostrar.php');
?>
22 changes: 21 additions & 1 deletion mostrar.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
<?php
ini_set('display_errors', true);

if(!isset($_GET['mostrar_solucao'])) {
$dir = 'imagens';
$pastas = array('..', '.');
$arquivos = array_diff(scandir($dir), $pastas);

shuffle($arquivos);
}

?>
<html>
<head>
<style>
*{padding:0; margin:0; border:0;}
table {border:0; border-spacing: 10px;}
table tr td{padding:0; margin:0}
.links{padding: 0 10px;}
</style>
</head>
<body>
<table>
<?php for($linha=1; $linha<=6; $linha++) : ?>
<tr>
<?php for($coluna=1; $coluna<=8; $coluna++) : ?>
<td><img src="imagens/<?php echo ($linha*8)-8+$coluna ?>.jpg" /></td>
<?php if(!isset($_GET['mostrar_solucao'])) : ?>
<td><img src="imagens/<?php echo array_shift($arquivos); ?>" /></td>
<?php else : ?>
<td><img src="imagens/<?php echo ($linha*8)-8+$coluna ?>.jpg" /></td>
<?php endif; ?>
<?php endfor; ?>
</tr>
<?php endfor; ?>
</table>
<div class="links">
<a href="atualizar_imagem.php">Alterar imagem</a> | <a href="mostrar.php">Embaralhar</a> | <a href="mostrar.php?mostrar_solucao=1">Mostrar solucionado</a>
</div>
</body>
</html>