<?php
/*********************************************
  CPG Dragonfly - DF_Arcade Block
  ********************************************
  CPG Dragonfly is copyright © 2004 - 2005 by CPG Dev Team
  http://www.dragonflycms.com

  Dragonfly and DF_Arcade are released under the terms
  and conditions of the GNU GPL version 2 or any later version

  port of pnFlashGames - http://pnflashgames.com/
  Written by gerry@redgerry.com
  redgerry.com - Home of RG_Sports
  Revision Date: 16/10/2005 11:46
  Version Number 1.00
  Credit for this fabulously effecient piece of code belongs to Biggles 

  UNDER NO CIRCUMSTANCES MAY THIS CODE BE USED FOR ANY COMMERCIAL
  PURPOSES UNDER THE GUISE OF V.I.P. OR ANY OTHER DESCRIPTION
********************************************************/
if (!defined('CPG_NUKE')) { exit; }
global $prefix, $db, $bgcolor1, $bgcolor2, $cpgtpl;
$rg_arcade_module_name = 'DF_Arcade';

// Select the list of high scores
$result_scores = $db->sql_query( 'SELECT a.game_id, a.playerscore, b.gname, c.username FROM ' . $prefix . '_rgarcade_hiscores a LEFT JOIN ' . $prefix . '_rgarcade_games b ON a.game_id = b.game_id LEFT JOIN ' . $prefix . '_users c ON a.uid = c.user_id ORDER BY DATE DESC LIMIT 0, 3', false, __FILE__, __LINE__ );
while( $row_score = $db->sql_fetchrow( $result_scores, SQL_ASSOC ) ) {

  // Add the high scores to the template
  $cpgtpl->assign_block_vars( 'rgalatesthighs', array(
    'S_GAME_NAME'       => $row_score['gname'],
    'S_GAME_SCORE'      => $row_score['playerscore'],
    'S_PLAYER_NAME'     => $row_score['username'],

    'U_GAME'            => getlink( $rg_arcade_module_name . '&amp;func=play&amp;game_id=' . $row_score['game_id'] ),
    'U_PLAYER_PROFILE'  => getlink( 'Forums&amp;file=profile&amp;mode=viewprofile&amp;u=' . $row_score['username'] )
    )
  );
}

// Display the high scores
ob_start();
$cpgtpl->set_template();
$cpgtpl->set_filenames( array( 'block_rga_latesthighs' => 'blocks/block-RGA_LatestHighs.html' ) );
$cpgtpl->display( 'block_rga_latesthighs' );
$content = ob_get_clean();