⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umod_pe.asp

📁 一个超级漂亮的班级主页asp代码
💻 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 + -