Advertisement
PifyZ

Compter les bulles SteetWriter

Jul 11th, 2014
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2. // Créé par jules93
  3. // un jour
  4. // Soutiré par Schizoko
  5. // un autre jour
  6. // Modifié (à l'arrache) par PifyZ
  7. // bien plus tard
  8. if (isset($_FILES['img'], $_POST['send'])) {
  9.     move_uploaded_file($_FILES['img']['tmp_name'], 'img.png');
  10.  
  11.     $total = 0;
  12.  
  13.     if ($image = imagecreatefrompng('img.png')){
  14.         $infos = getimagesize('img.png');
  15.  
  16.         for ($i = 0 ; $i < $infos[1] / 10 - 1 ; $i++) {
  17.             for ($j = 0 ; $j < $infos[0] / 10 - 1 ; $j++) {
  18.                 $rgb = imagecolorat($image, 5 + 10 * $j, 5 + 10 * $i);
  19.  
  20.                 $r = ($rgb >> 16) & 0xFF;
  21.                 $v = ($rgb >> 8) & 0xFF;
  22.  
  23.                 if (in_array($r, [ 255, 143, 82 ]) && in_array($v, [ 255, 143, 82 ])) {
  24.                     $total++;
  25.                 }
  26.             }
  27.         }
  28.     } else {
  29.         echo 'Un vrai PNG serait le bienvenue, merci pour l\'erreur é_è<br/>';
  30.     }
  31.  
  32.     if ($total > 0) {
  33.         echo 'Sur la dernière image uploadée, il y a ' . $total . ' points. (si c\'est une image correcte !)';
  34.     } else {
  35.         echo 'La dernière image semble totalement invalide !';
  36.     }
  37. }
  38. ?>
  39.  
  40. <form method="post" action="index.php" enctype="multipart/form-data">
  41.     <input type="file" name="img" />
  42.     <input type="submit" name="send" value="Envoyer" />
  43. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement