mirror of
https://github.com/gamaio/lobli.git
synced 2025-01-22 07:13:16 +00:00
Remove placeholder code for resolving, make links resolve, remove token from get on process
Fairly straightforward. Commit 298b2606ea also resolves #1 (http://lob.li/mk6) The messages are finally where they belong and link resolution for ids and long urls added - I might want to work on lob.li/linkid in the future too
This commit is contained in:
parent
298b2606ea
commit
7972971ee0
@ -21,32 +21,6 @@
|
||||
8 - Lookup of link Stats (returns 8 $sep JSONarray)
|
||||
*/
|
||||
|
||||
$short = "";
|
||||
$link = "";
|
||||
$error = "";
|
||||
|
||||
$messages = array(
|
||||
"
|
||||
<div class=\"alert alert-success\" id=\"success\">
|
||||
Your Resolved link: <a href=\"$link\">
|
||||
<span class=\"longlink\">$link</span></a>
|
||||
|
||||
<a href=\"#\" id=\"copylink\" title=\"Copy Link\" onclick=\"copyToClipboard('$link');\">
|
||||
<span class=\"glyphicon glyphicon-link\" style=\"float:right;padding-right:1%;\"></span>
|
||||
</a>
|
||||
</div>
|
||||
",
|
||||
"
|
||||
<div class=\"alert alert-warning\" id=\"warning\">
|
||||
Your link: <a href=\"$link\">
|
||||
<span class=\"longlink2\">$link</span></a> is not a lob.li link.<br> However we found that it has been shortened. <a href=\"http://lob.li/$short\" title=\"$title\">lob.li/$short</a>
|
||||
<a href=\"#\" id=\"copylink\" title=\"Copy Link\" onclick=\"copyToClipboard('http://lob.li/$short');\">
|
||||
<span class=\"glyphicon glyphicon-link\" style=\"float:right;padding-right:1%;\"></span>
|
||||
</a>
|
||||
</div>
|
||||
"
|
||||
);
|
||||
|
||||
require('Include/PHP/functions.php');
|
||||
|
||||
if(isset($_GET['resolve']) && !empty($_POST['link'])){
|
||||
@ -55,9 +29,8 @@
|
||||
}
|
||||
|
||||
if(!$redis->exists("tokens:".$_SESSION['token']) || $redis->get("tokens:".$_SESSION['token']) == 1){
|
||||
echo "<script>alert('Invalid or expired token. Please try again');</script>";
|
||||
include("Include/PHP/token.php");
|
||||
header("location:index.php");
|
||||
echo "<script>window.location = \"index.php\";</script>";
|
||||
}
|
||||
|
||||
$link = $_POST['link'];
|
||||
@ -75,13 +48,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
$short = $redis->lRange("links:$link", 0, 1);
|
||||
print_r($short); exit;
|
||||
$short = $redis->lRange("links:$link", 0, 0);
|
||||
if($short){
|
||||
$link = $short[0];
|
||||
echo "
|
||||
<div class=\"alert alert-success\" id=\"success\">
|
||||
Your Resolved link: <a href=\"$link\">
|
||||
<span class=\"longlink\">$link</span></a>
|
||||
|
||||
<a href=\"#\" id=\"copylink\" title=\"Copy Link\" onclick=\"copyToClipboard('$link');\">
|
||||
<span class=\"glyphicon glyphicon-link\" style=\"float:right;padding-right:1%;\"></span>
|
||||
</a>
|
||||
</div>
|
||||
";
|
||||
exit;
|
||||
}else{
|
||||
$short = $redis->get("llinks:$link");
|
||||
if($short){
|
||||
echo "
|
||||
<div class=\"alert alert-warning\" id=\"warning\">
|
||||
Your link: <a href=\"$link\">
|
||||
<span class=\"longlink2\">$link</span></a> is not a lob.li link.<br> However we found that it has been shortened. <a href=\"http://lob.li/$short\">lob.li/$short</a>
|
||||
<a href=\"#\" id=\"copylink\" title=\"Copy Link\" onclick=\"copyToClipboard('http://lob.li/$short');\">
|
||||
<span class=\"glyphicon glyphicon-link\" style=\"float:right;padding-right:1%;\"></span>
|
||||
</a>
|
||||
</div>
|
||||
";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($_POST['link']) || !empty($_POST['linkage'])){
|
||||
}elseif(!empty($_POST['link']) || !empty($_POST['linkage'])){
|
||||
if(empty($_POST[$catchid]) || $_POST[$catchid] != $catchVal){
|
||||
die("<div id=\"danger\" class=\"alert alert-danger\">Oh Noes! Something happened and I can't continue.<br />Please try again by using the form located at <a href=\"http://lob.li\">lob.li</a>.</div>");
|
||||
}
|
||||
|
@ -1,3 +1,13 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require('Include/PHP/token.php');
|
||||
|
||||
$catchid = substr(number_format(time() * mt_rand(),0,'',''),0,10);
|
||||
$catchVal = hash('sha256', $catchid.mt_rand().time().substr(number_format(time() * mt_rand(),0,'',''),0,10));
|
||||
$catchVal = base_convert($catchVal.$catchid, 10, 36);
|
||||
$_SESSION['catch'] = $catchid.":".$catchVal;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -33,7 +43,7 @@
|
||||
<form class="form-shorten form-inline" id="form-shorten" role="form">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">http://lob.li/</span>
|
||||
<input type="text" class="form-control input-lg" id="link" placeholder="id" required autofocus>
|
||||
<input type="text" class="form-control input-lg" id="link" name="link" placeholder="id" required autofocus>
|
||||
<input type="hidden" name="<?php echo $catchid; ?>" value="<?php echo $catchVal; ?>"/>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-primary btn-lg submitbtn">
|
||||
@ -103,8 +113,8 @@
|
||||
$("#theLoader").fadeIn("fast");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$.post("process.php?resolve&token=<?php echo $token; ?>", $(this).serialize(), function(data){
|
||||
$("#message").hide().slideDown("fast");
|
||||
$.post("process.php?resolve", $(this).serialize(), function(data){
|
||||
$("#message").hide().html(data).slideDown("fast");
|
||||
$("#theLoader").hide();
|
||||
if($('#danger').length){
|
||||
$('#short-button').removeClass("btn-primary btn-success btn-warning").addClass("btn-danger");
|
||||
|
Loading…
x
Reference in New Issue
Block a user