Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/Blocks/Block_karmaActions.php
<?php
/*
*****************************************************************

 Block_karmaActions.php

*****************************************************************
LSP: Lunabyte Systems Portal
Open-Source Project Inspired by Zef Hemel (hide@address.com)
*****************************************************************
Software Version:                  LSP 2.0 "Enigma 2"
Software by:                         Lunabyte Systems (http://www.lunabyte.net)
Copyright 2002-2005 by:       Lunabyte Systems (http://www.lunabyte.net)
Support, News, Updates at:    http://www.lunabyte.net
*****************************************************************
This program is free software; you may redistribute it and/or modify it 
under the terms of the provided license as published by Lunabyte Systems.

This program is distributed in the hope that it is and will be useful,                  
but WITHOUT ANY WARRANTIES; without even any implied warranty of           
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        

See the "LSP_license.txt" file for details of the LSP license.
The latest version can always be found at http://www.lunabyte.net.
*****************************************************************
*/

if (!defined('ENIGMA'))
	die('<b>Access Violation</b><br />Direct Access to this location is not allowed.');

// show last $max_listing?5 aploads/smits
function Block_karmaActions($max_listing = 5, $output_method = 'echo')
{
	global $db_prefix, $txt;

	// Get the data from the Karma log.
	$karma_result = db_query("
		SELECT lk.ID_TARGET, lk.ID_EXECUTOR, lk.logTime, lk.action, memt.realName AS targetName, meme.realName AS executorName
		FROM {$db_prefix}log_karma AS lk, {$db_prefix}members AS memt, {$db_prefix}members AS meme
		WHERE memt.ID_MEMBER = lk.ID_TARGET
		AND meme.ID_MEMBER = lk.ID_EXECUTOR
		ORDER BY logTime DESC
		LIMIT $max_listing", __FILE__, __LINE__);

	$return = array();
	// Build an array to return karama action data.
	while ($row_karmas = mysql_fetch_assoc($karma_result))
		$return[] = array(
			'executor' => $row_karmas['executorName'],
			'target' => $row_karmas['targetName'],
			'action' => ($row_karmas['action'] == 1) ? 'applauds' : 'smites',
			'time' => timeformat($row_karmas['logTime'])
		);

	mysql_free_result($karma_result);

	if (empty($return)) // nothing loaded?
		echo $txt['no_karma_actions'];
	elseif ($output_method != 'echo') // return the array?
		return $return;
	else // print as html?
	foreach ($return as $data)
		echo $data['executor'], ' ', $data['action'], ' ', $data['target'], ' ', $data['time'], '<br />';

	unset($return);
}
?>
Return current item: Enigma