<?php

################################################
# EVILCMS FLATFILE RECODE - 100% FUNCTIONALITY #
################################################

Session_Start();

If($CMS->LoggedIn) {
	If(isset($_POST['cur']) && $CMS->User_hasBadge($_USER['name'], $_POST['cur']) && isset($_POST['badgeonoff']) && is_numeric($_POST['badgeonoff'])) {
		$CMS->User_SetValue($_USER['name'], "curbadge", $_POST['cur']);
		$CMS->User_SetValue($_USER['name'], "badgeonoff", $_POST['badgeonoff']);
		echo "Updated badge information.<br />";
		$_USER = $CMS->User_Load($_SESSION[$CMS->SessionName]);
	}
	$badgeList = $CMS->User_getBadges($_USER['name']);
	If($badgeList == 0) {
		Echo "You have no badges.";
	}else{
		Foreach($badgeList as $badgeCode) {
			echo "<img src=\"".$CMS->DCR['BASE']."/c_images/Badges/".$badgeCode.".gif\" onClick=\"cur.value = '".$badgeCode."';\">&nbsp;";
		}
?>
<form method="post" action="?p=badgemanagement">
Press the badge you want to wear. More badges can be won through competitions, earned through ranks and gained in staff games.<br />
Show badge? <input type="radio" name="badgeonoff" value="1" <?php if($_USER['badgeonoff'] == 1): ?>checked<?php endif; ?>> Yes <input type="radio" name="badgeonoff" value="0"  <?php if($_USER['badgeonoff'] != 1): ?>checked<?php endif; ?>> No<br />
Selected badge: <input type="text" name="cur" id="cur" value="<?php print $_USER['curbadge']; ?>" readonly="true"><br />
<input type="submit" value="Update!">
</form>
<?php
	}
}Else{
	Echo "Please login first.";
}

?>