Location: PHPKode > scripts > PHPBB Donation MOD with Paypal IPN > install_PayPal_IPN_Donation_MOD-v1.0.4.6/root/lwdonors.php
<?php
/***************************************************************************
 *				lwdonors.php
 *							
 *	begin				: 14/SEP/2004
 *	copyright			: Zou Xiong - Loewen Exchange
 *	email				: hide@address.com
 *
 *	version				: 1.0.3 - 30/DEC/2006
 *
 *  @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *  
 ***************************************************************************/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);

//
// Start session management
//
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/lang_lw_donations');
//
// End session management

if( !$user->data['is_registered'] )
{
   //header("Location: " . append_sid($phpbb_script_path . "login." . $phpEx . "?redirect=lwdonors." . $phpEx));
   redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=login&amp;redirect=lwdonors." . $phpEx));
   exit;
}

//get necessary page header inforamtion first.
page_header('Donors List');


$start = request_var('start', '') + 0;

//
// Generate a 'Show topics in previous x days' select box. If the topicsdays var is sent
// then get it's value, find the number of topics with dates newer than it (to properly
// handle pagination) and alter the main query
//
$previous_days = array(7, 14, 30, 90, 180, 364, 400);
$previous_days_text = array($user->lang['7_DAYS'], $user->lang['2_WEEKS'], $user->lang['1_MONTH'], $user->lang['3_MONTHS'], $user->lang['6_MONTHS'], $user->lang['1_YEAR'], $user->lang['LW_ALL_RECORDS']);

$topic_days = 7;
$temp_topicdays = request_var('topicdays', '');
if ( strlen($temp_topicdays) > 0 )
{
	$topic_days = intval($temp_topicdays);

	if($topic_days > 0 && $topic_days < 400)
	{
		$min_topic_time = time() - ($topic_days * 86400);

		$limit_topics_time = " AND lw_date >= $min_topic_time";
	}
	else
	{
		$topic_days = 400;
		$limit_topics_time = '';
	}

	//if ( !empty($HTTP_POST_VARS['topicdays']) )
	//{
	//	$start = 0;
	//}
}
else
{
	$topic_days = 30;

	$limit_topics_time = '';

	$min_topic_time = time() - ($topic_days * 86400);

	$limit_topics_time = " AND lw_date >= $min_topic_time";
}

$donormode = request_var('mode', 'viewall');
$donorswhere = '';

if(strcmp($donormode, 'viewcurrent') == 0)
{	
	//format can only be 2004/08/04 yyyy/mm/dd
	$starttime = 0;
	$endtime = 0;
	if(strlen($config['donate_start_time']) == 10)
	{
		$starttime = mktime(0, 0, 0, substr($config['donate_start_time'], 5, 2), substr($config['donate_start_time'], 8, 2), substr($config['donate_start_time'], 0, 4) );
	}
	if(strlen($config['donate_end_time']) == 10)
	{
		$endtime = mktime(0, 0, 0, substr($config['donate_end_time'], 5, 2), substr($config['donate_end_time'], 8, 2), substr($config['donate_end_time'], 0, 4) );
	}	
	if($starttime > 0)
	{
		if($endtime <= $starttime)
		{
			$donorswhere = ' AND a.lw_date >= ' . $starttime;
		}
		else
		{
			$donorswhere = ' AND a.lw_date >= ' . $starttime . ' AND a.lw_date <= ' . $endtime;
		}
	}
}

$select_topic_days = '<select name="topicdays">';
for($i = 0; $i < count($previous_days); $i++)
{
	$selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';
	$select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
}
$select_topic_days .= '</select>';

$user_id = intval(request_var('userid', '0'));
if($user_id <= 0)
{
	$user_id = ($user->data['user_id']);
}
if($user_id != $user->data['user_id'] 
        && (!isset($user->data['session_admin']) || !$user->data['session_admin']) )
{
	$message = $user->lang['LW_NO_PRIVILEGE'] . '<br /><br />' .  sprintf($user->lang['LW_CLICK_RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>', $user->lang['FORUM_INDEX']);
	trigger_error($message);
	exit;
}

$template->assign_vars(array(
	'U_INDEX'		=> append_sid("{$phpbb_root_path}index.".$phpEx),
	'L_INDEX'			=> $user->lang['FORUM_INDEX'],
	'L_LW_DONORS_NAME' => $user->lang['L_LW_DONORS_NAME'],
	'L_LW_MONEY' => $user->lang['L_LW_MONEY'],
	'L_LW_COMMENT' => $user->lang['LW_ACCT_COMMENT'],
	'L_LW_DATE' => $user->lang['L_LW_DATE'],
	'L_GO' => 'GO',
	'U_INDEX' => append_sid("{$phpbb_root_path}index.".$phpEx),
	'L_DISPLAY_TOPICS' => $user->lang['LW_DONORS_DISPLAY_FROM'],
	'S_SELECT_TOPIC_DAYS' => $select_topic_days,
	'S_RECORDS_DAYS_ACTION' => 'lwdonors.' . $phpEx,
	'LW_HIDDEN_FIELDS' => '<input type="hidden" name="mode" value="' . $donormode . '">',
	)
	);


$topics_count = 0;
$sql = "SELECT COUNT(*) FROM " . ACCT_HIST_TABLE . " a, " . USERS_TABLE . " u" . " WHERE a.comment LIKE 'donate from%' AND u.user_id = a.user_id" . 
	"$limit_topics_time $donorswhere";
$result = $db->sql_query($sql);
if($row = $db->sql_fetchrow($result))
{
	$topics_count = $row["COUNT(*)"];
}

$topicsperpage = $config['topics_per_page'];

$sql = "SELECT a.*, u.* FROM " . ACCT_HIST_TABLE . " a, " . USERS_TABLE . " u" . " WHERE a.comment LIKE 'donate from%' AND u.user_id = a.user_id" . 
	"$limit_topics_time $donorswhere ORDER BY lw_date DESC LIMIT $start, $topicsperpage";

$result = $db->sql_query($sql);

while ( $row = $db->sql_fetchrow($result) ) {
		
		$last_donors = '';
		$style_color = '';
		//if ( $row['user_level'] == ADMIN )
		//{
		//	$row['username'] = '<b>' . $row['username'] . '</b>';
		//	$style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
		//}
		//else if ( $row['user_level'] == MOD )
		//{
		//	$row['username'] = '<b>' . $row['username'] . '</b>';
		//	$style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
		//}
		$row['username'] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
		if($row['user_id'] == ANONYMOUS)
		{
			$last_donors .= $user->lang['LW_ANONYMOUS_DONOR'];
		}
		else
		{
			$last_donors .= '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&amp;" . "u" . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
		}

   $template->assign_block_vars('topicrow', array(
   	'LW_DONORS_NAME' => $last_donors,
	'LW_MONEY' => $row['lw_money'] . ' ' . $config['paypal_currency_code'],
	'LW_DATE' => $user->format_date($row['lw_date']),
	)
   	);

}
if($topics_count > 0)
{
	$template->assign_vars(array(
		'PAGINATION' => generate_pagination( append_sid("{$phpbb_root_path}lwdonors.$phpEx",  "topicdays=$topic_days&userid=$user_id&mode=$donormode"), $topics_count, $topicsperpage, $start),
		'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $topicsperpage ) + 1 ), ceil( $topics_count / $topicsperpage )),

		'L_GOTO_PAGE' => $user->lang['Goto_page'])
	);
}
if($topics_count <= 0)
{
	//
	// No records
	//
	$no_topics_msg = $user->lang['LW_NO_RECORDS'];
	$template->assign_vars(array(
		'L_LW_NO_RECORDS' => $no_topics_msg,
		'S_LW_NO_RECORDS' => true, )
	);
}

// Output the page
$template->set_filenames(array(
	'body' => 'lwdonors_body.html')
);

page_footer();
?>
Return current item: PHPBB Donation MOD with Paypal IPN