turt2live

Untitled

May 26th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2. mysql_connect("localhost", "UN", "PWD") or die("<b>1</b> ".mysql_error());
  3. mysql_select_db("turt2l5_site") or die("<b>2</b> ".mysql_error());
  4. define("TABLE", "longurls");
  5. if(isset($_POST['url'])){
  6.     $url = clean($_POST['url']);
  7.     if(stristr($url, "http://") === FALSE){
  8.         $url = "http://".$url;
  9.     }
  10.     if(!(stristr($url, "long.turt2live") === FALSE)){
  11.         die("Nope, Sorry NuclearW<br><a href='index.php'>Try again</a>");
  12.     }
  13.     $longurl = "http://google.com";
  14.     $query = mysql_query("SELECT * FROM ".TABLE." WHERE ourl='".$url."'") or die("<b>3</b> ".mysql_error());
  15.     if(mysql_num_rows($query)>=1){
  16.         $row = mysql_fetch_array($query);
  17.         $longurl = $row['url'];
  18.     }else{
  19.         $longurl = sha1($url).sha1(md5($url)).md5(sha1($url));
  20.         if(isset($_POST['superlong'])){
  21.             $longurl = sha1($url).sha1(md5($url)).md5(sha1($url)).sha1($url).sha1(md5($url)).md5(sha1($url)).sha1($url).sha1(md5($url)).md5(sha1($url));
  22.         }
  23.         mysql_query("INSERT INTO ".TABLE." (ourl, url) VALUES ('".$url."', '".$longurl."')") or die("<b>4</b> ".mysql_error());
  24.     }
  25.     echo "<h2>$url = <a href='http://long.turt2live.com/?url=$longurl'>http://long.turt2live.com/?url=$longurl</a></h2>";
  26.     echo "Don't know what to do? Copy and paste this: <br><input type='text' style='width:400px' value='http://long.turt2live.com/?url=$longurl'><br><i>Hint: Use CTRL+A on Windows to select all</i>";
  27.     echo "<hr>";
  28. }else{
  29.     if(isset($_GET['url'])){
  30.         $url = clean($_GET['url']);
  31.         $query = mysql_query("SELECT * FROM ".TABLE." WHERE url='".$url."'") or die("<b>5</b> ".mysql_error());
  32.         if(mysql_num_rows($query)>=1){
  33.             $row = mysql_fetch_array($query);
  34.             if(isset($_GET['preview'])){
  35.                 echo "<i>http://long.turt2live.com/?url=$url points to :</i> <b>".$row['ourl']."</b>";
  36.                 echo "<hr>";
  37.             }else{
  38.                 header("Location: ".$row['ourl']);
  39.             }
  40.             $longurl = $row['url'];
  41.         }else{
  42.             echo "I don't know what you are looking for...";
  43.         }
  44.     }
  45. }
  46.  
  47. echo "<h1>Long URL</h1>";
  48. echo "<form action='index.php' method='post'>";
  49. echo "URL: <input type='text' name='url' style='width:300px;'>";
  50. echo "<input type='checkbox' name='superlong' value='yes'> Super Long URL<br>";
  51. echo "<input type='submit' name='submit' value='Longify'>";
  52. echo "<form>";
  53. echo "<hr>";
  54. echo "<h3>Unsure of where a link goes? <a href='preview.php'>Click here</a></h3>";
  55.  
  56. function clean($input){
  57.     if(get_magic_quotes_gpc()){
  58.         $input = stripslashes($input);
  59.     }
  60.     //$input = mysql_real_escape_string($input);
  61.     $input = htmlentities($input, ENT_COMPAT, "UTF-8");
  62.     return $input;
  63. }
  64. ?>
  65. <hr>Copyright &copy; turt2live 2012
Advertisement
Add Comment
Please, Sign In to add comment