Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

PIN Security

Iniciado por fissban, Jul 25, 2025, 11:48 PM

Tema anterior - Siguiente tema

fissban

No puedes ver este adjunto.

### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/scripts/handlers/voicedcommandhandlers/Seguridad.java
===================================================================
--- dist/game/data/scripts/handlers/voicedcommandhandlers/Seguridad.java    (revision 0)
+++ dist/game/data/scripts/handlers/voicedcommandhandlers/Seguridad.java    (working copy)
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack 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.
+ * 
+ * L2J DataPack 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/>.
+ */
+
+/**
+ * 
+ * @author fissban
+ * 
+ */
+
+package handlers.voicedcommandhandlers;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+public class Seguridad implements IVoicedCommandHandler
+{
+    
+    private static final String[] _voicedCommands =
+    {
+        "firstlogin",
+        "nextlogin",
+        "changecorreo"
+    };
+    
+    @Override
+    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String texto)
+    {
+        
+        /**
+         * Comando para el primer login del char. Necesita insertar datos en la DB
+         */
+        if (command.equalsIgnoreCase("firstlogin") || command.startsWith("firstlogin"))
+        {
+            StringTokenizer st = new StringTokenizer(texto);
+            try
+            {
+                String correo = null;
+                String repeatcorreo = null;
+                if (st.hasMoreTokens())
+                {
+                    correo = st.nextToken();
+                }
+                if (st.hasMoreTokens())
+                {
+                    repeatcorreo = st.nextToken();
+                }
+                
+                if (!((correo == null) || (repeatcorreo == null)))
+                {
+                    if (!correo.equals(repeatcorreo))
+                    {
+                        insertarDatos(activeChar.getObjectId(), "");
+                        activeChar.sendMessage("Los datos ingresados no coinciden!!");
+                        activeChar.sendMessage("En tu proximo login");
+                        activeChar.sendMessage("deveras dejarlo en blanco");
+                        activeChar.sendMessage("Para ingresar un correo usa .changecorreo!");
+                        activeChar.getAppearance().setVisible();
+                        activeChar.setIsParalyzed(false);
+                        return true;
+                    }
+                    // else
+                    insertarDatos(activeChar.getObjectId(), correo);
+                    activeChar.sendMessage("Has ingresado los datos correctamente!");
+                    activeChar.sendMessage("Recuerda que cada vez q ingreses te pediremos este correo!");
+                    activeChar.getAppearance().setVisible();
+                    activeChar.setIsParalyzed(false);
+                    return true;
+                    
+                }
+                // else
+                insertarDatos(activeChar.getObjectId(), "");
+                activeChar.sendMessage("Has olvidado completar un campo!!");
+                activeChar.sendMessage("Para ingresar un correo usa .changecorreo!");
+                activeChar.getAppearance().setVisible();
+                activeChar.setIsParalyzed(false);
+                return true;
+            }
+            catch (Exception e)
+            {
+                activeChar.sendMessage("un problema ocurrido durante la grabacion de datos!");
+                _log.log(Level.WARNING, "", e);
+            }
+        }
+        
+        /**
+         * Verificacion del correo del char Necesita leer datos de la DB
+         */
+        if (command.equalsIgnoreCase("nextlogin") || command.startsWith("nextlogin"))
+        {
+            String repeatcorreo = null;
+            
+            StringTokenizer st = new StringTokenizer(texto);
+            try
+            {
+                if (st.hasMoreTokens())
+                {
+                    repeatcorreo = st.nextToken();
+                }
+                String correo = leerDatos(activeChar.getObjectId());
+                
+                if (correo.equals(repeatcorreo))
+                {
+                    activeChar.getAppearance().setVisible();
+                    activeChar.setIsParalyzed(false);
+                    activeChar.sendMessage("La verificacion de datos es Correcta!");
+                    return true;
+                }
+                activeChar.sendMessage("La verificacion de datos es Incorrecta!");
+                activeChar.getClient().closeNow();
+                return true;
+            }
+            catch (Exception e)
+            {
+                activeChar.sendMessage("un problema ocurrido durante la lectura de datos!");
+                _log.log(Level.WARNING, "", e);
+            }
+            
+        }
+        return true;
+    }
+    
+    /**
+     * @param _accountId
+     * @param _correo
+     * @return
+     */
+    
+    public boolean insertarDatos(int _accountId, String _correo)
+    {
+        
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement statement = con.prepareStatement("INSERT INTO correo (charId,correo) values (?,?)"))
+        {
+            statement.setInt(1, _accountId);
+            statement.setString(2, _correo);
+            statement.execute();
+        }
+        catch (SQLException e)
+        {
+            _log.severe("error al grabar datos " + e.getMessage());
+        }
+        
+        return true;
+    }
+    
+    /**
+     * @param _accountId
+     * @return
+     */
+    
+    public String leerDatos(int _accountId)
+    {
+        String _correo = null;
+        
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement ps = con.prepareStatement("SELECT correo FROM correo WHERE charId=?"))
+        {
+            ps.setInt(1, _accountId);
+            try (ResultSet rs = ps.executeQuery())
+            {
+                while (rs.next())
+                {
+                    _correo = rs.getString(1);
+                }
+            }
+        }
+        catch (SQLException e)
+        {
+            _log.severe("error al leer el correo: " + e.getMessage());
+        }
+        return _correo;
+    }
+    
+    @Override
+    public String[] getVoicedCommandList()
+    {
+        return _voicedCommands;
+    }
+}
\ No newline at end of file
### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/html/seguridad/seguridad-1.htm
===================================================================
--- dist/game/data/html/seguridad/seguridad-1.htm    (revision 0)
+++ dist/game/data/html/seguridad/seguridad-1.htm    (working copy)
@@ -0,0 +1,33 @@
+<html><title>AdminsProL2</title><body>
+<center>
+    <!-- test -->
+    <table border=0 cellpadding=0 cellspacing=0>
+        <tr><td width=256 height=185 background="L2UI_CT1.OlympiadWnd_DF_GrandTexture"></td></tr>
+    </table>
+    <!-- test -->
+    
+<font color = "33FF66">Bienvenid@ usuari@</font>
+
+<img src="L2UI_CH3.herotower_deco" width=256 height=1><br>
+<br>
+
+Ingrese su Correo de seguridad:
+
+<br><tr>Su Correo:</tr>
+<tr><edit type="seguridad" var="repeatcorreo" width=150></tr><br>
+
+<button value=" Continuar " action="bypass -h voice .nextlogin $repeatcorreo" width=200 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></tr></td>
+
+
+<img src="L2UI.SquareWhite" width=256 height=1><br>
+
+<br><font color = "3ADF00">ADVERTENCIA!!</font>
+
+<br><font color = "FFFF00">Si fallas en la verificacion</font>
+<br><font color = "FFFF00">seras desconectado del juego</font>
+
+<br></font>
+<br>
+</center>
+</body>
+</html>
\ No newline at end of file
Index: dist/game/data/html/seguridad/seguridad.htm
===================================================================
--- dist/game/data/html/seguridad/seguridad.htm    (revision 0)
+++ dist/game/data/html/seguridad/seguridad.htm    (working copy)
@@ -0,0 +1,37 @@
+<html><title>AdminsProL2</title><body>
+<center>
+    <!-- test -->
+    <table border=0 cellpadding=0 cellspacing=0>
+        <tr><td width=256 height=185 background="L2UI_CT1.OlympiadWnd_DF_GrandTexture"></td></tr>
+    </table>
+    <!-- test -->
+    
+<font color = "33FF66">Bienvenid@ usuari@</font>
+
+<img src="L2UI_CH3.herotower_deco" width=256 height=1><br>
+<br>
+
+Ingrese su Correo de seguridad:
+
+<br><tr>Su Correo:</tr>
+<tr><edit type="seguridad" var="correo" width=150></tr><br>
+<br><tr>Confirme su Correo:</tr>
+<tr><edit type="seguridad" var="repeatcorreo" width=150></tr><br>
+
+
+<button value=" Continuar " action="bypass -h voice .firstlogin $correo $repeatcorreo" width=200 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></tr></td>
+
+
+<img src="L2UI.SquareWhite" width=256 height=1><br>
+
+<br><font color = "3ADF00">ADVERTENCIA!!</font>
+
+<br><font color = "FFFF00">Pueden usar cualquier tipo de correo </font>
+<br><font color = "FFFF00">Cada vez que logen se les pedira</font>
+<br><font color = "FFFF00">este correo para la seguridad de su personaje</font>
+
+<br></font>
+<br>
+</center>
+</body>
+</html>
\ No newline at end of file
### Eclipse Workspace Patch 1.0
#P L2J_Server_BETA
Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java    (revision 5761)
+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java    (working copy)
@@ -475,8 +497,38 @@
         SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
         Announcements.getInstance().showAnnouncements(activeChar);
         
-        if (showClanNotice)
+        /**
+         * Solo en el primer login el usuario tendra 0 exp asiq sera cuando se active el sistema de grabado luego se le setea 1 de exp por si decide salir del juego sin haber ganado exp por sus propios medios Era esta opcion o editar la tabla characters agregando una columna con un valor de 1 o 0
+         * para definir su login de esta forma evitamos mas lecturas en la DB y modificar las tablas propias de l2jserver. by Fissban
+         */
+        // addons correo de seguridad
+        if (Config.USE_CORREO_SEGURIDAD)
         {
+            activeChar.getAppearance().setInvisible();
+            activeChar.setIsParalyzed(true);
+            
+            if (activeChar.getExp() == 0)
+            {
+                activeChar.setExp(1);
+                String firstlogin = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/seguridad/seguridad.htm");
+                if (firstlogin != null)
+                {
+                    sendPacket(new NpcHtmlMessage(1, firstlogin));
+                }
+            }
+            else
+            {
+                String nextlogin = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/seguridad/seguridad-1.htm");
+                if (nextlogin != null)
+                {
+                    nextlogin.replace("%name%", activeChar.getName());
+                    sendPacket(new NpcHtmlMessage(1, nextlogin));
+                }
+            }
+            
+        }
+        else if (showClanNotice)
+        {
             NpcHtmlMessage notice = new NpcHtmlMessage(1);
             notice.setFile(activeChar.getHtmlPrefix(), "data/html/clanNotice.htm");
             notice.replace("%clan_name%", activeChar.getClan().getName());
### Eclipse Workspace Patch 1.0
#P L2J_Server_BETA
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java    (revision 5761)
+++ java/com/l2jserver/Config.java    (working copy)

@@ -85,6 +88,7 @@
     public static final String SERVER_VERSION_FILE = "./config/l2j-version.properties";
     public static final String DATAPACK_VERSION_FILE = "./config/l2jdp-version.properties";
     public static final String L2JMOD_CONFIG_FILE = "./config/L2JMods.properties";
+    public static final String L2JADMINSPROL2_CONFIG_FILE = "./config/Adminsprol2.properties"; // by Fissban
     public static final String LOGIN_CONFIGURATION_FILE = "./config/LoginServer.properties";
     public static final String NPC_CONFIG_FILE = "./config/NPC.properties";
     public static final String PVP_CONFIG_FILE = "./config/PVP.properties";

@@ -674,7 +683,153 @@
     public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
     public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
     
+    // -------------------------------------------------
+    // L2AdminsproL2 Settings
+    // -------------------------------------------------
+    // Sistema de seguridad al logear
+    public static boolean USE_CORREO_SEGURIDAD;
@@ -2688,6 +2860,227 @@
             }
             L2JMOD_ALLOW_CHANGE_PASSWORD = Boolean.parseBoolean(L2JModSettings.getProperty("AllowChangePassword", "False"));
             
