Advertisement
Guest User

Untitled

a guest
Dec 29th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.52 KB | None | 0 0
  1. <?PHP
  2.         $S = isset($_POST['salvador']);
  3.         $B = isset($_POST['brisas']);
  4.         $P = isset($_POST['pontes']);
  5.         $V = isset($_POST['porto_velho']);
  6.    
  7.         if($S && !$B && !$P && !$V) {
  8.             $image_path = "salvador.png";  
  9.         } elseif ($B && !$S && !$P && !$V) {
  10.             $image_path = "brisas.png";
  11.         } elseif ($P && !$S && !$B && !$V) {
  12.             $image_path = "pontes.png";
  13.         } elseif ($V && !$S && !$B && !$P) {
  14.             $image_path = "portovelho.png";
  15.         } elseif ($S && $P && !$B && !$V) {
  16.             $image_path = "salvador_pontes.png";
  17.         } elseif ($B && $P && !$S && !$V) {
  18.             $image_path = "brisas_pontes.png";
  19.         } elseif ($S && $P && $V && !$B) {
  20.             $image_path = "salvador_pontes_portovelho.png";
  21.         } elseif ($B && $P && $V && !$S) {
  22.             $image_path = "brisas_pontes_portovelho.png";
  23.         } elseif ($S && $B && $P && $V) {
  24.             echo "Não pode";
  25.         } elseif ($S && $B && !$P) {
  26.             echo "Não pode";
  27.         } elseif ($S && $B && $V) {
  28.             echo "Não pode";
  29.         }
  30.    
  31.         function watermark_image($oldimage_name, $new_image_name){
  32.             global $image_path;
  33.             list($owidth,$oheight) = getimagesize($oldimage_name);
  34.             $width = $height = 800;    
  35.             $im = imagecreatetruecolor($width, $height);
  36.             $img_src = imagecreatefromjpeg($oldimage_name);
  37.             imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
  38.             $watermark = imagecreatefrompng($image_path);
  39.             list($w_width, $w_height) = getimagesize($image_path);        
  40.             $pos_x = $width - $w_width;
  41.             $pos_y = $height - $w_height;
  42.             imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
  43.             imagejpeg($im, $new_image_name, 100);
  44.             imagedestroy($im);
  45.             unlink($oldimage_name);
  46.             return true;
  47.         }
  48.  
  49.         $demo_image= "";
  50.         if(isset($_POST['createmark']) and $_POST['createmark'] == "Submit"){
  51.             $path = "uploads/";
  52.             $valid_formats = array("jpg",  "bmp","jpeg");
  53.             $name = $_FILES['imgfile']['name'];
  54.             if(strlen($name))
  55.         {
  56.            list($txt, $ext) = explode(".", $name);
  57.            if(in_array($ext,$valid_formats)&& $_FILES['imgfile']['size'] <= 10*256*1024)
  58.             {
  59.             $upload_status = move_uploaded_file($_FILES['imgfile']['tmp_name'], $path.$_FILES['imgfile']['name']);
  60.             if($upload_status){
  61.                 $new_name = $path.time().".jpg";
  62.                 if(watermark_image($path.$_FILES['imgfile']['name'], $new_name))
  63.                         $demo_image = $new_name;
  64.  
  65.             }
  66.             }
  67.             else
  68.             $msg = "A foto tem que ter menos que 2,5mb.";
  69.             }
  70.         }
  71.  
  72.             # Conta quantos arquivos existem na pasta de upload
  73.            $diretorio = scandir("uploads/");
  74.             $qtd = count($diretorio) - 3;
  75.  
  76.     ?>
  77.  
  78.  
  79.  
  80.     <!DOCTYPE html>
  81.     <html lang="pt-br">
  82.  
  83.     <head>
  84.         <meta charset="UTF-8">
  85.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  86.         <title>Avatarizador :)</title>
  87.         <style>
  88.             body {
  89.                 font-family: arial;
  90.                 width: 600px;
  91.                 margin: 0 auto 0 auto;
  92.             }
  93.            
  94.             label.texto {
  95.                 font-size: 10pt;
  96.             }
  97.            
  98.             span {
  99.                 font-size: 8pt;
  100.             }
  101.         </style>
  102.         <script src="http://deepliquid.com/Jcrop/js/jquery.Jcrop.min.js"></script>
  103.         <script src="js/jquery.Jcrop.js"></script>
  104.         <link rel="stylesheet" href="css/jquery.Jcrop.css" type="text/css" />
  105.     </head>
  106.  
  107.     <body>
  108.         <form name="imageUpload" id="imageUpload" method="post" enctype="multipart/form-data" action="">
  109.             <h4>Escolha sua foto:
  110.                 <input type="file" name="imgfile" id="imgfile" />
  111.                 <br><span>* Fotos quadradas evitam destorção</span>
  112.             </h4>
  113.  
  114.             <label>Quais selos deseja por no avatar do EREA Ilhas ?
  115.                 <br/>
  116.             </label>
  117.  
  118.             <input type="checkbox" name="salvador" value="on">
  119.             <label class="texto">EREA Salvador 2017
  120.                 <br/>
  121.             </label>
  122.  
  123.             <input type="checkbox" name="brisas" value="on">
  124.             <label class="texto">EREA Brisas 2017
  125.                 <br/>
  126.             </label>
  127.  
  128.             <input type="checkbox" name="pontes" value="on">
  129.             <label class="texto">EREA Pontes 2016
  130.                 <br/>
  131.             </label>
  132.  
  133.             <input type="checkbox" name="porto_velho" value="on">
  134.             <label class="texto">EREA Porto Velho 2016
  135.                 <br/>
  136.             </label>
  137.             <br/>
  138.             <input type="submit" name="createmark" id="createmark" Value="Avatarizar" />
  139.             <br/>
  140.             <br/>
  141.             <?php
  142.                 if(!empty($demo_image))
  143.                     echo '<center>
  144.                            <a href="'.$demo_image.'" download="'.$demo_image.'">
  145.                                <img src="'.$demo_image.'" />
  146.                            </a>
  147.                            <br><br>
  148.                            Click com o botão direito do mouse e salve a foto modificada.<br><br>Criado por André Leal ♥</center>';
  149.             ?>
  150.         </form>
  151.  
  152.     </body>
  153.  
  154.     </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement