<!-- #include file="../include/skin.asp" -->
<!-- #include file="../include/upload_config.asp" -->
<!-- #include file="../include/upload_watermark.asp" -->
<!-- #include file="../include/jk_convert.asp" -->
<!-- #include file="../include/jk_enurl.asp" -->
<!-- #include file="../include/jk_msort.asp" -->
<!-- #include file="../include/jk_val_code.asp" -->

<%
dim wmobj,dim_upload,is_admin,upload,up_text,up_path,uptemp,up_name,up_temp,upfile,upfilename,upfile_name,upfile_name2,upfilesize,upid,today_num,st,upcount,noload_type,is_upload,dim_uptype
dim formname,upload_path,upload_type,upload_size,upload_mn,upload_mode,up_sort,up_valcode
dim session_for
dim ReFilSize,ReFilType
ReFilSize=100						'远程图片大小限制 KB
ReFilType="gif|jpg|jpeg|bmp"		
session_for=joekoe_cms.web_cookies&"_admin_"
upcount=1
today_num=0
tit="文件上传"
is_refur_true=false
is_admin=false
noload_type="asp,asa,aspx,php,cgi"
'--------------------------------------------------------------------------
Server.ScriptTimeOut=5000
'--------------------------------------------------------------------------
dim uptype,uppath,upname,uptext,upbg
uptype=trim(request.querystring("uptype"))
uppath=trim(request.querystring("uppath"))
upname=trim(request.querystring("upname"))
uptext=trim(request.querystring("uptext"))
upbg=trim(request.querystring("upbg"))


call web_head(0,1,4,0,0)
if session(session_for&"admin")="joekoe_admin" then
  is_admin=true
  login_username=session(session_for&"admines")
end if
call msort_start(0)
response.write vbcrlf&"<script language=javascript>" & _
               vbcrlf&"if (top.location==self.location) { top.location=""./""; }" & _
               vbcrlf&"</script>"

'----------------------------中间 开始----------------------------
call upload_frame(0)
if var_null(login_username)="" and is_admin=false then
  response.write web_nologin
else
  call upload_load()
end if
call upload_frame(1)
'----------------------------中间 结束----------------------------
call msort_end()
call web_end(0,4)

sub noload_load()  '检测是否允许上传
  dim noi,nodim,uptmp
  nodim=split(noload_type,",")
  for noi=0 to ubound(nodim)
    if instr(","&upload_type&",",","&nodim(noi)&",")>1 then
      uptmp=","&upload_type&","
      uptmp=replace(uptmp,","&nodim(noi)&",",",")
      upload_type=left(uptmp,len(uptmp)-1)
      upload_type=right(upload_type,len(upload_type)-1)
    end if
  next
end sub

sub upload_load()
  set wmobj=new CMS_WaterMark
  if session(session_for&"admin")="joekoe_admin" then
    is_admin=true
  end if
  dim_upload=split(web_dim(14),"|")
  dim_uptype=dim_upload(24) '图片过滤设置
  upload_path=web_dim(13)
  select case lcase(uptype)
  case "pic","pics"
    upload_type=lcase(dim_upload(17))
  case "swf","swfs"
    upload_type="swf"
  case "file","files"
    upload_type=lcase(dim_upload(18))
  case else
    upload_type=lcase(dim_upload(0))
  end select
  call noload_load()
  upload_size=dim_upload(1)
  upload_mn=dim_upload(2)
  upload_mode=dim_upload(3)
  wmobj.con_mode=int(dim_upload(7))
  wmobj.con_text=var_null(dim_upload(14))
  wmobj.con_color=dim_upload(8)
  wmobj.con_place=int(dim_upload(9))
  wmobj.con_watermark=dim_upload(10)
  wmobj.wm_width=int(dim_upload(11))
  wmobj.wm_height=int(dim_upload(12))
  wmobj.con_opacity=int(dim_upload(13))
  wmobj.base_width=int(dim_upload(15))
  wmobj.base_height=int(dim_upload(16))
  erase dim_upload
  if not(isnumeric(upload_size)) then upload_size=0
  if not(isnumeric(upload_mn)) then upload_mn=1
  if is_admin=false then
    call convert_load(login_mode)
    upload_mn=format_convert(upload_mn,"+")
  end if
  if not isnumeric(upload_mode) then upload_mode=0
  if upload_nums()=false then
    response.write "<font class=re>注意</font>：您今天已上传<font class=red>"&today_num&"</font>个文件，每天只能上传<font class=red>"&upload_mn&"</font>个文件。"
	exit sub
  end if
    select case action
    case "upfile"
      if joekoe_cms.post_chk()=false then
        response.write web_nopost
      else
        call upload_way()
        response.write uptemp
      end if
      case "remote"  '自动远程上传
        call upload_remote()
      case else 
        call upload_main() '上传表单
      end select
   set wmobj=nothing
