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

📄 misc.asp

📁 ASP原码
💻 ASP
字号:
<%
'将一个时间的类型的变量转化为字符串类型的变量
 function StrDate(byval mydate)
 	strDate=cstr(year(mydate)&"-"&month(mydate)&"-"&day(mydate))
 end function
 function strtime(byval mytime)
        strtime=cstr(hour(mytime)&":"&minute(mytime)&":"&second(mytime))
 end function
  
FUNCTION SELECTED( byVal theOption, byVal theVal )
  on error resume next
  theOption=cstr(trim(theOption))
  theVal=cstr(trim(theVal))
  if  theOption  =  theVal  then
    SELECTED = "SELECTED"
   end if
END FUNCTION

FUNCTION CHECKED( byVal theOption, byVal theVal )
  on error resume next
  theOption=cstr(trim(theOption))
  theVal=cstr(trim(theVal))
  if  theOption  =  theVal  then
    CHECKED = "CHECKED"
  else
    checked = ""
   end if
END FUNCTION

 function replacechar(str, c1, c2)
	dim i, lenstr
	replacechar=""
	lenstr=len(str)
	for i=1 to lenstr
		c=Mid(str,i,1)
		if c=c1 then 
			replacechar=replacechar+c2
		else 
			replacechar=replacechar+c
		end if
	next
 end function



	function GetNewID(cn, table_name, id_field_name)
		dim rs
		set rs=server.CreateObject("ADODB.recordset")
		rs.Open "Select max("&id_field_name&") from "&table_name&"", cn,0,1
	
		if isnull(rs.Fields(0)) then
			GetNewID=1
		else 
			GetNewID=rs.Fields(0)+1
		end if
		
		rs.Close
	End function

	function NameFromID(cn, table_name, field_id_name, field_name, value)
		dim rsTable
		set rsTable=server.CreateObject("ADODB.recordset")
		NameFromID=NA
		rsTable.Open "Select * from "&table_name&"",cn
		do while not rsTable.EOF
			if rsTable(field_id_name)=value then
				NameFromID=rsTable(field_name)
				exit do
			end if
			rsTable.MoveNext
		loop
		rsTable.Close
		set rsTable=nothing
	end function

	function SimpleTime(value) ' 12:30:19->12:30
		dim l
		l=len(value)
		SimpleTime=value
		if mid(value, l-2, 1)=":" then SimpleTime=mid(value,1,l-3)
		if mid(value, l-1, 1)=":" then SimpleTime=mid(txvalue1,l-2)
	end function

	function IA_URLUnicode(url)
		dim i, lenstr, c
		lenstr=len(url)
		IA_URLUnicode = ""
		for i=1 to lenstr
			c=Mid(url,i,1)
			if ASC(c)>=0 and ASC(c)< 128 then
				IA_URLUnicode = IA_URLUnicode+c
			else
				IA_URLUnicode = IA_URLUnicode+Server.URLEncode(c)
			end if
		next
	end function
	
	function IA_Server_IP(cn)
		dim rsx
		set rsx=server.CreateObject("ADODB.recordset")
		rsx.Open "select * from DEFINE where DEF_NAME='SERVER_IP'", cn
		IA_Server_IP=rsx("DEF_VALUE")
		rsx.close
		set rsx=nothing
	end function

	function IA_Server_PORT(cn)
		dim rsx
		set rsx=server.CreateObject("ADODB.recordset")
		rsx.Open "select * from DEFINE where DEF_NAME='SERVER_PORT'", cn
		IA_Server_PORT=rsx("DEF_VALUE")
		rsx.close
		set rsx=nothing
	end function

	function IA_CanAssignClassUser(usertype)
		if usertype>=UTP_STUDENT and usertype<=UTP_SPECIALIST then
			IA_CanAssignClassUser=true
		else
			IA_CanAssignClassUser=false
		end if
	end function

	function IA_SendMail(cn, is_to_smtp_user, mailtoaddress, mailsubject, mailcontent)
		dim rsx, i, lenstr, c, smaddress

		if isnull(mailtoaddress) or mailtoaddress="" or mailtoaddress=";" or isnull(smtp_server) or isnull(smtp_username) then
			IA_SendMail=true
			exit function
		end if
		
		set rsx=server.CreateObject("ADODB.recordset")
		rsx.Open "select * from DEFINE where DEF_NAME='SMTP_SERVER'", cn
		smtp_server=rsx("DEF_VALUE")
		rsx.close

		rsx.Open "select * from DEFINE where DEF_NAME='SMTP_USERNAME'", cn
		smtp_username=rsx("DEF_VALUE")
		rsx.close

		rsx.Open "select * from DEFINE where DEF_NAME='SMTP_PASSWORD'", cn
		smtp_password=rsx("DEF_VALUE")
		rsx.close
		set rsx=nothing

  		' Create the JMail message Object
		set msg = Server.CreateOBject( "JMail.Message" )

		msg.Logging = true
		msg.silent = true
		msg.Charset = "GB2312"

		msg.MailServerUserName=smtp_username
		msg.MailServerPassword=smtp_password

		msg.From = smtp_username
		msg.FromName = "系统管理员"
		
		msg.Subject = mailsubject
		msg.Body = mailcontent

		'msg.AddRecipient "test@iactive.com.cn", "His Name"
		lenstr=len(mailtoaddress)
		smaddress=""
		for i=1 to lenstr
			c=Mid(mailtoaddress,i,1)
			if c=";" then 
				msg.AddRecipient smaddress
				smaddress = ""
			else 
				smaddress = smaddress + c
			end if
		next
		if is_to_smtp_user then msg.AddRecipient smtp_username
		
		' To capture any errors which might occur, we wrap the call in an IF statement
		IA_SendMail = msg.Send(smtp_server)
		'response.write msg.log
		'response.end
		
	end function

	function TFto01(value)
		if value=True or value="True" then 
			Bool2Long="1"
		else
			Bool2Long="0"
		end if
	End function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -