Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.69 KB | None | 0 0
  1. <%@page contentType="text/html; charset=UTF-8"%>
  2. <%@page import="java.sql.*"%>
  3. <%@page import="java.util.*"%>
  4. <%@page import="java.security.*"%>
  5. <%@page import="java.io.*"%>
  6. <%@page import="java.text.*"%>
  7. <%@page import="java.lang.*"%>
  8. <%@page import="java.util.Calendar.*"%>
  9. <%@page import="com.goldhuman.util.*" %>
  10. <%@page import="protocol.*"%>
  11. <%@page import="com.goldhuman.auth.*"%>
  12. <%@page import="org.apache.commons.logging.Log"%>
  13. <%@page import="org.apache.commons.logging.LogFactory"%>
  14. <%@page import="com.goldhuman.util.LocaleUtil" %>
  15. <%@include file="/include/.config.jsp"%>
  16.  
  17. <html>
  18. <head>
  19. <link href="../iweb/include/style.css" rel="stylesheet" type="text/css">
  20. <title>Управление аккаунтами</title>
  21. <%@include file="/include/header.jsp"%>
  22. </head>
  23. <body style="background-color:#ffffff;">
  24. <div align="center"><font size="5">Управление аккаунтами</font>
  25. <table width="800" border="0" cellspacing="0">
  26.  
  27. <%
  28.     String message = "<br>";
  29.     if(request.getParameter("action") != null)
  30.     {
  31.             String action = new String(request.getParameter("action"));
  32.  
  33.  
  34.             if(action.compareTo("changegm") == 0)
  35.             {
  36.                     String type = request.getParameter("type");
  37.                     String ident = request.getParameter("ident");
  38.                     String truename = request.getParameter("truename");
  39.                     String act = request.getParameter("act");
  40.  
  41.                     if(type.length() > 0 && ident.length() > 0 && act.length() > 0)
  42.                     {
  43.                         try
  44.                         {
  45.                             Class.forName("com.mysql.jdbc.Driver").newInstance();
  46.                             Connection connection = DriverManager.getConnection("jdbc:mysql://" + db_host + ":" + db_port + "/" + db_database, db_user, db_password);
  47.                             Statement statement = connection.createStatement();
  48.                             ResultSet rs;
  49.                             int count;
  50.  
  51.                             if(type.compareTo("id") == 0)
  52.                             {
  53.                                 rs = statement.executeQuery("SELECT ID FROM users WHERE ID='" + ident + "'");
  54.                                 count = 0;
  55.                                 while(rs.next())
  56.                                 {
  57.                                     count++;
  58.                                 }
  59.                             }
  60.  
  61.                             else
  62.                             {
  63.                                 rs = statement.executeQuery("SELECT ID FROM users WHERE name='" + ident + "'");
  64.                                 count = 0;
  65.                                 while(rs.next())
  66.                                 {
  67.                                     ident = rs.getString("ID");
  68.                                     count++;
  69.                                 }
  70.                             }
  71.  
  72.                             if(count <= 0)
  73.                             {
  74.                                 message = "<font color=\"ee0000\">Пользователя не существует</font>";
  75.                             }
  76.                             else
  77.                             {
  78.                                 rs = statement.executeQuery("SELECT userid FROM auth WHERE userid='" + ident + "'");
  79.                                 count = 0;
  80.                                 while(rs.next())
  81.                                 {
  82.                                     count++;
  83.                                 }
  84.                                 if(count > 0)
  85.                                 {
  86.                                     if(act.compareTo("delete") == 0)
  87.                                     {
  88.                                         statement.executeUpdate("DELETE FROM auth WHERE userid='" + ident + "'");
  89.                                         message = "<font color=\"00cc00\">Права GM сняты с пользователя</font>";
  90.                                     }
  91.                                     else
  92.                                     {
  93.                                         message = "<font color=\"ee0000\">Пользователь Уже GM</font>";
  94.                                     }
  95.                                 }
  96.                                 else
  97.                                 {
  98.                                     if(act.compareTo("add") == 0)
  99.                                     {
  100.                                         rs = statement.executeQuery("call addGM('" + ident + "', '1')");
  101.                                         message = "<font color=\"00cc00\">Права GM выданы пользователю</font>";
  102.                                     }
  103.                                     else
  104.                                     {
  105.                                         message = "<font color=\"ee0000\">Доступ к GM Недоступен</font>";
  106.                                     }
  107.                                 }
  108.                             }
  109.  
  110.                             rs.close();
  111.                             statement.close();
  112.                             connection.close();
  113.                         }
  114.                         catch(Exception e)
  115.                         {
  116.                             message = "<font color=\"#ee0000\"><b>Подключиться к базе данных MySQL не удалось</b></font>";
  117.                         }
  118.                     }
  119.                     else ;
  120.             }
  121.             else ;
  122.  
  123.             if(action.compareTo("addcubi") == 0)
  124.             {
  125.                     String type = request.getParameter("type");
  126.                     String ident = request.getParameter("ident");
  127.                     int amount = 0;
  128.                     try
  129.                     {
  130.                         amount = Integer.parseInt(request.getParameter("amount"));
  131.                     }
  132.                     catch(Exception e)
  133.                     {}
  134.  
  135.                     if(type.length() > 0 && ident.length() > 0)
  136.                     {
  137.                         if(amount < 1 || amount > 999999999)
  138.                         {
  139.                             message = "<font color=\"ee0000\">Неверное количество (1-999999999)</font>";
  140.                         }
  141.                         else
  142.                         {
  143.                             try
  144.                             {
  145.                                 Class.forName("com.mysql.jdbc.Driver").newInstance();
  146.                                 Connection connection = DriverManager.getConnection("jdbc:mysql://" + db_host + ":" + db_port + "/" + db_database, db_user, db_password);
  147.                                 Statement statement = connection.createStatement();
  148.                                 ResultSet rs;
  149.                                 int count;
  150.  
  151.                                 if(type.compareTo("id") == 0)
  152.                                 {
  153.                                     rs = statement.executeQuery("SELECT ID FROM users WHERE ID='" + ident + "'");
  154.                                     count = 0;
  155.                                     while(rs.next())
  156.                                     {
  157.                                         count++;
  158.                                     }
  159.                                 }
  160.  
  161.                                 else
  162.                                 {
  163.                                     rs = statement.executeQuery("SELECT ID FROM users WHERE name='" + ident + "'");
  164.                                     count = 0;
  165.                                     while(rs.next())
  166.                                     {
  167.                                         ident = rs.getString("ID");
  168.                                         count++;
  169.                                     }
  170.                                 }
  171.  
  172.                                 if(count <= 0)
  173.                                 {
  174.                                     message = "<font color=\"ee0000\">Пользователь не существует</font>";
  175.                                 }
  176.                                 else
  177.                                 {
  178.                                     rs = statement.executeQuery("CALL usecash ( '" + ident + "' , 1, 0, 1, 0, '" + 100*amount + "', 1, @error)");
  179.                                     message = "<font color=\"00cc00\">" + amount + ".00 GOLD Добавлено</font><br><font color=\"ee0000\">Транзакция может занять до 5 минут<br>Relog, необходимые для получения GOLD</font>";
  180.                                 }
  181.                                
  182.                                 rs.close();
  183.                                 statement.close();
  184.                                 connection.close();
  185.                             }
  186.                             catch(Exception e)
  187.                             {
  188.                                 message = "<font color=\"#ee0000\"><b>Подключиться к базе данных MySQL не удалось</b></font>";
  189.                             }
  190.                         }
  191.                     }
  192.                     else ;
  193.             }
  194.             else ;
  195.            
  196.             if(action.compareTo("enhance") == 0)
  197.             {
  198.                     String type = request.getParameter("type");
  199.                     String ident = request.getParameter("ident");
  200.                     String truename = request.getParameter("truename");
  201.                     String act = request.getParameter("act");
  202.  
  203.                     if(type.length() > 0 && ident.length() > 0 && act.length() > 0)
  204.                     {
  205.                         try
  206.                         {
  207.                             Class.forName("com.mysql.jdbc.Driver").newInstance();
  208.                             Connection connection = DriverManager.getConnection("jdbc:mysql://" + db_host + ":" + db_port + "/" + db_database, db_user, db_password);
  209.                             Statement statement = connection.createStatement();
  210.                             ResultSet rs;
  211.                             int count;
  212.  
  213.                             if(type.compareTo("id") == 0)
  214.                             {
  215.                                 rs = statement.executeQuery("SELECT ID FROM users WHERE ID='" + ident + "'");
  216.                                 count = 0;
  217.                                 while(rs.next())
  218.                                 {
  219.                                     count++;
  220.                                 }
  221.                             }
  222.  
  223.                             else
  224.                             {
  225.                                 rs = statement.executeQuery("SELECT ID FROM users WHERE name='" + ident + "'");
  226.                                 count = 0;
  227.                                 while(rs.next())
  228.                                 {
  229.                                     ident = rs.getString("ID");
  230.                                     count++;
  231.                                 }
  232.                             }
  233.  
  234.                             if(count <= 0)
  235.                             {
  236.                                 message = "<font color=\"ee0000\">User Don't Exists</font>";
  237.                             }
  238.                             else
  239.                             {
  240.                                 rs = statement.executeQuery("SELECT userid FROM enhanced WHERE userid='" + ident + "'");
  241.                                 count = 0;
  242.                                 while(rs.next())
  243.                                 {
  244.                                     count++;
  245.                                 }
  246.                                 if(count > 0)
  247.                                 {
  248.                                     if(act.compareTo("delete") == 0)
  249.                                     {
  250.                                         statement.executeUpdate("DELETE FROM enhanced WHERE userid='" + ident + "'");
  251.                                         message = "<font color=\"00cc00\">Enhancement Removed From User</font>";
  252.                                     }
  253.                                     else
  254.                                     {
  255.                                         message = "<font color=\"ee0000\">User is Already enhanced</font>";
  256.                                     }
  257.                                 }
  258.                                 else
  259.                                 {
  260.                                     if(act.compareTo("farmer") == 0)
  261.                                     {
  262.                                         rs = statement.executeQuery("CALL addEnhanced('" + ident + "', '" + truename + "', '2')");
  263.                                         message = "<font color=\"00cc00\">User has been enhanced to farmer</font>";
  264.                                     }
  265.                                     if(act.compareTo("soldier") == 0)
  266.                                     {
  267.                                         rs = statement.executeQuery("CALL addEnhanced('" + ident + "', '" + truename + "', '3')");
  268.                                         message = "<font color=\"00cc00\">User has been enhanced to Soldier</font>";
  269.                                     }
  270.                                     if(act.compareTo("merchant") == 0)
  271.                                     {
  272.                                         rs = statement.executeQuery("CALL addEnhanced('" + ident + "', '" + truename + "', '4')");
  273.                                         message = "<font color=\"00cc00\">User has been enhanced to Merchant</font>";
  274.                                     }
  275.                                     if(act.compareTo("hero") == 0)
  276.                                     {
  277.                                         rs = statement.executeQuery("CALL addEnhanced('" + ident + "', '" + truename + "', '5')");
  278.                                         message = "<font color=\"00cc00\">User has been enhanced to Hero</font>";
  279.                                     }
  280.                                     else
  281.                                     {
  282.                                         message = "<font color=\"ee0000\">User is not enhanced</font>";
  283.                                     }
  284.                                 }
  285.                             }
  286.  
  287.                             rs.close();
  288.                             statement.close();
  289.                             connection.close();
  290.                         }
  291.                         catch(Exception e)
  292.                         {
  293.                             message = "<font color=\"#ee0000\"><b>Подключиться к базе данных MySQL не удалось</b></font>";
  294.                         }
  295.                     }
  296.                     else ;
  297.             }
  298.             else ;
  299.     }
  300.     else ;
  301. %>
  302.  
  303. <table width="800" cellpadding="0" cellspacing="0" border="0">
  304.  
  305. <tr>
  306.     <td height="1" align="center" valign="top" colspan="3">
  307.         <b><% out.print(message); %></b>
  308.     </td>
  309. </tr>
  310.  
  311. <tr>
  312.     <td height="1" align="center" valign="top" colspan="3">
  313.         <br>
  314.     </td>
  315. </tr>
  316.  
  317. <tr>
  318.     <td height="1" colspan="3">
  319.         <br>
  320.     </td>
  321. </tr>
  322.  
  323. <tr>
  324.     <td align="center" valign="top">
  325.         <%
  326.                 out.println("<form action=\"index.jsp?page=account&action=changegm\" method=\"post\" style=\"margin: 0px;\"><table width=\"240\" cellpadding=\"5\" cellspacing=\"0\" style=\"border:1px solid #cccccc;\">");
  327.                 out.println("<tr><th align=\"center\" colspan=\"2\"><b><font color=\"#000000\">ИГРОВОЙ MASTER</font></b></th></tr>");
  328.                 out.println("<tr><td>Тип:</td><td align=\"right\"><select name=\"type\" style=\"width: 100; text-align: center;\"><option value=\"id\">ID</option><option value=\"login\">Login</option></select></td></tr>");
  329.                 out.println("<tr><td>Аккаунт (ID):</td><td align=\"right\"><input type=\"text\" name=\"ident\" style=\"width: 100; text-align: center;\"></td></tr>");
  330.                 out.println("<tr><td>Имя персонажа:</td><td align=\"right\"><input type=\"text\" name=\"truename\" style=\"width: 100; text-align: center;\"></td></tr>");
  331.                 out.println("<tr><td>Действие:</td><td align=\"right\"><select name=\"act\" style=\"width: 100; text-align: center;\"><option value=\"add\">Дать GM</option><option value=\"delete\">Убрать GM</option></select></td></tr>");
  332.                 out.println("<tr><td align=\"center\" colspan=\"2\"><input type=\"image\" name=\"submit\" src=\"include/btn_submit.jpg\" style=\"border: 0px;\"></td></tr>");
  333.                 out.println("</table></form>");
  334.         %>
  335.     </td>
  336.  
  337.     <td align="center" valign="top">
  338.         <%
  339.                 out.println("<form action=\"index.jsp?page=account&action=addcubi\" method=\"post\" style=\"margin: 0px;\"><table width=\"240\" cellpadding=\"5\" cellspacing=\"0\" style=\"border:1px solid #cccccc;\">");
  340.                 out.println("<tr><th align=\"center\" colspan=\"2\"><b><font color=\"#000000\">ЗАЧИСЛИТЬ GOLD</font></b></th></tr>");
  341.                 out.println("<tr><td>Тип:</td><td align=\"right\"><select name=\"type\" style=\"width: 100; text-align: center;\"><option value=\"id\">ID</option><option value=\"login\">Login</option></select></td></tr>");
  342.                 out.println("<tr><td>Аккаунт (ID):</td><td align=\"right\"><input type=\"text\" name=\"ident\" style=\"width: 100; text-align: center;\"></td></tr>");
  343.                 out.println("<tr><td>Количество:</td><td align=\"right\"><input type=\"text\" name=\"amount\" style=\"width: 100; text-align: center;\"></td></tr>");
  344.                 out.println("<tr><td align=\"center\" colspan=\"2\"><input type=\"image\" name=\"submit\" src=\"include/btn_submit.jpg\" style=\"border: 0px;\"></td></tr>");
  345.                 out.println("</table></form>");
  346.         %>
  347.     </td>
  348.  
  349.     <td align="center" valign="top">
  350.         <%
  351.                 out.println("<table cellpadding=\"0\" cellspacing=\"0\" style=\"border:1px solid #cccccc;\">");
  352.                 out.println("<tr><th height=\"1\" align=\"center\" colspan=\"3\" style=\"padding: 5;\"><b><font color=\"#000000\">СПИСОК АККАУНТА</font></b></th></tr>");
  353.                 out.println("<tr bgcolor=\"f0f0f0\"><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\"><b>ID</b></td><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\"><b>Имя</b></td><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\"><b>Время создания</b></td></tr>");
  354.                 out.println("<tr><td colspan=\"3\" ><div style=\"width: 280; height: 110; overflow: auto;\">");
  355.                 out.println("<table width=\"100%\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:0px solid #cccccc;\">");
  356.  
  357.                 try
  358.                 {
  359.                     Class.forName("com.mysql.jdbc.Driver").newInstance();
  360.                     Connection connection = DriverManager.getConnection("jdbc:mysql://" + db_host + ":" + db_port + "/" + db_database, db_user, db_password);
  361.                     Statement statement = connection.createStatement();
  362.                     ResultSet rs;
  363.  
  364.                     rs = statement.executeQuery("SELECT DISTINCT userid FROM auth");
  365.                     ArrayList gm = new ArrayList();
  366.  
  367.                     while(rs.next())
  368.                     {
  369.                         gm.add(rs.getInt("userid"));
  370.                     }
  371.  
  372.                     rs = statement.executeQuery("SELECT ID, name, creatime FROM users");
  373.                     while(rs.next())
  374.                     {
  375.                         if(gm.contains(rs.getInt("ID")))
  376.                         {
  377.                             out.print("<tr><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\">" + rs.getString("ID") + "</td><td style=\"border-bottom: 1px solid #cccccc;\"><font color=\"#ee0000\">" + rs.getString("name") + "</font></td><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\">" + rs.getString("creatime").substring(0, 16) + "</td></tr>");
  378.                         }
  379.                         else
  380.                         {
  381.                             out.print("<tr><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\">" + rs.getString("ID") + "</td><td style=\"border-bottom: 1px solid #cccccc;\">" + rs.getString("name") + "</td><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\">" + rs.getString("creatime").substring(0, 16) + "</td></tr>");
  382.                         }
  383.                     }
  384.  
  385.                     rs.close();
  386.                     statement.close();
  387.                     connection.close();
  388.                 }
  389.                 catch(Exception e)
  390.                 {
  391.                     out.println("<tr><td align=\"center\" style=\"border-bottom: 1px solid #cccccc;\"><font color=\"#ee0000\"><b>Подключиться к базе данных MySQL не удалось</b></font></table></div></td></tr>");
  392.                 }
  393.  
  394.                 out.println("</table></div></td></tr></table>");
  395.         %>
  396.     </td>
  397. </tr>
  398. </table>
  399. </div>
  400. </body>
  401. <%@include file="../include/foot.jsp"%>
  402. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement