<%@ LANGUAGE = "VBScript.Encode" codepage="65001" %>
<html>
<head>
<title>上传反馈信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/css.css" type="text/css" rel="stylesheet" />
</head>
<!--#include FILE="../../inc/conn.asp"-->
<!--#include FILE="../../inc/inc.asp"-->
<!--#include FILE="../../inc/ThumbnailFunction.asp"-->
<%
if request.cookies("kkadmin")="" or request.cookies("kkadminlogin")<>"true" then
	response.Write "<script language='javascript'>top.location.href='../index.asp';</script>"
	response.End
end if
Function CreateOnlyID()
	tmpid=right(year(now()),2)
	tmpid=tmpid & month(now())
	tmpid=tmpid & day(now())
	tmpid=tmpid & hour(now())
	tmpid=tmpid & minute(now())
	tmpid=tmpid & second(now())
	Randomize
	upperbound=99999
	lowerbound=10000
	tmpid=tmpid & Int((upperbound - lowerbound + 1) * Rnd + lowerbound) 
	CreateOnlyID=tmpid
End Function
function TrueStr(fileTrue)
 str_len=len(fileTrue)
 pos=Instr(fileTrue,chr(0))
 if pos=0 or pos=str_len then
 TrueStr=true
 else
 TrueStr=false
 end if
end function
Server.ScriptTimeOut=999999
%>
<body bgcolor="#666666">
<table width="100%" border="0" height="100%">
  <tr>
    <td>
      <table width="80%" height="200" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#000000">
        <tr> 
          <td valign="middle"> <table width="99%" border="0" align="center" bgcolor="#FFFFFF" height="99%" cellpadding="20">
              <tr> 
                <td bgcolor="#F1F1F1"> 
                  <!--#include FILE="upload_5xsoft.inc"-->
 <%
set upload=new upload_5xsoft
set file=upload.file("file1")
if session("uppath")="" then uppath="other"
	uppath=session("uppath")
	ProdId=session("ProdId")
	frmname=session("frmname")
if uppath="" then 
	response.write "<BLOCKQUOTE>参数错误！请返回前一个页面<b>刷新后</b>上传！"
	Response.write "<br><A HREF='javascript:history.go(-1)'><b>点击返回,然后刷新页面</b></A></BLOCKQUOTE>"
	response.end
end if
if file.fileSize>0 then
    '自动生成文件名
    Tfilename=date()
    Tfilename=Tfilename&time()
    Tfilename=replace(Tfilename,"-","")
    Tfilename=replace(Tfilename,":","")
    Tfilename=replace(Tfilename," ","")
    Tfilename=createonlyid()&"."
    Tfilenameend=file.filename
    Tfilenameend=split(Tfilenameend,".")
    Tfilename=Tfilename&Tfilenameend(1)
	if Tfilenameend(1)="gif" or Tfilenameend(1)="jpg" or Tfilenameend(1)="GIF" or Tfilenameend(1)="JPG" or Tfilenameend(1)="swf" or Tfilenameend(1)="SWF"  then
	else
	response.write "<BLOCKQUOTE>请确认上传的图片类型为 jpg 或者 gif 或者swf"
		Response.write "<br><br>操作失败！<A HREF='javascript:history.go(-1)'><b>点击返回</b></A></BLOCKQUOTE>"
		response.end
	end if
	if InStr(uppath,".")>0 then
		  response.cookies("admin")=""
		  response.write "<script>alert('非法操作,系统已经记录');top.location.href='../login.asp'</script>"
		  response.end
	end if
	web_tpath=Web_Get_RootDir(Web_C_setupfolder)&"uploadimage/"&uppath&""
	 if TrueStr(web_tpath)=false then
        	 response.write "<script>alert('非法文件,系统已经记录');top.location.href='../login.asp'</script>"
        	response.end
    	end if
	if uppath="moreproduct" then
		file.saveAs Server.mappath("../../uploadimage/product/"&Tfilename) 
	else
		call createuplodfolder(web_tpath)
		file.saveAs Server.mappath("../../uploadimage/"&uppath&"/"&Tfilename) 
	end if
	
	'上传路径设定
	if uppath="product" or uppath="moreproduct" then
		web_MarkComponent=getonevalue("web_webconfig","ThumbnailComponent","id=1")
	   	web_c_filepath="../../uploadimage/product/"&Tfilename&""
 	  	web_c_filepath_1="../../uploadimage/product/"&Tfilename&""
 	   	web_c_filepath_2="../../uploadimage/product/S_"&Tfilename&""
          	AddWaterMark web_c_filepath
		if uppath="product" then
	  		call CreateThumbnailEx (web_c_filepath_1,web_c_filepath_2)
		end if	
	end if
    	
%>
<%if session("prodid")="one" then%>
<script language=JavaScript>
function inserttext(){
<%
	if uppath="moreproduct" then
		response.write "self.opener.myform."&frmname&".value =""uploadimage/product/"&tfilename&""";"
	else
		response.write "self.opener.myform."&frmname&".value =""uploadimage/"&uppath&"/"&tfilename&""";"
		if uppath="product" then
		call getsmallpic(web_MarkComponent)	  	
   		end if
	end if
%>
}
inserttext();
alert("文件上传成功");
window.close();
</script>
<% else %>
<%
  response.write "<br><center><font size=2 color=red>图片上传成功，请复制下边剪切板中内容而后粘贴到商品图片剪切板内!</font></center><br>"
  response.write "<center><input type=text size=26 value='uploadimage/"&uppath&"/"&tfilename&"'><button onclick=window.clipboardData.setData('text',this.previousSibling.value)>复制</button><br><br><a href='javascript:window.close()'><font color=red size=2>关闭窗口</font></a></center>"
  response.end
%>
<% end if%>
<%

else
    response.write "文件内容不能为空"
    response.write "<a href='javascript:history.go(-1);'>返回"
end if
set upload=nothing
response.write "<br>"
%>
                </td>
              </tr>

            </table></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body> 
</html>
<%
sub getsmallpic(web_MarkComponent)
	If web_MarkComponent <> "0" Then						'选择了某个水印组件,否则退出
		Select Case web_MarkComponent
		
			Case "1"													'使用AspJpeg组件												
				If  IsObjInstalled("Persits.Jpeg") Then					'AspJpeg组件已安装,否则退出
					If IsExpired("Persits.Jpeg")=false Then
						response.write "self.opener.myform.smallphoto.value =""uploadimage/"&uppath&"/S_"&Tfilename&""";"	
					End if
							
				End if
			Case "2"													'使用wsImage组件
					
				If IsObjInstalled("wsImage.Resize") Then				'wsImage组件已安装,否则退出
					If IsExpired("wsImage.Resize")=false Then
								response.write "self.opener.myform.smallphoto.value =""uploadimage/"&uppath&"/S_"&Tfilename&""";"
					End if
							
				End if
			Case "3"													'使用SA-ImgWriter组件
				If IsObjInstalled("SoftArtisans.ImageGen") Then			'SA-ImgWriter组件已安装,否则退出
					If IsExpired("SoftArtisans.ImageGen")=false  Then
						response.write "self.opener.myform.smallphoto.value =""uploadimage/"&uppath&"/S_"&Tfilename&""";"
					End if
							
				End if
		End Select
	End if
end sub
session("uppath")=""
session("ProdId")=""
session("frmname")=""
%> 

 
 

