Skip to content

Commit

Permalink
Fix secret URL stats and fix 404
Browse files Browse the repository at this point in the history
  • Loading branch information
cydrobolt committed Apr 1, 2015
1 parent af2419f commit a46a1ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
11 changes: 6 additions & 5 deletions r.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@

$row = mysqli_fetch_assoc($result);


if (!$row['rurl']) {
if (!isset($row['rurl']) || strlen($row['rurl']) < 1) {
header("Location: 404.php", true, 302);
die();
}
if (strtolower($row['rurl']) == "disabled") {
require_once 'layout-headerlg.php';
echo "<h2>The link you are trying to reach has been disabled.</h2><br>"
. "Sorry for the inconvienience.";
require_once 'layout-footerlg.php';
die();
}
$lkey = @$row['lkey'];
if (strlen($lkey)>1) {
// Key needed? Check for it
if (strlen($lkey) > 1) {
// check for key
$sent_lkey = isset($_GET[$lkey]);
if ($sent_lkey) {
// yup, right key...continue on
// correct key
}
else {
require_once('layout-headerlg.php');
Expand Down
16 changes: 11 additions & 5 deletions stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@
require_once 'layout-footerlg.php';
die();
}
$query = "SELECT `clicks`,`country`,`rurl` FROM redirinfo WHERE baseval='{$bv}';";
$query = "SELECT `clicks`,`country`,`rurl`,`lkey` FROM redirinfo WHERE baseval='{$bv}';";
$result = $mysqli->query($query);
$row = mysqli_fetch_assoc($result);
if(!$row) {

if(isset($row['lkey']) == true && strlen($row['lkey']) > 0) {
echo "<h3>Cannot show stats for a secret URL</h3>";
die();
}
if(!isset($row)) {
echo "404 Not Found";
require_once 'layout-footerlg.php';die();
require_once 'layout-footerlg.php';
die();
}

if(!$row['user']) {
if(!isset($row['user']) || strlen($row['user']) < 1) {
$row['user'] = '<i>Anonymous</i>';
}
if(!$row['country']) {
if(!isset($row['country']) || strlen($row['country']) < 1) {
$row['country'] = '<i>Unknown</i>';
}

Expand Down

0 comments on commit a46a1ce

Please sign in to comment.