Some help in JSP Script

Results 1 to 2 of 2
  1. #1
    Apprentice evandroga is offline
    MemberRank
    Aug 2011 Join Date
    20Posts

    smile Some help in JSP Script

    Hello
    I'm trying to create a script in jsp, based in the archives of pwAdmin that will search for an item in the bank and , based on the amount of items, will give a reward. I am wanting to use it in a promotion like "At the bank your coins are worth more Cubis". In logic is to check for" perfect coupons "in the first slot of each bank char, add up all and multiply by 1500 Cubis (15 Golds). Since I can not virtually nothing in jsp, I hope someone more experienced can guide me and to implement this idea if it is really useful.
    Here's what I did, no big deal but I hope those who help me to improve:
    <%@page import="java.io.*"%>
    <%@page import="java.sql.*"%>
    <%@page import="protocol.*"%>
    <%@page import="java.io.*"%>
    <%@page import="java.text.*"%>
    <%@page import="java.lang.*"%>
    <%@page import="java.util.Calendar.*"%>
    <%@page import="java.util.*"%>
    <%@page import="java.util.Iterator"%>
    <%@page import="com.goldhuman.Common.Octets"%>
    <%@page import="com.goldhuman.IO.Protocol.Rpc.Data.DataVector"%>
    <%@page import="org.apache.commons.lang.StringEscapeUtils"%>
    <%@include file="../WEB-INF/.pwadminconf.jsp"%>

    <%
    //==============================
    //First of all, stop the server
    //==============================
    Process p;
    String command;
    File working_directory;

    try
    {
    command = pw_server_path + "gamedbd/./gamedbd " + pw_server_path + "gamedbd/gamesys.conf exportclsconfig";
    working_directory = new File(pw_server_path + "gamedbd/");
    p = Runtime.getRuntime().exec(command, null, working_directory);
    p.waitFor();
    Thread.sleep(1000);

    Runtime.getRuntime().exec("pkill -9 gs");
    Runtime.getRuntime().exec("pkill -9 glinkd");
    Runtime.getRuntime().exec("pkill -9 gdeliveryd");
    Runtime.getRuntime().exec("pkill -9 gfactiond");
    Runtime.getRuntime().exec("pkill -9 gacd");
    Runtime.getRuntime().exec("pkill -9 gamedbd");
    Runtime.getRuntime().exec("pkill -9 uniquenamed");
    p = Runtime.getRuntime().exec("ps -A w");
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while((line = input.readLine()) != null)
    {
    if(line.indexOf("authd") != -1)
    {
    Runtime.getRuntime().exec("kill " + line.substring(0, 5).replace(" ", ""));
    }
    }
    Runtime.getRuntime().exec("pkill -9 logservice");
    Runtime.getRuntime().exec("sync");
    Thread.sleep(6000);
    //==============================
    //Start the search
    //==============================
    //Heare is to list the accounts, chars and search for the item
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection connection = DriverManager.getConnection("jdbc:mysql://" + db_host + ":" + db_port + "/" + db_database, db_user, db_password);
    Statement statement = connection.createStatement();
    Statement update = connection.createStatement();
    ResultSet rs;
    rs = (statement.executeQuery("SELECT ID FROM users"));
    while(rs.next())
    {
    // Get all character of current userid
    DataVector dv = GameDB.getRolelist(rs.getInt("ID"));
    if(dv != null)
    {
    Iterator itr = dv.iterator();
    while(itr.hasNext())
    {
    IntOctets ios = (IntOctets)itr.next();
    chr = GameDB.get(ios.m_int);
    }
    }
    }

    //======================================
    //End of the search - It's incomplet :(
    //======================================
    }
    catch(Exception e)
    {
    message = "<font color=\"#ee0000\"><b>Something is wrong!</b></font>";
    }

    //==============================
    //And now start the server
    //==============================
    File f = new File(pw_server_path + "iweb_starter.sh");
    try
    {
    FileWriter fw = new FileWriter(f);
    fw.write("if [ ! -d " + pw_server_path + "logs ]; then\n");
    fw.write("mkdir " + pw_server_path + "logs\n");
    fw.write("fi\n");
    fw.write("cd " + pw_server_path + "logservice; ./logservice logservice.conf >" + pw_server_path + "logs/logservice.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "uniquenamed; ./uniquenamed gamesys.conf >" + pw_server_path + "logs/uniquenamed.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "authd/; ./authd >" + pw_server_path + "logs/auth.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamedbd; ./gamedbd gamesys.conf >" + pw_server_path + "logs/gamedbd.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gacd; ./gacd gamesys.conf >" + pw_server_path + "logs/gacd.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gfactiond; ./gfactiond gamesys.conf >" + pw_server_path + "logs/gfactiond.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gdeliveryd; ./gdeliveryd gamesys.conf >" + pw_server_path + "logs/gdeliveryd.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 1 >" + pw_server_path + "logs/glink1.log &\n");
    fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 2 >" + pw_server_path + "logs/glink2.log &\n");
    fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 3 >" + pw_server_path + "logs/glink3.log &\n");
    fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 4 >" + pw_server_path + "logs/glink4.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs gs01 >" + pw_server_path + "logs/gs01.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is11 >" + pw_server_path + "logs/is11.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is14 >" + pw_server_path + "logs/is14.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is15 >" + pw_server_path + "logs/is15.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is16 >" + pw_server_path + "logs/is16.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is17 >" + pw_server_path + "logs/is17.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is19 >" + pw_server_path + "logs/is19.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is21 >" + pw_server_path + "logs/is21.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is22 >" + pw_server_path + "logs/is22.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is23 >" + pw_server_path + "logs/is23.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is24 >" + pw_server_path + "logs/is24.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is25 >" + pw_server_path + "logs/is25.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is26 >" + pw_server_path + "logs/is26.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is27 >" + pw_server_path + "logs/is27.log &\n");
    fw.write("sleep 1\n");
    fw.write("cd " + pw_server_path + "gamed; ./gs is31 >" + pw_server_path + "logs/is31.log &\n");
    fw.write("sleep 1\n");
    fw.write("rm foo\n");
    fw.write("sleep 1");
    fw.close();

    command = "sh " + pw_server_path + "iweb_starter.sh";
    working_directory = new File(pw_server_path);
    Runtime.getRuntime().exec("chmod 777 " + pw_server_path + "iweb_starter.sh");
    Runtime.getRuntime().exec(command, null, working_directory);
    Thread.sleep(12000);
    f.delete();
    }
    catch(Exception e)
    {
    f.delete();
    message = "<font color=\"#ee0000\"><b>Something is wrong!</b></font>" + e.getMessage();
    }


  2. #2
    [B]aSH nofxpunkerbrian is offline
    MemberRank
    Apr 2009 Join Date
    1,151Posts

    Re: Some help in JSP Script

    The above is just the start scripts....



Advertisement