// Decompiled Using: FrontEnd Plus v2.03 and the JAD Engine
// Available From: http://www.reflections.ath.cx
// Decompiler options: packimports(3)
// Source File Name: SmartUpload.java
package com.jspsmart.upload;
import java.io.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
// Referenced classes of package com.jspsmart.upload:
// Files, Request, SmartUploadException, File
public class SmartUpload
{
public SmartUpload()
{
m_totalBytes = 0;
m_currentIndex = 0;
m_startData = 0;
m_endData = 0;
m_boundary = new String();
m_totalMaxFileSize = 0L;
m_maxFileSize = 0L;
m_deniedFilesList = new Vector();
m_allowedFilesList = new Vector();
m_denyPhysicalPath = false;
m_forcePhysicalPath = false;
m_contentDisposition = new String();
m_files = new Files();
m_formRequest = new Request();
}
/**
* @deprecated Method init is deprecated
*/
public final void init(ServletConfig servletconfig)
throws ServletException
{
m_application = servletconfig.getServletContext();
}
/**
* @deprecated Method service is deprecated
*/
public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
{
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public final void initialize(ServletConfig servletconfig, HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException
{
m_application = servletconfig.getServletContext();
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public final void initialize(PageContext pagecontext)
throws ServletException
{
m_application = pagecontext.getServletContext();
m_request = (HttpServletRequest)pagecontext.getRequest();
m_response = (HttpServletResponse)pagecontext.getResponse();
}
/**
* @deprecated Method initialize is deprecated
*/
public final void initialize(ServletContext servletcontext, HttpSession httpsession, HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, JspWriter jspwriter)
throws ServletException
{
m_application = servletcontext;
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public void upload()
throws ServletException, IOException, SmartUploadException
{
int i = 0;
boolean flag = false;
long l = 0L;
boolean flag1 = false;
String s = new String();
String s2 = new String();
String s4 = new String();
String s5 = new String();
String s6 = new String();
String s7 = new String();
String s8 = new String();
String s9 = new String();
String s10 = new String();
boolean flag2 = false;
m_totalBytes = m_request.getContentLength();
m_binArray = new byte[m_totalBytes];
int j;
for(; i < m_totalBytes; i += j)
try
{
m_request.getInputStream();
j = m_request.getInputStream().read(m_binArray, i, m_totalBytes - i);
}
catch(Exception exception)
{
throw new SmartUploadException("Unable to upload.");
}
for(; !flag1 && m_currentIndex < m_totalBytes; m_currentIndex++)
if(m_binArray[m_currentIndex] == 13)
flag1 = true;
else
m_boundary = m_boundary + (char)m_binArray[m_currentIndex];
if(m_currentIndex == 1)
return;
for(m_currentIndex++; m_currentIndex < m_totalBytes; m_currentIndex = m_currentIndex + 2)
{
String s1 = getDataHeader();
m_currentIndex = m_currentIndex + 2;
boolean flag3 = s1.indexOf("filename") > 0;
String s3 = getDataFieldValue(s1, "name");
if(flag3)
{
s6 = getDataFieldValue(s1, "filename");
s4 = getFileName(s6);
s5 = getFileExt(s4);
s7 = getContentType(s1);
s8 = getContentDisp(s1);
s9 = getTypeMIME(s7);
s10 = getSubTypeMIME(s7);
}
getDataSection();
if(flag3 && s4.length() > 0)
{
if(m_deniedFilesList.contains(s5))
throw new SecurityException("The extension of the file is denied to be uploaded (1015).");
if(!m_allowedFilesList.isEmpty() && !m_allowedFilesList.contains(s5))
throw new SecurityException("The extension of the file is not allowed to be uploaded (1010).");
if(m_maxFileSize > 0L && (long)((m_endData - m_startData) + 1) > m_maxFileSize)
throw new SecurityException("Size exceeded for this file : " + s4 + " (1105).");
l += (m_endData - m_startData) + 1;
if(m_totalMaxFileSize > 0L && l > m_totalMaxFileSize)
throw new SecurityException("Total File Size exceeded (1110).");
}
if(flag3)
{
com.jspsmart.upload.File file = new com.jspsmart.upload.File();
file.setParent(this);
file.setFieldName(s3);
file.setFileName(s4);
file.setFileExt(s5);
file.setFilePathName(s6);
file.setIsMissing(s6.length() == 0);
file.setContentType(s7);
file.setContentDisp(s8);
file.setTypeMIME(s9);
file.setSubTypeMIME(s10);
if(s7.indexOf("application/x-macbinary") > 0)
m_startData = m_startData + 128;
file.setSize((m_endData - m_startData) + 1);
file.setStartData(m_startData);
file.setEndData(m_endData);
m_files.addFile(file);
} else
{
String s11 = new String(m_binArray, m_startData, (m_endData - m_startData) + 1,"gb2312");
m_formRequest.putParameter(s3, s11);
}
if((char)m_binArray[m_currentIndex + 1] == '-')
break;
}
}
public int save(String s)
throws ServletException, IOException, SmartUploadException
{
return save(s, 0);
}
public int save(String s, int i)
throws ServletException, IOException, SmartUploadException
{
int j = 0;
if(s == null)
s = m_application.getRealPath("/");
if(s.indexOf("/") != -1)
{
if(s.charAt(s.length() - 1) != '/')
s = s + "/";
} else
if(s.charAt(s.length() - 1) != '\\')
s = s + "\\";
for(int k = 0; k < m_files.getCount(); k++)
if(!m_files.getFile(k).isMissing())
{
m_files.getFile(k).saveAs(s + m_files.getFile(k).getFileName(), i);
j++;
}
return j;
}
public int getSize()
{
return m_totalBytes;
}
public byte getBinaryData(int i)
{
byte byte0;
try
{
byte0 = m_binArray[i];
}
catch(Exception exception)
{
throw new ArrayIndexOutOfBoundsException("Index out of range (1005).");
}
Eric_CY
- 粉丝: 7
- 资源: 2
最新资源
- 汇编语言分支结构实验:实现大小写字母转换及其实现方法
- markdown编辑器,使用electron开发
- 汇编语言中循环结构的设计实现及其应用-通过具体实验掌握数据块传送与循环指令应用
- 某米扫地机 大厂程序源码 STM32端代码能实现延边避障防跌 落充电等功能 适合需要学习项目与代码规范的工程师 硬件驱动包含 陀螺仪姿态传感器bmi160、电源管理bq24733等 软件驱动包
- 汇编语言中的子程序设计:实现小写字母转大写的技术详解与实践
- matlab Golay码编码译码
- 自动驾驶车道保持LKA,基于LQR算法,carsim与simulink联合仿真,包括说明书及LQR的推导过程(每一步怎么做的)
- 利用BES秃鹰优化算法优化LSSVM做多特征变量输入,单个因变量输出的拟合预测模型 程序语言为matlab 直接替excel数据就可以用
- PMSM永磁同步电机滑模控制的直接转矩控制改进算法仿真模型,在传统算法上结合滑模控制算法加以改进,基于matlab simulink搭建,以供参考学习
- 图像增强技术中自动色彩增强(ACE)及其快速实现的方法与应用研究
- 带负载转矩前馈补偿的永磁同步电机无感FOC 1.采用龙伯格负载转矩观测器,可快速准确观测到负载转矩; 2.将观测到的负载转矩用作前馈补偿,可提高系统抗负载扰动能力; 提供算法对应的参考文献和仿真模型
- PMSM永磁同步电机控制类仿真 三相永磁同步电机模型 1、直接转矩控制DTC 2、矢量控制FOC 3、无位置控制 4、滑膜控制 #Matlab simulink
- Web前端大作业-个人网页HTML+CSS+JavaScript(高分项目)
- LocalColorCorrection-master.zip
- matlab代码 布谷鸟优化算法CS原代码, 包含23个基准测试函数,都可运行 可用于后续改进和对比, 代码百分百可运行
- 汽车电子网络安全(信息安全)HSM技术资料分享及项目开发 芯片型号:英飞凌 支持算法:RSA,AES,签名生成及验证,CMAC生成及验证等 支持功能:安全服务,SecureBoot,HsmBootl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