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 '

Popular Links in the Last '. $numdays . ' Days:


' . $urlt2 . "

\n\r"; } //edit these if you want to show a different number of days/number of links! i.e. 1,5 = 5 most popular links created in the last 1 day show_top(1,5); show_top(30,5); show_top(365,5); show_top(1000,5); }