Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $longurl = $_GET['longurl'];
- $custom = $_GET['customname'];
- if($longurl == "") {
- die(header("Location: http://www.ohjustthatguy.com/htmlshort/?invalidurl=true"));
- }
- if(!preg_match("|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i", $longurl)) {
- header("Location: http://www.ohjustthatguy.com/htmlshort/?invalidurl=true");
- }
- require_once "/home/a7435766/public_html/scripts/dbconnect.php";
- $sqlquery = mysql_query("SELECT * FROM url WHERE shortened = '$custom'");
- if(mysql_num_rows($sqlquery) != 0) {
- die(header("Location: http://www.ohjustthatguy.com/htmlshort/?taken=true"));
- }
- $urlinput = mysql_real_escape_string($longurl);
- $id=rand(10000,99999);
- if($custom != ""){
- if(strlen($custom) > 4) {
- die(header('Location: http://www.ohjustthatguy.com/htmlshort/?length=true'));
- }
- $shorturl = $custom;
- } else {
- $shorturl=base_convert($id,20,36);
- }
- $sql = "INSERT INTO url VALUES('$id','$urlinput','$shorturl')";
- mysql_query($sql);
- header('Location: http://www.ohjustthatguy.com/htmlshort/disp.html?customurl=' . $shorturl);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement