Topic Calendar (regular phpBB edition)

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
265
59%
Very Good
97
22%
Good
44
10%
Fair
10
2%
Poor
32
7%
 
Total votes: 448

Rubber_Bullets
Registered User
Posts: 11
Joined: Thu Dec 20, 2007 1:48 am

Re: Topic Calendar (regular phpBB edition)

Post by Rubber_Bullets »

It works fine on my board. the only question I have is what do I edit so that the year starts with the current year and not 1970
User avatar
RMcGirr83
Former Team Member
Posts: 22011
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Topic Calendar (regular phpBB edition)

Post by RMcGirr83 »

Rubber_Bullets wrote:It works fine on my board. the only question I have is what do I edit so that the year starts with the current year and not 1970
I haven't tested this, but you can give it a shot.

OPEN

includes/class_calendar_posting.php

FIND
foreach ( $order as $key => $dummy )
{
$options = false;
switch ( $key )
{
case 'y':
$options = $this->count_list($xtime[$key], 1970, 2037, '%04d');
break;
change the 1970.

I wonder what will happen in 29 years? :)
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beer Image
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by Ptirhiik »

> Peter77sx: if you have Run stat mod, activate the sql debug to get the list of requests performed: it will allow you to track where they are made.
baerenwurm
Registered User
Posts: 131
Joined: Wed Nov 06, 2002 2:38 pm
Location: Germany

Re: Topic Calendar (regular phpBB edition)

Post by baerenwurm »

Is there any reminder feature that lets the users decide whether they want to be reminded of events by email?
baerenwurm
Registered User
Posts: 131
Joined: Wed Nov 06, 2002 2:38 pm
Location: Germany

Re: Topic Calendar (regular phpBB edition)

Post by baerenwurm »

K, following errors occur when I try to access

1. (the main page of) my arcade arena:

Code: Select all

Fatal error: Call to a member function on a non-object in /srv/www/htdocs/web16/html/includes/page_header.php on line 619
(http://www.quentintarantino.de/activity ... _id,0.html does work though)
#619:

Code: Select all

$user->set();
and

2. the archive of my (AJAX) shoutbox:

Code: Select all

Fatal error: Cannot redeclare embvid() (previously declared in /srv/www/htdocs/web16/html/includes/embvid.php:14) in /srv/www/htdocs/web16/html/includes/embvid.php on line 14
#14:

Code: Select all

function embvid($message)
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by Ptirhiik »

> baerenwurm: this is due to the way your scripts includes common.php or page_header.php, eg within functions or methods without the global vars added by the mod (common.php and page_header.php are not designed to be included within functions without a caution review of the global line in the function). Search along this very thread, this is a recurrent question.
baerenwurm
Registered User
Posts: 131
Joined: Wed Nov 06, 2002 2:38 pm
Location: Germany

Re: Topic Calendar (regular phpBB edition)

Post by baerenwurm »

Thanks a lot for your quick reply!

I've solved the second issue. I changed following includes in chat.php

Code: Select all

// Include Post functions and BBCodes
      include($phpbb_root_path.'includes/bbcode.'.$phpEx);
      include($phpbb_root_path.'includes/functions_post.'.$phpEx);
to include_once.

I have no idea how to solve the first one though. This is my activity.php:

Code: Select all

<?php
/***************************************************************************
 *
 *                               activity.php
 *                            -------------------
 *   begin                : Tuesday, Jan 2nd, 2007
 *   copyright            : (c) 2003-2007 dEfEndEr www.phpbb-arcade.com
 *   email                : [email protected]
 *
 *   $Id: activity.php,v 2.1.8 2007/01/02 dEfEndEr Exp $
 *   Support @ http://www.phpbb-arcade.com
 *   v 2.0.0 2003/12/12 12:59:59 Napoleon
 *
 ***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************
 *
 *   This is a MOD for phpbb v2.0.+ The phpbb group has all rights to the
 *   phpbb source. They can be contacted at :
 *
 *      I-Net : www.phpbb.com
 *      E-Mail: [email protected]
 *
 ***************************************************************************
 * 	CREDITS:
 *  Napoleon - Original Activity Mod v2.0.0
 *  Painkiller - Add-On's, Alpha Testing & Support
 *  wizzzzzzzz - Dutch Support/Translation & Alpha Testing
 *  femu - German Support/Translation
 *  Mark - Add-On & Support
 *  Minesh - Add-On's & Support
 *
 ***************************************************************************/

define('IN_PHPBB', true);
if(isset($_GET['phpbb_root_path']))
{
	die("Hacking attempt");
}
$phpbb_root_path = './';

include($phpbb_root_path . 'extension.inc');

$filename = basename(__FILE__);
$phpEx    = substr(strrchr(__FILE__, '.'), 1);

include_once($phpbb_root_path . 'common.'.$phpEx);
include_once($phpbb_root_path . 'includes/functions_arcade.'.$phpEx);
include_once($phpbb_root_path . 'includes/bbcode.' .$phpEx);

// Start session management
$userdata = session_pagestart($user_ip, PAGE_ACTIVITY);
init_userprefs($userdata);
$page_title = 'Arcade'; // This is Hard Coded as it is a NAME.
$user_id = $userdata['user_id'];
// End session management

// Make sure the player is registered
if (!$userdata['session_logged_in'] && $user_id == ANONYMOUS && $board_config['games_no_guests'])
{
	$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
	header($header_location . append_sid("login.$phpEx?redirect=$filename", true));
	exit;
}

//
// Check the mod has been installed correctly and is ONLINE.
//
if($board_config['games_offline'] && $userdata[user_level] != ADMIN && $userdata[user_level] != MOD)
{
	message_die(GENERAL_MESSAGE, $lang['games_are_offline'], $lang['Information']);
}
if (!defined('iNA') || !defined('iNA_USER_DATA'))
{
	message_die(GENERAL_ERROR, 'Incorrect Installation, Check the install.txt and update your includes/constants.php');
}
$version = get_ina_version();
if ($version != 'v2.0.7')
{
	message_die(GENERAL_ERROR, 'Incorrect Installation, Version Missmatch ' . $version . ' should be v2.0.7');
}

define('SHOW_ONLINE', true);

$GUEST_ONLY = FALSE;

if ($board_config['use_rewards_mod'])
{
	if ( $board_config['use_point_system'] )
	{
		include($phpbb_root_path . 'includes/functions_points.'.$phpEx);
	}
	if ( $board_config['use_cash_system'] || $board_config['use_allowance_system'] )
	{
		include($phpbb_root_path . 'includes/rewards_api.'.$phpEx);
	}
}

if (isset($HTTP_GET_VARS['cat_id']) || isset($HTTP_POST_VARS['cat_id']))
{
	$cat_id = (isset($HTTP_GET_VARS['cat_id'])) ? $HTTP_GET_VARS['cat_id'] : $HTTP_POST_VARS['cat_id'];
	$cat_id = intval(htmlspecialchars($cat_id));
}

if (isset($HTTP_GET_VARS['search_word']) || isset($HTTP_POST_VARS['search_word']))
{
	$mode = 'search';
}
else if (isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']))
{
	$mode = (isset($HTTP_GET_VARS['mode'])) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
	$mode = htmlspecialchars($mode);
}
else 
{
	if( isset($HTTP_POST_VARS['game']) )
	{
		$mode = 'game';
	}
	else if( isset($HTTP_POST_VARS['stats']) )
	{
		$mode = 'stats';
	}
	else
	{
		$mode = '';
	}
}

if (isset($HTTP_GET_VARS['sort_mode']) || isset($HTTP_POST_VARS['sort_mode']))
{
	$sort_mode = (isset($HTTP_GET_VARS['sort_mode'])) ? $HTTP_GET_VARS['sort_mode'] : $HTTP_POST_VARS['sort_mode'];
	$sort_mode = htmlspecialchars($sort_mode);
}

$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
$start = intval(htmlspecialchars($start));

if(isset($HTTP_POST_VARS['order']))
{
	$sort_order = ($HTTP_POST_VARS['order'] == 'DESC') ? 'DESC' : 'ASC';
}
else if(isset($HTTP_GET_VARS['order']))
{
	$sort_order = ($HTTP_GET_VARS['order'] == 'DESC') ? 'DESC' : 'ASC';
}
else
{
	$sort_order = 'DESC';
}
$sort_order = htmlspecialchars($sort_order);

if ($board_config['use_point_system'])
{
	$game_cost = $board_config['points_name'];
}
else
{
	$game_cost = $lang['game_cost'];
}

$mode_types_text = array($lang['date_added'], $lang['alphabetically'], $lang['game_instructions'], $game_cost, $lang['game_bonuses'], $lang['game_played']);
$mode_types = array('date_added','alphabetical', 'game_instructions', 'game_charge', 'game_bonus', 'game_played');

$select_sort_mode = '<select name="sort_mode">';
for($i = 0; $i < count($mode_types_text); $i++)
{
	$selected = ( $sort_mode == $mode_types[$i] ) ? ' selected="selected"' : '';
	$select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
}
$select_sort_mode .= '</select>';

$select_sort_order = '<select name="order">';
if($sort_order == 'DESC')
{
	$select_sort_order .= '<option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option><option value="ASC">' . $lang['Sort_Ascending'] . '</option>';
}
else
{
	$select_sort_order .= '<option value="DESC">' . $lang['Sort_Descending'] . '</option><option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option>';
}
$select_sort_order .= '</select>';

switch( $sort_mode )
{
	case 'alphabetical':
		$order_by = "game_desc";
		break;
		
	case 'game_instructions':
		$order_by = "instructions ";
		break;
		
	case 'game_charge':
		$order_by = "game_charge ";
		break;
		
	case 'game_bonus':
		$order_by = "game_bonus ";
		break;
		
	case 'game_played':
		$order_by = "played ";
		break;
		
	default:
		$order_by = "game_id ";
		break;
}

if($cat_id > 0)
{
	$sql = "SELECT * FROM " . iNA_CAT . "
		WHERE cat_id = " . $cat_id;
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, $lang['no_game_data'], '', __LINE__, __FILE__, $sql);
	}
	$cat_info = $db->sql_fetchrow($result);
	$catagory_name = $cat_info['cat_name'];
	$mod_id = $cat_info['mod_id'];
	$page_title = $cat_info['cat_name'] . ' - ' . $page_title; 
}
else
{
	$catagory_name = $lang['all_games'];
}

$url = ' -> <a href="' . $filename . '?mode=cat&cat_id=' . $cat_id . '&start=' . $start . '&sort_mode=' . $sort_mode . '&order=' . $sort_order . '" class="nav">' . $catagory_name . '</a>';

//
//	Mode will tell me what the user wants me to do.
//
if( $mode != '' )
{
	$game_id = (isset($HTTP_GET_VARS['id'])) ? intval($HTTP_GET_VARS['id']) : 0;
// Grab Game info from game_id
	$sql = "SELECT * FROM " . iNA_GAMES . "
		WHERE game_id = " . $game_id;
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql);
	}
	$game_info = $db->sql_fetchrow($result);
