+
+
Welcome to the UnPS-GAMA link shortner
-
-
'.$random.'
-
-
-
-Service by '.$pagepath.'
-
-
-';
- fwrite($fh, $stringData);
- fclose($fh);
-echo '
-Thanks for using '.$pagetitle.'
-your link is available here (right click, copy link):
-
'.$pagepath.$random.'
-
Back to index
-
Home
-
-';
- }if($dest == ""){
- echo '
- Sorry, you are not able to shorten something without a url
-
Back to index
-
Home
-
-';
-
+if($_POST["submit"]){
+ if(isset($_POST['dest'])) {
+ $dest=$_POST['dest'];
+ $dest = input($dest);
+ $sql = "SELECT id, link, shortlink FROM $tbl_name WHERE link='$dest'";
+ $result = mysql_query($sql);
+ $count = mysql_num_rows($result);
+ if($count == 1){
+ while ($row = mysql_fetch_assoc($result)){ // Attempt to pull all data concerning that one user from table
+ $id = $row['id'];
+ $link = $row['link'];
+ $short = $row['shortlink'];
+ echo "From what I can tell, this particular link was already shortened before.
Here's the link:
http://unps.us/?l=$short";
+ }
+ }else{
+ $short = substr(number_format(time() * rand(),0,'',''),0,10);
+ $sql="INSERT INTO $tbl_name (link, shortlink) VALUES ('$dest', '$short')";
+ $result=mysql_query($sql);
+ if($result){
+ echo "It appears that I have succeded in making a short link.
You'll find it here:
http://unps.us/?l=$short ";
+ }else {
+ echo "There was a problem trying to register your link - Could be a database error";
+ }
}
-
}
+ if(!$dest){
+ echo '
+ Sorry, you are not able to shorten something without a url
+
Back to index
+
Home
+ ';
+ }
+}
+mysql_close();
?>