Ir para conteúdo
  • Cadastre-se

(Resolvido)Problema ao criar guilds no site


Ir para solução Resolvido por Cdaniel.oliveira,

Posts Recomendados

Pessoal preciso de uma ajuda com criação de guild. De alguma forma as informações não são escritas no banco de dados ao criar uma nova guild e o erro em anexo aparece. Esta é parte do código guilds.php que está sendo usado no site.

 

Conseguem me ajudar a decifrar o que acontece? Se precisar eu posto o arquivo todo. 

 

Quem quiser fazer um teste para ver o erro em tempo real, pode acessar http://tibia.testecloud.com/ é só fazer o cadastro (menos de 5 minutos) e entrar em Accounts, Guilds e criar uma guild

guilds.lua

Spoiler

//create guild
if($action == 'createguild')
{
	$new_guild_name = trim($_REQUEST['guild']);
	$name = $_REQUEST['name'];
	$todo = $_REQUEST['todo'];
	if(!$logged)
		$guild_errors[] = 'You are not logged in. You can\'t create guild.';
	if(empty($guild_errors)) 
	{
		$account_players = $account_logged->getPlayers();
		foreach($account_players as $player)
		{
			$player_rank = $player->getRank();
			if(empty($player_rank))
				if($player->getLevel() >= $config['site']['guild_need_level'])
					if(!$config['site']['guild_need_pacc'] || $account_logged->isPremium())
						$array_of_player_nig[] = $player->getName();
		}
	}

	if(count($array_of_player_nig) == 0)
		$guild_errors[] = 'On your account all characters are in guilds or have too low level to create new guild.';
	if($todo == 'save')
	{
		if(!check_guild_name($new_guild_name))
		{
			$guild_errors[] = 'Invalid guild name format.';
		}
		if(!check_name($name))
		{
			$guild_errors[] = 'Invalid character name format.';
		}
		if(empty($guild_errors))
		{
			$player = new Player();
			$player->find($name);
			if(!$player->isLoaded())
				$guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
		}
		if(empty($guild_errors))
		{
			$guild = new Guild();
			$guild->find($new_guild_name);
			if($guild->isLoaded())
				$guild_errors[] = 'Guild <b>'.htmlspecialchars($new_guild_name).'</b> already exist. Select other name.';
		}
		if(empty($guild_errors))
		{
			$bad_char = TRUE;
			foreach($array_of_player_nig as $nick_from_list)
				if($nick_from_list == $player->getName())
					$bad_char = FALSE;
			if($bad_char)
				$guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t on your account or is already in guild.';
		}
		if(empty($guild_errors))
		{
			if($player->getLevel() < $config['site']['guild_need_level'])
				$guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> has too low level. To create guild you need character with level <b>'.$config['site']['guild_need_level'].'</b>.';
			if($config['site']['guild_need_pacc'] && !$account_logged->isPremium())
				$guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> is on FREE account. To create guild you need PREMIUM account.';
		}
	}
	if(!empty($guild_errors))
	{
		$main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
		foreach($guild_errors as $guild_error)
			$main_content .= '<li>'.$guild_error.'</li>';
		$main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>  </div></div><br>';
		unset($todo);
	}

	if($todo == 'save')
	{
		$new_guild = new Guild();
		$new_guild->setCreationData(time());
		$new_guild->setName($new_guild_name);
		$new_guild->setOwner($player);
		$new_guild->setDescription('New guild. Leader must edit this text :)');
		$new_guild->setGuildLogo('image/gif', Website::getFileContents('./images/default_guild_logo.gif'));
		
		$new_guild->save();
		$ranks = $new_guild->getGuildRanksList(true);
		foreach($ranks as $rank)
			if($rank->getLevel() == 3)
			{
				$player->setRank($rank);
				$player->save();
			}
		$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Create guild</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%><b>Congratulations!</b><br/>You have created guild <b>'.htmlspecialchars($new_guild_name).'</b>. <b>'.htmlspecialchars($player->getName()).'</b> is leader of this guild. Now you can invite players, change picture, description and motd of guild. Press submit to open guild manager.</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$new_guild->getId().'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
	}
	else
	{
		$main_content .= 'To play on '.$config['server']['serverName'].' you need an account. 
		All you have to do to create your new account is to enter your email address, password to new account, verification code from picture and to agree to the terms presented below. 
		If you have done so, your account number, password and e-mail address will be shown on the following page and your account and password will be sent 
		to your email address along with further instructions.<BR><BR>
		<FORM ACTION="?subtopic=guilds&action=createguild&todo=save" METHOD=post>
		<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
		<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" CLASS=white><B>Create an '.htmlspecialchars($config['server']['serverName']).' Account</B></TD></TR>
		<TR><TD BGCOLOR="'.$config['site']['darkborder'].'"><TABLE BORDER=0 CELLSPACING=8 CELLPADDING=0>
		  <TR><TD>
		    <TABLE BORDER=0 CELLSPACING=5 CELLPADDING=0>';
		$main_content .= '<TR><TD width="150" valign="top"><B>Leader: </B></TD><TD><SELECT name="name">';
		if(count($array_of_player_nig) > 0)
		{
			sort($array_of_player_nig);
			foreach($array_of_player_nig as $nick)
				$main_content .= '<OPTION>'.htmlspecialchars($nick).'</OPTION>';
		}
		$main_content .= '</SELECT><BR><font size="1" face="verdana,arial,helvetica">(Name of leader of new guild.)</font></TD></TR>
			<TR><TD width="150" valign="top"><B>Guild name: </B></TD><TD><INPUT NAME="guild" VALUE="" SIZE=30 MAXLENGTH=50><BR><font size="1" face="verdana,arial,helvetica">(Here write name of your new guild.)</font></TD></TR>
			</TABLE>
		  </TD></TR>
		</TABLE></TD></TR>
		</TABLE>
		<BR>
		<TABLE BORDER=0 WIDTH=100%>
		  <TR><TD ALIGN=center>
		    <IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR>
		  </TD><TD ALIGN=center VALIGN=top>
		    <INPUT TYPE=image NAME="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>
		    </FORM>
		  </TD><TD ALIGN=center>
		    <FORM  ACTION="?subtopic=guilds" METHOD=post>
		    <INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18>
		    </FORM>
		  </TD><TD ALIGN=center>
		    <IMG SRC="/images/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR>
		  </TD></TR>
		</TABLE>
		</TD>
		<TD><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
		</TR>
		</TABLE>';
	}
}

 

 

print do erro

Spoiler

Screenshot_20180111-114810.png

 

Editado por Cdaniel.oliveira
Estou deixando o tópico mais organizado para melhor compreensão (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Pedro, o problema acontece especificamente ao criar a Guild. 

 

Eu digito o nome dela e clico em Submit. Uma mensagem de sucesso aparece, com um botão submit para que eu possa abrir o guild manager. Quando clico lá, aparece a mensagem de erro que deixei no post. 

Link para o post
Compartilhar em outros sites
  • Solução
9 horas atrás, JonyKerckoff disse:

Estou a dias procurando uma solução para o mesmo problema..

 

Se alguém souber por favor deixe um comentário..

 

Desde já agradeço vlw

@JonyKerckoff, consegui resolver o problema e coloquei um post falando sobre isso. Dá uma olhada e ve se te ajuda! :) 

 

-----------------------------

EDIT

Se algum Moderador puder, pode fechar este tópico porque eu mesmo acabei resolvendo problema. Obrigado

Editado por Cdaniel.oliveira
Problema resolvido. (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
23 minutos atrás, Cdaniel.oliveira disse:

@JonyKerckoff, consegui resolver o problema e coloquei um post falando sobre isso. Dá uma olhada e ve se te ajuda! :) 

 

-----------------------------

EDIT

Se algum Moderador puder, pode fechar este tópico porque eu mesmo acabei resolvendo problema. Obrigado

 

 

 

Consegui resolver com isso mesmo por conta de 1 letra pelamor.... vlw 

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo