Oh Noes! Something happened and I can't continue.
Please try again by using the form located at lob.li.");
}
if(!$redis->exists("tokens:".$_SESSION['token']) || $redis->get("tokens:".$_SESSION['token']) == 1){
include("Include/PHP/token.php");
echo "";
}
$link = $_POST['link'];
$trTtl = $redis->ttl("links:$link");
if($trTtl == -2){ // Didn't find links:linkid, checking if long link
$trTtl = $redis->ttl("llinks:$link");
if($trTtl == -2){ // Didn't find that either, give error
echo "
Your link:
$link is not a lob.li link and has not been shortened.
";
exit;
}
}
$short = $redis->lRange("links:$link", 0, 0);
if($short){
$link = $short[0];
echo "
Your Resolved link:
$link
";
exit;
}else{
$short = $redis->get("llinks:$link");
if($short){
echo "
Your link:
$link is not a lob.li link.
However we found that it has been shortened.
lob.li/$short
";
exit;
}
}
}elseif(!empty($_POST['link']) || !empty($_POST['linkage'])){
if(empty($_POST[$catchid]) || $_POST[$catchid] != $catchVal){
die("Oh Noes! Something happened and I can't continue.
Please try again by using the form located at
lob.li.
");
}
if(!$redis->exists("tokens:".$_SESSION['token']) || $redis->get("tokens:".$_SESSION['token']) == 1){
include("Include/PHP/token.php");
echo "";
}
$redis->set("tokens:".$_SESSION['token'], 1);
//$short = sanitize($_POST['link'], $seperator);
$short = $_POST['link'];
$linkage = $_POST['linkage'];
//echo $short;
if(strpos($short, "http://") === false && strpos($short, "https://") === false){
$short = "http://$short";
}
$reShort = shorten($redis, $short, $linkage, $seperator);
$reShort = explode($seperator, $reShort);
$retCode = $reShort[0];
switch($retCode){
case "0": // Successful link Shorten
$short = $reShort[1];
echo "
";
break;
case "1": // Existing Short Link Found
$short = $reShort[1];
echo "
";
break;
case "2": // Dead Link
$link = $reShort[1];
echo "
ERROR! - Your link:
$link didn't resolve to a website.
Please check your link and try again.
";
break;
case "3": // DB Error
$error = $reShort[1];
echo "
ERROR! - Well this is embarrassing... This never happens, but I appear to have suffered a database error.
Here's what I know: $error
";
break;
case "4": // Sanitize Failure Error
echo "
ERROR! - The sanitize function seems to have failed. This shouldn't happen, maybe
c0de forgot a semi-colon somewhere or something.
";
break;
default:
echo "Oh Noes! Something happened and I can't continue.
Please try again by using the form located at
lob.li.
";
break;
}
exit;
//foreach($messages as $message){
// echo $message;
//}
}else{ die("I can't do my job if I'm not given a link to work on...
"); }
?>