1
0
mirror of https://github.com/gamaio/lobli.git synced 2024-12-22 19:52:40 +00:00

Move stat table generation to stats.php.

This page is mostly static and it shouldn't require a call to process just to make a table.
This commit is contained in:
alopexc0de 2014-08-09 20:30:10 -04:00
parent da266cce1a
commit 7c71c5744e
No known key found for this signature in database
GPG Key ID: 48E847F18074C953
3 changed files with 30 additions and 97 deletions

View File

@ -54,13 +54,6 @@
}
}
function stats($redis, $seperator){
$tracking = $redis->keys("tracking:clicks:*");
$tracking = rsort($tracking);
$tracking = array_slice($tracking, 0, 5, true);
return "8$seperator".json_encode($tracking);
}
function getRemoteTitle($url){
$url = parse_url($url);
if($tags = get_meta_tags($url['scheme'].'://'.$url['host'])){

View File

@ -56,42 +56,6 @@
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 "
<tr class=\"success\">
<td></td>
<td class=\"centertab\"><a href=\"#\">$id</a></td>
<td><a href=\"$link\" title=\"$title\" class=\"res\">$link</a></td>
<td class=\"centertab\">$trackClicks</td>
<td>$date</td>
</tr>
";
}
}elseif($_GET['type'] == "json"){
echo $stats[1];
exit;
}else{
die("ERROR: Wrong type. I accept htmltable or json as my type<br>htmltable will send the partial table that loads on <a href=\"http://s.lob.li\">lob.li/stats</a>, 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("<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>");

View File

@ -41,57 +41,37 @@
</tr>
</thead>
<tbody>
<div class="stattable">
<tr>
<td></td>
<td></td>
<td>
<div id="theLoader" style="padding-left:10%;">
<div class="wrap">
<div class="loading">
<span class="title">loading....</span>
<span class="text">Please Wait</span>
</div>
</div>
</td>
</tr>
<?php
<!--<tr class="success">
$stats = $redis->keys("tracking:clicks:*");
rsort($stats);
$stats = array_slice($stats, 0, 5, true);
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);
print_r($linkData); exit;
$link = $linkData[0];
$title = $linkData[1];
$date = $linkData[2];
$trackClicks = $redis->get("tracking:clicks:$id");
echo "
<tr class=\"success\">
<td></td>
<td class="centertab"><a href="#">1</a></td>
<td><a href="#" title="Resolved website title" class="res">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</a></td>
<td class="centertab">44444</td>
<td>00/00/0000</td>
<td class=\"centertab\"><a href=\"#\">$id</a></td>
<td><a href=\"$link\" title=\"$title\" class=\"res\">$link</a></td>
<td class=\"centertab\">$trackClicks</td>
<td>$date</td>
</tr>
<tr class="success">
<td></td>
<td class="centertab"><a href="#">6</a></td>
<td><a href="#" title="Resolved website title" class="res">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</a></td>
<td class="centertab">44444</td>
<td>00/00/0000</td>
</tr>
<tr class="success">
<td></td>
<td class="centertab"><a href="#">236</a></td>
<td><a href="#" title="Resolved website title" class="res">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</a></td>
<td class="centertab">44444</td>
<td>00/00/0000</td>
</tr>
<tr class="success">
<td></td>
<td class="centertab"><a href="#">f42</a></td>
<td><a href="#" title="Resolved website title" class="res">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</a></td>
<td class="centertab">44444</td>
<td>00/00/0000</td>
</tr>
<tr class="success">
<td></td>
<td class="centertab"><a href="#">tg54<a></td>
<td><a href="#" title="Resolved website title" class="res">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</a></td>
<td class="centertab">44444</td>
<td>00/00/0000</td>
</tr>-->
</div>
";
}
?>
</tbody>
</table>
</div>
@ -113,10 +93,6 @@
<script type="text/javascript" language="JavaScript">
jQuery(document).ready(function(){
$('#statlink').addClass('active');
$.get("process.php?getstats&type=htmltable", function(data) {
$(".stattable").html(data);
});
});
$(function(){