Yourls Pages and Mods
I have been using Yourls for over a year now with Gkurl.us, so I thought I would share the code for some of the modifications I have made.
Popular Page
This page shows the top links for day/week/month, and year, etc.
Note that you will need to change the website URL, and possibly the table name (mine is url). Save as popular.php and upload to the pages directory.
<?php
require( ‘includes/load-yourls.php’ );
// TOP TODAY
$urlt2 = ”;
$sqlcode = “SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE timestamp >= SUBDATE(CURDATE(), 1) “;
$sqlcode .= “order by clicks desc limit 1″;
$query = $ydb->get_results($sqlcode);
if ($query) {
foreach( $query as $query_result ) {
$thisURLArray = parse_url(stripslashes($query_result->url));
$urlt2 .= ‘<a href=”http://gkurl.us/’ . $query_result->keyword .’” target=”blank”>’;
$urlt2 .= str_replace(‘www.’, ”, $query_result->title) . ‘</a> <a href=”http://gkurl.us/’ . $query_result->keyword .’+” target=”blank”>(‘ . $query_result->clicks . ‘) </a> – ‘ .$thisURLArray[host] .’ Submitted ‘ . $query_result->timestamp . ‘<br/>’;
}
}
echo ‘<h3><b>Trending Today:</b></h3><br/> ‘ . $urlt2 . “<br><br>\n\r”;
?>
<?php
// THIS WEEKS TOP LINKS
$urlt2 = ”;
$sqlcode = “SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE timestamp >= SUBDATE(CURDATE(), 7) “;
$sqlcode .= “order by clicks desc limit 10″;
$query = $ydb->get_results($sqlcode);
if ($query) {
foreach( $query as $query_result ) {
$thisURLArray = parse_url(stripslashes($query_result->url));
$urlt2 .= ‘<a href=”http://gkurl.us/’ . $query_result->keyword .’” target=”blank”>’;
$urlt2 .= str_replace(‘www.’, ”, $query_result->title) . ‘</a> <a href=”http://gkurl.us/’ . $query_result->keyword .’+” target=”blank”>(‘ . $query_result->clicks . ‘) </a> – ‘ .$thisURLArray[host] .’ Submitted ‘ . $query_result->timestamp . ‘<br/>’;
}
}
echo ‘<h3><b>This Week\’s Top links:</b></h3><br/> ‘ . $urlt2 . “<br><br>\n\r”;
?>
<?php
// THIS MONTHS TOP LINKS
$urlt4 = ”;
$sqlmonth = “SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE timestamp >= SUBDATE(CURDATE(), 31) “;
$sqlmonth .= “order by clicks desc limit 10″;
$query = $ydb->get_results($sqlmonth);
if ($query) {
foreach( $query as $query_result ) {
$thisURLArray = parse_url(stripslashes($query_result->url));
$urlt4 .= ‘<a href=”http://gkurl.us/’ . $query_result->keyword .’” target=”blank”>’;
$urlt4 .= str_replace(‘www.’, ”, $query_result->title) . ‘</a> <a href=”http://gkurl.us/’ . $query_result->keyword .’+” target=”blank”>(‘ . $query_result->clicks . ‘) </a> – ‘ .$thisURLArray[host] .’ Submitted ‘ . $query_result->timestamp . ‘<br/>’;
}
}
echo ‘<h3><b> This Months\’s Top links:</b></h3><br/>’ . $urlt4 . “<br><br>\n\r”;
?>
<?php
//THIS YEAR
$urlt5 = ”;
// This year
$sqlyear = “SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE timestamp >= SUBDATE(CURDATE(), 366) “;
$sqlyear .= “order by clicks desc limit 10″;
$query = $ydb->get_results($sqlyear);
if ($query) {
foreach( $query as $query_result ) {
$thisURLArray = parse_url(stripslashes($query_result->url));
$urlt5 .= ‘<a href=”http://gkurl.us/’ . $query_result->keyword .’” target=”blank”>’;
$urlt5 .= str_replace(‘www.’, ”, $query_result->title) . ‘</a> <a href=”http://gkurl.us/’ . $query_result->keyword .’+” target=”blank”>(‘ . $query_result->clicks . ‘) </a> – ‘ .$thisURLArray[host] .’ Submitted ‘ . $query_result->timestamp . ‘<br/>’;
}
}
echo ‘<h3><b> All Time Top links:</b></h3><br/> ‘ . $urlt5 . “<br><br>\n\r”;
?>
Top Pics Page
This code shows the top images (urls with gif, jpg, jpeg, or png).
Again, you will have to change the URL and table name.
<?phprequire( 'includes/load-yourls.php' );?><?php// This month$sqlyear = "SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE timestamp >= SUBDATE(CURDATE(), 1) AND url like '%.jpg%' OR timestamp >= SUBDATE(CURDATE(), 1) AND url like '%.gif%' OR timestamp >= SUBDATE(CURDATE(), 1) AND url like '%.png%' ";$sqlyear .= "order by clicks desc limit 5";$query = $ydb->get_results($sqlyear);if ($query) {$i = 0;foreach( $query as $query_result ) {$i++;$thisURLArray = parse_url(stripslashes($query_result->url));$url = $query_result->url;$urlt5 .= '<a href="http://gkurl.us/' .$query_result->keyword. '" title="' . $query_result->title . ' ( ' . $query_result->clicks . ') "><img align="center" src="' .$url. '" width="20%" height="20%" alt="" /></a>';}}echo '<h3><b> Top Pictures Today:</b></h3><br/> ' . $urlt5 . "<br><br>\n\r";?><?php//THIS week$urlt5 = '';// This weel$sqlyear = "SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE timestamp >= SUBDATE(CURDATE(), 7) AND url like '%jpg%' OR timestamp >= SUBDATE(CURDATE(), 7) AND url like '%.gif%' OR timestamp >= SUBDATE(CURDATE(), 7) AND url like '%.png%' ";$sqlyear .= "order by clicks desc limit 5";$query = $ydb->get_results($sqlyear);if ($query) {$i = 0;foreach( $query as $query_result ) {$i++;$thisURLArray = parse_url(stripslashes($query_result->url));$url = $query_result->url;$urlt5 .= '<a href="http://gkurl.us/' .$query_result->keyword. '" title="' . $query_result->title . ' ( ' . $query_result->clicks . ') "><img src="' .$url. '" width="20%" height="20%" alt="" /></a>';}}echo '<h3><b> This Weeks Top Pics:</b></h3><br/> ' . $urlt5 . "<br><br>\n\r";?><?php//THIS month$urlt5 = '';// This month$sqlyear = "SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE timestamp >= SUBDATE(CURDATE(), 31) AND url like '%.jpg%' OR timestamp >= SUBDATE(CURDATE(), 31) AND url like '%.gif%' OR timestamp >= SUBDATE(CURDATE(), 31) AND url like '%.png%' ";$sqlyear .= "order by clicks desc limit 5";$query = $ydb->get_results($sqlyear);if ($query) {$i = 0;foreach( $query as $query_result ) {$i++;$thisURLArray = parse_url(stripslashes($query_result->url));$url = $query_result->url;$urlt5 .= '<a href="http://gkurl.us/' .$query_result->keyword. '" title="' . $query_result->title . ' ( ' . $query_result->clicks . ') "><img src="' .$url. '" width="20%" height="20%" alt="" /></a>';}}echo '<h3><b> This Months Top Pics:</b></h3><br/> ' . $urlt5 . "<br><br>\n\r";?><?php//THIS YEAR$urlt5 = '';// This year$sqlyear = "SELECT title, timestamp, url, keyword, clicks FROM `url` WHERE url like '%jpg%' OR url like '%.gif%' OR url like '%.png%' ";$sqlyear .= "order by clicks desc limit 5";$query = $ydb->get_results($sqlyear);if ($query) {$i = 0;foreach( $query as $query_result ) {$i++;$thisURLArray = parse_url(stripslashes($query_result->url));$url = $query_result->url;$urlt5 .= '<a href="http://gkurl.us/' .$query_result->keyword. '" title="' . $query_result->title . ' ( ' . $query_result->clicks . ') "><img src="' .$url. '" width="20%" height="20%" alt="" /></a>';}}echo '<h3><b> All Time Top Pics:</b></h3><br/> ' . $urlt5 . "<br><br>\n\r";?>More Coming Soon
As I make more mods and pages, I’ll add them here.
Recent Comments
Archives
- January 2012
- October 2011
- September 2011
- February 2011
- January 2011
- December 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
Categories





