comm.asp页面:
'***** 输出简写 *****
sub echo(s)
Response.write s & chr(13) '输出单行内容, 加“回车”
end sub
'***** 结束简写 ****
sub endit()
Response.end
end sub
'***** 返回 RecordSet ****
function GetRS()
set GetRs = Server.CreateObject("adodb.recordset")
end function
'***** 返回当前页面URL ****
function SelfUrl()
set SelfUrl = Request.ServerVariables("Script_Name")
end function
'***** 是否为注册用户 ****
function IsRegUser()
if isEmpty( session("oskey") ) then
IsRegUser = false
else
IsRegUser = true
end if
end function
' ***** insert / update SQL语句生成函数 *****
' 使用范例
' f = "a|b|c" // 字段名列表
' v = "1|2|3" // 字段值列表
' Response.write GetSQL("update", "aa", f, v, "id=1")
function GetSQL(c, table, f, v, condition )
dim sql
' 过滤掉单引号
v = replace(v, "'", "’")
' 开始按|拆分字串成数组
field = split(f, "|")
value = split(v, "|")
select case c
case "insert":
sql = "INSERT INTO " & table & "("
sql = sql & join(field, ",") & ") VALUES('"
sql = sql & join(value, "','") & "')"
case "update":
n = ubound(field)
sql = "UPDATE " & table & " SET "
for i=0 to n
sql = sql & field(i) & "='" & value(i) & "'"
if i<n then sql = sql & ","
next
sql = sql & " WHERE "& condition
end select
GetSQL = sql
end function
'***** 判断是否为页面提交动作 *****
function IsPost()
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
IsPost = true
else
IsPost = false
end if
end function
'***** 用于消息提示 *****
function ShowMsg( msg )
echo "<script>alert('"& msg &"')</script>"
end function
'***** 用于跳转页面 *****
function GoUrl( url )
echo "<script>window.location='"& url &"';</script>"
call endit ' 结束页面输出
end function
'***** 用于屏蔽一些特殊字符 *****
function EscapeChar( s )
s = replace(s, "'", "‘") ' 处理引号
s = replace(s, """", "”")
s = replace(s, ",", ",")
s = replace(s, ")", ")")
s = replace(s, "(", "(")
s = replace(s, "|", "-") ' | 为首要屏蔽的字符, 否则会直接影响 GetSQL 的工作
EscapeChar = s
end function
Function getExt(ename)'得到文件扩展名
getExt = right(ename, 3)
End Function
For ii = LBound(typeList) To UBound(typeList)
If UCase(ext) = UCase(typeList(ii)) Then
isPIC = True
Exit For
End If
Next
End Function
'*************无组件上传图片函数**************'
'*** 调用方法:Call SavePic(path) *******'
'*** 页面使用时需包包含upload_5xsoft.inc文件 *'
'*** 作者:李建军 日期:2004-05-11 *****'
'*** 获得图片名称用filearray(0,1,2,3)得到 ***'
'*********************************************'
dim filearray
reDim fileArray(0)
dim upload,file,filename
Function SavePic(path)
set upload=new upload_5xsoft ''建立上传对象
i = 0
if right(path,1)<>"/" then
path = path&"/"
end if
for each formName in upload.objFile ''列出所有上传了的文件
thefilename = year(date())&month(now())&day(now())&hour(now())&minute(now())&second(now())&i
set file=upload.file(formname)
filename2 = getext(file.FileName)
if IsPic(filename2) then
if file.FileSize < 0 or file.FileSize > 200*1024 then
echo "<div align=center><font color=red><b>图片 "&file.fileName&" 文件超过200K,请核对后重新上传!</b></font><br><br>"
echo "<a href='javascript:window.history.back()'><font color= blue><b>返回</b></div></a>"
exit for
else
filename = thefilename&"."&filename2
fileArray(i) = filename
i = i + 1
reDim Preserve fileArray(i)
file.SaveAs Server.mappath(path & filename)
end if
else
echo "<div align=center><font color=red><b>文件 "&file.fileName&" 类型不对,请核对后重新上传!只支持JPG\GIF\PNG图片类型!</b></font><br><br>"
echo "<a href='javascript:window.history.back()'><font color= blue><b>返回</b></div></a>"
exit for
end if
next
End function
'*********无组件上传图片结束函数**********
Function EndSavePic()
set file=nothing
set upload=nothing
End Function