index.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. // Todas variáveis vieram pra ca
  3. include_once("static.php");
  4. $error = null;
  5. $uri = strtok($_SERVER['REQUEST_URI'], '?');
  6. $parts = explode('/', $uri);
  7. $code = array_pop($parts);
  8. date_default_timezone_set("America/Sao_Paulo");
  9. // Recaptcha
  10. include_once("lib/recaptchalib.php");
  11. if ($code) {
  12. include_once("lib/Thrash.class.php");
  13. if ($thrash = Thrash::get_by_code($code)) {
  14. $title = "<strong>{$site}</strong> | {$thrash->title}";
  15. } else {
  16. die('codigo invalido');
  17. }
  18. } else {
  19. $test = strpos($_SERVER['HTTP_HOST'], 'localhost') === 0;
  20. if (isset($_POST['url']) && ($test || isset($_POST["recaptcha_response_field"]))) {
  21. if (!$test) $resp = recaptcha_check_answer ($privatekey,
  22. $_SERVER["REMOTE_ADDR"],
  23. @$_POST["recaptcha_challenge_field"],
  24. @$_POST["recaptcha_response_field"]);
  25. if ($test || $resp->is_valid) {
  26. include_once("lib/Thrash.class.php");
  27. $thrash = Thrash::create($_POST['url'], $_POST['title']);
  28. $redirect_url = $thrash->get_url();
  29. if ($thrash->blocked_domain) $redirect_url .= "?created=1";
  30. header("Location: ".$redirect_url);
  31. die();
  32. } else {
  33. $error = $resp->error;
  34. }
  35. }
  36. }
  37. ?>
  38. <!DOCTYPE html>
  39. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  40. <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  41. <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  42. <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
  43. <head>
  44. <meta charset="utf-8">
  45. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  46. <title><?php echo strip_tags($title); ?></title>
  47. <meta name="description" content="">
  48. <meta name="viewport" content="width=device-width, initial-scale=1">
  49. <link rel="stylesheet" href="css/normalize.min.css">
  50. <link rel="stylesheet" href="css/main.css">
  51. <!--[if lt IE 9]>
  52. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  53. <script>window.html5 || document.write('<script src="js/vendor/html5shiv.js"><\/script>')</script>
  54. <![endif]-->
  55. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  56. <script src="js/main.js"></script>
  57. <script src='https://www.google.com/recaptcha/api.js?hl=pt-BR'></script>
  58. </head>
  59. <body>
  60. <!--[if lt IE 7]>
  61. <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  62. <![endif]-->
  63. <div class="header-container">
  64. <header class="wrapper clearfix">
  65. <h1 class="title"><?php echo $title; ?></h1>
  66. <nav>
  67. <ul>
  68. <li><a href="./">encurtar url</a></li>
  69. <li><a href="#reclameaqui" onclick="alert('¯\\_(ツ)_/¯');">reclamações</a></li>
  70. <li><a href="http://naofo.de" target="_self">outro site</a></li>
  71. </ul>
  72. </nav>
  73. </header>
  74. </div>
  75. <?php
  76. if (isset($thrash) && $thrash && $thrash->blocked_domain == 1) {
  77. $url = "http://webcache.googleusercontent.com/search?q=cache:".$thrash->original_url;
  78. if (isset($_REQUEST['created'])) {
  79. include("inc/share.php");
  80. ?>
  81. <p>A URL que voc&ecirc; encurtou est&aacute; num dom&iacute;nio que bloqueia o <?php echo $site; ?>. Esta url funcionar&aacute; como um redirecionamento para o cache do google.</p>
  82. <p><a href="<?php echo $url; ?>">Exemplo do redirecionamento</a>.</p>
  83. <?php
  84. } else {
  85. header("Location: $url");
  86. die();
  87. }
  88. } else if (isset($thrash) && $thrash) {
  89. $imgs = $thrash->get_image_path();
  90. ?>
  91. <p>URL original: <?php echo "<script>document.write(decode_base64('" . base64_encode("<a href=\"{$thrash->original_url}\">{$thrash->original_url}</a>") . "'));</script>"; ?> - Capturada em: <?php echo date("d/m/Y H\hi", strtotime($thrash->date_created)); ?></p>
  92. <meta property="og:image" content="<?php echo $imgs[0]; ?>"/>
  93. <meta property="og:title" content="<?php echo $title; ?>"/>
  94. <?php
  95. include("inc/share.php");
  96. foreach ($imgs as $img) {
  97. echo "<img src=\"${img}\" /><br/>";
  98. }
  99. } else {
  100. ?>
  101. <div id="mask"></div>
  102. <div class="main-container">
  103. <div class="main wrapper clearfix">
  104. <article>
  105. <h1>Encurtar url</h1>
  106. <p>
  107. <!-- Pra que essa classe? -->
  108. <form action="" accept-charset="UTF-8" method="post" class="<?php if (isset($_POST['url']) && isset($_POST['title'])): ?>scriptlet ready<?php endif; ?>">
  109. <label for="url">Endere&ccedil;o:</label>
  110. <input type="text" name="url" value="<?php echo @$_REQUEST['url']; ?>" required /><br />
  111. <?php if (@$_GET['error'] == 'load') : ?><span class="error">Não foi possível carregar a página. Por favor, confira o endereço e tente novamente.</span><?php endif; ?>
  112. <label for="title">T&iacute;tulo:</label>
  113. <fieldset class="title <?php if (isset($_POST['title'])): ?>filled<?php endif; ?>"><textarea name="title"><?php echo @$_POST['title']; ?></textarea></fieldset>
  114. <fieldset>
  115. <div class="g-recaptcha" data-sitekey="<?php echo getenv('naofode_recaptchapubkey'); ?>"></div>
  116. </fieldset>
  117. <input type="submit" value="<?php if (isset($_POST['url']) && isset($_POST['title'])): ?>gerar &excl;<?php else: ?>prosseguir &raquo;<?php endif; ?>" />
  118. </form>
  119. </p>
  120. <p>N&atilde;o est&aacute; funcionando? Tente <a href="http://naofo.de" target="_self">outro site</a>.</p>
  121. </article>
  122. <aside>
  123. <h3>O que é?</h3>
  124. <p>O <?php echo $site; ?> é um serviço de compartilhamento/encurtamento de URLs com propósito de denúncia/comentário crítico. Em vez da página original, a URL encurtada direciona para uma cópia (em imagem) do conteúdo, de modo que não se aumentará o tráfego ou o <em>pagerank</em> da página em questão. Além disso, a cópia ficará disponível mesmo que a página original seja tirada do ar.</p>
  125. <p><strong>IMPORTANTE</strong><br/>
  126. NÃO compartilhe conteúdo ilegal e criminoso, tais como pedofilia ou exposição vexatória de pessoas, por este serviço. O conteúdo será retirado do ar e seu acesso ao serviço barrado. Eventualmente forneceremos seu IP a autoridades competentes.
  127. Há outras formas de denunciar e é criminosa (além de contraproducente) a reprodução desses conteúdos. Use, por exemplo: <a href="http://www.dpf.gov.br/servicos/fale-conosco/denuncias">http://www.dpf.gov.br/servicos/fale-conosco/denuncias</a>
  128. <p>
  129. Tampouco use o <?php echo $site; ?> como um encurtador comum: fazer cópia do conteúdo implica em custos de servidor, e um crescimento da demanda tornaria inviável o serviço, que jamais terá fins lucrativos. Por favor, use apenas para denúncia e compartilhamento de conteúdo desprezível.
  130. </p>
  131. </p>
  132. </aside>
  133. </div> <!-- #main -->
  134. </div> <!-- #main-container -->
  135. <?php
  136. }
  137. ?>
  138. <div class="footer-container">
  139. <footer class="wrapper">
  140. <a href="https://github.com/naofode/naofo.de">código fonte</a>
  141. &nbsp;&nbsp;-&nbsp;&nbsp;
  142. <a title="botao <?php echo $site; ?>" href='javascript:var d=document,b=d.body,div=d.createElement("div");div.innerHTML="<form accept-charset=\"UTF-8\" action=\"http://<?php echo $site; ?>\" method=\"post\" target=\"_blank\"><input name=\"url\"><input name=\"title\"></form>";div.style.display="none";b.appendChild(div);var f=div.children[0];f["url"].value=window.location.href;f["title"].value=d.title;f.submit();' onclick="return false;">botão <?php echo $site; ?></a> (arraste para sua barra de favoritos e clique quando estiver na página que deseja encurtar)
  143. </footer>
  144. </div>
  145. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  146. <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.0.min.js"><\/script>')</script>
  147. <script src="js/plugins.js"></script>
  148. <script src="js/main.js"></script>
  149. <script>
  150. (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
  151. function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
  152. e=o.createElement(i);r=o.getElementsByTagName(i)[0];
  153. e.src='//www.google-analytics.com/analytics.js';
  154. r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
  155. ga('create', 'UA-50387468-1', 'naofo.de');ga('send','pageview');
  156. </script>
  157. </body>
  158. </html>