<?php
include("../../../includes/db_functions.inc.php");
include("../../../includes/config.inc.php");
$id = $_GET['gameid'];
?>
<br/><br/>
<?php
$query = yasDB_select("SELECT count(id) AS count FROM comments WHERE gameid = '$id'");
$result = $query->fetch_array(MYSQLI_ASSOC);
$total = $result['count'];
$prefix = $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/smileys/';
if($total == 0) {
	echo '<div id="comment_text">This game has no comments, be the first to add one!</div>';
} else {
	$query = yasDB_select("SELECT * FROM comments WHERE gameid = '$id'");
	while($row = $query->fetch_array(MYSQLI_ASSOC)) {
		$text = $row['comment'];
		$text = str_replace(':D','<img src="' . $prefix . 'biggrin.gif" title="biggrin" alt="biggrin" />',$text);
		$text = str_replace(':?','<img src="' . $prefix . 'confused.gif" title="confused" alt="confused" />',$text);
		$text = str_replace('8)','<img src="' . $prefix . 'cool.gif" title="cool" alt="cool" />',$text);
		$text = str_replace(':cry:','<img src="' . $prefix . 'cry.gif" title="cry" alt="cry" />',$text);
		$text = str_replace(':shock:','<img src="' . $prefix . 'eek.gif" title="eek" alt="eek" />',$text);
		$text = str_replace(':evil:','<img src="' . $prefix . 'evil.gif" title="evil" alt="evil" />',$text);
		$text = str_replace(':lol:','<img src="' . $prefix . 'lol.gif" title="lol" alt="lol" />',$text);
		$text = str_replace(':x','<img src="' . $prefix . 'mad.gif" title="mad" alt="mad" />',$text);
		$text = str_replace(':P','<img src="' . $prefix . 'razz.gif" title="razz" alt="razz" />',$text);
		$text = str_replace(':oops:','<img src="' . $prefix . 'redface.gif" title="redface" alt="redface" />',$text);
		$text = str_replace(':roll:','<img src="' . $prefix . 'rolleyes.gif" title="rolleyes" alt="rolleyes" />',$text);
		$text = str_replace(':(','<img src="' . $prefix . 'sad.gif" title="sad" alt="sad" />',$text);					
		$text = str_replace(':)','<img src="' . $prefix . 'smile.gif" title="smile" alt="smile" />',$text);
		$text = str_replace(':o','<img src="' . $prefix . 'surprised.gif" title="surprised" alt="surprised" />',$text);
		$text = str_replace(':twisted:','<img src="' . $prefix . 'twisted.gif" title="twisted" alt="twisted" />',$text);
		$text = str_replace(':wink:','<img src="' . $prefix . 'wink.gif" title="wink" alt="wink" />',$text);
		echo '<p class="comments"><strong>' . $row['name'] . ' </strong>- ' . $text . '<br/><br/>';
	}
}
$query->close();
if (isset($_POST['comment'])) {
	$comment = $_POST['comment'];
} else {
	$comment = '';
}
?>