Перейти к содержанию
Авторизация  
hodor

Community board мозги компосирует (bypass not exists)

Рекомендуемые сообщения

Ребят, подскажите пожалуйста, что этот гад от меня хочет? Вызываю board - тыкаю на любые кнопки и получаю ошибку в ГС: 

Can't decode bypass (bypass not exists): [bbs] 10 / Player: Hodor
19:23:46 WARN Client: [Character: Hodor - Account: hodor - IP: 127.0.0.1] - Failed reading: [C] RequestBypassToServer ; java.lang.NullPointerException

1affcffe4c.jpg

 

Если тыкнуть на Favorites или любую другую надпись, то все пропадает и пишет ошибку в ГС, которую я указал в начале темы.

 

98609668b4.jpg

 

<html><body><br>
	<table width="610">
		<tr>
			<td align="center" height="30"><img src="l2ui.bbs_lineage2" width="128" height="16"></td>
		</tr>
	</table>
	<table width="610" bgcolor="A7A19A">
		<tr>
			<td width="50" align="center">&$412;</td>
			<td width="380" align="center">&$413;</td>
			<td width="90" align="center">&$414;</td>
			<td width="90" align="center">&$415;</td>
		</tr>
	</table><br>
	<table width="610">
		<tr>
			<td width="50" align="center"><img src="l2ui.bbs_folder" width="32" height="32"></td>
			<td width="380" align="left"><a action="bypass _bbsgetfav">Favorites</a><br1><font color="AAAAAA">Bookmarks</font></td>
			<td width="90" align="center">0</td>
			<td width="90" align="center">admin</td>
		</tr>
	</table>
	<table border=0 cellspacing=0 cellpadding=0>
		<tr>
			<td width=610><img src="l2ui.squaregray" width="600" height="1"></td>
		</tr>
	</table><br>
	<table border=0 cellspacing=0 cellpadding=2>
		<tr>
			<td FIXWIDTH=50 align=right valign=top><img src="l2ui.bbs_folder" width=32 height=32></td>
			<td FIXWIDTH=380 align=left valign=top><a action="bypass _bbshome;rules.htm">Server Rules</a><br1><font color="AAAAAA">Read them carefully</font></td>
			<td FIXWIDTH=90 align=center valign=top>0</td>
			<td FIXWIDTH=90 align=center valign=top>admin</td>
		</tr>
	</table>
	<table border=0 cellspacing=0 cellpadding=0>
		<tr>
			<td width=610><img src="l2ui.squaregray" width="600" height="1"></td>
		</tr>
	</table><br>
	<table border=0 cellspacing=0 cellpadding=2>
		<tr>
			<td FIXWIDTH=50 align=right valign=top><img src="l2ui.bbs_folder" width=32 height=32></td>
			<td FIXWIDTH=380 align=left valign=top><a action="bypass _bbshome;news.htm">Lineage II News</a><br1><font color="AAAAAA">New Information</font></td>
			<td FIXWIDTH=90 align=center valign=top>0</td>
			<td FIXWIDTH=90 align=center valign=top>admin</td>
		</tr>
	</table>
	<table border=0 cellspacing=0 cellpadding=0>
		<tr>
			<td width=610><img src="l2ui.squaregray" width="600" height="1"></td>
		</tr>
	</table><br>
	<table border=0 cellspacing=0 cellpadding=2>
		<tr>
			<td FIXWIDTH=50 align=right valign=top><img src="l2ui.bbs_folder" width=32 height=32></td>
			<td FIXWIDTH=380 align=left valign=top><a action="bypass _bbsclan">Clan Community</a><br1><font color="AAAAAA">Clan Community</font></td>
			<td FIXWIDTH=90 align=center valign=top>0</td>
			<td FIXWIDTH=90 align=center valign=top>admin</td>
		</tr>
	</table>
	<table border=0 cellspacing=0 cellpadding=0>
		<tr>
			<td width=610><img src="l2ui.squaregray" width="600" height="1"></td>
		</tr>
	</table>
</center></body></html> 

 

 

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.gameserver.network.clientpackets;

import java.security.MessageDigest;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringTokenizer;

import net.sf.l2j.commons.Base64;
import net.sf.l2j.commons.config.Config;
import net.sf.l2j.commons.db.DatabaseFactory;
import net.sf.l2j.gameserver.cache.HtmCache;
import net.sf.l2j.gameserver.communitybbs.CommunityBoard;
import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
import net.sf.l2j.gameserver.handler.admin.AdminCommandHandler;
import net.sf.l2j.gameserver.handler.admin.IAdminCommandHandler;
import net.sf.l2j.gameserver.handler.voiced.IVoicedCommandHandler;
import net.sf.l2j.gameserver.handler.voiced.VoicedCommandHandler;
import net.sf.l2j.gameserver.instancemanager.BypassManager;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2OlympiadManagerInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.Hero;
import net.sf.l2j.gameserver.model.entity.events.AbstractEvent;
import net.sf.l2j.gameserver.model.entity.events.EventManager;
import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.util.GMAudit;

public final class RequestBypassToServer extends L2GameClientPacket
{
	private BypassManager.DecodedBypass bp = null;
	
	@Override
	protected void readImpl()
	{
		String bypass = readS();
		
		if (!bypass.isEmpty())
		{
			bp = getClient().getActiveChar().decodeBypass(bypass);
		}
	}
	
