Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- $S = isset($_POST['salvador']);
- $B = isset($_POST['brisas']);
- $P = isset($_POST['pontes']);
- $V = isset($_POST['porto_velho']);
- if($S && !$B && !$P && !$V) {
- $image_path = "salvador.png";
- } elseif ($B && !$S && !$P && !$V) {
- $image_path = "brisas.png";
- } elseif ($P && !$S && !$B && !$V) {
- $image_path = "pontes.png";
- } elseif ($V && !$S && !$B && !$P) {
- $image_path = "portovelho.png";
- } elseif ($S && $P && !$B && !$V) {
- $image_path = "salvador_pontes.png";
- } elseif ($B && $P && !$S && !$V) {
- $image_path = "brisas_pontes.png";
- } elseif ($S && $P && $V && !$B) {
- $image_path = "salvador_pontes_portovelho.png";
- } elseif ($B && $P && $V && !$S) {
- $image_path = "brisas_pontes_portovelho.png";
- } elseif ($S && $B && $P && $V) {
- echo "Não pode";
- } elseif ($S && $B && !$P) {
- echo "Não pode";
- } elseif ($S && $B && $V) {
- echo "Não pode";
- }
- function watermark_image($oldimage_name, $new_image_name){
- global $image_path;
- list($owidth,$oheight) = getimagesize($oldimage_name);
- $width = $height = 800;
- $im = imagecreatetruecolor($width, $height);
- $img_src = imagecreatefromjpeg($oldimage_name);
- imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
- $watermark = imagecreatefrompng($image_path);
- list($w_width, $w_height) = getimagesize($image_path);
- $pos_x = $width - $w_width;
- $pos_y = $height - $w_height;
- imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
- imagejpeg($im, $new_image_name, 100);
- imagedestroy($im);
- unlink($oldimage_name);
- return true;
- }
- $demo_image= "";
- if(isset($_POST['createmark']) and $_POST['createmark'] == "Submit"){
- $path = "uploads/";
- $valid_formats = array("jpg", "bmp","jpeg");
- $name = $_FILES['imgfile']['name'];
- if(strlen($name))
- {
- list($txt, $ext) = explode(".", $name);
- if(in_array($ext,$valid_formats)&& $_FILES['imgfile']['size'] <= 10*256*1024)
- {
- $upload_status = move_uploaded_file($_FILES['imgfile']['tmp_name'], $path.$_FILES['imgfile']['name']);
- if($upload_status){
- $new_name = $path.time().".jpg";
- if(watermark_image($path.$_FILES['imgfile']['name'], $new_name))
- $demo_image = $new_name;
- }
- }
- else
- $msg = "A foto tem que ter menos que 2,5mb.";
- }
- }
- # Conta quantos arquivos existem na pasta de upload
- $diretorio = scandir("uploads/");
- $qtd = count($diretorio) - 3;
- ?>
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Avatarizador :)</title>
- <style>
- body {
- font-family: arial;
- width: 600px;
- margin: 0 auto 0 auto;
- }
- label.texto {
- font-size: 10pt;
- }
- span {
- font-size: 8pt;
- }
- </style>
- <script src="http://deepliquid.com/Jcrop/js/jquery.Jcrop.min.js"></script>
- <script src="js/jquery.Jcrop.js"></script>
- <link rel="stylesheet" href="css/jquery.Jcrop.css" type="text/css" />
- </head>
- <body>
- <form name="imageUpload" id="imageUpload" method="post" enctype="multipart/form-data" action="">
- <h4>Escolha sua foto:
- <input type="file" name="imgfile" id="imgfile" />
- <br><span>* Fotos quadradas evitam destorção</span>
- </h4>
- <label>Quais selos deseja por no avatar do EREA Ilhas ?
- <br/>
- </label>
- <input type="checkbox" name="salvador" value="on">
- <label class="texto">EREA Salvador 2017
- <br/>
- </label>
- <input type="checkbox" name="brisas" value="on">
- <label class="texto">EREA Brisas 2017
- <br/>
- </label>
- <input type="checkbox" name="pontes" value="on">
- <label class="texto">EREA Pontes 2016
- <br/>
- </label>
- <input type="checkbox" name="porto_velho" value="on">
- <label class="texto">EREA Porto Velho 2016
- <br/>
- </label>
- <br/>
- <input type="submit" name="createmark" id="createmark" Value="Avatarizar" />
- <br/>
- <br/>
- <?php
- if(!empty($demo_image))
- echo '<center>
- <a href="'.$demo_image.'" download="'.$demo_image.'">
- <img src="'.$demo_image.'" />
- </a>
- <br><br>
- Click com o botão direito do mouse e salve a foto modificada.<br><br>Criado por André Leal ♥</center>';
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement