?? umod_pe.asp
字號:
<!--插入html頭部分以及數據庫接口-->
<!--#include file="in_conn.asp"-->
<!--#include file="inc/md5.asp"-->
<body>
<!--插入網站置頂-->
<% if u_name="" then
Response.Redirect "log_err.asp"
else
%>
<!--#include file="in_topmb.asp"-->
<% end if %>
<%
Server.ScriptTimeOut=5000
Dim UploadFilePath,UploadLimitSize,UploadfileAllowext
UploadFilePath = "face/upface/"
'文件上傳路徑
UploadLimitSize = 100*1024
'最大上傳文件大小,單位為K
UploadfileAllowext = "jpg/gif"
'可以上傳的文件類型
function CanUp(Fileurl)
if InStr(1,UploadfileAllowext,Fileurl,1)=0 OR InStr(1,UploadfileAllowext,Fileurl,1)=null Then
CanUp=False
else
CanUp=True
end if
end function
'*****************************************
'建立上傳對象
on error resume next
dim savepath
savepath=Server.MapPath(UploadFilePath)
dim Upload
Set Upload=Server.CreateObject("Persits.Upload")
Upload.SetMaxSize UploadLimitSize,True
Upload.OverwriteFiles = false
Count=Upload.Save(savepath)
'******************************************
'清除已上傳文件的函數
Sub killup()
For Each File in Upload.Files
File.Delete
Next
set Upload=Nothing
End Sub
'判斷用戶名格式的函數
FUNCTION userstr(stru)
dim i,aa
dim istr
For i=1 To Len(stru)
istr=mid(stru,i,1)
aa=ASC(istr)
If aa>31 AND aa<48 Then
userstr=False
Exit For
Elseif aa>57 AND aa<65 Then
userstr=False
Exit For
Elseif aa>90 AND aa<95 Then
userstr=False
Exit For
Elseif aa>95 AND aa<97 Then
userstr=False
Exit For
Else
userstr=True
End if
Next
END FUNCTION
'判斷郵件格式是否正確
Function isEmail(strng)
Dim regEx,regVal
Set regEx=New RegExp
regEx.Pattern="^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$"
regEx.IgnoreCase=True
isEmail=regEx.Test(strng)
End Function
dim vname,vopwd,vpwd,vrepwd,vemail,vhome,vnowdo,vcontact,vface,vsign,vmsn,vhp
dim vsex,vqq,vhometel,vmob,vy,vm,vd,vfacew,vfaceh
dim vbirth,vdate
'獲得表單傳值
vname=trim(Upload.Form("txtname"))
vpwd=trim(Upload.Form("txtpwd"))
vrepwd=trim(Upload.Form("txtrepwd"))
vopwd=trim(Upload.Form("txtopwd"))
vemail=trim(Upload.Form("txtemail"))
vhome=trim(Upload.Form("txthome"))
vnowdo=trim(Upload.Form("txtdo"))
vcontact=trim(Upload.Form("txtcontact"))
vsign=trim(Upload.Form("txtsign"))
vmsn=trim(Upload.Form("txtmsn"))
vhp=trim(Upload.Form("txthp"))
if Upload.Form("radsex")="gg" then
vsex=1
else
vsex=0
end if
vqq=trim(Upload.Form("txtqq"))
vhometel=trim(Upload.Form("txthometel"))
vmob=trim(Upload.Form("txtmobile"))
vy=Upload.Form("syear")
vm=Upload.Form("smonth")
vd=Upload.Form("sday")
vdate=now()
'檢查正確性
flagerr=0
IF Upload.Form("radface")="up" THEN
if Count<1 then
flagerr=1
end if
if Err.Number=8 then
flagerr=2
elseif Err.Number<>0 then
flagerr=-1
end if
dim size
For Each File in Upload.Files
strShortFileName=File.filename '取得文件名
strExtension=Mid(strShortFileName, InStrRev(strShortFileName, ".")+1) '取得擴展名
'檢查正確性
if strShortFileName="" OR InStrRev(strShortFileName, ".")=0 OR InStrRev(strShortFileName, ".")=Null then
File.Delete
flagerr=1
elseif CanUp(strExtension)=False then
File.Delete
flagerr=3
else
vvvsize=file.size
'獲取圖片的寬和高
vpw=File.ImageWidth
vph=File.ImageHeight
'產生隨機數
randomize
ranNum=int(900*rnd)+100
'這下面兩行代碼功能為改名,如果不要改名,請去掉
NewName = year(now) & "-" & month(now) & "-" & day(now) & "-" & hour(now) & "-" & minute(now) & "-" & second(now) &ranNum&"."&LCase(strExtension)
File.Move savepath & "\" & NewName
end if
next
END IF
If userstr(vname)=False or vname="" or vname<>u_name Then
call killup()
Response.Redirect "resp.asp?cmd=uname_err"
ElseIf isEmail(vemail)=False or vemail="" Then
call killup()
Response.Redirect "resp.asp?cmd=uemail_err"
ElseIF vmsn<>"" AND isEmail(vmsn)=False Then
call killup()
Response.Redirect "resp.asp?cmd=uemail_err"
ElseIf vpwd<>"" Then
if Len(vpwd)<6 OR Len(vpwd)>14 then
call killup()
Response.Redirect "resp.asp?cmd=upwd_len"
elseif vpwd<>vrepwd then
call killup()
Response.Redirect "resp.asp?cmd=urepwd_err"
end if
ElseIf vcontact<>"" And Len(vcontact)>150 Then
call killup()
Response.Redirect "resp.asp?cmd=ucontact_len"
ElseIf vsign<>"" And Len(vsign)>255 Then
call killup()
Response.Redirect "resp.asp?cmd=usign_len"
ElseIf vqq<>"" And isnumeric(vqq)=False Then
call killup()
Response.Redirect "resp.asp?cmd=uqq_num"
End If
'判斷頭像
IF Upload.Form("radface")="up" AND flagerr<>1 THEN
if flagerr=0 then
'如果上傳成功
vface=UploadFilePath&NewName
vfacew=vpw
vfaceh=vph
if isNumeric(vfacew) then
'如果圖片寬高不符界限,則
If vfacew>150 or vfaceh>150 Then
if vfacew>vfaceh then
vfaceh=Cint(150 / vfacew * vfaceh)
vfacew=150
else
vfacew=Cint(150 / vfaceh * vfacew)
vfaceh=150
end if
End If
else
vfacew=150
vfaceh=150
end if
else
'如果上傳失敗
Response.Redirect "resp.asp?cmd=uface_up"
end if
ElseIF Upload.Form("radface")="sel" Then
vface="face/"&Upload.Form("sface")&".gif"
vfacew=42
vfaceh=85
Else
vface=""
END IF
vy=Upload.Form("syear")
vm=Upload.Form("smonth")
vd=Upload.Form("sday")
if isDate(vy&"-"&vm&"-"&vd) then
vbirth=CDate(vy&"-"&vm&"-"&vd)
else
call killup()
Response.Redirect "resp.asp?cmd=ubirth_day"
end if
'開始修改數據
sqlstr="SELECT * FROM tblmates WHERE ID="&u_ID
rs.open sqlstr,conn,1,2
'是否修改密碼
if vpwd<>"" then
'判斷舊密碼是否正確
vopwd=md5(vopwd,32)
if vopwd<>rs("pwd") then
call killup()
Response.Redirect "resp.asp?cmd=uopwd_err"
else
vpwd=md5(vpwd,32)
rs("pwd")=vpwd
end if
end if
rs("sex")=CBool(vsex)
rs("email")=vemail
rs("qq")=CStr(vqq)
rs("home")=vhome
rs("hometel")=CStr(vhometel)
rs("mobile")=CStr(vmob)
rs("nowdo")=vnowdo
rs("contact")=vcontact
rs("birthday")=vbirth
rs("birthm")=vm
rs("moddate")=vdate
rs("signline")=vsign
rs("msn")=vmsn
rs("hp")=vhp
IF vface<>"" THEN
'判斷原來的頭像
if Left(rs("faceurl"),12)="face/upface/" then
dim fpath
dim fso1
fpath=server.MapPath(rs("faceurl"))
set fso1=Server.CreateObject("Scripting.FileSystemObject")
if fso1.FileExists(fpath) then
fso1.DeleteFile fpath,True
end if
set fso1=nothing
end if
rs("faceurl")=vface
rs("facew")=vfacew
rs("faceh")=vfaceh
END IF
rs.update
rs.close
set Upload=Nothing
'刪除以更新在線資料
sqlstr="DELETE FROM tblonline WHERE o_name='"&u_name&"'"
conn.Execute sqlstr
Response.Redirect "rego.asp?cmd=mod_ok"
%>
<!--插入網站置底-->
<!--#include file="in_bottom.asp"-->
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -