首页
社区
课程
招聘
[旧帖] 求助JSP转php 0.00雪花
发表于: 2016-10-4 20:46 3000

[旧帖] 求助JSP转php 0.00雪花

2016-10-4 20:46
3000
要求转后 在代码中预留Q_Q联系方式
<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="java.util.*"%>
<%@page import="protocol.*"%>
<%@page import="com.goldhuman.Common.Octets"%>
<%@include file="../../WEB-INF/.pwadminconf.jsp"%>
<%!
	byte[] hextoByteArray(String x) {
		if (x.length() < 2) {
			return new byte[0];
		}
		if (x.length() % 2 != 0) {
			System.err.println("hextoByteArray error! hex size=" + Integer.toString(x.length()));
		}
		byte[] rb = new byte[x.length() / 2];
		for (int i = 0; i < rb.length; ++i) {
			rb[i] = 0;

			int n = x.charAt(i + i);
			if ((n >= 48) && (n <= 57)) {
				n -= 48;
			} else if ((n >= 97) && (n <= 102)) {
				n = n - 97 + 10;
			}
			rb[i] = (byte) (rb[i] | n << 4 & 0xF0);

			n = x.charAt(i + i + 1);
			if ((n >= 48) && (n <= 57)) {
				n -= 48;
			} else if ((n >= 97) && (n <= 102)) {
				n = n - 97 + 10;
			}
			rb[i] = (byte) (rb[i] | n & 0xF);
		}
		return rb;
	}
%>
<%
	String message = "<br>";
	
	if (request.getParameter("process") != null && request.getParameter("process").compareTo("mail") == 0) {
		if (request.getParameter("roleid") != "" && request.getParameter("title") != "" 
				&& request.getParameter("content") != "" && request.getParameter("coins") != "" ) {
			int roleid = Integer.parseInt(request.getParameter("roleid"));
			String title = request.getParameter("title");
			String content = request.getParameter("content");
			int coins = Integer.parseInt(request.getParameter("coins"));
			
			String itemids = request.getParameter("itemid");
			int itemnum = Integer.parseInt(request.getParameter("itemnum"));
			itemnum = itemnum > 0 ? itemnum : 1;
			String itemhex = request.getParameter("itemhex");
			if(itemhex.length() > 1){
				itemnum = 1;
			}
			String[] itemattr =  itemids.split(",");
			for(int i = 0; i < itemattr.length; i++){
				int itemid = 0;
				try{
					itemid = Integer.valueOf(itemattr[i]);
				}catch(NumberFormatException e){
				}
				GRoleInventory gri = new GRoleInventory();
	
				if (itemid > 0 && itemhex.length() > 0) {
					gri.id = itemid;
					gri.guid1 = 0;
					gri.guid2 = 0;
					gri.mask = 1;
					gri.proctype = 0;
					gri.pos = 0;
					gri.count = itemnum;
					gri.max_count = 1;
					gri.expire_date = 0;
					gri.data = new Octets(hextoByteArray(itemhex));
				}
	
				if (protocol.DeliveryDB.SysSendMail(roleid, title, content, gri, coins)) {
					message = "<font color=\"#00cc00\"><b>邮件发送成功!</b></font>";
				} else {
					message = "<font color=\"#ee0000\"><b>邮件发送失败!</b></font>";
				}
			}
		} else {
			message = "<font color=\"#ee0000\"><b>请填写必要信息!</b></font>";
		}
	}
%>
<html>

<head>
	<link rel="shortcut icon" href="../../include/fav.ico">
	<link rel="stylesheet" type="text/css" href="../../include/style.css">
</head>

<body>
<table width="100%" height="350"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td align="center"><form action="?process=mail" method="post">
        <table align="center" width="600" cellpadding="2" cellspacing="0" style="border: 1px solid #cccccc;">
          <tr>
            <th height="1" colspan="2" style="padding: 5;"> <b>发送邮件</b> </th>
          </tr>
          <tr bgcolor="#f0f0f0">
            <td colspan="2" align="center" height="1"><% out.print(message);%></td>
          </tr>
          <tr>
            <td height="1" width="120"> 角色ID: </td>
            <td height="1" width="480"><input type="text" name="roleid" style="width: 100%; text-align: left;"/>
              <b style="color:red">*</b></td>
          </tr>
          <tr>
            <td height="1">邮件标题: </td>
            <td height="1"><input type="text" value="奖品来了" name="title" style="width: 100%; text-align: left;"/>
              <b style="color:red">*</b></td>
          </tr>
          <tr>
            <td height="1" valign="top"> 邮件内容: </td>
            <td height="1"><textarea name="content" rows="5" style="width: 100%; text-align: left;">0</textarea>
              <b style="color:red">*</b></td>
          </tr>
          <tr>
            <td height="1" valign="top">金币: </td>
            <td height="1"><input type="text" name="coins" value="0" style="width: 100%; text-align: left;">
              </input></td>
          </tr>
          <tr>
            <td height="1" valign="top">物品ID: </td>
            <td height="1"><input type="text" name="itemid" style="width: 100%; text-align: left;">
            	<p style="color:#666">可以发送多个物品以(,)隔开,例: 1222,1444,1444</p>
            </td>
          </tr>
          <tr>
            <td height="1" valign="top"> 物品数量: </td>
            <td height="1"><input type="text" name="itemnum" style="width: 100%; text-align: left;" value="1">
            	<p style="color:#666">严格注意物品堆积</p>
            </td>
          </tr>
          <tr>
            <td height="1" valign="top">物品属性数据: </td>
            <td height="1"><textarea name="itemhex" rows="5" style="width: 100%; text-align: left;">0</textarea>
            	<p style="color:#666">物品xml type="Octets" 的字符串</p>
            </td>
          </tr>
          <tr bgcolor="#f0f0f0">
            <td colspan="2" align="center" height="1"><input type="submit" name="submit" value="发送" /></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
</body>

</html>

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 56
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
沙发为先
2016-10-5 10:11
0
雪    币: 269
活跃值: (70)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
已经自己解决了
2016-11-6 05:49
0
游客
登录 | 注册 方可回帖
返回
//