//
//	OK, you wanna play :)
//
	if ($mode == 'game')
	{
		$gen_simple_header = TRUE;
		$game_name = $game_info['game_name'];
		$game_hash = update_ina_session($userdata['user_id'], $user_ip, PAGE_ACTIVITY, $game_name);
		$gamepath = 'game.' . $phpEx . '?gid=' . $game_hash;
		$game_charge = $game_info['game_charge'];

		if(!$game_id)
		{
			message_die(GENERAL_MESSAGE, $lang['no_game_data']);
		}

		if(!$game_info['allow_guest'] && ($userdata['user_id'] == ANONYMOUS))
		{
			message_die(GENERAL_MESSAGE, $lang['games_no_guests'], $lang['Information']);
		}
		
		if(($board_config['use_point_system'] && $board_config['use_rewards_mod']) && ( $userdata['user_id'] != ANONYMOUS ))
		{
			if ($userdata['user_points'] >= $game_charge)
			{
				subtract_points($user_id,$game_charge);
      		}
			else
			{
				message_die(GENERAL_MESSAGE, $lang['not_enough_points'], '', __LINE__, __FILE__, $sql);
			}
		}
		if((($board_config['use_cash_system'] || $board_config['use_allowance_system']) && $board_config['use_rewards_mod']) && ( $userdata['user_id'] != ANONYMOUS ))
		{
			if (get_reward($user_id) >= $game_charge)
			{
				subtract_reward($user_id,$game_charge);
      		}
			else
			{
				if($board_config['points_name'])
				{
					message_die(GENERAL_MESSAGE, $lang['not_enough_points'], '', __LINE__, __FILE__, $sql);
				}
				else
				{
					message_die(GENERAL_MESSAGE, $lang['not_enough_reward'], '', __LINE__, __FILE__, $sql);
				}
			}
		}

		$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
		header($header_location . append_sid($gamepath, true));
		exit;
	}
//
//	We are looking at the Information for the game.
//
	else if ($mode == 'stats')
	{
		$page_title = $game_info['game_desc'] . ' - ' . $board_config['sitename']; 
		$page_meta_desc = $page_title;
		$page_meta_key = trim(htmlspecialchars(str_replace(",-,",",",str_replace(" ", ",", $game_info['game_desc'] . ',' . $board_config[sitename]))));

		$url .= ' &raquo; ' . $game_info['game_desc'];

		if ($game_info['reverse_list'])
		{
			$list_type = 'ASC';
		}
		else
		{
			$list_type = 'DESC';
		}
		$sql = "SELECT game_name, player_id, score, username FROM " . iNA_SCORES . " s, " . USERS_TABLE . " u
			WHERE s.player_id = u.user_id
			AND game_name = '" . $game_info['game_name'] . "'
			ORDER BY score $list_type";
		if(!$result = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql);
		}
		$score_info = $db->sql_fetchrow($result);
		$sql = "SELECT game_name, player_id, score, username FROM " . iNA_AT_SCORES . " s, " . USERS_TABLE . " u
			WHERE s.player_id = u.user_id
			AND game_name = '" . $game_info['game_name'] . "'
			ORDER BY score $list_type";
		if(!$result = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql);
		}
		$score_at_info = $db->sql_fetchrow($result);
		if($game_info['game_charge'])
		{
			$cost = $game_info['game_charge'] . " "; 
		}
		else
		{
			$cost = $lang['game_free']; 
		}

		if($board_config['use_point_system'] && ($game_info['game_charge'] > 0))
		{
			$cost .= $board_config['points_name'];
		}

		if($game_info['instructions'])
		{
			$instructions = $game_info['instructions'];
		}
		else
		{
			$instructions = $lang['game_no_instructions'];
		}
		
		$image_path = $game_info['image_path'];
		if ( $image_path == "" )
		{
			if( file_exists("./". $game_info['game_path'] ."/". $game_info['game_name'] .".gif") )
				$image_path = './' . $game_info['game_path'] . $game_info['game_name'] . '.gif';
			else
				$image_path = $board_config['games_default_img'];
		}
		else if ( strlen( $image_path ) < 5 )
		{
			$image_path = './' . $game_info['game_path'] . $game_info['game_name'] . $game_info['image_path'];
		}

		$best_player = $score_info['username'];
		if( $best_player == 'Anonymous' )
		{
			$best_player = $lang['Guest'];
		}
		if($game_info['game_reward'] > 0)
		{
			$reward = sprintf("Reward given for every %s points scored", $game_info['game_reward']);
		}
		else
		{
			$reward = $lang['None'];
		}
		
		if ($board_config['games_at_highscore'])
		{
			$template->assign_block_vars('at_highscore', array());
		}
		
		$template->set_filenames(array('body' => 'arcade_stats.tpl') );

		$template->assign_vars(array(
			'NAME' => $game_info['game_name'],
			'PATH' => $game_info['game_path'],
			'U_ADD_FAV' =>  append_sid("$filename?mode=fav&cat_id=$cat_id&id=$game_id"),
			'L_ADD_FAV' => $lang['games_add_fav'],
			'IMAGE' => $image_path,
			'DESC' => $game_info['game_desc'],
			'PLAYED' => $game_info['played'],
			'COST' => $cost,
			'BONUS' => $game_info['game_bonus'],
			'AT_BONUS' => $game_info['at_game_bonus'],
			'REWARD' => $reward,
			'BEST_PLAYER' => $best_player,
			'BEST_SCORE' => doubleval($score_info['score']),
			'BEST_AT_PLAYER' => $score_at_info['username'],
			'BEST_AT_SCORE' => doubleval($score_at_info['score']),
			'INSTRUCTIONS' => $instructions,
			'ARCADE_MOD' => sprintf($lang['activitiy_mod_info'], get_ina_version()),
			
			"L_INSTRUCTIONS" => $lang['game_instructions'],
			"L_GAME_STATS" => $lang['game_statistics'],
			"L_PLAYED" => $lang['game_played'],
			"L_PRICE" => $lang['game_stat_price'],
			"L_HIGHSCORE" => $lang['game_stat_highscore'],
			"L_AT_HIGHSCORE" => $lang['game_stat_at_highscore'],
			"L_SCORE_REWARD" => $lang['game_score_reward'],
			"L_BEST_PLAYER" => $lang['game_best_player'],
			"L_ALL_TIME_SCORE" => $lang['game_all_time_score'],
			"L_CURRENT_BEST" => $lang['game_current_best'],
			"L_HIGHEST_SCORE" => $lang['game_highest_score'],
			"L_TOURNAMENT" => $lang['game_tournament'],
			
			"U_CAT" => $url) );
	}
//
//	We are looking for the highscores.
//
	else if ($mode == "highscore" || $mode == 'at_highscore')
	{ 
		$page_title			= $game_info['game_desc'] . ' - ' . $cat_info['cat_name'] . ' - ' . $board_config['sitename'] ; 
		$game_name			= $game_info['game_name'];
		$highscore_limit	= $game_info['highscore_limit']; 
		$high_score_text	= $lang['game_highscores'];
		$high_score_table	= iNA_SCORES;

		if( $mode == "at_highscore" )
		{
			$high_score_text = $lang['game_at_highscores'] . ' ' . $lang['game_highscores'];
			$high_score_table = iNA_AT_SCORES;
			$highscore_limit = $game_info['at_highscore_limit'];
		}

		$url .= " -> " . $game_info['game_desc'];

		$template->set_filenames(array('body' => 'arcade_scores.tpl') ); 
		$template->assign_vars(array(
			"TITLE" => $game_info['game_desc'], 
			"L_HIGHSCORE" => $high_score_text, 
			"L_SCORE" => $lang['game_score'], 
			"L_PLAYED" => $lang['game_played'], 
	        "DASH" => $lang['game_dash'],
			"ARCADE_MOD" => sprintf($lang['activitiy_mod_info'], get_ina_version()),
				
			"U_CAT" => $url)); 

		if ($game_info['reverse_list']) 
		{
			$list_type = 'ASC'; 
		}
		else 
		{
			$list_type = 'DESC'; 
		}

		$sql = "SELECT game_name, player_id, score, date, username, user_allow_viewonline FROM " . $high_score_table . " s, " . USERS_TABLE . " u
			WHERE s.player_id = u.user_id
			AND game_name = '" . $game_name . "'
			ORDER BY score $list_type, date ASC";
		if (!empty($highscore_limit)) 
		{
			$sql .= " LIMIT 0,$highscore_limit"; 
		}
		if(!$result = $db->sql_query($sql)) 
		{
			message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql); 
		}
		if ($row = $db->sql_fetchrow($result)) 
		{ 
			$i = 1; 
	        do // Loop until we hit the end :) to output the page..
		    { 
				$user_name = $row['username'];
				if($last_score != $row['score'])
				{
					$pos = $i;
				}
				else
				{
					$pos = ' ';
				}

				if($pos == 1)
				{
					$pos = '<img src="images/trophy.gif">';
				}

				if($user_name == 'Anonymous')
				{
					$user_name = $lang['Guest'];
				}
				else if(!$row['user_allow_viewonline'] && $userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD)
				{
					$user_name = $lang['game_hidden'];
				}

		        $template->assign_block_vars("scores", array(
				    "ROW_CLASS" => ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'], 
               		"POS" => $pos, 
	               	"NAME" => $user_name, 
		           	"SCORE" => doubleval($row['score']),                                  
			       	"DATE" => create_date($board_config['default_dateformat'], $row['date'], $board_config['board_timezone'])) ); 
					$i++; 

				$last_score = $row['score'];
			} 
			while ($row = $db->sql_fetchrow($result)); 
		} 
	}
