Created
May 29, 2015 22:38
-
-
Save everaldo/0cf948773db6dca450bf to your computer and use it in GitHub Desktop.
Encurtador de URLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Turma de Oficina de Programação - 18h15 | |
29/05/2015 | |
Encurtador de URLs | |
*/ | |
$url = $_POST["url"]; | |
function imprime_url(){ | |
global $url; | |
echo $url; | |
echo "<br>"; | |
calcula_hash($url); | |
} | |
function calcula_hash($url){ | |
$hash = base64_encode(sha1($url)); | |
echo substr($hash, 0, 6); | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Encurtador de URLs</title> | |
<link rel="stylesheet" type="text/css" media="screen" href="" /> | |
<script type="text/javascript" src=""></script> | |
</head> | |
<body> | |
<h1>Encurtador de URLs do BSI</h1> | |
<form name="encurta" method="post" | |
action="encurta.php"> | |
<input type="text" | |
name="url" placeholder="Digite uma URL"> | |
<input type="submit" | |
value="Enviar"> | |
</form> | |
<?php imprime_url() ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment