Your Resolved link:
$link
",
"
Your link:
$link is not a lob.li link.
However we found that it has been shortened.
lob.li/$short
",
"
Your link:
$link is not a lob.li link and has not been shortened.
"
);
require('Include/PHP/functions.php');
if(!isset($_GET['getstats'])){
$stats = stats($redis, $seperator);
$stats = explode($seperator, $stats);
if(!empty($_GET['type'])){
if($_GET['type'] == "htmltable"){
foreach($stats as $stat){ // There should only be 5, but the page doesn't limit how many
$id = explode(":", $stat);
$id = $id[2]; // Grab just the short link ID
$linkData = $redis->lRange("links:$id", 0, -1);
$link = $linkData[0];
$title = $linkData[1];
$date = $linkData[2];
$trackClicks = $redis->get("tracking:clicks:$id");
echo "
|
$id |
$link |
$trackClicks |
$date |
";
}
}elseif($_GET['type'] == "json"){
echo $stats[1];
exit;
}else{
die("ERROR: Wrong type. I accept htmltable or json as my type
htmltable will send the partial table that loads on lob.li/stats, json outputs raw json array");
}
}
}
if(!empty($_POST['link']) && !empty($_POST['linkage'])){
if(empty($_GET['token']) || $_GET['token'] != $_SESSION['token'] || 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.
");
}
//$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";
}
echo shorten($redis, $short, $linkage, $seperator);
$reShort = shorten($redis, $short, $linkage, $seperator);
$reShort = explode($seperator, $reShort);
$retCode = $reShort[0];
switch($retCode){
case "0": // Successful link Shorten
$short = $reShort[1];
$title = $reShort[2];
echo "
";
break;
case "1": // Existing Short Link Found
$short = $reShort[1];
$title = $reShort[2];
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...
"); }
?>