	@Override
	protected void runImpl()
	{
		final L2PcInstance activeChar = getClient().getActiveChar();
		if (activeChar == null)
		{
			return;
		}
		
		if (!getClient().getFloodProtectors().getServerBypass().tryPerformAction(bp.bypass))
		{
			return;
		}
		
		if (bp.bypass.isEmpty())
		{
			_log.info(activeChar.getName() + " sent an empty requestBypass packet.");
			activeChar.logout();
			return;
		}
		
		try
		{
			if (bp.bypass.startsWith("admin_"))
			{
				String command = bp.bypass.split(" ")[0];
				
				IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
				if (ach == null)
				{
					if (activeChar.isGM())
					{
						activeChar.sendMessage("The command " + command.substring(6) + " doesn't exist.");
					}
					
					_log.warn("No handler registered for admin command '" + command + "'");
					return;
				}
				
				if (!AdminCommandAccessRights.getInstance().hasAccess(command, activeChar.getAccessLevel()))
				{
					activeChar.sendMessage("You don't have the access rights to use this command.");
					_log.warn(activeChar.getName() + " tried to use admin command " + command + " without proper Access Level.");
					return;
				}
				
				if (Config.GMAUDIT)
				{
					GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", bp.bypass, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
				}
				
				ach.useAdminCommand(bp.bypass, activeChar);
			}
			else if (bp.bypass.startsWith("player_help "))
			{
				playerHelp(activeChar, bp.bypass.substring(12));
			}
			else if (bp.bypass.startsWith("event"))
			{
				String eventName = bp.bypass.substring(6);
				int i = eventName.indexOf(" ");
				String cmd = "";
				String param = "";
				if (i != -1)
				{
					cmd = eventName.substring(i + 1);
					eventName = eventName.substring(0, i);
				}
				i = cmd.indexOf(" ");
				if (i != -1)
				{
					param = cmd.substring(i + 1);
					cmd = cmd.substring(0, i);
				}
				AbstractEvent evt = EventManager.getInstance().findEvent(eventName);
				if (evt != null)
				{
					evt.onCommand(activeChar, cmd, param);
				}
			}
			else if (bp.bypass.startsWith("SecondAnswer"))
			{
				activeChar.sendMessage("Вы прошли проверку, продолжайте игру.");
				activeChar.PassedProt = true;
			}
			else if (bp.bypass.startsWith("FirstAnswer"))
			{
				activeChar.sendMessage("Вы не прошли проверку на бота, до свидания.");
				activeChar.PassedProt = false;
			}
			else if (bp.bypass.startsWith("npc_"))
			{
				int endOfId = bp.bypass.indexOf('_', 5);
				String id;
				if (endOfId > 0)
				{
					id = bp.bypass.substring(4, endOfId);
				}
				else
				{
					id = bp.bypass.substring(4);
				}
				
				try
				{
					final L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
					
					if (object != null && object instanceof L2Npc && endOfId > 0 && ((L2Npc) object).canInteract(activeChar))
					{
						((L2Npc) object).onBypassFeedback(activeChar, bp.bypass.substring(endOfId + 1));
					}
					
					activeChar.sendPacket(ActionFailed.STATIC_PACKET);
				}
				catch (NumberFormatException nfe)
				{
				}
			}
			// Navigate throught Manor windows
			else if (bp.bypass.startsWith("manor_menu_select?"))
			{
				L2Object object = activeChar.getTarget();
				if (object instanceof L2Npc)
				{
					((L2Npc) object).onBypassFeedback(activeChar, bp.bypass);
				}
			}
			else if (bp.bypass.startsWith("bbs_") || bp.bypass.startsWith("_bbs") || bp.bypass.startsWith("_friend") || bp.bypass.startsWith("_mail") || bp.bypass.startsWith("_block"))
			{
				CommunityBoard.getInstance().handleCommands(getClient(), bp.bypass);
			}
			else if (bp.bypass.startsWith("Quest "))
			{
				String[] str = bp.bypass.substring(6).trim().split(" ", 2);
				if (str.length == 1)
				{
					activeChar.processQuestEvent(str[0], "");
				}
				else
				{
					activeChar.processQuestEvent(str[0], str[1]);
				}
			}
			else if (bp.bypass.startsWith("_match"))
			{
				String params = bp.bypass.substring(bp.bypass.indexOf("?") + 1);
				StringTokenizer st = new StringTokenizer(params, "&");
				int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
				int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
				int heroid = Hero.getInstance().getHeroByClass(heroclass);
				if (heroid > 0)
				{
					Hero.getInstance().showHeroFights(activeChar, heroclass, heroid, heropage);
				}
			}
			else if (bp.bypass.startsWith("_diary"))
			{
				String params = bp.bypass.substring(bp.bypass.indexOf("?") + 1);
				StringTokenizer st = new StringTokenizer(params, "&");
				int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
				int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
				int heroid = Hero.getInstance().getHeroByClass(heroclass);
				if (heroid > 0)
				{
					Hero.getInstance().showHeroDiary(activeChar, heroclass, heroid, heropage);
				}
			}
			else if (bp.bypass.startsWith("arenachange")) // change
			{
				final boolean isManager = activeChar.getCurrentFolkNPC() instanceof L2OlympiadManagerInstance;
				if (!isManager)
				{
					// Without npc, command can be used only in observer mode on arena
					if (!activeChar.inObserverMode() || activeChar.isInOlympiadMode() || activeChar.getOlympiadGameId() < 0)
					{
						return;
					}
				}
				
				if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
				{
					activeChar.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
					return;
				}
				
				if (activeChar.getEvent() != null)
				{
					return;
				}
				
				final int arenaId = Integer.parseInt(bp.bypass.substring(12).trim());
				activeChar.enterOlympiadObserverMode(arenaId);
			}
			else if (bp.bypass.startsWith("voice_"))
			{
				String command = bp.bypass.split(" ")[0].replace("voice_", "");
				IVoicedCommandHandler vh = VoicedCommandHandler.getInstance().getHandler(command);
				if (vh == null)
				{
					_log.warn("No handler registered for voice command '" + command + "'");
					return;
				}
				
				vh.useVoicedCommand(command, activeChar, bp.bypass.replace("voice_", "").replace(command, "").trim());
			}
			else if (bp.bypass.startsWith("mod_menu_"))
			{
				IVoicedCommandHandler vch = VoicedCommandHandler.getInstance().getHandler("mod_menu_");
				vch.useVoicedCommand(bp.bypass, activeChar, null);
			}
			else if (bp.bypass.equalsIgnoreCase("pkrecovery"))
			{
				String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/recovery.htm");
				NpcHtmlMessage html = new NpcHtmlMessage(1);
				html.setHtml(htmContent);
				html.replace("%question%", getPassKeyQuestion(activeChar));
				activeChar.sendPacket(html);
				html = null;
			}
			else if (bp.bypass.equalsIgnoreCase("pkrecovery"))
			{
				String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/recovery.htm");
				NpcHtmlMessage html = new NpcHtmlMessage(1);
				html.setHtml(htmContent);
				html.replace("%question%", getPassKeyQuestion(activeChar));
				activeChar.sendPacket(html);
				html = null;
			}
			else if (bp.bypass.startsWith("pkset"))
			{
				StringTokenizer st = new StringTokenizer(bp.bypass, "]");
				
				if (st.countTokens() != 5)
				{
					activeChar.sendMessage("Вы ввели не все данные!");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/setup.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					activeChar.sendPacket(html);
					html = null;
					return;
				}
				
				String newCommand = st.nextToken();
				String pass1 = st.nextToken();
				pass1 = pass1.substring(1, pass1.length() - 1);
				String pass2 = st.nextToken();
				pass2 = pass2.substring(1, pass2.length() - 1);
				String question = st.nextToken();
				question = question.substring(1, question.length() - 1);
				String answer = st.nextToken();
				answer = answer.substring(1, answer.length());
				
				if (pass1 == null || pass2 == null || question == null || answer == null)
				{
					activeChar.sendMessage("Ошибка при вводе");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/setup.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					activeChar.sendPacket(html);
					html = null;
					return;
				}
				
				if (!pass1.equals(pass2))
				{
					activeChar.sendMessage("Вы ввели разные пароли");
					activeChar.sendMessage("pass1 = " + pass1);
					activeChar.sendMessage("pass2 = " + pass2);
					activeChar.sendMessage("Question = " + question);
					activeChar.sendMessage("answer = " + answer);
					
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/setup.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					activeChar.sendPacket(html);
					html = null;
					return;
				}
				insertPassKeyInformation(activeChar, pass1, question, answer);
				String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/login.htm");
				NpcHtmlMessage html = new NpcHtmlMessage(1);
				html.setHtml(htmContent);
				activeChar.sendPacket(html);
				html = null;
			}
			else if (bp.bypass.startsWith("pklogin"))
			{
				StringTokenizer st = new StringTokenizer(bp.bypass, " ");
				if (st.countTokens() != 2)
				{
					activeChar.sendMessage("Вы допустили ошибку при вводе пароля!");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/login.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					activeChar.sendPacket(html);
					html = null;
					return;
				}
				String newCommand = st.nextToken();
				String pass = st.nextToken();
				
				Connection con = null;
				String query = "SELECT passkey FROM passkey WHERE obj_Id = ?";
				String pwdindb = "error";
				try
				{
					con = DatabaseFactory.getInstance().getConnection();
					PreparedStatement ps = con.prepareStatement(query);
					ps.setInt(1, activeChar.getObjectId());
					ResultSet rs = ps.executeQuery();
					
					while (rs.next())
					{
						pwdindb = rs.getString(1);
					}
					
					rs.close();
					ps.close();
					ps = null;
					rs = null;
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
				finally
				{
					try
					{
						con.close();
					}
					catch (SQLException e)
					{
						e.printStackTrace();
					}
					con = null;
				}
				
				if (pwdindb.equals(encodePass(pass)))
				{
					activeChar.setIsPassKey(false);
					activeChar.setIsImmobilized(false);
				}
				else
				{
					activeChar.sendMessage("Вы ввели не правильный пароль");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/login.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					activeChar.sendPacket(html);
					html = null;
					return;
				}
			}
			else if (bp.bypass.startsWith("pkrec"))
			{
				StringTokenizer st = new StringTokenizer(bp.bypass, " ");
				if (st.countTokens() != 4)
				{
					activeChar.sendMessage("Вы допустили ошибку при вводе данных!");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/recovery.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					html.replace("%question%", getPassKeyQuestion(activeChar));
					activeChar.sendPacket(html);
					html = null;
					return;
				}
				
				String newCommand = st.nextToken();
				String answer = st.nextToken();
				String pass1 = st.nextToken();
				String pass2 = st.nextToken();
				
				if (!pass1.equals(pass2))
				{
					activeChar.sendMessage("Вы ввели разные пароли");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/recovery.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					html.replace("%question%", getPassKeyQuestion(activeChar));
					activeChar.sendPacket(html);
					html = null;
					return;
				}
				
				Connection con = null;
				String query = "SELECT answer FROM passkey WHERE obj_Id = ?";
				String anwindb = "error";
				try
				{
					con = DatabaseFactory.getInstance().getConnection();
					PreparedStatement ps = con.prepareStatement(query);
					ps.setInt(1, activeChar.getObjectId());
					ResultSet rs = ps.executeQuery();
					
					while (rs.next())
					{
						anwindb = rs.getString(1);
					}
					
					rs.close();
					ps.close();
					ps = null;
					rs = null;
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
				finally
				{
					try
					{
						con.close();
					}
					catch (SQLException e)
					{
						e.printStackTrace();
					}
					con = null;
				}
				
				if (anwindb.equals(answer))
				{
					updPassKey(activeChar, pass1);
					activeChar.sendMessage("Вы успешно изменили пароль.");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/login.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					activeChar.sendPacket(html);
					html = null;
				}
				else
				{
					activeChar.sendMessage("Вы ввели неправильный ответ на свой вопрос");
					String htmContent = HtmCache.getInstance().getHtm("data/html/mods/passkey/recovery.htm");
					NpcHtmlMessage html = new NpcHtmlMessage(1);
					html.setHtml(htmContent);
					html.replace("%question%", getPassKeyQuestion(activeChar));
					activeChar.sendPacket(html);
					html = null;
					return;
				}
			}
		}
		catch (Exception e)
		{
			_log.warn("Bad RequestBypassToServer: ", e);
		}
	}
	
	private void updPassKey(L2PcInstance player, String pass)
	{
		String query = "UPDATE passkey SET passkey = ? WHERE obj_Id = ?";
		try (Connection con = DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement st = con.prepareStatement(query);
			st.setString(1, encodePass(pass));
			st.setInt(2, player.getObjectId());
			st.executeUpdate();
			st.close();
			st = null;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	private String encodePass(String password)
	{
		String pass = "error";
		try
		{
			MessageDigest md = MessageDigest.getInstance("SHA");
			byte[] raw = password.getBytes("UTF-8");
			byte[] hash = md.digest(raw);
			pass = Base64.encodeBytes(hash);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		return pass;
	}
	
	private void insertPassKeyInformation(L2PcInstance player, String pass, String question, String answer)
	{
		String query = "INSERT INTO passkey (obj_Id, passkey, question, answer) VALUES (?,?,?,?)";
		try (Connection con = DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement st = con.prepareStatement(query);
			st.setInt(1, player.getObjectId());
			st.setString(2, encodePass(pass));
			st.setString(3, question);
			st.setString(4, answer);
			st.execute();
			st.close();
			st = null;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	private String getPassKeyQuestion(L2PcInstance player)
	{
		String query = "SELECT question FROM passkey WHERE obj_Id = ?";
		String question = "error";
		try (Connection con = DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement st = con.prepareStatement(query);
			st.setInt(1, player.getObjectId());
			ResultSet rs = st.executeQuery();
			
			while (rs.next())
			{
				question = rs.getString(1);
			}
			
			rs.close();
			st.close();
			st = null;
			rs = null;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
		return question;
	}
	
	public static boolean getPassKeyEnable(L2PcInstance player)
	{
		String query = "SELECT COUNT(*) FROM passkey WHERE obj_Id = ?";
		int count = 0;
		try (Connection con = DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement st = con.prepareStatement(query);
			st.setInt(1, player.getObjectId());
			ResultSet rs = st.executeQuery();
			
			while (rs.next())
			{
				count = rs.getInt(1);
			}
			
			rs.close();
			st.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
		if (count == 1)
		{
			return true;
		}
		return false;
	}
	
	private static void playerHelp(L2PcInstance activeChar, String path)
	{
		if (path.indexOf("..") != -1)
		{
			return;
		}
		
		final StringTokenizer st = new StringTokenizer(path);
		final String[] cmd = st.nextToken().split("#");
		
		NpcHtmlMessage html = new NpcHtmlMessage(0);
		html.setFile("data/html/help/" + cmd[0]);
		if (cmd.length > 1)
		{
			html.setItemId(Integer.parseInt(cmd[1]));
		}
		html.disableValidation();
		activeChar.sendPacket(html);
	}
}
 

 

 

package net.sf.l2j.gameserver.instancemanager;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.util.Util;

public class BypassManager
{
	private static final Pattern p = Pattern.compile("\"(bypass +-h +)(.+?)\"");
	private static final Pattern p_is_bbs = Pattern.compile("\"(bypass +)(.+?)\"");
	
	public static enum BypassType
	{
		ENCODED,
		ENCODED_BBS,
		SIMPLE,
		SIMPLE_BBS,
		SIMPLE_DIRECT
	}
	
	public static BypassType getBypassType(String bypass)
	{
		switch (bypass.charAt(0))
		{
			case '0':
				return BypassType.ENCODED;
			case '1':
				return BypassType.ENCODED_BBS;
			default:
				if (Util.matches(bypass, "^(_bbshome|_bbslink|_bbsreglist|_bbsgetfav|_bbsloc|_bbsregion|_clbbsclan|_bbsclan|_bbsmemo|_maillist|_friendlist|_bbsaddfav).*", Pattern.DOTALL))
				{
					return BypassType.SIMPLE_BBS;
				}
				if (Util.matches(bypass, "^(_mrsl|_diary|_match|manor_menu_select|_match|_olympiad).*", Pattern.DOTALL))
				{
					return BypassType.SIMPLE;
				}
				return BypassType.SIMPLE_DIRECT;
		}
	}
	
	public static String encode(String html, List<String> bypassStorage, boolean bbs)
	{
		Matcher m = bbs ? p_is_bbs.matcher(html) : p.matcher(html);
		StringBuffer sb = new StringBuffer();
		
		while (m.find())
		{
			String bypass = m.group(2);
			
			String code = bypass;
			String params = "";
			int i = bypass.indexOf(" $");
			boolean use_params = i >= 0;
			if (use_params)
			{
				code = bypass.substring(0, i);
				params = bypass.substring(i).replace("$", "\\$");
			}
			
			if (bbs)
			{
				m.appendReplacement(sb, "\"bypass -h 1" + Integer.toHexString(bypassStorage.size()) + params + "\"");
			}
			else
			{
				m.appendReplacement(sb, "\"bypass -h 0" + Integer.toHexString(bypassStorage.size()) + params + "\"");
			}
			
			bypassStorage.add(code);
		}
		
		m.appendTail(sb);
		return sb.toString();
	}
	
	public static DecodedBypass decode(String bypass, List<String> bypassStorage, boolean bbs, L2PcInstance player)
	{
		synchronized (bypassStorage)
		{
			String[] bypass_parsed = bypass.split(" ");
			int idx = Integer.parseInt(bypass_parsed[0].substring(1), 16);
			String bp;
			
			try
			{
				bp = bypassStorage.get(idx);
			}
			catch (Exception e)
			{
				bp = null;
			}
			
			if (bp == null)
			{
				System.out.println("Can't decode bypass (bypass not exists): " + (bbs ? "[bbs] " : "") + bypass + " / Player: " + player.getName());
				return null;
			}
			
			DecodedBypass result;
			result = new DecodedBypass(bp, bbs);
			for (int i = 1; i < bypass_parsed.length; i++)
			{
				result.bypass += " " + bypass_parsed[i];
			}
			result.trim();
			
			return result;
		}
	}
	
	public static class DecodedBypass
	{
		public String bypass;
		public boolean bbs;
		
		public DecodedBypass(String _bypass, boolean _bbs)
		{
			bypass = _bypass;
			bbs = _bbs;
		}
		
		public DecodedBypass trim()
		{
			bypass = bypass.trim();
			return this;
		}
	}
} 

 

 

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.gameserver.communitybbs;

import net.sf.l2j.commons.config.Config;
import net.sf.l2j.gameserver.communitybbs.Manager.BaseBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.ClanBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.CustomBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.FriendsBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.MailBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.PostBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.RegionBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.TopBBSManager;
import net.sf.l2j.gameserver.communitybbs.Manager.TopicBBSManager;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.SystemMessageId;

public class CommunityBoard
{
	protected CommunityBoard()
	{
	}
	
	public static CommunityBoard getInstance()
	{
		return SingletonHolder._instance;
	}
	
	public void handleCommands(L2GameClient client, String command)
	{
		final L2PcInstance activeChar = client.getActiveChar();
		if (activeChar == null)
		{
			return;
		}
		
		if (!Config.ENABLE_COMMUNITY_BOARD)
		{
			activeChar.sendPacket(SystemMessageId.CB_OFFLINE);
			return;
		}
		
		if (command.startsWith("_bbshome"))
		{
			TopBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_bbsloc"))
		{
			RegionBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_bbsclan"))
		{
			ClanBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_bbsmemo"))
		{
			TopicBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_bbsmail") || command.equals("_maillist_0_1_0_"))
		{
			MailBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_friend") || command.startsWith("_block"))
		{
			FriendsBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_bbstopics"))
		{
			TopicBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_bbsposts"))
		{
			PostBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else if (command.startsWith("_bbsQuest"))
		{
			CustomBBSManager.getInstance().parseCmd(command, activeChar);
		}
		else
		{
			BaseBBSManager.separateAndSend("<html><body><br><br><center>The command: " + command + " isn't implemented.</center></body></html>", activeChar);
		}
	}
	
	public void handleWriteCommands(L2GameClient client, String url, String arg1, String arg2, String arg3, String arg4, String arg5)
	{
		final L2PcInstance activeChar = client.getActiveChar();
		if (activeChar == null)
		{
			return;
		}
		
		if (!Config.ENABLE_COMMUNITY_BOARD)
		{
			activeChar.sendPacket(SystemMessageId.CB_OFFLINE);
			return;
		}
		
		if (url.equals("Topic"))
		{
			TopicBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, activeChar);
		}
		else if (url.equals("Post"))
		{
			PostBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, activeChar);
		}
		else if (url.equals("_bbsloc"))
		{
			RegionBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, activeChar);
		}
		else if (url.equals("_bbsclan"))
		{
			ClanBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, activeChar);
		}
		else if (url.equals("Mail"))
		{
			MailBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, activeChar);
		}
		else if (url.equals("_friend"))
		{
			FriendsBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, activeChar);
		}
		else
		{
			BaseBBSManager.separateAndSend("<html><body><br><br><center>The command: " + url + " isn't implemented.</center></body></html>", activeChar);
		}
	}
	
	private static class SingletonHolder
	{
		protected static final CommunityBoard _instance = new CommunityBoard();
	}
} 

 

 

 

Подскажите решение, пожалуйста  :help:

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Зафиксил в коде... Ребзи, а что надо сделать, чтобы в комьюнити борд вывести диалоги бафера или хотя бы какой-нибудь мультиселл? Этого уже недостаточно?

<td width="380" align="left"><a action="bypass -h Quest 50000_Buffer Chat 2">Buffer</a></td>

Просто ничего не происходит по нажатию на Buffer, не открывает диалоги Chat 2...

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
Авторизация  

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

×
×
  • Создать...