<?
	function resultado($str)
{
				return mssql_result(mssql_query("$str"), 0, 0);
}
	function recordon()
{
$arquivo	=	"record.xamaee";
$queryOn = mssql_query("SELECT memb___id FROM MEMB_STAT WHERE ConnectStat='1'");
$resultOn = mssql_num_rows($queryOn);
$read = fopen($arquivo, "r");
$recAtual = fread($read, filesize($arquivo));
fclose($read);
      if($resultOn > $recAtual){
            $tmp = @fopen($arquivo, "w+");
            @fwrite($tmp, $resultOn);
            print $resultOn;
      }else{
            print $recAtual;
      }
}

	function mapa($mapa_numero)
{		
	  switch ($mapa_numero)
	   {
				default: return "Indefinido";break;
				case "0": return "Lorencia";break;
				case "1": return "Dungeon";break;
				case "2": return "Davias";break;
				case "3": return "Noria";break;
				case "4": return "Losttower";break;
				case "5": return "Exile";break;
				case "6": return "Stadium";break;
				case "7": return "Atlans";break;
				case "8": return "Tarkan"; break;
				case "9": return "Devil Square"; break;
				case "10": return "Icarus"; break;
				case "11": return "BC1";break;
				case "12": return "BC2"; break;
				case "13": return "BC3"; break;
				case "14": return "BC4"; break;
				case "15": return "BC5"; break;
				case "16": return "BC6"; break;
				case "17": return "BC7"; break;
				case "24": return "Kalima1"; break;
				case "25": return "Kalima2"; break;
				case "26": return "Kalima3"; break;
				case "27": return "Kalima4"; break;
				case "28": return "Kalima5"; break;
				case "29": return "Kalima6"; break;
				case "36": return "Kalima7"; break;
				case "33": return "Aida"; break;
				case "34": return "CryWolF"; break;
				case "37": return "Kantru1"; break;
				case "38": return "Kantru2"; break;
				case "39": return "EventoKantru"; break;
				case "31": return "LandOfTrials"; break;
				case "30": return "CastleSiege"; break;

	  }
}
		function Classe($str, $revert=false)
{		switch($str)
		{
				case "0": return "DW"; break;
				case "1": return "SM"; break;
				case "2": return "GM"; break;
				case "16": return "DK"; break;
				case "17": return "BK"; break;
				case "18": return "BM"; break;
				case "32": return "FE"; break;
				case "33": return "ME"; break;
				case "34": return "HE"; break;
				case "48": return "MG"; break;
				case "49": return "DM"; break;
				case "64": return "DL"; break;
				case "65": return "LE"; break;
				case "80": return "Sum"; break;
				case "81": return "Sum"; break;
				case "82": return "Sum"; break;
				default: return "Indefinido"; break;
		}


}
	function	char_alert($chr)
{		
		$arraya	=	mssql_query("select * from Character where Name='$chr'");
		$array	=	mssql_fetch_array($arraya);
		$Soma	=	$array['Strength']+$array['Dexterity']+$array['Vitality']+$array['Energy']+$array['LevelUpPoint'];
	  return "Dados Do Personagem: ".$array["Name"]."\\r\\nForca: ".$array["Strength"]."\\r\\nAgilidade: ".$array["Dexterity"]."\\r\\nVitalidade: ".$array["Vitality"]."\\r\\nEnergia: ".$array["Energy"]."\\r\\nLevel: ".$array["cLevel"]."\\r\\nResets: ".$array["Resets"]."\\r\\nPontos Sobrando: ".$array["LevelUpPoint"]."\\r\\nSoma De Pontos: ".$Soma."\\r\\nClasse: ".classe($array["Class"])."\\r\\nMapa: ".mapa($array["MapNumber"])."\\r\\nStatus: ".vip2($array["AccountID"])."";
}
	function guild_alert($guild)
{
		$membros=	mssql_result(mssql_query("select count(*) from GuildMember WHERE G_Name='$guild'"), 0, 0);
		$gg	=	mssql_query("select * from Guild where G_Name='$guild'");
		$ggg	=	mssql_fetch_array($gg);
		$pp="Personagens";
		$guildd	= "Dados Da Guild: ".$guild."\\r\\nTotal Membros: ".$membros."\\r\\nGuildMaster: ".$ggg['G_Master']."\\r\\nPontos: ".$ggg['G_Score']."\\r\\n$pp:";
		$arraya	=	mssql_query("select * from GuildMember where G_Name='$guild'");
		while( $array	=	mssql_fetch_array($arraya) ){
		$ssssa=mssql_query("select Resets from Character where Name='".$array['Name']."'");
		if(mssql_num_rows($ssssa) > 0){
		$asd=mssql_result($ssssa, 0, 0);
		$guildd .="\\r\\n".$array['Name'].",   Resets:".$asd."";
		}
	}
	  return $guildd;


}

	
	function vip($status_vip)
{		$status_vipp = mssql_fetch_row(mssql_query("SELECT vip FROM MEMB_INFO WHERE memb___id='$status_vip'"));
		switch($status_vipp[0])
		{
	  default: return "Indefinido"; break;
	  case 0: return "<font color=red>FREE</font>"; break;
	  case 1: return "<font color=#3333FF>VIP</font>"; break;
	  case 2: return "<font color=blue>GOLD</font>"; break;
	  case 3: return "<font color=#FF9900>PREMIUM</font>"; break;
	    }
}

	function vip2($status_vip)
{		$status_vipp = mssql_fetch_row(mssql_query("SELECT vip FROM MEMB_INFO WHERE memb___id='$status_vip'"));
		switch($status_vipp[0])
		{
	  default: return "Indefinido"; break;
	  case 0: return "Free"; break;
	  case 1: return "Vip"; break;
	  case 2: return "Gold"; break;
	  case 3: return "Premium"; break;
	    }
}
	    function filtrar($string) {
        $string = @str_replace('À', '&Agrave;', $string);
        $string = @str_replace('Á', '&Aacute;', $string);
        $string = @str_replace('É', '&Eacute;', $string);
        $string = @str_replace('Ó', '&Iacute;', $string);
        $string = @str_replace('Ó', '&Oacute;', $string);
        $string = @str_replace('Ú', '&Uacute;', $string);
        $string = @str_replace('ã', '&atilde;', $string);
        $string = @str_replace('õ', '&otilde;', $string);
        $string = @str_replace('ã', '&atilde;', $string);
        $string = @str_replace('à', '&agrave;', $string);
        $string = @str_replace('á', '&aacute;', $string);
        $string = @str_replace('é', '&eacute;', $string);
        $string = @str_replace('í', '&iacute;', $string);
        $string = @str_replace('ó', '&oacute;', $string);
        $string = @str_replace('ú', '&uacute;', $string);
        $string = @str_replace('ê', '&ecirc;',  $string);
        $string = @str_replace('ô', '&ocirc;',  $string);
        $string = @str_replace('ö', '&ouml;',   $string);
        $string = @str_replace('ü', '&uuml;',   $string);
        $string = @str_replace('ç', '&ccedil;', $string);
        return $string;
    }
?>