Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['acao']) == 'enviar') {
  3.  
  4. $link = trim($_POST['link']);
  5.  
  6. if(empty($link)){
  7. echo 'Insira uma URl';
  8. }elseif(!filter_var($link, FILTER_VALIDATE_URL)){
  9. echo 'Insira uma URL valida';
  10. }else{
  11.  
  12. $url = substr(md5(time()), 0, 6);
  13.  
  14. $arquivo = fopen("arquivos/$url.php", 'x+');
  15. fwrite($arquivo, "<?php header(\"Location: $link\"); exit(); ?>");
  16. fclose($arquivo);
  17.  
  18. echo 'A sua URL e: worldigital.xp3.biz/links/?p='. $url;
  19.  
  20. }
  21.  
  22. }
  23.  
  24. $linkAtual = $_GET['p'];
  25.  
  26. if(isset($linkAtual)){
  27. if(file_exists("arquivos/$linkAtual.php")){
  28. require "arquivos/$linkAtual.php";
  29. }else{
  30. echo 'URL existente!';
  31.  
  32. }
  33. }
  34. ?>
  35.  
  36. <html>
  37. <head>
  38. <title>Gerador de Urls</title>
  39. </head>
  40. <body>
  41. <form action="" method="post">
  42.  
  43. Link: <input type="text" name="link" value="http://" size="40" />
  44.  
  45. <input type="hidden" name="acao" value="enviar" />
  46. <input type="submit" name="Enviar" value="Gerar URL" />
  47.  
  48. </form>
  49.  
  50.  
  51. </body>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement