Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_FILES['img'], $_POST['send'])) {
- move_uploaded_file($_FILES['img']['tmp_name'], 'img.png');
- $total = 0;
- if ($image = imagecreatefrompng('img.png')){
- $infos = getimagesize('img.png');
- for ($i = 0 ; $i < $infos[1] / 10 - 1 ; $i++) {
- for ($j = 0 ; $j < $infos[0] / 10 - 1 ; $j++) {
- $rgb = imagecolorat($image, 5 + 10 * $j, 5 + 10 * $i);
- $r = ($rgb >> 16) & 0xFF;
- $v = ($rgb >> 8) & 0xFF;
- if (in_array($r, [ 255, 143, 82 ]) && in_array($v, [ 255, 143, 82 ])) {
- $total++;
- }
- }
- }
- } else {
- echo 'Un vrai PNG serait le bienvenue, merci pour l\'erreur é_è<br/>';
- }
- if ($total > 0) {
- echo 'Sur la dernière image uploadée, il y a ' . $total . ' points. (si c\'est une image correcte !)';
- } else {
- echo 'La dernière image semble totalement invalide !';
- }
- }
- ?>
- <form method="post" action="index.php" enctype="multipart/form-data">
- <input type="file" name="img" />
- <input type="submit" name="send" value="Envoyer" />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement