| Цитата(mstalker26 @ 1.8.2012, 22:20) | Метод ip() точно вызываете перед тем, как вывести значение MyIP?
Если код не суперсекретный, можете выложить или послать в личку; иначе у нас гадание на кофейной гуще получается , маловато информации. |
| Цитата(mstalker26 @ 1.8.2012, 22:20) | Метод ip() точно вызываете перед тем, как вывести значение MyIP?
Если код не суперсекретный, можете выложить или послать в личку; иначе у нас гадание на кофейной гуще получается , маловато информации. |
просто очень много кода прийдётся читать и комментарий к нему...
вот выкладываю всё.
вот класс в котором пытаюсь получить то самое нужное... то что нужно смотрите выше по постам..
просьба не удивляйтесь нтмл коду, там всё правильно написанно и работает.
| Код | package net.sf.l2j.gameserver.communitybbs.Manager;
import java.net.InetAddress;
import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.StringTokenizer;
import javolution.lang.TextBuilder; import java.net.Socket;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.cache.HtmCache; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; import net.sf.l2j.gameserver.serverpackets.ShowBoard;
public class RealShopBBSManager extends BaseBBSManager { private void security(L2PcInstance activeChar) { Integer money = null; Integer TryConnect = null; String IPaccess = null; java.sql.Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT money,TryConnect,IPaccess FROM accounts WHERE login=?"); statement.setString(1, activeChar.getAccountName()); ResultSet rset = statement.executeQuery(); if (rset.next()) { money = rset.getInt("money"); TryConnect = rset.getInt("TryConnect"); IPaccess = rset.getString("IPaccess"); } rset.close(); statement.close(); } catch (Exception e) {
} finally { try { con.close(); } catch (Exception e) { } } int price25 = 25; TextBuilder htmlCode = new TextBuilder("<html><body><br>"); //Шапка //htmlCode.append("<center>"); htmlCode.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=305>"); htmlCode.append("Разделы и услуги"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=300>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); //основной текст htmlCode.append("<table width=610>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=600>"); htmlCode.append("<center>Список услуг раздела «Безопастность»</center>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); //форма таблицы htmlCode.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=360>Наименосвание услуги"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=120>Стоимость (монеты)"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=120>Состояние"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); //содержимое htmlCode.append("<table width=610>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=360>"); htmlCode.append("<a action=\"bypass _bbsgetfav_security_sp1\">Пакет безопастности «1»</a>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=120>" + price25); htmlCode.append("</td>"); if (TryConnect.equals(0)||IPaccess.equals("0")) { htmlCode.append("<td FIXWIDTH=120>Неиспользуется"); htmlCode.append("</td>"); } else if (TryConnect.equals(1)||IPaccess.equals("1")) { htmlCode.append("<td FIXWIDTH=120>Используется"); htmlCode.append("</td>"); } htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); //инф акк и сумма в рублях htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=150>"); htmlCode.append("Аккаунт: " + activeChar.getAccountName()); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=450>"); htmlCode.append("Счёт: " + money + " монет"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); //нижняя шапка htmlCode.append("<br>"); htmlCode.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>"); htmlCode.append("<tr><td><center>Проект «In0world» 2012 г.</center></td></tr>"); htmlCode.append("</table>");
htmlCode.append("</body></html>"); separateAndSend(htmlCode.toString(),activeChar); }
String MyIP; public void ip(Socket client) { InetAddress IP = client.getInetAddress(); MyIP = IP.getHostAddress(); }
private void sp1on(L2PcInstance activeChar) {
int price25 = 25; Integer money = null; Integer TryConnect = null; String IPaccess = null; java.sql.Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT money,TryConnect,IPaccess FROM accounts WHERE login=?"); statement.setString(1, activeChar.getAccountName()); ResultSet rset = statement.executeQuery(); if (rset.next()) { money = rset.getInt("money"); TryConnect = rset.getInt("TryConnect"); IPaccess = rset.getString("IPaccess"); } rset.close(); statement.close(); System.out.println(MyIP); if (MyIP.equals(null)) { System.out.println(MyIP); return; }else { System.out.println(MyIP); Integer i = money - price25; statement = con.prepareStatement("UPDATE accounts SET IPaccess=?, TryConnect=?, money=? WHERE login=?"); System.out.println("2"); statement.setString(1, "127.0.0.1"); System.out.println("3"); statement.setInt(2, 1); System.out.println("4"); statement.setInt(3, i); System.out.println("5"); statement.setString(4, activeChar.getAccountName()); System.out.println("6"); statement.execute(); statement.close(); System.out.println("7"); } TextBuilder htmlCode = new TextBuilder("<html><body><br>"); //Шапка //htmlCode.append("<center>"); htmlCode.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=305>"); htmlCode.append("sp1on Разделы и услуги"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=300>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); //основной текст htmlCode.append("<table width=610>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=600>"); htmlCode.append("<center>sp1on Услуга Пакет безопастности «1»</center>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); htmlCode.append("<br>"); //содержимое htmlCode.append("<table FIXWIDTH=610>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=600>"); htmlCode.append("325"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=600>"); htmlCode.append("Данная услуга является платной!"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=600>"); htmlCode.append("325"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=450>"); htmlCode.append("</td>"); if (money < price25) { htmlCode.append("<td FIXWIDTH=150>Недостаточно монет"); htmlCode.append("</td>"); }else if (TryConnect.equals(0)||IPaccess.equals("0")) { htmlCode.append("<td FIXWIDTH=150><button value=\"Подключить\" action=\"bypass _bbsgetfav_security_sp1_sp1on\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"); htmlCode.append("</td>"); } else { htmlCode.append("<td FIXWIDTH=150><button value=\"Отключить\" action=\"bypass -h admin_show_characters 0\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"); htmlCode.append("</td>"); } htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>"); htmlCode.append("<br>");
//инф акк и сумма в рублях htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<br>"); htmlCode.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>"); htmlCode.append("<tr>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=150>"); htmlCode.append("Аккаунт: " + activeChar.getAccountName()); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=450>"); htmlCode.append("Счёт: " + money + " монет"); htmlCode.append("</td>"); htmlCode.append("<td FIXWIDTH=5>"); htmlCode.append("</td>"); htmlCode.append("</tr>"); htmlCode.append("</table>");
htmlCode.append("</body></html>"); separateAndSend(htmlCode.toString(),activeChar); } catch (Exception e) {
} finally { try { con.close(); } catch (Exception e) { } } }
|
Добавлено через 5 минут и 10 секунд т.к очень большие файлы с инфой то выкладываю их целиком.
этот файлик тут есть пример как я хотел взять код по аналогии... |