//
//	User Game Stats
//
	else if ($mode == "game_stats")
	{
		$url		= ' -> <a href="' . $filename . '" class="nav">' . $lang['games_catagories'] . '</a>';

		if (isset($HTTP_GET_VARS['user_id']) || isset($HTTP_POST_VARS['user_id']))
		{
			$user_id = (isset($HTTP_GET_VARS['user_id'])) ? $HTTP_GET_VARS['user_id'] : $HTTP_POST_VARS['user_id'];
			$user_id	= intval(htmlspecialchars($user_id));
//
//	Send PM to user, to tell them thier highscores are under attack :)
//
			$sql = "SELECT username FROM " . USERS_TABLE . "
				WHERE user_id = '" . $userdata['user_id'] . "'";
			if(!$result = $db->sql_query($sql)) 
			{
				message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql); 
			}
			$user_row = $db->sql_fetchrow($result); 
				
			if ((ina_check_last_pm($user_id, $userdata['user_id']) == FALSE) && $board_config['games_use_pms'])
			{
				$message = sprintf($lang['games_pm_info'], $user_row['username']);
				ina_send_user_pm($user_id, $lang['games_important_info'], $message, -1);
			}
		}

		$stats_id	= intval(htmlspecialchars($game_id));
		if($stats_id > 0 && $stats_id < 4)
		{
			$scores = total_highscores($user_id, iNA_AT_SCORES);
			$stats_id = $stats_id + 3;
			$table = iNA_AT_SCORES;
		}
		else
		{
			$table = iNA_SCORES;
			$scores = total_highscores($user_id);
		}

		$template->set_filenames(array('body' => 'arcade_stats_body.tpl') );
		$template->assign_vars(array(
			"U_CAT" => $url,
			"ARCADE_MOD" => sprintf($lang['activitiy_mod_info'], get_ina_version())));

		$i = 0;
		$game_name = explode('|', $scores[$stats_id]);
		do
		{
			$sql = "SELECT g.game_id, g.win_width, g.win_height, g.game_desc, s.score, s.date FROM ". iNA_GAMES . " g, " . $table . " s
				WHERE g.game_name = '" . $game_name[$i] . "'
					AND g.game_name = s.game_name
					AND player_id = '$user_id'
					LIMIT 0,1";
			if(!$result = $db->sql_query($sql)) 
			{
				message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql); 
			}
			$row = $db->sql_fetchrow($result); 
		
			if($user_id != ANONYMOUS)
			{
				$game_link = "<a href=\"javascript:Gk_PopTart('$filename?mode=game&id=" . $row['game_id'] . "&ex_user=" . $user_id . "$SID', 'New_Window', '" . $row['win_width'] . "', '" . $row['win_height'] . "', 'no')\" onClick=\"blur()\">" . $row['game_desc'] . "</a>";
			}
			else
			{
				$game_link = $row['game_desc'];
			}
			
			$template->assign_block_vars("stats", array(
				"ROW_CLASS" => ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'], 
				"GAME" => $game_link,
				"SCORE" => doubleval($row['score']),
				"LAST_PLAYED" => create_date($board_config['default_dateformat'], $row['date'], $board_config['board_timezone']) ) ); 
			$i++;
		} while ($game_name[$i]);
	}
//
//	Favorities Mode
//
	else if ($mode == 'fav_del')
	{
		$sql = "DELETE FROM " . iNA_FAV . "
			WHERE user_id = '" . $user_id . "'
				AND game_id = '" . $game_id . "'";
		if(!$result = $db->sql_query($sql)) 
		{
			message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql);
		}

		$message = $lang['del_fav'];
		$message .= '<a href="' . append_sid("$filename?mode=fav&cat_id=$cat_id") . '">Return</a>';
		message_die(GENERAL_MESSAGE, $message);
	}
//
//	Tournament Mode
//
	else if ($mode == 'tour')
	{
		$page_title = $board_config['sitename'] . ' - ' . $tour['tour_name']; 
		$url		= ' -> <a href="' . $filename . '" class="nav">' . $lang['games_catagories'] . '</a> -> ' . $tour['tour_name'];

		if (isset($HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']))
		{
			$tour_id = (isset($HTTP_GET_VARS['id'])) ? $HTTP_GET_VARS['id'] : $HTTP_POST_VARS['id'];
		}
		$tour_id = intval(htmlspecialchars($tour_id));
		
		$sql = "SELECT * FROM " . iNA_TOUR;
		if( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql);
		}
		$tour = $db->sql_fetchrow($result);

		$template->set_filenames(array('body' => 'arcade_tour_body.tpl') );
		$template->assign_vars(array(
			"NAME" => $tour['tour_name'],

			"U_CAT" => $url,
			"ARCADE_MOD" => sprintf($lang['activitiy_mod_info'], get_ina_version())));
	}
//
// (DEFAULT if MODE set, so we don't get any template errors.)
//
	else
	{	
//		if($board_config['games_posts_required'] || $board_config['games_rank_required'])
//		{
			if(((intval($userdata['user_posts']) < intval($board_config['games_posts_required'])) || (intval($userdata['user_rank']) < intval($board_config['games_rank_required']))) && $userdata['user_level'] != ADMIN && $userdata['user_id'] != ANONYMOUS)
			{
				if(!$HTTP_GET_VARS['warning'])
				{
					$warning_url = '<a href="' . $filename . '?mode=cat&cat_id=' . $cat_id . '&start=' . $start . '&sort_mode=' . $sort_mode . '&order=' . $sort_order . '&warning=true">OK</a>';
					message_die(GENERAL_MESSAGE, sprintf($lang['games_not_enough_posts'], $warning_url), $lang['Information']);
				}
				else
				{
					$GUEST_ONLY = TRUE;
				}
			}
//		}
//
// Now lets start building the list of Activities for the catagory :)
//
		$game_count = 0;
		$sort_mode_link_info = append_sid("$filename?mode=cat&cat_id=$cat_id&");
		
		$template->set_filenames(array('body' => 'arcade_body.tpl') );
		
		if ($board_config['use_gamelib'] == 1)
		{
			$gamelib_link = "<div align=\"center\"><span class=\"copyright\">" . $lang['game_lib_link'] . "</span></div>";
		}
		if ($board_config['use_gamelib'] == 0)
		{
			$gamelib_link = '';		
		}
	
		if ($board_config['games_tournament_mode'])
		{
				$total_tournaments = get_total_tour();
				$template->assign_block_vars('tournament_menu', array());
		}
		if ($board_config['use_point_system'] && $board_config['use_rewards_mod'])
		{
			$template->assign_vars(array("L_MONEY" => $board_config['points_name']));
		}
		else if (($board_config['use_cash_system'] || $board_config['use_allowance_system']) && $board_config['use_rewards_mod'])
		{
			$template->assign_vars(array("L_MONEY" => $lang['game_cost']));
		}
		else
		{
			$template->assign_vars(array("L_MONEY" => $lang['game_number']));
		}
		$user_id = $userdata['user_id'];
//
//	Seach Mode
//
		if ($mode == 'search')
		{
			if (isset($HTTP_GET_VARS['search_word']) || isset($HTTP_POST_VARS['search_word']))
			{
				$search_word = (isset($HTTP_GET_VARS['search_word'])) ? $HTTP_GET_VARS['search_word'] : $HTTP_POST_VARS['search_word'];
			}
			$search_word	= (isset($search_word)) ? strtolower(htmlspecialchars($search_word)) : $lang['None'];
			$sql = "SELECT * from " . iNA_GAMES . "
				WHERE game_desc LIKE '%$search_word%'";
			if( $userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD)
			{
				$sql .= " AND game_avail = 1";
			}
		}
//
//	User Favourites Mode
//
		else if ($mode == 'fav')
		{
			if ($game_id)
			{
				if (isset($HTTP_GET_VARS['quiet']) || isset($HTTP_POST_VARS['quiet']))
				{
					$gen_simple_header	= TRUE; 
				}
				$sql = "SELECT * FROM " . iNA_FAV . "
					WHERE user_id = '" . $user_id . "'
						AND game_id = '" . $game_id . "'";
				if(!$result = $db->sql_query($sql)) 
				{
					message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql);
				}
				$row_count = $db->sql_numrows($result);
				if($row_count == 0)
				{
					$sql = "INSERT INTO " . iNA_FAV . " (user_id, game_id)
						VALUES ('$user_id', '$game_id')";
					if ( !$db->sql_query($sql) )
					{
						message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql);
					}
				}
				else if($gen_simple_header != TRUE)
				{
					$message = $lang['already_fav'];
					$message .= '<a href="' . append_sid("$filename?mode=stats&cat_id=$cat_id&id=$game_id") . '">Return</a>';
					message_die(GENERAL_MESSAGE, $message);
				}
			}
			if ($gen_simple_header == TRUE)
			{
				$message = '<a href="javascript:parent.window.close();">' . $lang['game_score_close'] . '</a>';
				message_die(GENERAL_MESSAGE, $message);
			}
			$sql = "SELECT * FROM " . iNA_FAV . " f, " . iNA_GAMES . " g
				WHERE f.user_id = '" . $user_id . "'
					AND f.game_id = g.game_id
					ORDER BY g.$order_by $sort_order";
					
			$sort_mode_link_info = append_sid("$filename?mode=fav&");

		}
		else
		{
//
// Taken a leap of faith here, I hope you don't have any 'Anonymous' ADMIN users :)
//
			$sql = "SELECT * FROM " . iNA_GAMES;
			if($cat_id > 0)
			{
				$sql .= " WHERE cat_id = '$cat_id'";
				if( $userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD )
				{
					$sql .= " AND game_avail = 1";
				}
			}
			else if( $userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD )
			{
				$sql .= " WHERE game_avail = 1";
			}
		}
		if ($mode != 'fav')
		{
			if ( $user_id == ANONYMOUS || $GUEST_ONLY == TRUE)
			{
				$sql .= " AND allow_guest = 1 AND game_charge = 0";
			}
			$sql .= " ORDER BY $order_by $sort_order";
		}
		if($board_config['games_per_page'] > 0)
		{
			$sql .= " LIMIT $start," . $board_config['games_per_page'];
		}
		if( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $listsql);
		}
		$game_count = $db->sql_numrows($result);
		$game_rows = $db->sql_fetchrowset($result);

		for($i = 0; $i < $game_count; $i++)
		{
			$game_id = $game_rows[$i]['game_id'];
			if($mode == 'fav')
			{
				$stats_img = 'images/icon_delete.gif';
				$stats_link = append_sid("$filename?mode=fav_del&id=$game_id&cat_id=$cat_id&start=$start&order=$sort_order&sort_mode=$sort_mode");	
			}
			else
			{
				$stats_img = 'templates/subSilver/images/game_info.gif';
				$stats_link = append_sid("$filename?mode=stats&id=$game_id&cat_id=$cat_id&start=$start&order=$sort_order&sort_mode=$sort_mode");
			}
			$game_name = $game_rows[$i]['game_name'];
			$game_path = $game_rows[$i]['game_path'];
			$image_path = $game_rows[$i]['image_path'];
			if ( $image_path == "")
			{
				if( file_exists("./". $game_path ."/". $game_name .".gif") )
				{
					$image_path = './' . $game_path . '/' . $game_name . '.gif';
				}
				else
				{
					$image_path = './' . $board_config['games_default_img'];
				}
			}
			else if ( strlen( $image_path ) < 5 )
			{
				$image_path = './' . $game_path . '/' . $game_name . $game_rows[$i]['image_path'];
			}
			if($board_config['use_rewards_mod'])
			{
				if($game_rows[$i]['game_charge'])
				{
					$game_charge = $game_rows[$i]['game_charge'];
				}
				else
				{
					$game_charge = $lang['game_free']; 
				}
			}
			else
			{
				$game_charge = $start+$i+1;
			}
			$game_desc = $game_rows[$i]['game_desc'];
			if ( $game_rows[$i]['game_avail'] == 0 )
			{
				$game_desc .= " (**********OFFLINE**********)";
			}
			$extension = get_ina_extension($game_name);
			if ( ($game_rows[$i]['game_flash'] || $extension == 'swf' || $extension == 'gif' || $extension == 'jpg' || $extension == 'png' ) && $board_config['games_auto_size'] && !$game_rows[$i]['game_autosize'])
			{
				$check_name = $game_path . $game_name;
				if($game_rows[$i]['game_flash'])
				{
					$check_name .= '.swf'; 
				}
				$game_size = getimagesize($check_name); 
				$win_width = $game_size[0] + 20; 
				$win_height = $game_size[1] + 25; 
			}
			else
			{
				$win_width = $game_rows[$i]['win_width'] + 20;
				$win_height = $game_rows[$i]['win_height'] + 25;
			}
			if ($game_rows[$i]['reverse_list'])
			{
				$list_type = 'ASC';
			}
			else
			{
				$list_type = 'DESC';
			}
			if ($game_rows[$i]['game_show_score'] == '1')
			{
				$bonus_info = $game_rows[$i]['game_bonus'] ? $bonus_info = $game_rows[$i]['game_bonus'] : '';
				$score_info = best_game_player(iNA_SCORES, $game_name, $list_type);
				$best_score = $score_info['score'] ? doubleval($score_info['score']) : '';
				$best_player_id = $score_info['player_id'];
				$best_player = $score_info['username'] ? $score_info['username'] : '';
				if($best_player != '')
				{
					if($best_player != 'Anonymous')
					{
						if($score_info['user_allow_viewonline'] || $userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD)
						{
							$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$best_player_id");
							$profile = '<a href="' . $temp_url . '"><span class="gentbl">' . $score_info['username'] . '</span></a>';
							$best_player = $profile;
						}
						else
						{
							$best_player = $lang['game_hidden'];
						}
					}
					else
					{
						$best_player = $lang['Guest'];
					}
					$highscore_link = "<a href=\"" . append_sid("$filename?mode=highscore&id=$game_id&cat_id=$cat_id&start=$start&order=$sort_order&sort_mode=$sort_mode") . "\"> " . $lang['game_highscores'] . "</a>";
				}
				else
				{
					$highscore_link = '';
				}
				if($board_config['games_at_highscore'])
				{
					$at_score_info = best_game_player(iNA_AT_SCORES, $game_name, $list_type);
					$best_at_score = $at_score_info['score'] ? '<br /><br />'.doubleval($at_score_info['score']) : '';
					$best_at_player_id = $at_score_info['player_id'];
					$best_at_player = $at_score_info['username'] ? $at_score_info['username'] : '';
					if ($best_at_player != '')
					{
						if($at_score_info['user_allow_viewonline'] || $userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD)
						{
							$best_at_player = $at_score_info['username'];
							$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$best_at_player_id");
							$profile = '<a href="' . $temp_url . '"><span class="gentbl">' . $best_at_player . '</span></a>';
							$best_at_player = '<br /><br />'.$profile;
						}
						else
						{
							$best_at_player = '<br /><br />'.$lang['game_hidden'];
						}
						if($best_player != '')
						{
							$at_highscore_link = " <br />-:-<br /><a href=\"" . append_sid("$filename?mode=at_highscore&id=$game_id&cat_id=$cat_id&start=$start&order=$sort_order&sort_mode=$sort_mode") . "\">" . $lang['game_at_highscores'] . "</a>";
						}
						else
						{
							$at_highscore_link = " <br />   <br /><a href=\"" . append_sid("$filename?mode=at_highscore&id=$game_id&cat_id=$cat_id&start=$start&order=$sort_order&sort_mode=$sort_mode") . "\">" . $lang['game_at_highscores'] . "</a>";
						}
					}
					else 
					{
						$at_highscore_link = '';
					}
					$bonus_info = $game_rows[$i]['game_bonus'] ? $bonus_info = $game_rows[$i]['game_bonus'] : '';
					$bonus_info .= '<br /><br />';
					$bonus_info .= $game_rows[$i]['at_game_bonus'] ? $game_rows[$i]['at_game_bonus'] : '<br />';
				}
				$dash = $lang['game_dash'];
			}
			else
			{
				$highscore_link = 
				$at_highscore_link = 
				$best_score = 
				$best_at_score = 
				$best_player = 
				$best_at_player = '';
			}
			if ($board_config['games_show_played'])
			{
				$played = sprintf($lang['Played_Times'], $game_rows[$i]['played']);
			}

			$template->assign_block_vars("game", array(
				'ROW_CLASS' => ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'],

				'BEST_SCORE' => $best_score,
				'BEST_PLAYER' => $best_player,
				'BEST_AT_SCORE' => $best_at_score,
				'BEST_AT_PLAYER' => $best_at_player,
				'TOURNAMENT' => $tournament,

				'NAME' => $game_name,
				'PATH' => $game_path,
				'IMAGE' => $image_path,
				'IMAGE_WIDTH' => $board_config['games_image_width'],
				'IMAGE_HEIGHT' => $board_config['games_image_height'],
				'CHARGE' => $game_charge,
				'DESC' => smilies_pass($game_desc),
				'INST' => $game_rows[$i]['instructions'],
				'PLAYED' => $played,
				'WIDTH' => $win_width,
				'HEIGHT' => $win_height,
				'LINK' => append_sid("$filename?mode=game&id=$game_id"),
				'STATS_IMAGE' => $stats_img,
				'STATS' => $stats_link,
				'ALT_STATS' => $lang['game_stats'],
				'DASH' => $dash,
				'BONUS' => $bonus_info,
				'LIST' => $highscore_link,
				'AT_LIST' => $at_highscore_link) );
		}
		
		$extra = 'cat_id = ' . $cat_id;
		if($cat_id <> 0)
		{
			$total_all_games = get_games_total('COUNT(*)',$extra);
			$total_games_played = get_games_total('SUM(played)',$extra);
		}
		else
		{
			$total_all_games = get_games_total('COUNT(*)','');
			$total_games_played = get_games_total('SUM(played)','');
		}
		
		if ($board_config['games_show_stats'])
		{
			$bottom_games_header = $lang['games_bum_header'];
			$top_games_list = games_list('DESC', $board_config['games_total_top'], $cat_id);
			if($cat_info['special_play'] && !$board_config['games_new_games'])
			{
				if(get_games_total('COUNT(*)',$extra) > $cat_info['special_play'])
				{
					$bottom_games_list = games_list('ASC',$board_config['games_total_top'],$cat_id);
				}
				else 
				{
					$bottom_games_list = $lang['no_special_play_games'];
				}
			}
			else if ($board_config['games_new_games'])
			{
				$bottom_games_list = games_list('DESC', $board_config['games_total_top'], $cat_id, 'date_added');
				$bottom_games_header = sprintf($lang['games_new_header'], $board_config['games_total_top']);
			}
			else 
			{
				$bottom_games_list = $lang['no_special_play_games'];
			}
		}
