Popular Links
HTML;
function show_top($numdays,$numlinks) {
//credit where credit is due - based on hack by MrTech at http://www.mrtech.com/forums/index.php/topic,2524.0.html
//define stuff
global $ydb;
$base = YOURLS_SITE;
$table_url = YOURLS_DB_TABLE_URL;
// go!
$urlt2 = '';
$query = $ydb->get_results("SELECT title, timestamp, url, keyword, clicks FROM `$table_url` WHERE timestamp >= SUBDATE(CURDATE(), $numdays) order by clicks desc limit $numlinks");
if ($query) {
foreach( $query as $query_result ) {
$thisURLArray = parse_url(stripslashes($query_result->url));
$diff = abs( time() - strtotime( $query_result->timestamp ) );
$days = floor( $diff / (60*60*24) );
if( $days == 0 ) {
$created = 'today';
} else {
$created = $days.' '.yourls_plural( 'day', $days).' ago';
}
$urlt2 .= '(' . $query_result->clicks . ') - ' .$thisURLArray[host] .' - ';
$urlt2 .= str_replace('www.', '', $query_result->title) . ' Created ' . $created . '
';
}
}
echo '