end sub

sub upload_0()	'无组件上传
  up_name=trim(upload.form("up_name"))
  up_text=trim(upload.form("up_text"))
  up_path=trim(upload.form("up_path"))
  up_temp=trim(upload.form("up_temp"))
  up_valcode=trim(upload.form("valcode"))
  call upload_val_par()
  if not up_val_chk(uppath) then
    call upload_msg(6)
    set upfile=nothing
    exit sub
  end if
  set upfile=upload.file("file_name1")
  upfilesize=upfile.filesize
  if upfilesize<=0 then
    call upload_msg(1)
    set upfile=nothing
    exit sub
  end if
  upfilename=upfile.fileName
  if upfilesize>(upload_size*1024) then
    call upload_msg(2)
    set upfile=nothing
    exit sub
  end if
  upfile_name=right(upfilename,len(upfilename)-InstrRev(upfilename,".")) 
  upfile_name=lcase(upfile_name)
  if instr(","&upload_type&",",","&upfile_name&",")<=0 then
    call upload_msg(3)
    set upfile=nothing
    exit sub
  end if
  upfile_name2=upfile_name
  upfile_name=up_name&"."&upfile_name
  upfile.saveas up_path&upfile_name
  call tmp_upload(up_path&upfile_name)  
  if is_upload=false then exit sub  
  call upload_data()
  call upload_msg(4)
  set upfile=nothing
end sub

