This post describes how to add a Latest Links page to your phpLinkBid directory. It is completely free to use and share, and takes just a minute to add to your bidding directory.
This MOD is tested with phpLinkBid v1.2 and is compatible with Advanced Link Stats.
View example of Latest Links and Latest Links with ALS.
1. Create a new file called latest.php and enter the code found below (click on the link view the full source). Upload to your phpLinkBid site in /content/latest.php.
/**
* latest.php - phpLinkBid latest links script
*
* Usage: Place this file in your /content/ folder and go to http://www.yoursite.com/latest.html
*
* Copyright (c) 2007, Intavant (www.intavant.com)
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @version 1.0
* @author Gabriel Harper
*
* 2007-07-17 v1.0
*
*/
$latest_max = 10; // # of latest links to display
$show_added = true; // Display the date added (true/false)
$date_format = ‘F j, Y’; // Date format (see: http://php.net/date)
$latest_msg = ‘These are the ‘ . $latest_max . ‘ most recently added links on ‘ . $cfg->getVar(’site_name’) . ‘.’;
$cfg->setVar(‘page_title’, ‘Latest Links on ‘ . $cfg->getVar(’site_name’));
$tpl->define(‘latest_top’, ‘
‘ . $latest_max . ‘ Latest Links
‘ . $latest_msg . ‘
‘, 1);
$tpl->parse(‘latest_top’);
$tpl->define(‘latest’, ‘links.tpl’);
$tpl->define_d(‘link_row’, ‘latest’);
$tpl->define_d(‘nolink_row’, ‘latest’);
$tpl->parse(‘latest’);
$sql = ‘SELECT ‘ . TBL_LINKS . ‘.*, ‘ . TBL_BIDS . ‘.bid_amount, SUM(‘ . TBL_BIDS . ‘.bid_amount) as bid_amount FROM ‘ . TBL_LINKS . ‘ LEFT JOIN ‘ .
TBL_BIDS . ‘ ON ‘ . TBL_BIDS . ‘.link_id = ‘ . TBL_LINKS . ‘.link_id WHERE bid_amount > 0 GROUP BY link_id ORDER BY datecreated DESC LIMIT ‘ . $latest_max;
if(($rs = $db->execute($sql)) && (!$rs->EOF))
{
$link_index = 0;
while(!$rs->EOF)
{
$link_index++;
$tpl->assign_d(‘link_row’, ‘link_index’, $link_index);
if($show_added === true)
{
$rs->fields['link_desc2'] .= ‘
Added ‘ . date($date_format, dbtime_to_unix($rs->fields['datecreated'])) . ‘‘;
}
$tpl->assign_array_d(‘link_row’, $rs->fields, 1);
$bid_url = str_replace(‘%link_id%’, $rs->fields['link_id'], $cfg->getVar(‘urlformat_link’));
$bid_url = DIR_BASE . $bid_url;
$tpl->assign_d(‘link_row’, ‘bid_url’, $bid_url);
$tpl->parse_d(‘link_row’);
$rs->MoveNext();
}
}
?>
2. You can now view the latest links page by visiting http://www.yoursite.com/latest.html.
3. To add a link to your Latest Links page in the menu you must edit /tpl/phplb/header.tpl and add a link to “{dir_base}latest.html”.
4. You can customize the script by changing $latest_max, $show_added, $date_format and $latest_msg. See comments in the MOD for details on these variables.