User Settings';
 if ($err != '')
	$pg .= "$err
";
 $pg .= '
';
 $pg .= '| ';
 $pg .= makeForm('userset');
 $pg .= '';
 $pg .= ' | 
';
 $pg .= '
';
 return $pg;
}
#
function douserset($data, $user)
{
 $err = '';
 $chg = getparam('Change', false);
 $api = false;
 switch ($chg)
 {
  case 'API Key':
	$ans = getAtts($user, 'KAPIKey.str,KAPIKey.dateexp');
	if ($ans['STATUS'] != 'ok')
		dbdown(); // Should be no other reason?
	if (isset($ans['KAPIKey.dateexp']) && $ans['KAPIKey.dateexp'] == 'N')
	{
		$err = 'You can only change it once a day';
		if (isset($ans['KAPIKey.str']))
			$api = $ans['KAPIKey.str'];
	}
	else
	{
		$ran = $ans['STAMP'].$user.rand(100000000,999999999);
		$api = hash('md4', $ran);
		$day = 60 * 60 * 24;
		$ans = setAtts($user, array('ua_KAPIKey.str' => $api,
						'ua_KAPIKey.date' => "now+$day"));
		if ($ans['STATUS'] != 'ok')
			syserror();
	}
	break;
 }
 if ($api === false)
 {
	$ans = getAtts($user, 'KAPIKey.str');
	if ($ans['STATUS'] != 'ok')
		dbdown(); // Should be no other reason?
	if (isset($ans['KAPIKey.str']))
		$api = $ans['KAPIKey.str'];
 }
 $pg = uset($data, $user, $api, $err);
 return $pg;
}
#
function show_userset($page, $menu, $name, $user)
{
 gopage(NULL, 'douserset', $page, $menu, $name, $user);
}
#
?>