sub upload_1()	'LyfUpload
  up_name=trim(upload.request("up_name"))
  up_text=trim(upload.request("up_text"))
  up_path=trim(upload.request("up_path"))
  up_temp=trim(upload.request("up_temp"))
  up_valcode=trim(upload.request("valcode"))
  if var_null(up_temp)="" then
    call upload_msg(1)
    exit sub
  end if
  upload.maxsize=upload_size*1024
  upload.extname=upload_type
  call upload_val_par()
  if not up_val_chk(uppath) then
    call upload_msg(6)
    set upfile=nothing
    exit sub
  end if
  upfile_name=apart_filename(up_temp,2,"\")
  upfile_name=lcase(upfile_name)
  if instr(","&upload_type&",",","&upfile_name&",")>0 then
    upfile_name2=upfile_name
    upfile_name=up_name&"."&upfile_name
  end if
  if right(up_path,1)="/" then up_path=left(up_path,len(up_path)-1)
  if right(up_path,1)<>"\" then up_path=up_path&"\"
  st=upload.savefile("file_name1",up_path,true,upfile_name)
  select case cstr(st)
  case "0"
    call upload_msg(2)
    exit sub
  case "1"
    call upload_msg(3)
    exit sub
  case "3"
    if is_admin=false then
      call upload_msg(0)
      exit sub
    end if
    upfilesize=upload.filesize
  case ""
    call upload_msg(5)
    exit sub
  case else
    upfilesize=upload.filesize
  end select
  call tmp_upload(up_path&upfile_name)  
  if is_upload=false then exit sub  
  call upload_data()
  call upload_msg(4)
end sub

sub upload_2()	'Aspupload
  on error resume next
  if is_admin=true or session(session_for&"uploadtype")="s" then
    upload.overwritefiles=true			'能复盖
  else
    upload.overwritefiles=false			'不能复盖
  end if
  upload.ignorenopost=true
  upload.setmaxSize upload_size*1024,true	'限制大小
  upcount=upload.save
  if err.number=8 then
    err.clear
    call upload_msg(2)
    exit sub
  end if
  if err<>0 then	'Err.Description
    call upload_msg(5)
    exit sub
  end if
  up_name=trim(upload.form("up_name"))
  up_text=trim(upload.form("up_text"))
  up_path=trim(upload.form("up_path"))
  up_temp=trim(upload.form("up_temp"))
  up_valcode=trim(upload.form("valcode"))
  call upload_val_par()
  if not up_val_chk(uppath) then
    call upload_msg(6)
    set upfile=nothing
    exit sub
  end if
  set upfile=upload.files("file_name1")
  if upcount<>1 then
    call upload_msg(1)
    set upfile=nothing
    exit sub
  end if
  upfilename=upfile.filename
  upfilesize=upfile.Size
  upfile_name=apart_filename(upfilename,2,".")
  upfile_name=lcase(upfile_name)
  if instr(","&upload_type&",",","&upfile_name&",")<=0 then
    call upload_msg(3)
    set upfile=nothing
    exit sub
  end if
  upfile_name2=upfile_name
  upfile_name=up_name&"."&upfile_name
  upfile.saveas up_path&upfile_name
  call tmp_upload(up_path&upfile_name)  
  if is_upload=false then exit sub  
  call upload_data()
  call upload_msg(4)
  set upfile=nothing
end sub

sub upload_val_par()
  up_name=var_null(up_name)
  if session(session_for&"admin")<>"joekoe_admin" and len(up_name)>2 and session(session_for&"uploadtype")<>"s" then up_name=""
  if len(up_name)<3 then up_name=up_name&joekoe_cms.rand_file("")
  if not upsort_path(up_path) then up_path="other"
  if len(up_path)<3 then up_path="other"
  uppath=up_path
  if uppath="face" then
    upload_type="gif"
    up_name="face_"&login_id
  end if
 if right(upload_path,1)<>"/" then upload_path=upload_path&"/"&joekoe_cms.time_type(now(),6)&"/"
  call upload_val_folder(upload_path,up_path)   '验证文件夹是否存在 
  up_path=server.mappath(upload_path&up_path)
  if right(up_path,1)<>"/" then up_path=up_path&"/"&joekoe_cms.time_type(now(),6)&"/"
end sub

sub upload_data()
  dim uiid,unsort,utypes
  uiid=0
  unsort=""
  utypes=0
  sql="select id from upload where url='"&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"'"
  if session(session_for&"uploadtype")="s" then
    uiid=int(login_id)
    unsort="uface"
    utypes=1
    sql="select id from upload where iid="&uiid&" and nsort='"&unsort&"'"
  end if
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
sql="insert into upload(iid,nsort,types,username,url,genre,sizes,tim) " & _
        "values("&uiid&",'"&unsort&"',"&utypes&",'"&login_username&"','"&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"','"&upfile_name2&"',"&upfilesize&",'"&joekoe_cms.now_time&"')"
    call joekoe_cms.exec(sql,0)
    sql="select top 1 id from upload order by id desc"
    set rs=joekoe_cms.exec(sql,1)
    upid=int(rs("id"))
  else
    call joekoe_cms.exec("update upload set username='"&login_username&"',sizes="&upfilesize&",tim='"&joekoe_cms.now_time&"',url='"&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"' where id="&rs("id"),0)
  end if
  rs.close
  session(session_for&"uploadtype")=""
end sub

function upload_nums()
  dim ta
  ta="#"
  upload_nums=true
  if is_admin=true then
    exit function
  end if
if session(session_for&"admin")<>"joekoe_admin" then
  sql="select count(*) from upload where username='"&login_username&"' and tim>="&ta&formatdatetime(formatdatetime(joekoe_cms.now_time,2))&ta
  set rs=joekoe_cms.exec(sql,1)
  today_num=rs(0)
  rs.close
  if not(isnumeric(today_num)) then today_num=0
  if int(today_num)>=int(upload_mn) then
    upload_nums=false
  end if
  end if
end function

sub upload_msg(mn)
  dim tmpjs
  select case mn
  case 0
    uptemp=vbcrlf&"<font class=red>上传失败</font>：参数出错！"&go_back
  case 1
    uptemp=vbcrlf&"<font class=red>上传失败</font>：您可能没有选择想要上传的文件！"&go_back
  case 2
    uptemp=vbcrlf&"<font class=red>上传失败</font>：文件太大！(不能超过<font class=red>"&int(upload_size)&"KB</font>) "&go_back
  case 3
    uptemp=vbcrlf&"<font class=red>上传失败</font>：文件类型只能为：<font class=blue>"&replace(upload_type,"|","、")&"</font> 等格式 "&go_back
  case 4
    if lcase(upfile_name2)="jpg" or lcase(upfile_name2)="jpeg" then
      wmobj.con_filename=upload_path&uppath&"/"&upfile_name
      call wmobj.create_watermark()
    end if
    uptemp=vbcrlf&"<font class=red>上传成功</font>：<a href='"&upload_path&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"' target=_blank>"&upfile_name&"</a> ("&upfilesize&"Byte)"
    if instr(up_text,"pic")>0 then
 if uppath="face" then
        tmpjs=tmpjs&"parent.document.all."&up_text&".value='"&upload_path&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"';"
        upid=0
      else
        tmpjs=tmpjs&"parent.document.all."&up_text&".value='"&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"';"
      end if
        '//*新增：判断传回 HTML 编辑器上传 JS 变量(相对根路径) *//
    elseif instr(up_text,"htmledit")>0 then
        tmpjs=tmpjs&"parent.document.all."&up_text&".value='"&upload_path&uppath&"/"&upfile_name&"';"
    else
    '//* 结束 *//
      uptemp=uptemp&vbcrlf&"&nbsp;&nbsp;[ <a href='?uppath="&uppath&"&upname=&uptext="&up_text&"&action=upload'>点击继续上传</a> ]"
      tmpjs=tmpjs&"parent.document.all."&up_text&".value+='"
      select case lcase(upfile_name2)
      case "gif","jpg","bmp","png"
        tmpjs=tmpjs&"[IMG]"&upload_path&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"[/IMG]"
      case "swf"
        tmpjs=tmpjs&"[FLASH=350,250]"&upload_path&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"[/FLASH]"
      case else
        'tmpjs=tmpjs&"[DOWNLOAD]"&upload_path&uppath&"/"&joekoe_cms.time_type(now(),6)&"/"&upfile_name&"[/DOWNLOAD]"
	    tmpjs=tmpjs&"[DOWNLOAD]"&joekoe_cms.web_path&"common/upload_download.asp?id="&upid&"[/DOWNLOAD] [文件大小：[color=red]"&int((upfilesize/1024)*1000)/1000&"[/color]KB]"
      end select
      tmpjs=tmpjs&"\n';"
    end if
    if int(upid)>0 then tmpjs=tmpjs&"parent.document.all.upid.value+=',"&upid&"';"
    if tmpjs<>"" then
      uptemp=uptemp&vbcrlf&"<script language=javascript>"&vbcrlf&tmpjs&vbcrlf&"</script>"
    end if
    call val_chk_end("up_"&uppath)
  case 5
    uptemp=vbcrlf&"<font class=red>上传失败</font>：未知错误！"&go_back
  case 6
    uptemp=vbcrlf&"<font class=red>上传失败</font>： <font class=red>验证码</font> 为空或有错误！"&go_back
  case 7
    uptemp=vbcrlf&"<font class=red>上传失败</font>：含有非法文件内容！"&go_back
  end select
end sub

sub upload_way()
  on error resume next
  dim up_way
  select case upload_mode
  case 0
    up_way="无"
    set upload=new upload_classes
  case 1
    up_way="LyfUpload"
    set upload=server.createobject("lyfupload.uploadfile")
  case 2
    up_way="AspUpload"
    set upload = server.createobject("persits.upload")
  end select
  if err then
    set upload=nothing
    err.clear
    response.write "空间不支持 <font class=red>"&up_way&" 组件</font> 上传！请后台配置后再进行上传功能。"
    exit sub
  end if
  
  select case upload_mode
  case 1
    call upload_1()
  case 2
    call upload_2()
  case else
    call upload_0()
  end select
  
  set upload=nothing
  if err then err.clear
end sub

sub upload_val_folder(uf_upload,uf_uppath)
  dim myfso,myfile,up_path
  set myfso=createobject("scripting.filesystemobject")
  if uf_uppath<>"" then
    myfile=server.mappath(uf_upload&uf_uppath&"/"&joekoe_cms.time_type(now(),6))
    if not myfso.folderexists(myfile) then
      set up_path=myfso.createfolder(myfile)
    end if
  end if
  set myfso=nothing
end sub

sub upload_main()
  dim cid
  session(session_for&"uploadtype")=""
  if session(session_for&"admin")<>"joekoe_admin" then
    if len(upname)>2 then upname=""
  end if
  if not upsort_path(uppath) then
    response.write "参数(1)出错！"
    exit sub
  end if
  if uppath="face" then
    session(session_for&"uploadtype")="s"
    if int(login_id)<1 then
      response.write "参数(2)出错！"
      exit sub
    end if
    upname="face_"&login_id
  end if
  if len(uppath)<1 or len(uptext)<1 then
    response.write "参数(3)出错！"
    exit sub
  end if
%>
<script language=javascript>
function frm_submit(theform)
{
  if (document.all||document.getElementById)
  {
    for (i=0;i<theform.length;i++)
    {
      var tempobj=theform.elements[i];
      if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
      tempobj.disabled=true;
    }
  }
}
</script>
<table border=0 cellspacing=0 cellpadding=2>
<form name=form1 action='?uptype=<%response.write uptype%>&upbg=<% response.write upbg %>&action=upfile' method=post enctype='multipart/form-data'<%if cstr(upload_mode)<>"0" then response.write " onsubmit=""javascript:frm_submit(this);"""%>>
<input type=hidden name=up_path value='<%response.write uppath%>'>
<input type=hidden name=up_name value='<% response.write upname %>'>
<input type=hidden name=up_text value='<% response.write uptext %>'>
<input type=hidden name=up_temp value=''>
<%response.write val_code_num("up_"&uppath,1)%>
<tr>
<td><input type=file name=file_name1 value='' size=15 class=txt></td>
<td align=center height=30><%
  if uppath="face" then
    response.write "<input type=submit class=btn name=submit onclick=""up_temp.value=file_name1.value"" value='上 传'> <font class=blue>GIF</font> 格式，小于<font class=red>"&upload_size&"</font>KB"
  else
    response.write "<input type=submit class=btn name=submit onclick=""up_temp.value=file_name1.value"" value='上 传'> ("
    if instr(",pics,swfs,files,",","&lcase(uptype)&",")=0 then
      response.write "今天上传<font class=red>"&today_num&"</font>个,"
    end if
    if is_admin=false then
      response.write "每天<font class=red>"&upload_mn&"</font>个,"
    end if
    response.write "每个<font class=red>"&upload_size&"</font>KB)"
  end if
%></td>
</tr>
</form>
</table>
<%
end sub

function up_val_chk(vsort)
  if not val_is_true then
    up_val_chk=true
    exit function
  end if
  dim valcode,valc
  up_val_chk=false
  valcode="jk"&up_valcode
  valc=trim(request.cookies(joekoe_cms.web_cookies)("vc_up_"&vsort))
  if valcode<>"" and valcode<>"jk" and cstr(valcode)=cstr(valc) then
    up_val_chk=true
  end if
end function

function upsort_path(pvar)
  dim si
  upsort_path=true
  if pvar="face" then exit function
  upsort_path=msort_true(pvar)
end function 

'//* 远程保存图片代码开始，ngbanyan 添加 *//
'//* 部分代码改动过 *//
Sub upload_Remote()
	uppath = trim(request.querystring("uppath"))
	if not upsort_path(uppath) then
		response.write joekoe_cms.js_put("parent.remoteUploadOK();",1)
		Exit Sub
	end if
	Dim sContent, k
	For k = 1 To Request.Form("eWebEditor_UploadText").Count
		sContent = sContent & Request.Form("eWebEditor_UploadText")(k)
	Next
	sContent = ReplaceRemoteUrl(sContent, ReFilType)
	Response.Write "<HTML><HEAD><TITLE>远程上传</TITLE><meta http-equiv='Content-Type' content='text/html; charset=gb2312'></head><body>" & _
		"<input type=hidden id=UploadText value=""" & inHTML(sContent) & """>" & _
		"</body></html>"
	response.write joekoe_cms.js_put("parent.setHTML(UploadText.value); parent.remoteUploadOK();",1)
End Sub
'================================================
'作  用：替换字符串中的远程文件为本地文件并保存远程文件
'参  数：
'	sHTML		: 要替换的字符串
'	sExt		: 执行替换的扩展名
'================================================
Function ReplaceRemoteUrl(sHTML, sExt)
	Dim s_Content
	s_Content = sHTML
	If IsObjInstalled("Microsoft.XMLHTTP") = False then
		ReplaceRemoteUrl = s_Content
		Exit Function
	End If

	Dim re, RemoteFile, RemoteFileurl, SaveFileName
	Set re = new RegExp
	re.IgnoreCase  = True
	re.Global = True
	re.Pattern = "((http|https|ftp|rtsp|mms):(\/\/|\\\\){1}(([A-Za-z0-9_-])+[.]){1,}(net|com|cn|org|cc|tv|[0-9]{1,3})(\S*\/)((\S)+[.]{1}(" & sExt & ")))"

	Set RemoteFile = re.Execute(s_Content)
	Dim a_RemoteUrl(), n, k, bRepeat
	n = 0
	' 转入无重复数据
	For Each RemoteFileurl in RemoteFile
		If n = 0 Then
			n = n + 1
			Redim a_RemoteUrl(n)
			a_RemoteUrl(n) = RemoteFileurl
		Else
			bRepeat = False
			For i = 1 To UBound(a_RemoteUrl)
				If UCase(RemoteFileurl) = UCase(a_RemoteUrl(i)) Then
					bRepeat = True
					Exit For
				End If
			Next
			If bRepeat = False Then
				n = n + 1
				Redim Preserve a_RemoteUrl(n)
				a_RemoteUrl(n) = RemoteFileurl
			End If
		End If
	Next
	' 开始替换操作
	For k = 1 To n
		upfile_name2 = Mid(a_RemoteUrl(k), InstrRev(a_RemoteUrl(k), ".") + 1)
		SaveFileName = Left(uppath,1) & joekoe_cms.rand_file("") & "." & upfile_name2
		If SaveRemoteFile(SaveFileName, a_RemoteUrl(k)) = True Then
			s_Content = Replace(s_Content, a_RemoteUrl(k), upload_path & uppath & "/" & SaveFileName, 1, -1, 1)
		End If
	Next

	ReplaceRemoteUrl = s_Content
End Function
'================================================
'作  用：保存远程的文件到本地
'参  数：s_LocalFileName ------ 本地文件名
'		 s_RemoteFileUrl ------ 远程文件URL
'返回值：True  ----成功
'        False ----失败
'================================================
Function SaveRemoteFile(s_LocalFileName, s_RemoteFileUrl)
	Dim Ads, Retrieval, GetRemoteData
	Dim bError
	bError = False
	SaveRemoteFile = False
	On Error Resume Next
	Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
	With Retrieval
		.Open "Get", s_RemoteFileUrl, False, "", ""
		.Send
		GetRemoteData = .ResponseBody
	End With
	Set Retrieval = Nothing

	If LenB(GetRemoteData) > ReFilSize*1024 Then
		bError = True
	Else
		Set Ads = Server.CreateObject("Adodb.Stream")
		With Ads
			.Type = 1
			.Open
			.Write GetRemoteData
			.SaveToFile Server.MapPath(upload_path & uppath & "/" & s_LocalFileName), 2
			.Cancel()
			.Close()
		End With
		Set Ads=nothing
		upfilesize=LenB(GetRemoteData)
		upfile_name=s_LocalFileName
	    call upload_data()
 		if int(upid)>0 then response.write joekoe_cms.js_put("parent.insertUpid("","&upid&""");",1)
	End If

	If Err.Number = 0 And bError = False Then
		SaveRemoteFile = True
	Else
		Err.Clear
	End If