//
//	Get Pagination Total
//
		if($board_config['games_per_page'] > 0)
		{
			if ($mode == 'search')
			{
				$sql = "SELECT count(*) as total from " . iNA_GAMES . "
					WHERE game_desc LIKE '%$search_word%'
						AND game_id <> 0";
			}
			else if ($mode == 'fav')
			{
				$sql = "SELECT count(*) AS total FROM " . iNA_FAV . " f, " . iNA_GAMES . " g
					WHERE f.user_id = '" . $user_id . "'
						AND f.game_id = g.game_id";
			}
			else
			{
				$sql = "SELECT count(*) AS total FROM " . iNA_GAMES . "
					WHERE game_id <> 0";
			}
			if ($userdata['user_id'] == ANONYMOUS || $GUEST_ONLY == TRUE)
			{
				$sql .= " AND allow_guest = 1 AND game_charge = 0";
			}
			if($cat_id > 0)
			{
				$sql .= " AND cat_id = '$cat_id'";
			}
			if($userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD)
			{
				$sql .= " AND game_avail = 1";
			}
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, $lang['no_game_total'], '', __LINE__, __FILE__, $sql);
			}
			$total = $db->sql_fetchrow($result);
			if ( $total['total'] >= $board_config['games_per_page'] )
			{
				$total_games = $total['total'];
				$pagination = generate_pagination("$filename?mode=$mode&sort_mode=$sort_mode&order=$sort_order&cat_id=$cat_id", $total_games, $board_config['games_per_page'], $start). '&nbsp;';
				$page_number = sprintf($lang['Page_of'], ( floor( $start / $board_config['games_per_page'] ) + 1 ), ceil( $total_games / $board_config['games_per_page'] ));
			}
		}
		if ($board_config['points_name'])
		{
			$player_points = sprintf($lang['games_total_points'], $userdata[$board_config['default_reward_dbfield']], $board_config['points_name']);
		}
		else if ($board_config['default_reward_dbfield'])
		{
			$player_points = sprintf($lang['games_total_points'], $userdata[$board_config['default_reward_dbfield']], $lang['game_points']);
		}
		if((($mod_id && $mod_id == $user_id) || $userdata['user_level'] == ADMIN) && $board_config['games_moderators_mode'])
		{
			$moderate = '<a href="arcade_modcp.'.$phpEx.'?mode=mod&cat_id='.$cat_id.'"><img src="'.$images['moderate'].'" border="0" alt="'.$lang{'Rules_moderate2'}.'"></a> ';
		}
		if ($board_config['games_show_stats'])
		{
			$template->assign_block_vars('stats_menu', array());
		}
		$template->assign_vars(array(
			"GAMELIB_LINK" => $gamelib_link,
			"PAGINATION" => $pagination,
			"PAGE_NUMBER" => $page_number, 
			"TOP_HEADER" => sprintf($lang['games_top_header'], $board_config['games_total_top']),
			"BOTTOM_HEADER" => $bottom_games_header,
			"TOTAL_GAMES" => sprintf($lang['total_games'], $total_all_games),
			"TOTAL_GAMES_PLAYED" => sprintf($lang['total_games_played'], $total_games_played),
			"TOP_TEN_LIST" => smilies_pass($top_games_list),
			"BOTTOM_TEN_LIST" => smilies_pass($bottom_games_list),
			"PLAYER_POINTS" => $player_points,
			"LAST_PLAYED" => last_played($userdata['user_id']),

			"S_GAME_SELECT" => $select_game,
			"S_MODE_SELECT" => $select_sort_mode,
			"S_ORDER_SELECT" => $select_sort_order,
			"S_MODE_ACTION" => $sort_mode_link_info,
			"S_GAMES_REGISTER" => $lang['games_register'],
	
			"L_ACTIVE_TOURNAMENTS" => sprintf($lang['Active_Tournaments'], $total_tournaments),
			"L_GAMES" => $lang['game_list'],
			"L_TOURNAMENT" => $lang['game_tournament'],
			"L_SCORES" => $lang['game_score'],
			"L_SCORE_BONUS" => $lang['admin_bonus'],
			"L_INFO" => $lang['game_info'],
			"L_PLAYER" => $lang['game_best_player'],
			"L_ORDER" => $lang['Order'],
			"L_SORT" => $lang['Sort'],
			"L_SUBMIT" => $lang['Sort'],
			"L_GAME_SELECT" => $lang['Game_Select'],
			"L_SELECT_SORT_METHOD" => $lang['Select_sort_method'],
			"L_GOTO_PAGE" => $lang['Goto_page'],
			"L_WELCOME" => sprintf($lang['game_welcome'], $board_config['sitename']),
			"L_WELCOME_GUEST" => sprintf($lang['game_guest_welcome'], $board_config['sitename']),
			"L_GUEST_TXT" => $board_config['games_default_txt'],
			"ARCADE_MOD" => sprintf($lang['activitiy_mod_info'], get_ina_version()),
			
			"MODERATE" => $moderate,
			"U_CAT" => $url) );
	}	
}

//
//	OK, so if mode is not set, then show the standard catagory page :)
//
else
{
	$template->set_filenames(array('body' => 'arcade_cats.tpl') ); 

	if ($board_config['games_show_all'])
	{
		$template->assign_block_vars("all_games", array(
		));
	}

	$sql = "SELECT * FROM " . iNA_CAT . "
		ORDER by cat_id";
	if(!$result = $db->sql_query($sql))
		message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql);
	$i = 1;
	$url = ' -> <a href="' . $filename . '" class="nav">' . $lang['games_catagories'] . '</a>';
	if ($row = $db->sql_fetchrow($result)) 
	{ 
        do // Loop until we hit the end :) to output the page..
	    { 
			$icon = '';
			if($row['cat_icon'])
			{
				if($board_config['games_cat_image_width'])
				{
					$icon = "<img src=\"" . $row['cat_icon'] . "\" width=\"" . $board_config['games_cat_image_width'] . "\" height=\"" . $board_config['games_cat_image_height'] . "\" border=\"0\">";
				}
				else
				{
					$icon = "<img src=\"" . $row['cat_icon'] . "\" border=\"0\">";
				}
			}
			$extra = "cat_id = '" . $row['cat_id'] . "'";
			$moderator = '';
			$moderators = '';
			if($row['mod_id'])
			{
				$sql = "SELECT username FROM " . USERS_TABLE . "
					WHERE user_id = '" . $row['mod_id'] . "'";
				if(!$user = $db->sql_query($sql))
				{
					message_die(GENERAL_ERROR, $lang['no_user_data'], "", __LINE__, __FILE__, $sql); 
				}
				$mod_row = $db->sql_fetchrow($user);
				$moderator = '<br /><b>'.$lang['Moderator'].':</b>';
				$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=". $row['mod_id'] . "");
				$profile = ' <a href="' . $temp_url . '"><span class="gentbl">' . $mod_row['username'] . '</span></a>';
				$moderators = $profile;
			}
			$last_played = '';
			if($row['last_player'])
			{
				if($row['last_player'] != ANONYMOUS)
				{
					$sql = "SELECT username, user_allow_viewonline FROM " . USERS_TABLE . "
						WHERE user_id = '" . $row['last_player'] . "'";
					if(!$user = $db->sql_query($sql)) 
					{
						message_die(GENERAL_ERROR, $lang['no_user_data'], "", __LINE__, __FILE__, $sql); 
					}
					$last_row = $db->sql_fetchrow($user);
					$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=". $row['last_player'] . "");
					if($last_row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD)
					{
						$profile = '<a href="' . $temp_url . '"><span class="gentbl">' . $last_row['username'] . '</span></a>';
					}
					else
					{
						$profile = $lang['game_hidden'];
					}
				}
				else
				{
					$profile = $lang['Guest'];
				}
				if($row['last_game'])
				{
					$last_played = '<a href="' . $filename . '?mode=cat&cat_id=' . $row['cat_id'] . '">' . $row['last_game'];
				}
				if(strlen($row['last_game']) > 24)
				{
					$last_played .=	'..';
				}
				$last_played .= '</a><br />' . create_date($board_config['default_dateformat'], $row['last_time'], $board_config['board_timezone']);
				$last_played .= '<br />' . $profile;
			}
			
			$template->assign_block_vars("cats", array(
				'ROW_CLASS' => ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'], 
           		'CAT_ID' => $row['cat_id'], 

				'TOTAL_GAMES' => get_games_total('COUNT(*)',$extra),
				'TOTAL_PLAYED' => get_games_total('SUM(played)',$extra),
				'LAST_PLAYED' => $last_played,

		 		'MODERATOR' => $moderator,
 
		 		'L_MODERATORS' => $moderators,
 
             	'ICON' => $icon, 
               	'LINK' => append_sid("$filename?mode=cat&cat_id=".$row['cat_id']),
	           	'NAME' => $row['cat_name'],                                  
		       	'DESC' => smilies_pass($row['cat_desc'])) ); 
			$i++;
		} while ($row = $db->sql_fetchrow($result)); 
	}

	if($board_config['games_show_stats'])
	{
		$top_games_list = games_list('DESC', $board_config['games_total_top'], 0);
	
		if($board_config['games_new_games'])
		{
			$bottom_games_list = games_list('DESC', $board_config['games_total_top'], 0, 'date_added');
			$bottom_games_header = sprintf($lang['games_new_header'], $board_config['games_total_top']);
		}
		else
		{
			$bottom_games_list = games_list('ASC', $board_config['games_total_top'],0);
			$bottom_games_header = $lang['games_bum_header'];
		}
		
		$total_scores = total_highscores($user_id);
		if($userdata['user_id'] != ANONYMOUS || $GUEST_ONLY != TRUE)
		{
			$at_scores = total_highscores($user_id, iNA_AT_SCORES);
			$score_text = sprintf($lang['games_highscore'] . "<img src=\"images/trophy.gif\">" . $lang['highscore_you_have'] . "<b>%d</b> <a href=\"$filename?mode=game_stats&id=4\">1st" . $lang['places'] . "</a><br /><b>%d</b> <a href=\"$filename?mode=game_stats&id=5\">2nd" . $lang['places'] . "</a><br /><b>%d</b> <a href=\"$filename?mode=game_stats&id=6\">3rd" . $lang['places'] . "</a><br />", $total_scores[1] ,$total_scores[2] ,$total_scores[3] );
			$at_score_text = sprintf($lang['games_athighscore'] . "<img src=\"images/trophy.gif\">" . $lang['highscore_you_have'] . "<b>%d</b> <a href=\"$filename?mode=game_stats&id=1\">1st" . $lang['places'] . "</a><br /><b>%d</b> <a href=\"$filename?mode=game_stats&id=2\">2nd" . $lang['places'] . "</a><br /><b>%d</b> <a href=\"$filename?mode=game_stats&id=3\">3rd" . $lang['places'] . "</a><br />", $at_scores[1] ,$at_scores[2] ,$at_scores[3] );
		}
		else
		{
			$score_text = sprintf($lang['games_highscore'] . "<img src=\"images/trophy.gif\">" . $lang['highscore_you_have'] . "<b>%d</b> 1st" . $lang['places'] . "br /><b>%d</b> 2nd" . $lang['places'] . "<br /><b>%d</b> 3rd" . $lang['places'] . "<br />", $total_scores[1] ,$total_scores[2] ,$total_scores[3] );
		}
		
		$best_player = best_player();
		$best_at_player = best_player('at_first_places');
		
		$template->assign_block_vars('stats_menu', array(
			'L_INFO_STATS' => $lang['cat_info_stats'],
			'TOP_HEADER' => sprintf($lang['games_top_header'], $board_config['games_total_top']),
			'BOTTOM_HEADER' => $bottom_games_header,

			'BEST_PLAYER' => $best_player,
			'BEST_AT_PLAYER' => $best_at_player,
			'LEADER' => $score_text, 
			'AT_LEADER' => $at_score_text, 

			'TOP_TEN_LIST' => smilies_pass($top_games_list),
			'BOTTOM_TEN_LIST' => smilies_pass($bottom_games_list)
		));
	}

	if ($board_config['games_tournament_mode'])
	{
		$template->assign_block_vars('tournament_menu', array());
		$total_tournaments = get_total_tour();
	}

	$template->assign_vars(array(
		'L_WELCOME' => sprintf($lang['game_welcome'], $board_config['sitename']),
		'L_WELCOME_GUEST' => sprintf($lang['game_guest_welcome'], $board_config['sitename']),
		'ARCADE_MOD' => sprintf($lang['activitiy_mod_info'], get_ina_version()),

		'U_LIST_FAV' =>  append_sid("$filename?mode=fav"),
		'ACTIVE_TOURNAMENTS' => sprintf($lang['Active_Tournaments'], $total_tournaments),
		'LAST_PLAYED' => last_played($userdata['user_id']),

		'LINK' => append_sid("$filename?mode=cat&cat_id=0"),
		'DESC' => $board_config['games_cat_zero'],
		'TOTAL_GAMES' => get_games_total('COUNT(*)'),
		'TOTAL_PLAYED' => get_games_total('SUM(played)'),
		'ICON' => '<img src="images/games.gif" border="0">',

		'L_SEARCH' => $lang['Search'],
		'L_SUBMIT' => $lang['Submit'],
		'L_LIST_FAV' => $lang['favorites'],
		'L_ACTIVE_TOURNAMENTS' => game_list_tour(),
		'L_CAT_ID' => "#",
		'L_CATS' => $lang['games_section'],
		'L_TOTAL_GAMES' => $lang['cat_total_games'],
		'L_TOTAL_PLAYED' => $lang['cat_total_played'],
		'L_LAST_PLAYED' => $lang['cat_last_played'],
		
		'U_CAT' => $url,
		'ARCADE_MOD' => sprintf($lang['activitiy_mod_info'], get_ina_version())));
}

$page_meta_desc = $page_title;

// Generate page
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
functions_arcade.php:

Code: Select all

<?php
/***************************************************************************
 *                           functions_arcade.php
 *                           --------------------
 *   begin                : Friday, Dec 3, 2004
 *   copyright            : (C) 2004 free-game.co.uk
 *   email                : [email protected]
 *
 *   $Id: functions_arcade.php, v0.8.0 2004/12/03 20:46:00 dEfEndEr Exp $
 *
 ***************************************************************************
 *
 *   These functions are apart of a free software package; you can redistribute
 *   them and/or modify them under the terms of the GNU General Public License as
 *   published by the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************
 * 	CREDITS: 
 *  Whoo - Games and part code - 'http://www.amodgames.com/'
 *  Napoleon - Original Activity Mod v2.0.0
 *  Minesh - Add-On's
 *  ~Maverick~ - Add-On's
 *  Zorial - Add-On's
 *  qx17417 - beta testing
 *  Madman - Chief Tester :)
 ***************************************************************************/

if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
}

if ( defined('ARCADE_INCLUDE') )
{
	return;
}

define('ARCADE_INCLUDE',TRUE);

include_once($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_arcade.' . $phpEx);

function best_player($type = 'first_places')
{	global $db, $lang;
	$sql = "SELECT u.user_id, u.username, a.$type FROM " . USERS_TABLE . " as u, " . iNA_USER_DATA . " as a
		WHERE u.user_id = a.user_id
		ORDER by $type DESC, last_won_date LIMIT 0,1";
	if(!$user = $db->sql_query($sql)) 
	{
		message_die(GENERAL_ERROR, $lang['no_user_data'], "", __LINE__, __FILE__, $sql); 
	}
	$user_row = $db->sql_fetchrow($user);
	if ($user_row[$type] > 0)
	{
		return sprintf($lang['games_best_player'] , $user_row['user_id'], $user_row['username'], $user_row[$type]);
	}
	else
	{
		return NULL;
	}
}

function last_played($user_id)
{	global $db, $lang;
	$sql = "SELECT g.game_desc FROM " . iNA_USER_DATA . " as u, " . iNA_GAMES . " as g
		WHERE user_id = '" . $user_id . "'
		AND g.game_name = u.last_played";
	if(!$user = $db->sql_query($sql)) 
	{
		message_die(GENERAL_ERROR, $lang['no_user_data'], "", __LINE__, __FILE__, $sql); 
	}
	$user_row = $db->sql_fetchrow($user);
	if ($user_row)
	{
		return sprintf($lang['games_last_u_viewed'], $user_row['game_desc']);
	}
	else
	{
		return NULL;
	}
}

function games_position($games_place)
{	global $games_position_text;
	$place_text = '';

	if($games_place > 3)
	{
		if($games_place < 21)
		{
			$place_text = $games_place . $games_position_text[4];
		}
		else
		{
			$place_text = $games_position_text[0];
			
		}
	}
	else
	{
		$place_text = $games_place . $games_position_text[$games_place];
	}
	
	return $place_text;
}

function get_ina_version()
{	global $db;
	$sql = "SELECT version FROM " . iNA;
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, $lang['no_main_data'], "", __LINE__, __FILE__, $sql);
	}
	$ina_info = $db->sql_fetchrow($result);
	return $ina_info['version'];
}

function update_ina_session($user_id, $user_ip, $page, $game, $old_hash = FALSE)
{	global $db;

	$start_time		= time();
	$string			= sprintf("ARCADE_MOD %s %s %d %d %d", $game, $board_config['sitename'], $page, $user_id, $user_ip);
	$arcade_hash	= md5($string);
	//
	// The next two lines are used only for the human readable part of the MCP and can be commented out if they cause problems
	// (some sites have been set-up on a private network and do not use TCP/IP)
	//
	$ip_num			= (getenv('HTTP_X_FORWARDED_FOR')) ? getenv('HTTP_X_FORWARDED_FOR') : getenv('REMOTE_ADDR'); 
	$ip_nam			= gethostbyaddr($ip_num); 
	
	$sql = "UPDATE " . iNA_SESSIONS . "
		SET start_time = '$start_time', page = '$page', game_name = '$game', arcade_hash = '$arcade_hash'";
	if($old_hash != FALSE)
	{
		$sql .= " WHERE arcade_hash = '$old_hash'";
	}
	else
	{
		$sql .= " WHERE user_id = '$user_id'";
		if($user_id == ANONYMOUS)
		{
			$sql .= " AND session_ip = '$user_ip'";
		}
	}
	if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
	{
		$sql = "INSERT INTO " . iNA_SESSIONS . "
			(game_name, arcade_hash, user_id, start_time, session_ip, page, user_ip, ip_name)
			VALUES ('$game', '$arcade_hash', '$user_id', '$start_time', '$user_ip', '$page', '$ip_num', '$ip_nam')";
		if ( !$db->sql_query($sql) )
		{
			message_die(CRITICAL_ERROR, $lang['session_error'], '', __LINE__, __FILE__, $sql);
		}
	}
	return $arcade_hash;
}

function user_fav_list($user_id, $number)
{	global $db;

	$sql = "SELECT g.game_desc FROM " . iNA_FAV . " f, " . iNA_GAMES . " g
		WHERE f.user_id = '" . $user_id . "'
			AND f.game_id = g.game_id
			ORDER BY g.desc ASC
			LIMIT 0,$number";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['no_game_data'], '', __LINE__, __FILE__, $sql);
	}
	while($fav_games = $db->sql_fetchrow($result))
	{
		$fav_list .= $fav_games['game_desc'] . '<br />';
	}
	return $fav_list;
}

function games_list($mode, $number, $cat_id, $option = 'played', $image_path = FALSE)
{	global $db, $phpEx, $SID, $userdata, $board_config;
	
	$sql = "SELECT * FROM " . iNA_GAMES . "
		WHERE game_id <> 0
		AND game_avail = 1";
		if($cat_id > 0)
		{
			$sql .= " AND cat_id = '$cat_id'";
		}
		$sql .= " ORDER BY $option $mode
		LIMIT 0,$number";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['no_game_data'], '', __LINE__, __FILE__, $sql);
	}
	while($top_games = $db->sql_fetchrow($result))
	{
		if($top_games['game_flash'] && $board_config['games_auto_size'] && !$top_games['game_autosize'])
		{
			$game_name = $top_games['game_name'] . '.swf';
			$game_size = getimagesize($top_games['game_path'].$game_name); 
			$width = $game_size[0] + 20; 
			$height = $game_size[1] + 25; 
		}
		else
		{
			$width = $top_games['win_width'] + 20;
			$height = $top_games['win_height'] + 25; 
		}
		if ( ($userdata['user_id'] == ANONYMOUS && $top_games['allow_guest'] == 0) || ( intval($userdata['user_posts']) < intval($board_config['games_posts_required']) && $top_games['allow_guest'] == 0) || (intval($userdata['user_rank']) < intval($board_config['games_rank_required']) && $top_games['allow_guest'] == 0) && $userdata['user_level'] != ADMIN )
		{
			$games_list .= $top_games['game_desc'] . '<br />';
		}
		else 
		{
			if($image_path != FALSE)
			{
				$image_path = $top_games['image_path'];
				if ( $image_path == '' )
				{
					if( file_exists("./". $top_games['game_path'] ."/". $top_games['game_name'] .".gif") )
					{
						$image_path = './' . $top_games['game_path'] . $top_games['game_name'] . '.gif';
					}
					else
					{
						$image_path = $board_config['games_default_img'];
					}
				}
				else if ( strlen( $image_path ) < 5 )
				{
					$image_path = './' . $top_games['game_path'] . $top_games['game_name'] . $top_games['image_path'];
				}
				if (file_exists($image_path ))
				{
					$games_list .= "<a href=\"javascript:Gk_PopTart('activity.$phpEx?mode=game&id=" . $top_games['game_id'] . "$SID', 'New_Window', '$width', '$height', 'no')\" onClick=\"blur()\"><img src=\"". $image_path ."\" height=\"25\" width=\"25\">" . $top_games['game_desc'] . "</a><br />";
				}
				else
				{
					$games_list .= "<a href=\"javascript:Gk_PopTart('activity.$phpEx?mode=game&id=" . $top_games['game_id'] . "$SID', 'New_Window', '$width', '$height', 'no')\" onClick=\"blur()\">" . $top_games['game_desc'] . "</a><br />";
				}
			}
			else
			{
				$games_list .= "<a href=\"javascript:Gk_PopTart('activity.$phpEx?mode=game&id=" . $top_games['game_id'] . "$SID', 'New_Window', '$width', '$height', 'no')\" onClick=\"blur()\">" . $top_games['game_desc'] . "</a><br />";
			}
		}
	}
	return $games_list;
}

function best_game_player($tablename, $gamename, $type)
{	global $db;

	$sql = "SELECT s.player_id, s.score, u.username, u.user_allow_viewonline FROM " . $tablename . " s, " . USERS_TABLE . " u
		WHERE s.player_id = u.user_id
		AND game_name = '" . $gamename . "'
		ORDER BY score $type, date ASC";
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql);
	}
	$score_info = $db->sql_fetchrow($result);
	if ($score_info['score'] > 0)
	{
		return $score_info;
	}
	else
	{
		return NULL;
	}
}

function get_games_total($data, $extra = '')
{	global $db;

	$sql = "SELECT $data AS total
		FROM " . iNA_GAMES . "
		WHERE game_id <> 0
		AND game_avail = 1";
	if($extra)
	{
		$sql .= " AND $extra";
	}
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['no_game_total'], '', __LINE__, __FILE__, $sql);
	}
	$total = $db->sql_fetchrow($result);

	return $total['total'];
}

