Tekrar merhabalar;

}
			
		$comments[] = array (
			'comment'	=>	utf8_encode(word_filter(bbcode(nl2br(nohtml($comments_row['comment']))))),
			'date'		=>	mod_date($comments_row['dateadded']),
			'user'		=>	$poster_username
		);
	}
Buda file.php nin tam dökümü:
<?php
/**
 * onArcade 2.0.0
 * Copyright © 2006-2007 Hans Mäesalu & Eveterm OÜ, All Rights Reserved
 **
 * ONARCADE IS NOT FREE SOFTWARE!
 * http://www.onarcade.com
 **/
 
session_start();

require ('includes/config.php');

require ('templates/'. $settings['template'] .'/file.template.php');

require ('languages/'. $settings['language'] .'/file.lang.php');

$file_id = $_GET['f'];

if (!is_numeric($file_id) && strlen($file_id)) {
	die('Bad hacker!!!');
}

switch ($_GET['a']) {
case 'rate':
	if ($settings['rate'] == '1' || $settings['rate'] == '2' && $user['status'] == '1') {
		$file_rating = $_GET['r'];
		if (strlen($file_rating) == 1 && is_numeric($file_rating) && $file_rating >= 1 && $file_rating <= 5) {
			$session_file = $_SESSION['rate_file'];
			// Let's try to stop people from voting more than once
			if ($session_file != $file_id) {
				// And let's rate
				$update_rating_query = mysql_query("UPDATE ". $tbl_prefix ."files SET totalvotes = totalvotes + 1, totalvotepoints = totalvotepoints + '". $file_rating ."', rating = totalvotepoints / totalvotes WHERE fileid = '". $file_id ."'");
				$_SESSION['rate_file'] = $file_id;
			}
		}
		// Get the new value of rating
		$file_rating_query = mysql_query("SELECT rating FROM ". $tbl_prefix ."files WHERE fileid = '". $file_id ."' && status = '1' LIMIT 1");
		$file_rating_row = mysql_fetch_assoc($file_rating_query);
				
		echo stars($file_rating_row['rating']);
	}
	break;
case 'report_broken':
	if ($settings['report_broken'] == '0' || empty($file_id)) {
		exit();
	}
	
	$report_comment = nohtml($_POST['comment']);
	if (strlen($report_comment) > '100') {
	    $report_comment = substr($report_comment , 0, 100);
    }
    
    // Use sessions make sure that report isn't submited more than once
    $session_file = $_SESSION['report_file'];
	if ($session_file != $file_id) {
		// Insert report to database
		$report_add_query = mysql_query("INSERT INTO ". $tbl_prefix ."report_broken SET file_id = '". $file_id ."', comment = '". $report_comment ."', ip = '". $user['ip'] ."', date_reported = '". time() ."'");
		$_SESSION['report_file'] = $file_id;
	}
    
	echo $lang['thanks_for_reporting'];
	break;
case 'tellafriend':
	if ($settings['tellfriend'] == '0') {
		die('Tell a friend offline!!!');
	}
	$file_query = mysql_query("SELECT title FROM ". $tbl_prefix ."files WHERE fileid = '". $file_id ."' LIMIT 1");
	
	if (mysql_num_rows($file_query) == 0) {
		$blank_page = array (
			'title'		=>	$settings['sitename'],
			'content'	=>	$lang['no_page_found']
		);
    			
    	$page_title = $lang['no_page_found'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	
	$file_row = mysql_fetch_assoc($file_query);

	$file = array (
		'id'	=>	$file_id,
		'title'	=>	$file_row['title']

	);
	
	// Send email to friend
	if (isset($_POST['submit'])) {
		$tf_yourname = $_POST['yourname'];
		$tf_youremail = $_POST['youremail'];
		$tf_friendemail = $_POST['friendemail'];
		$tf_verification_code = $_POST['verification_code'];
		// check image verification code
		if ($settings['image_verification'] == '1') {
			$verification_check_query = mysql_query("SELECT verification_code FROM ". $tbl_prefix ."online WHERE ip = '". $user['ip'] ."' && verification_code = '". $tf_verification_code ."'");
			$verification_rows_number = mysql_num_rows($verification_check_query);
		}
		
		if ($verification_rows_number == '0' && $settings['image_verification'] == '1' || empty($tf_verification_code) && $settings['image_verification'] == '1') {
			$file['error'] = $lang['invalid_verification_code'];
		} else {
			if (strlen($tf_yourname) && strlen($tf_youremail) && strlen($tf_friendemail)) {
				if (preg_match(' /[\r\n,;\'"]/ ', $tf_youremail) || preg_match(' /[\r\n,;\'"]/ ', $tf_friendemail)) {
					$file['error'] = $lang['invalid_email'];
        		} else {
        			$session_friend_email = $_SESSION['session_friend_email'];
        			if ($session_friend_email != $tf_friendemail) {
        				$email_header = 'Return-Path: '. $tf_youremail .'
From: '. $tf_yourname .' <'. $tf_youremail .'>
MIME-Version: 1.0
Content-type: text/plain';

       					// Lets send email to friend
						include ('languages/'. $settings['language'] .'/email.lang.php');
						@mail($tf_friendemail, $lang['check_out'], $lang['tell_a_friend_message'], $email_header);
						$_SESSION['session_friend_email'] = $tf_friendemail;
					}
				
					// Load template
					template_tellafriend2();
					exit();
        		}
			} else {
				$file['error'] = $lang['all_fields_required'];
			}
		}
	}

	$page_title = $lang['tell_a_friend'];
	
	// Load template
	template_tellafriend();
	break;
case 'comments':
	if ($settings['comments'] == '0') {
		exit();
	}
	
	// Comments page number
	$comments_page = $_GET['p'];
	if (empty($comments_page) || !is_numeric($comments_page) || $comments_page == 0) {
		$comments_page = 1;
	}
	$comments_number_query = mysql_query("SELECT count(fileid) FROM ". $tbl_prefix ."comments WHERE fileid = '". $file_id ."' && status = '1'");
	$comments_number_row = mysql_fetch_assoc($comments_number_query);
	$pages_count = ceil($comments_number_row['count(fileid)'] / $settings['max_comments']);
	$navigation = NULL;
	for ($pagen = 1; $pagen <= $pages_count; $pagen++) {
		if ($pagen == $comments_page) {
			$navigation .= ' <b>'. $pagen .'</b>';
        } else {
			$navigation .= ' <a href="" onclick="display_comments('. $file_id .', '. $pagen .'); return false;">'. $pagen .'</a>';

	    } 
    }
	
	$offset = ($comments_page - 1) * $settings['max_comments'];
	
	$comments_query = mysql_query("SELECT * FROM ". $tbl_prefix ."comments WHERE fileid = '". $file_id ."' && status = '1' ORDER BY commentid DESC LIMIT ". $offset .", ". $settings['max_comments']);
	
	while ($comments_row = mysql_fetch_assoc($comments_query)) {
		if ($comments_row['userid'] == '0' || empty($comments_row['username'])) {
			$poster_username = $lang['guest'];
		} else {
			$poster_username = '<a href="'. profileurl($comments_row['userid'], $comments_row['username']) .'">'. $comments_row['username'] .'</a>';
		}
			
		$comments[] = array (
			'comment'	=>	utf8_encode(word_filter(bbcode(nl2br(nohtml($comments_row['comment']))))),
			'date'		=>	mod_date($comments_row['dateadded']),
			'user'		=>	$poster_username
		);
	}
	
	// Load template
	template_display_comments();
	break;
case 'make_favourite':
	// Do nothing if user not logged in
	if ($user['status'] != '1') {
		exit();
	}
		
	$user_favourites = NULL;
	if (strlen($user_row['favourites'])) {
		$user_favourites = unserialize($user_row['favourites']);
		
		$user_favourites[$file_id] = $file_id;
		$update_favourite_query = mysql_query("UPDATE ". $tbl_prefix ."users SET favourites = '". serialize($user_favourites) ."' WHERE userid = '". $user['id'] ."'");
	} else {
		$user_favourites[$file_id] = $file_id;
		$update_favourite_query = mysql_query("UPDATE ". $tbl_prefix ."users SET favourites = '". serialize($user_favourites) ."' WHERE userid = '". $user['id'] ."'");
	}
	
	echo $lang['file_added_favourites'];
	break;
case 'remove_favourite':
	// Do nothing if user not logged in
	if ($user['status'] != '1') {
		exit();
	}
		
	$user_favourites = NULL;
	if (strlen($user_row['favourites'])) {
		$user_favourites = unserialize($user_row['favourites']);
		
		unset($user_favourites[$file_id]);
			
		$update_favourite_query = mysql_query("UPDATE ". $tbl_prefix ."users SET favourites = '". serialize($user_favourites) ."' WHERE userid = '". $user['id'] ."'");
	}
	
	echo $lang['file_removed_favourites'];
	break;
case 'popup':
	if ($user['plays_left'] <= 0 && $user['status'] == 0 && $settings['guestcredits'] == 1) {
		$blank_page = array (
			'title'		=>	$settings['sitename'],
			'content'	=>	$lang['you_no_more_plays_left']
		);
		
		$page_title = $lang['you_no_more_plays_left'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	$file_query = mysql_query("SELECT title, file, filelocation, category, filetype, width, height FROM ". $tbl_prefix ."files WHERE fileid = '". $file_id ."' && status = '1' LIMIT 1");
	
	$file_row = mysql_fetch_assoc($file_query);
	
	if (empty($file_row)) {
		$blank_page = array (
			'title'		=>	$settings['sitename'],
			'content'	=>	$lang['no_page_found']
		);
    			
    	$page_title = $lang['no_page_found'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	
	// Get category information
	$category_query = mysql_query("SELECT permissions, status FROM ". $tbl_prefix ."categories WHERE catid = '". $file_row['category'] ."' LIMIT 1");
	$category_row = mysql_fetch_assoc($category_query);
	if ($category_row['status'] == 0) {
		$blank_page = array (
			'title'		=>	$settings['sitename'],
			'content'	=>	$lang['no_page_found']
		);
    			
    	$page_title = $lang['no_page_found'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	if ($category_row['permissions'] == 2 && $user['status'] != '1') {
		$blank_page = array (
			'title'		=>	$lang['plese_log_in_title'],
			'content'	=>	$lang['plese_log_in']
		);
    			
    	$page_title = $lang['plese_log_in_title'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	// Direct URL to file
	if ($file_row['filelocation'] == '1') {
		$file_url = $settings['siteurl'] .'/files/'. $settings['filesdir'] .'/'. $file_row['file'];
    } else {
	    $file_url = $file_row['file'];
    }
    
    // Load player for file
    $play_file = file_get_contents('includes/file_type/'. $file_row['filetype'] .'.php');
    
    // Replace variables
    $play_file = str_replace('{$width}', $file_row['width'], $play_file);
    $play_file = str_replace('{$height}', $file_row['height'], $play_file);
    $play_file = str_replace('{$file_url}', $file_url, $play_file);
    $play_file = str_replace('{$siteurl}', $settings['siteurl'], $play_file);

	$file = array (
		'play_file'	=>	$play_file
	);

	$page_title = $file_row['title'];
	
	// Load template
	template_new_window();
	break;
case 'submit_comment':
	if ($user['plays_left'] <= 0 && $user['status'] == 0 && $settings['guestcredits'] == 1 || $settings['comments'] == '0') {
		exit();
	}
	$file_query = mysql_query("SELECT fileid FROM ". $tbl_prefix ."files WHERE fileid = '". $file_id ."' && status = '1' LIMIT 1");
	if (mysql_num_rows($file_query) == 0) {
		exit();
	}
	
	// Add comment
	if ($settings['comments_who'] == '1' || $settings['comments_who'] == '2' && $user['status'] == '1') {
		$comment_text = $_POST['message'];
		if (empty($comment_text)) {
			echo utf8_encode($lang['comment_empty']);
		} else {
			$banned_ips = explode(' ', $settings['comments_banned_ip']);
			if (in_array($user['ip'], $banned_ips)) {
					echo utf8_encode($lang['ip_has_been_banned']);
			} else {
				$last_comment_sql = mysql_query("SELECT dateadded FROM ". $tbl_prefix ."comments WHERE ip = '". $user['ip'] ."' ORDER BY commentid DESC LIMIT 1");
				$last_comment_row = mysql_fetch_assoc($last_comment_sql);
				$categoryname = $last_comment_row['dateadded'];
		
				// Flood protection
				if (time() - $last_comment_row['dateadded'] > $settings['comments_flood_time']) {
					if ($settings['comments_approval'] == '0' || $settings['comments_approval'] == '1' && $user['status'] == '1') {
						$comment_error = $lang['comment_added'];
						$comment_query = mysql_query("INSERT INTO ". $tbl_prefix ."comments SET fileid = '". $file_id ."', userid = '". $user['id'] ."', username = '". $user['username'] ."', comment = '". $comment_text ."', ip = '". $user['ip'] ."', dateadded = '". time() ."', status = '1'");
					} else {
						$comment_error = $lang['comment_awaiting_approval'];
						$comment_query = mysql_query("INSERT INTO ". $tbl_prefix ."comments SET fileid = '". $file_id ."', userid = '". $user['id'] ."', username = '". $user['username'] ."', comment = '". $comment_text ."', ip = '". $user['ip'] ."', dateadded = '". time() ."', status = '0'");
					}
					// Update comments
					if ($user['status'] == '1') {
						$user['comments'] = $user['comments'] + 1;
						$update_user_comments = mysql_query("UPDATE ". $tbl_prefix ."users SET comments = '". $user['comments'] ."' WHERE userid = '". $user['id'] ."'");
					}
					echo utf8_encode($comment_error);
				} else {
					echo utf8_encode($lang['comment_flood_text']);
				}
			}
		}
	}
	break;
default:
	if ($user['plays_left'] <= 0 && $user['status'] == 0 && $settings['guestcredits'] == '1') {
		$blank_page = array(
			'title'		=>	$settings['sitename'],
			'content'	=>	$lang['you_no_more_plays_left']
		);
		
		$page_title = $lang['you_no_more_plays_left'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	
	// Get file information from database
	$file_query = mysql_query("SELECT * FROM ". $tbl_prefix ."files WHERE fileid = '". $file_id ."' && status = '1' LIMIT 1");
	
	$file_row = mysql_fetch_assoc($file_query);
	
	if (empty($file_row)) {
		$blank_page = array (
			'title'		=>	$settings['sitename'],
			'content'	=>	$lang['no_page_found']
		);
    			
    	$page_title = $lang['no_page_found'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	
	// Get category information
	$category_query = mysql_query("SELECT name, permissions, status FROM ". $tbl_prefix ."categories WHERE catid = '". $file_row['category'] ."' LIMIT 1");
	$category_row = mysql_fetch_assoc($category_query);

	if ($category_row['status'] == 0) {
		$blank_page = array (
			'title'		=>	$settings['sitename'],
			'content'	=>	$lang['no_page_found']
		);
    			
    	$page_title = $lang['no_page_found'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	if ($category_row['permissions'] == 2 && $user['status'] != '1') {
		$blank_page = array (
			'title'		=>	$lang['plese_log_in_title'],
			'content'	=>	$lang['plese_log_in']
		);
    			
    	$page_title = $lang['plese_log_in_title'];
    
    	// Load template		
    	template_blank_page();
		exit();
	}
	
	// So the user is *****...
	if ($_GET['a'] == '*****') {
		$update_*****_query = mysql_query("UPDATE ". $tbl_prefix ."online SET ***** = '1' WHERE ip = '". $user['ip'] ."' && isonline = '1'");
		
		$_SESSION['*****'] = '1';
	}
	
	// ***** verification for ***** games
	if ($file_row['*****'] == '1' && $_SESSION['*****'] != '1') {
		$*****_verification_query = mysql_query("SELECT ***** FROM ". $tbl_prefix ."online WHERE ip = '". $user['ip'] ."' && isonline = '1' && ***** = '1' LIMIT 1");
		$*****_verification_row = mysql_fetch_assoc($*****_verification_query);
		
		if ($*****_verification_row['*****'] == '1') {
			// So the user is *****, there is no need to ask him the question again
			$_SESSION['*****'] = '1';
		} else {
			$lang['warning_*****_content'] = str_replace('{$file_id}', $file_id, $lang['warning_*****_content']);
			$blank_page = array (
				'title'		=>	$settings['sitename'],
				'content'	=>	$lang['warning_*****_content']
			);
    			
    		$page_title = $lang['*****_verification'];
    
    		// Load template		
    		template_blank_page();
			exit();
		}
	}
	
	// Update statistics
	$times_played = $file_row['timesplayed'] + 1;
	$stats['played_today'] = $stats['played_today'] + 1;
	$stats['total_played'] = $stats['total_played'] + 1;
	
	if ($user['status'] == '1') {
		$user['played'] = $user['played'] + 1;
		$update_played_query = mysql_query("UPDATE ". $tbl_prefix ."files, ". $tbl_prefix ."statistics, ". $tbl_prefix ."users SET ". $tbl_prefix ."files.timesplayed = '". $times_played ."', ". $tbl_prefix ."statistics.played_today = '". $stats['played_today'] ."', ". $tbl_prefix ."statistics.total_played = '". $stats['total_played'] ."', ". $tbl_prefix ."users.played = '". $user['played'] ."' WHERE ". $tbl_prefix ."files.fileid = '". $file_row['fileid'] ."' && ". $tbl_prefix ."statistics.stats_id = '". $stats['id'] ."' && ". $tbl_prefix ."users.userid = '". $user['id'] ."'");
    } elseif ($user['status'] == '0' && $settings['guestcredits'] == '1') {
    	$update_played_query = mysql_query("UPDATE ". $tbl_prefix ."files, ". $tbl_prefix ."statistics, ". $tbl_prefix ."online SET ". $tbl_prefix ."files.timesplayed = '". $times_played ."', ". $tbl_prefix ."statistics.played_today = '". $stats['played_today'] ."', ". $tbl_prefix ."statistics.total_played = '". $stats['total_played'] ."', ". $tbl_prefix ."online.played = ". $tbl_prefix ."online.played + 1 WHERE ". $tbl_prefix ."files.fileid = '". $file_row['fileid'] ."' && ". $tbl_prefix ."statistics.stats_id = '". $stats['id'] ."' && ". $tbl_prefix ."online.ip = '". $user['ip'] ."'");
    } else {
    	$update_played_query = mysql_query("UPDATE ". $tbl_prefix ."files, ". $tbl_prefix ."statistics SET ". $tbl_prefix ."files.timesplayed = '". $times_played ."', ". $tbl_prefix ."statistics.played_today = '". $stats['played_today'] ."', ". $tbl_prefix ."statistics.total_played = '". $stats['total_played'] ."' WHERE ". $tbl_prefix ."files.fileid = '". $file_row['fileid'] ."' && ". $tbl_prefix ."statistics.stats_id = '". $stats['id'] ."'");
    }
    
    if ($settings['added_by'] == '1') {
    	if (empty($file_row['added_by'])) {
    		$added_by_username = NULL;
  		} else {
  			// Get adder username
    		$added_by_query = mysql_query("SELECT username FROM ". $tbl_prefix ."users WHERE userid = '". $file_row['added_by'] ."' LIMIT 1");
			$added_by_row = mysql_fetch_assoc($added_by_query);
			$added_by_username = '<a href="'. profileurl($file_row['added_by'],nohtml($added_by_row['username'])) .'">'. $added_by_row['username'] .'</a>';
		}
	}
	
	// Check if file is favourite
	if (isset($user_row['favourites']) && strlen($user_row['favourites'])) {
		$user_favourites = unserialize($user_row['favourites']);
		
		if (in_array($file_row['fileid'], $user_favourites)) {
			$is_favourite = TRUE;
		} else {
			$is_favourite = FALSE;
		}
	} else {
		$is_favourite = FALSE;
	}
	
	// If file is framed then lets frame it
    if ($file_row['filelocation'] == '3') {
    	$file = array (
			'id'				=>	$file_row['fileid'],
			'title'				=>	$file_row['title'],
			'description'		=>	$file_row['description'],
			'file'				=>	$file_row['file'],
			'played'			=>	number_format($times_played),
			'rating'			=>	$file_row['rating'],
			'favourite'			=>	$is_favourite
		);
    	
    	$settings['sitedescription'] = $file['description'];
		if (strlen($file_row['keywords'])) {
			$settings['sitekeywords'] = $settings['sitekeywords'] .', '. $file_row['keywords'];
		}
		$page_title = $file['title'];
    	
    	// Load template
    	template_frame();
    	exit();
    }
	
	// Find best score
	if ($file_row['scores'] == '1') {
		$best_score_query = mysql_query("SELECT user_id, username, score FROM ". $tbl_prefix ."scores WHERE is_high = '1' && file_id = '". $file_row['fileid'] ."'");
	
		if (mysql_num_rows($best_score_query) == 0) {
			$best_score_user = $lang['no_one'];
			$best_score = '0';
		} else {
			$best_score_row = mysql_fetch_assoc($best_score_query);
			
			$best_score_user = '<a href="'. profileurl($best_score_row['user_id'], $best_score_row['username']) .'">'. $best_score_row['username'] .'</a>';
			$best_score = number_format($best_score_row['score'], 1);
		}
		// Replace some variables
		$lang['is_champion_with_score'] = str_replace('{$best_score_user}', $best_score_user, $lang['is_champion_with_score']);
		$lang['is_champion_with_score'] = str_replace('{$file_title}', $file_row['title'], $lang['is_champion_with_score']);
		$lang['is_champion_with_score'] = str_replace('{$best_score}', $best_score, $lang['is_champion_with_score']);
	}
    
    // Direct URL to file
	if ($file_row['filelocation'] == '1') {
		$file_url = $settings['siteurl'] .'/files/'. $settings['filesdir'] .'/'. $file_row['file'];
    } else {
	    $file_url = $file_row['file'];
    }
    
    // Direct URL to image
    if ($file_row['iconlocation'] == '1') {
		$image_url = $settings['siteurl'] .'/files/image/'. $file_row['icon'];
    } else {
	    $image_url = $file_row['icon'];
    }
    
    // Add to your website text
    $add_your_website = '<img src = "'. $image_url .'" border="0" alt="'. $file_row['title'] .'" title="'. $file_row['title'] .'" /><br /><a href="'. fileurl($file_row['fileid'],$file_row['title']) .'">'. $file_row['title'] .'</a>';
    
    // Get the file displaying code
    if ($file_row['width'] > $settings['max_file_width'] && $settings['auto_resize'] == '0' || $file_row['height'] > $settings['max_file_height'] && $settings['auto_resize'] == '0') {
    	$play_file = '<a href="" onclick="window.open(\''. $settings['siteurl'] .'/file.php?f='. $file_row['fileid'] .'&a=popup\', \'\', \'width='. $file_row['width'] .',height='. $file_row['height'] .',menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0\'); return false;">'. $lang['open_file_in_new_window'] .'</a>';
    } elseif ($file_row['filetype'] == 'code') {
		$play_file = $file_row['customcode'];
	} else {
    	// Resize if file is too big
		if ($file_row['width'] > $settings['max_file_width']) {
		    $size_change = $file_row['width'] / $settings['max_file_width'];
			$file_row['width'] = $settings['max_file_width'];
			$file_row['height'] = round($file_row['height'] / $size_change);    
		}
		if ($file_row['height'] > $settings['max_file_height']) {
		    $size_change = ($file_row['height'] / $settings['max_file_height']);
			$file_row['height'] = $settings['max_file_height'];
			$file_row['width'] = round($file_row['width'] / $size_change);    
		}
    	// Load player for file
    	$play_file = file_get_contents('includes/file_type/'. $file_row['filetype'] .'.php');
    	
    	// Replace variables
    	$play_file = str_replace('{$width}', $file_row['width'], $play_file);
    	$play_file = str_replace('{$height}', $file_row['height'], $play_file);
    	$play_file = str_replace('{$file_url}', $file_url, $play_file);
    	$play_file = str_replace('{$siteurl}', $settings['siteurl'], $play_file);
    }
    
	$file = array (
		'id'				=>	$file_row['fileid'],
		'title'				=>	$file_row['title'],
		'description'		=>	$file_row['description'],
		'played'			=>	number_format($times_played),
		'added'				=>	mod_date($file_row['dateadded']),
		'rating'			=>	$file_row['rating'],
		'added_by'			=>	$added_by_username,
		'play_file'			=>	$play_file,
		'scores'			=>	$file_row['scores'],
		'add_your_website'	=>	$add_your_website,
		'cat_title'			=>	$category_row['name'],
		'cat_url'			=>	categoryurl($file_row['category'], $category_row['name'], 1),
		'favourite'			=>	$is_favourite,
		'comment_error'		=>	$comment_error
	);
	
	if ($settings['comments'] == '1') {
		// Build navigation menu
		$comments_number_query = mysql_query("SELECT count(fileid) FROM ". $tbl_prefix ."comments WHERE fileid = '". $file_id ."' && status = '1'");
		$comments_number_row = mysql_fetch_assoc($comments_number_query);
		$pages_count = ceil($comments_number_row['count(fileid)'] / $settings['max_comments']);
		$navigation = NULL;
		for ($pagen = 1; $pagen <= $pages_count; $pagen++) {
			if ($pagen == 1) {
				$navigation .= ' <b>'. $pagen .'</b>';
        	} else {
				$navigation .= ' <a href="" onclick="display_comments('. $file_id .', '. $pagen .'); return false;">'. $pagen .'</a>';
	    	} 
    	}
    	// Get comments
		$comments_query = mysql_query("SELECT * FROM ". $tbl_prefix ."comments WHERE fileid = '". $file_id ."' && status = '1' ORDER BY commentid DESC LIMIT 0, ". $settings['max_comments']);
		
		while ($comments_row = mysql_fetch_assoc($comments_query)) {
			if ($comments_row['userid'] == '0' || empty($comments_row['username'])) {
				$poster_username = $lang['guest'];
			} else {
				$poster_username = '<a href="'. profileurl($comments_row['userid'], $comments_row['username']) .'">'. $comments_row['username'] .'</a>';
			}
			
			$comments[] = array (
				'comment'	=>	word_filter(bbcode(nl2br(nohtml($comments_row['comment'])))),
				'date'		=>	mod_date($comments_row['dateadded']),
				'user'		=>	$poster_username
			);
	
		}
	}
	
	if ($settings['related_files'] == '1') {
		$related_query = mysql_query("SELECT fileid, title, description, icon, iconlocation, timesplayed FROM ". $tbl_prefix ."files WHERE category = '". $file_row['category'] ."' && status ='1' && fileid != '". $file_row['fileid'] ."' ORDER BY RAND() LIMIT ". $settings['max_related_files']);
		while ($related_row = mysql_fetch_assoc($related_query)) {
			if ($related_row['iconlocation'] == '1') {
				$image_url = $settings['siteurl'] .'/files/image/'. $related_row['icon'];
			} else {
				$image_url = $related_row['icon'];
			}
			$related_files[] = array (
				'title'			=>	$related_row['title'],
				'url'			=>	fileurl($related_row['fileid'],$related_row['title'],1),
				'description'	=>	$related_row['description'],
				'image'			=>	$image_url
			);	
		
		}
	}
	
	$settings['sitedescription'] = $file['description'];
	if (strlen($file_row['keywords'])) {
		$settings['sitekeywords'] = $settings['sitekeywords'] .', '. $file_row['keywords'];
	}
	$page_title = $file['title'];

	// Load template
	template_file();
}

?>