End Function
' ============================================
' 去除Html格式，用于从数据库中取出值填入输入框时
' 注意：value="?"这边一定要用双引号
' ============================================
Function inHTML(str)
	Dim sTemp
	sTemp = str
	inHTML = ""
	If IsNull(sTemp) = True Then
		Exit Function
	End If
	sTemp = Replace(sTemp, "&", "&amp;")
	sTemp = Replace(sTemp, "<", "&lt;")
	sTemp = Replace(sTemp, ">", "&gt;")
	sTemp = Replace(sTemp, Chr(34), "&quot;")
	inHTML = sTemp
End Function
'================================================
'作  用：检查组件是否已经安装
'参  数：strClassString ----组件名
'返回值：True  ----已经安装
'        False ----没有安装
'================================================
Function IsObjInstalled(strClassString)
	On Error Resume Next
	IsObjInstalled = False
	Err = 0
	Dim xTestObj
	Set xTestObj = Server.CreateObject(strClassString)
	If 0 = Err Then IsObjInstalled = True
	Set xTestObj = Nothing
	Err = 0
End Function

sub upload_frame(ft)
  if ft=1 then
    response.write vbcrlf&"</td></tr>" & _
                   vbcrlf&"</table>"
    exit sub
  end if
  response.write vbcrlf&"<table border=0 height='100%' width='100%' cellspacing=0 cellpadding=0 class=bg" & _
                 vbcrlf&"<tr><td height='100%' align=left bgcolor="""&upbg&""">"
end sub

'================================================
'作  用：上传文件非法代码过滤
'参  数：upname ----组件名
'================================================
sub tmp_upload(upname) 
  On Error Resume Next 
  Dim objFSO,objTS,strText,strArray,ii  
  Set objFSO=Server.CreateObject("scripting.FileSystemObject")   
  Set objTS=objFSO.OpenTextFile(upname,1) '以文本文件方式读取文件  
  strText=lcase(objTS.ReadAll) '全文读取，并转换为小写 
     objTS.Close   
  strArray=split(dim_uptype,",") 
    for ii=0 to ubound(strArray) 
    if instr(strText,strArray(ii))<>0 then 
  is_upload=false 
     objFSO.DeleteFile Server.MapPath(upname),True '删除文件 
  call upload_msg(7) '上传提示
    else 
  is_upload=true 
   end if 
    next  
  Set objFSO=nothing 
end sub
%>