function total_highscores($player_id, $table = iNA_SCORES)
{	global $db;

	$player[0] = $player_id;
	$player[1] = $player[2] = $player[3] = 0;
	$player[4] = $player[5] = $player[6] = '';

	$sql = "SELECT g.game_name, s.player_id, s.score FROM  " . iNA_GAMES . " g,  " . $table . " s
		WHERE g.game_name = s.game_name
			AND g.game_avail = 1
			AND g.game_show_score = 1
			AND g.reverse_list = 0
		ORDER BY g.game_name, s.score DESC"; 
	if ( !($best_result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['no_game_total'], '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($best_result);
	do
	{
		if($row['game_name'] != $last_game)
		{
			$row_count=1;
		}
		if($row['player_id'] == $player_id)
		{
			if($row_count == 1)
			{
				$player[1]++;
				$player[4] .= $row['game_name'].'|';
			}
			else if($row_count == 2)
			{
				$player[2]++;
				$player[5] .= $row['game_name'].'|';
			}
			else if($row_count == 3)
			{
				$player[3]++;
				$player[6] .= $row['game_name'].'|';
			}
		}
		$row_count++;
		$last_game = $row['game_name'];
	} while ($row = $db->sql_fetchrow($best_result));

	$sql = "SELECT g.game_name, s.player_id, s.score FROM  " . iNA_GAMES . " g,  " . $table . " s
		WHERE g.game_name = s.game_name
			AND g.game_avail = 1
			AND g.game_show_score = 1
			AND g.reverse_list = 1
		ORDER  BY g.game_name, s.score ASC"; 
	if ( !($best_result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['no_game_total'], '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($best_result);
	do
	{
		if($row['game_name'] != $last_game)
		{
			$row_count=1;
		}
		if($row['player_id'] == $player_id)
		{
			if($row_count == 1)
			{
				$player[1]++;
				$player[4] .= $row['game_name'].'|';
			}
			else if($row_count == 2)
			{
				$player[2]++;
				$player[5] .= $row['game_name'].'|';
			}
			else if($row_count == 3)
			{
				$player[3]++;
				$player[6] .= $row['game_name'].'|';
			}
		}
		$row_count++;
		$last_game = $row['game_name'];
	} while ($row = $db->sql_fetchrow($best_result));
	return $player;
}

function get_ina_extension($name)
{
	$extension		= strrchr(strtolower($name), '.');
	$extension[0]	= ' ';
	$extension		= strtolower(trim($extension));
	
	return $extension;
}

function ina_ban_user($game, $users_ip, $user_id, $username, $score)
{	global $db,$board_config;

	$currdate = create_date('d-m-Y', time(), $board_config['board_timezone']) ;

	$sql = "INSERT INTO ". iNA_BANNED . " (username, user_id, player_ip, game, score, date)
		VALUES ('$username', '$user_id', '$users_ip', '$game', '$score', '$currdate')";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['no_game_total'], '', __LINE__, __FILE__, $sql);
	}
}

function check_ina_user($users_ip, $user_id, $username)
{	global $db;

	$sql = "SELECT* FROM ". iNA_BANNED . "
		WHERE $user_id = '$user_id'";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['no_game_total'], '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	if($row)
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

function check_ina_game($game_name)
{	global $db;

	if($game_name)
	{
		$old_game_sql = "SELECT * FROM " . iNA_GAMES . "
			WHERE game_name = '" . $game_name . "'";
		if( !$old_game_result = $db->sql_query($old_game_sql) )
		{
			message_die(GENERAL_ERROR, $lang['no_read_game_data'], "", __LINE__, __FILE__, $sql);
		}
		$old_game = $db->sql_fetchrow($old_game_result);

		if( $old_game['game_name'] == $game_name )
		{
			return TRUE;
		}
	}
	return FALSE;
}

function insert_ina_game($game_name, $game_path, $reverse_list = 0, $game_desc = '', $game_flash = 1, $game_avail = 0, $win_width = 0, $win_height = 0)
{	global $db, $phpbb_root_path;

	if($win_width ==0 && $game_flash == 1)
	{
		$game_size = getimagesize($phpbb_root_path.$game_path.'/'.$game_name.'.swf'); 
		$win_width = $game_size[0];
		$win_height = $game_size[1];
	}
	if($game_desc == '')
	{
		$game_desc = trim(str_replace("_", " ", $game_name));
		$game_desc[0] = strtoupper($game_desc[0]);
	}
	$inst_sql = "INSERT INTO " . iNA_GAMES . "
		(date_added, game_name, game_path, game_desc, win_width, win_height, reverse_list , game_flash, game_avail)
			VALUES ('" . (time()) . "', '$game_name', '$game_path', '$game_desc', '$win_width', '$win_height', '$rev', $game_flash, $game_avail)";
	if( !$inst_result = $db->sql_query($inst_sql) )
	{
		message_die(GENERAL_ERROR, $lang['no_read_game_data'], "", __LINE__, __FILE__, $inst_sql);
	}
}

function get_total_tour()
{	global $db;

	$sql = "SELECT count(*) as total FROM " . iNA_TOUR;
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	$total_tournaments = $row['total'];

	return $total_tournaments;
}

function game_list_tour()
{	global $db, $SID, $phpEx;

	$tour_list = '';

	$sql = "SELECT tour_id, tour_name FROM " . iNA_TOUR;
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	$tour_list .= "<br /><a href=\"activity.".$phpEx."?mode=tour&id=" . $row['tour_id'] . "$SID\">" . $row['tour_name'] . "</a>";

	return $tour_list;
}

//
// Code from ADR
//
function ina_send_user_pm($dest_user, $subject, $message, $from_id = FALSE)
{
	global $db, $phpbb_root_path, $phpEx, $lang, $user_ip, $board_config, $userdata;

	$dest_user 	= intval($dest_user);
	$msg_time 	= time();
	if($from_id == FALSE)
	{
		$from_id 	= $userdata['user_id'];
	}
	
	if($dest_user != $from_id)
	{
		$html_on 	= 1;
		$bbcode_on 	= 1;
	    $smilies_on = 1;

		include_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
		include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
   
		$privmsg_subject 	= trim(strip_tags($subject));
		$bbcode_uid 		= make_bbcode_uid();
		$privmsg_message 	= trim(strip_tags($message));

// APM compliance
		if ( defined('PRIVMSGA_TABLE'))
		{
			include_once($phpbb_root_path . 'includes/functions_messages.'.$phpEx);
			send_pm( 0 , '' , $dest_user , $privmsg_subject, $privmsg_message, '' );
		}
		else
		{
			$sql = "SELECT user_id, user_notify_pm, user_email, user_lang, user_active
			 	FROM ". USERS_TABLE ."
			 	WHERE user_id = '". $dest_user ."'";
			if (!($result = $db->sql_query($sql)))
			{
				$error = TRUE;
				$error_msg = $lang['No_such_user'];
			}
			$to_userdata = $db->sql_fetchrow($result);

			$sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time
				FROM ". PRIVMSGS_TABLE ."
				WHERE ( privmsgs_type = ". PRIVMSGS_NEW_MAIL ."
			  	OR privmsgs_type = ". PRIVMSGS_READ_MAIL ." 
				OR privmsgs_type = ". PRIVMSGS_UNREAD_MAIL ." )
				AND privmsgs_to_userid = '". $dest_user ."'";
			if (!($result = $db->sql_query($sql)))
			{
				message_die(GENERAL_MESSAGE, $lang['No_such_user']);
			}

			$sql_priority = (SQL_LAYER == 'mysql') ? 'LOW_PRIORITY' : '';

			if($inbox_info = $db->sql_fetchrow($result))
			{
				if ($inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'])
				{
					$sql = "SELECT privmsgs_id 
						FROM ". PRIVMSGS_TABLE ."
						WHERE ( privmsgs_type = ". PRIVMSGS_NEW_MAIL ."
						OR privmsgs_type = ". PRIVMSGS_READ_MAIL ."
						OR privmsgs_type = ". PRIVMSGS_UNREAD_MAIL ."  )
						AND privmsgs_date = ". $inbox_info['oldest_post_time'] . "
						AND privmsgs_to_userid = '". $dest_user ."'";
					if (!$result = $db->sql_query($sql))
					{	
						message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql);
					}
					$old_privmsgs_id = $db->sql_fetchrow($result);
					$old_privmsgs_id = $old_privmsgs_id['privmsgs_id'];
           
					$sql = "DELETE $sql_priority 
						FROM ". PRIVMSGS_TABLE ."
						WHERE privmsgs_id = '". $old_privmsgs_id ."'";
					if(!$db->sql_query($sql))
					{
						message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)'.$sql, '', __LINE__, __FILE__, $sql);
					}

					$sql = "DELETE $sql_priority 
						FROM " . PRIVMSGS_TEXT_TABLE . "
						WHERE privmsgs_text_id = '". $old_privmsgs_id ."'";
					if (!$db->sql_query($sql))
					{
						message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql);
					}
				}
			}

			$sql_info = "INSERT INTO ". PRIVMSGS_TABLE ." 
					(privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies)
					VALUES ( 1 , '". str_replace("\'", "''", addslashes($privmsg_subject)) ."' , ". $from_id .", ". $to_userdata['user_id'] .", $msg_time, '$user_ip' , $html_on, $bbcode_on, $smilies_on)";
			if(!$db->sql_query($sql_info))
			{
				message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql_info);
			}

			$privmsg_sent_id = $db->sql_nextid();

			$sql = "INSERT INTO ". PRIVMSGS_TEXT_TABLE ." (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
				VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace("\'", "''", addslashes($privmsg_message)) . "')"; 
			if (!$db->sql_query($sql, END_TRANSACTION))
			{
				message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql);
			}

			$sql = "UPDATE ". USERS_TABLE ."
				SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " 
				WHERE user_id = '". $to_userdata['user_id'] ."'";
			if(!$status = $db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
			}

			if($to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active'] )
			{
			// have the mail sender infos
				$script_name 		= preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
				$script_name 		= ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx;
				$server_name 		= trim($board_config['server_name']);
				$server_protocol 	= ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
				$server_port 		= ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

				include_once($phpbb_root_path . './includes/emailer.'.$phpEx);
				$emailer = new emailer($board_config['smtp_delivery']);
        
				if($board_config['version'] == '.0.5' || $board_config['version'] == '.0.6' || $board_config['version'] == '.0.7' || $board_config['version'] == '.0.8' || $board_config['version'] == '.0.9' )
				{   
					$emailer->from($board_config['board_email']);
					$emailer->replyto($board_config['board_email']);
					$emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
				}
				else
				{
					$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
					$emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
					$emailer->extra_headers($email_headers);
				}
				$emailer->email_address($to_userdata['user_email']);
				$emailer->set_subject($lang['Notification_subject']);

				$emailer->assign_vars(array(
					'USERNAME' => $to_username,
					'SITENAME' => $board_config['sitename'],
					'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
					'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')
					 );

				$emailer->send();
				$emailer->reset();
			}
		}
	}
	return;
}

//
// Simple code that makes sure a user does not get any more than one PM from each user every 24 hours.
//
function ina_check_last_pm($to_id, $from_id)
{	global $db;

	if($to_id == $from_id)
	{
		return TRUE;
	}
	$sql = "SELECT * FROM " . iNA_PMs_TABLE . "
		WHERE to_id = '" . $to_id . "'
			AND from_id = '" . $from_id . "'";
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, $lang['no_score_data'], "", __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	if($row['last_sent'] < (time() - 86400))
	{
		$sql = "UPDATE " . iNA_PMs_TABLE . "
			SET last_sent = '" . time() . "', total_sent = total_sent+1
				WHERE to_id = '" . $to_id . "'
			AND from_id = '" . $from_id . "'";
		if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
		{
			$sql = "INSERT INTO " . iNA_PMs_TABLE . "
				(to_id, from_id, last_sent, total_sent)
				VALUES ('$to_id', '$from_id', '". time() . "', 1)";
			if ( !$db->sql_query($sql) )
			{
				message_die(CRITICAL_ERROR, $lang['session_error'], '', __LINE__, __FILE__, $sql);
			}
		}
		return FALSE;
	
	}
	
	return TRUE;
}

?>
threeeyedtoad
Registered User
Posts: 23
Joined: Tue May 22, 2007 8:34 pm

Viewing the Scheduler using a date range?

Post by threeeyedtoad »

I've successfully installed TC on phpBB 2.0.22, and it seems to work perfectly. The only issue I have is with the Scheduler. While it appears to work as intended, it only shows events from a single day. I would like to allow the end-user to specify a range of dates while in the Scheduler, which would allow them to view a cumulative list of ALL the events taking place, say, during the month of June.

I've searched around this forum, but haven't found this question specifically asked, or answered. Even if it isn't possible to allow the end-user to specify a custom range, could I default the Scheduler to list all the Events coming up in the following 30 days, beginning with the date specified in the UI?

Any ideas? Many thanks!
mojavemark
Registered User
Posts: 42
Joined: Tue Jan 30, 2007 12:01 am
Name: Mark
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by mojavemark »

Heres my first problem-- When I click the link to go to the calendar, I get this error message
Could not obtain topics informations

DEBUG MODE

SQL Error : 1054 Unknown column 't.topic_calendar_time' in 'where clause'

SELECT t.* FROM phpbb_topics t WHERE t.topic_moved_id = 0 AND t.topic_calendar_time > 0 AND t.topic_calendar_time < 1217570400 AND (t.topic_calendar_time + t.topic_calendar_duration) >= 1214892000 AND t.forum_id IN(3, 20, 2, 19, 6, 4, 25, 5, 7, 24, 8, 21, 9, 10, 11, 13, 12, 14, 15, 16, 23, 17, 18) ORDER BY t.topic_calendar_time, t.topic_calendar_duration DESC

Line : 94
File : class_calendar_topics.php

I've check line 94 in class_calendar-topics.php, this didnt help me, I'm not good at understanding what the programing language means. Any insight will be helpful.

Second problem, not sure where to put the java code for the little links to make the calendar pop up and down at.
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by Ptirhiik »

> mojavemark: this means the install has not run on your setup. How do you installed the mod ?
mojavemark
Registered User
Posts: 42
Joined: Tue Jan 30, 2007 12:01 am
Name: Mark
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by mojavemark »

First I did try using the easy mod thing and got a bunch of errors and a crashed board. NO problem, I uploaded the backup pages. So I made a duplicate forum, hand coded the pages as I really shouda done to start with, uplaoded each page one at a time, took care of any errors or warnings that showed up until the only problem I have now is the data base error.

I think I see what I have failed to do. Am I supposed to run the install.php that came with the pakage down load by going to it with my web browser like when I installed the board to start with? I did try that, and got a permision warning. I will try it again to see what happens.

To make sure I got this right, any files not required to be in other directories to fix invalid path errors need to be in the root directory, such as the *.sql files, right.

Thanks for the quick response, Mark.
mojavemark
Registered User
Posts: 42
Joined: Tue Jan 30, 2007 12:01 am
Name: Mark
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by mojavemark »

I get this message when I try to run the install php.
Warning: main(./../common.php): failed to open stream: No such file or directory in /home/content/m/o/j/mojavemark/html/testforum/install.php on line 29

Warning: main(./../common.php): failed to open stream: No such file or directory in /home/content/m/o/j/mojavemark/html/testforum/install.php on line 29

Warning: main(): Failed opening './../common.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/m/o/j/mojavemark/html/testforum/install.php on line 29

Fatal error: Call to a member function on a non-object in /home/content/m/o/j/mojavemark/html/testforum/install.php on line 30
I'm sure I'm doing something wrong. Which page do I need to put the tags for the java script?
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by Ptirhiik »

> mojavemark: you are just supposed to copy the install_cal/ directory (directory included :)) into your board root. The install should start itself, redirecting you to http://your_board.url/install_cal/install.php
mojavemark
Registered User
Posts: 42
Joined: Tue Jan 30, 2007 12:01 am
Name: Mark
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by mojavemark »

OK, I'm a idiot! 1 little mistake at the beginning of installing this mod has caused me all the problems, and it is all on me. When I unzipped the files using winzip, instead of using the "extract option", I just highlighted the files and unzipped then into a folder. With out knowing the proper directory sturcture I keep getting all sorts of errors for missing files. And all this copy root to root stuff was a little confusing.
Then Ptirhiik left this message
Ptirhiik wrote:> mojavemark: you are just supposed to copy the install_cal/ directory (directory included :)) into your board root. The install should start itself, redirecting you to http://your_board.url/install_cal/install.php
Light bulb went on. Extracted the files from the zip file with the extract option to keep the file and directory structure, and 10 minutes later, all the files I needed where there and where I needed them to be.

This is a simple to install mod till I made it hard. :roll:
Thank you Ptirhiik for your help.
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Re: Topic Calendar (regular phpBB edition)

Post by Ptirhiik »

;)
Post Reply

Return to “[2.0.x] MOD Database Releases”