+            // -----------------------
+            // Config By Fissban START
+            // -----------------------
+            
+            // Load Config L2AdminsproL2 L2Properties file (if exists)
+            L2Properties Adminsprol2Settings = new L2Properties();
+            final File Adminsprol2 = new File(L2JADMINSPROL2_CONFIG_FILE);
+            try (InputStream is = new FileInputStream(Adminsprol2))
+            {
+                Adminsprol2Settings.load(is);
+            }
+            catch (Exception e)
+            {
+                _log.log(Level.SEVERE, "Error while loading L2JMod settings!", e);
+            }
+            
+            USE_CORREO_SEGURIDAD = Boolean.parseBoolean(Adminsprol2Settings.getProperty("SeguridadCorreo", "True"));
### Eclipse Workspace Patch 1.0
#P L2J_Server_BETA
Index: dist/game/config/Adminsprol2.properties
===================================================================
--- dist/game/config/Adminsprol2.properties    (revision 0)
+++ dist/game/config/Adminsprol2.properties    (working copy)
@@ -0,0 +1,289 @@
+# Creditos Fissban
+# Sistema de seguridad basado en verificacion de correo electronico
+# En el primer login en el juego se pedira al usuario un correo q sera grabado en la DB
+# el mismo sera requerido con cada login y podra ser modificado por medio de .changecorreo
+# Deven tener en cuenta q este config desactivara el sistema de servernew y noticias de clan
+SeguridadCorreo = true
### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/sql/game/correo.sql
===================================================================
--- dist/sql/game/correo.sql    (revision 0)
+++ dist/sql/game/correo.sql    (working copy)
@@ -0,0 +1,5 @@
+CREATE TABLE IF NOT EXISTS `correo` (
+  `charId` int(10) NOT NULL,
+  `correo` VARCHAR(35) NOT NULL,
+  PRIMARY KEY (`charId`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
\ No newline at end of file

By Fissban