Recomendado: coleção útil de funções no desenvolvimento de ASP (3) Uma coleção de funções úteis no desenvolvimento do ASP é bastante útil, por favor, mantenha -o! '*****************************************
Uma coleção de funções úteis no desenvolvimento do ASP é bastante útil, por favor, mantenha -o!
'********************************************
'Filter hiperlinks
'********************************************
Função checkurl (byval chkstr)
Dim Str: STR = ChkStr
STR = TRIM (STR)
Se isnull (str) então
checkurl =
Função de saída
Final se
Dim re
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
re.Pattern = (D) (Ocument/.Cookie)
Str = re.place (str, 1ocument Cookie)
re.pattern = (d) (Ocument/.Write)
Str = re.place (str, 1ocument write)
re.pattern = (s) (script :)
Str = re.place (str, 1script)
re.pattern = (s) (script)
Str = re.place (str, 1script)
re.Pattern = (O) (BJECT)
Str = re.place (str, 1bject)
re.pattern = (a) (pplet)
Str = re.Replace (str, 1plet)
re.pattern = (e) (mbed)
Str = re.place (str, 1Mbed)
Definir re = nada
Str = substituir (str,>,>)
Str = substituir (str, <, <)
checkurl = str
Função final
'********************************************
'Nome do arquivo de filtro
'********************************************
Função fixname (upfileExt)
Se isEmpty (upfileExt), a função de saída
Fixname = ucase (upfileExt)
FixName = Substituir (FixName, Chr (0),)
FixName = Substitua (FixName ,.,)
FixName = Substitua (FixName, ASP,)
FixName = Substituir (FixName, Asa,)
FixName = Substitua (FixName, ASPX,)
FixName = Substitua (FixName, CER,)
FixName = Substitua (FixName, CDX,)
FixName = Substitua (FixName, HTR,)
Função final
'********************************************
'Filtre caracteres especiais
'********************************************
Função checkstr (byval chkstr)
Dim Str: STR = ChkStr
Se isnull (str) então
Checkstr =
Função de saída
Final se
Str = substituir (str, & &)
Str = substituir (str, ',')
Str = substituir (str ,,)
Dim re
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
re.pattern = (w) (aqui)
Str = re.place (str, 1here)
re.pattern = (s) (eleito)
Str = re.place (str, 1Elect)
re.pattern = (i) (NSert)
Str = re.Place (str, 1NSert)
re.pattern = (c) (rate)
Str = re.Place (str, 1Reado)
re.pattern = (d) (ROP)
Str = re.Replace (str, 1rop)
re.pattern = (a) (lter)
Str = re.Place (str, 1lTer)
re.pattern = (d) (elete)
Str = re.place (str, 1Elete)
re.pattern = (u) (pdate)
Str = re.place (str, 1pdate)
re.pattern = (/s) (ou)
Str = re.Replace (str, 1or)
Definir re = nada
Checkstr = str
Função final
'********************************************
'Restaurar personagens especiais
'********************************************
Função unaleckstr (byval str)
Se isnull (str) então
UMeckstr =
Função de saída
Final se
Str = substituir (str, ',')
Str = substituir (str ,,)
Dim re
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
re.pattern = (w) (aqui)
str = re.place (str, 1here)
re.pattern = (s) (eleito)
str = re.place (str, 1Elect)
re.pattern = (i) (NSert)
str = re.Place (str, 1NSert)
re.pattern = (c) (rate)
str = re.Place (str, 1Reado)
re.pattern = (d) (ROP)
str = re.Replace (str, 1rop)
re.pattern = (a) (lter)
str = re.Place (str, 1lTer)
re.pattern = (d) (elete)
str = re.place (str, 1Elete)
re.pattern = (u) (pdate)
str = re.place (str, 1pdate)
re.pattern = (/s) (ou)
Str = re.Replace (str, 1or)
Definir re = nada
Str = substituir (str, & &)
Unceclowstr = str
Função final
'********************************************
'Converta o código HTML
'********************************************
Função htmlencode (BYVAL RESTRING)
Dim STR: STR = RESTRAÇÃO
Se não é Isnull (str) então
Str = substituir (str,>,>)
Str = substituir (str, <, <)
Str = substituir (str, chr (9),)
Str = substituir (str, chr (32),)
Str = substituir (str, chr (39), ')
Str = substituir (str, chr (34),)
Str = substituir (str, chr (13),)
Str = substituir (str, chr (10), <br/>)
Htmlencode = str
Final se
Função final
'********************************************
'Código HTML de conversão inversa
'********************************************
Função htmldecode (restrição byval)
Dim STR: STR = RESTRAÇÃO
Se não é Isnull (str) então
Str = substituir (str,>,>)
Str = substituir (str, <, <)
Str = substituir (str ,, chr (9))
Str = substituir (str ,, chr (32))
Str = substituir (str, ', cr (39)))
Str = substituir (str ,, chr (34))
Str = substituir (str ,, chr (13))
Str = substituir (str, <br/>, chr (10))
Htmldecode = str
Final se
Função final
'********************************************
'Recuperar e caráter
'********************************************
função clearhtml (restrição byval)
Dim STR: STR = RESTRAÇÃO
Se não é Isnull (str) então
Str = substituir (str, & &)
Clearhtml = str
Final se
Função final
'********************************************
'Filtrar textarea
'********************************************
Função ubbfilter (restrição byval)
Dim STR: STR = RESTRAÇÃO
Se não é Isnull (str) então
Str = substituir (str, </sexttarea>, </sexttarea>)
Ubbfilter = str
Final se
Função final
'********************************************
'Filtrar código HTML
'********************************************
Função editdehtml (conteúdo byval)
EditDehtml = Content
Se não é Isnull (editdehtml) então
Editdehtml = UNSECKSTR (EditDehtml)
Editdehtml = substituir (editdehtml, & &)
Editdehtml = substituir (editdehtml, <, <)
Editdehtml = substituir (editdehtml,>,>)
Editdehtml = substituir (editdehtml, chr (34),)
Editdehtml = substituir (editdehtml, chr (39), ')
Final se
Função final
'********************************************
'Função de conversão de data
'********************************************
Função DATEToStr (DateTime, Showtype)
Dim Datohemth, Datey, DateHour, Dateminute, DateWeek, DateSecond
Dim Fullweekday, Shortweekday, Fullmonth, Shortmonth, Fuzone1, Fuzone2
TimeZone1 =+0800
TimeZone2 =+08: 00
FullWeekday = Array (domingo, segunda, terça, quarta, sexta -feira, sábado)
Shortweekday = Array (Sol, Segun, Ter, Qua, qui, sex, sábado)
Fullmonth = Array (janeiro, fevereiro, março, abril, maio, junho, julho, agosto, setembro, outubro, novembro, dezembro)
Shortmonth = Array (janeiro, fevereiro, março, abril, maio, junho, julho, agosto, setembro, outubro, novembro, dez)
DATEMONTH = Mês (DATETIME)
Datey = dia (datetime)
DATEHOUR = HORA (DATETIME)
DATEMINUTE = MINUTO (DATETIME)
DateWeek = Weekday (DateTime)
DateSecond = Second (DateTime)
Se Len (DATEMONTH) <2 então DATEMONH = 0 & DATEMONHTH
Se Len (datey) <2 então datey = 0 & datey
Se Len (Dateminute) <2 então DATEMINUTE = 0 & DATEMINUTE
Selecione Case ShowType
Caso ymd
DateToStr = Ano (DateTime)-& DATEMONTH- & DATATAY
Caso YMD H: IA
Dim Dataampm
Se datehour> 12 então
DateHour = DateHour-12
Dataampm = pm
Outro
DateHour = DateHour
Dataampm = AM
Final se
Se len (datehour) <2 então datehour = 0 & datehour
DateToStr = Ano (DateTime)-& DATEMONTH- & DATEDAY & DATEHOUR: & DATEMINUTE & DATEAMPM
Case ymd h: i: s
Se len (datehour) <2 então datehour = 0 & datehour
Se Len (datesegund) <2, então datesecond = 0 & datesecond
DateToStr = Ano (DateTime)-& DATEMONTH- & DATEDAY & DATEHOUR: & DATEMINUTE: & DateSecond
Caso ymdhis
DateSecond = Second (DateTime)
Se len (datehour) <2 então datehour = 0 & datehour
Se Len (datesegund) <2, então datesecond = 0 & datesecond
DateToStr = Ano (DateTime) e DATEMONTH & DATATAY & DATEHOUR & DATEMINUTE & DATESSECOND
Caso YM
DateToStr = Right (Ano (DateTime), 2) e DATEMONTH
Caso d
DateToStr = Datey
Caso ymd
DateToStr = Right (Ano (DateTime), 4) e DATEMONTH & DATATAY
Caso Mdy
DIA DIA DO DIA
Selecione Case Datey
Caso 1
DIAND = ST
Caso 2
Dayend = nd
Caso 3
Dayend = Rd
Caso mais
Dayend = th
Final Selecione
DATETOSTR = FULLONTH (DATEMONH-1) & DATATAY & DIEND & Right (Ano (DateTime), 4)
Caso W, DMY H: i: s
DateSecond = Second (DateTime)
Se len (datehour) <2 então datehour = 0 & datehour
Se Len (datesegund) <2, então datesecond = 0 & datesecond
DATETOSTR = ShortWeekday (DateWeek-1), & Datey & Left (Fullmonth (DataMonth-1), 3) e Right (Ano (DateTime), 4) & DateHour: & Dateminute: & DateSecond & TimeZone1
Caso YM-dth: i: s
Se len (datehour) <2 então datehour = 0 & datehour
Se Len (datesegund) <2, então datesecond = 0 & datesecond
DateToStr = Ano (DateTime)-& DATEMONTH- & DATEDAYT & DATEHOUR: & DATEMINUTE: & DATESECOND & TIMEZONE2
Caso mais
Se len (datehour) <2 então datehour = 0 & datehour
DateToStr = Ano (DateTime)-& DATEMONTH- & DATEDAY & DATEHOUR: & DATEMINUTE
Final Selecione
Função final
'********************************************
Função de paginação
'********************************************
Dim FirstShortcut, atalho
FirstShortcut = false
Multipagem de função (números, perpagem, cuba, url_add, aname, estilo)
Curpage = int (Curpage)
Números = int (números)
URL dim
Url = request.Servervariables (script_name) & url_add
Multipagem =
Página escura, deslocamento, PageI
'Se int (números)> int (perpagem) então
Página = 9
Deslocamento = 4
Páginas escuras, From Page, TopAge
Se números mod Cint (perpagem) = 0 então
Páginas = int (números/perpagem)
Outro
Páginas = int (números/perpagem) +1
Final se
FromPage = Offset Curpage
TOPAGE = CURPAGE+PÁGINA-OFFSET-1
Se página> páginas, então
Frompage = 1
TOPAGE = Páginas
Outro
Se da página <1 então
TOPAGE = CURPAGE+1 FROMPAGE
Frompage = 1
If (topage-frompage) <página e (topage-frompage) <páginas, então topage = página
Elseif topoge> páginas então
FromPage = Curpage-Pages +Topage
TOPAGE = Páginas
If (topage-frompage) <página e (topage-frompage) <páginas, então frompage = páginas-página+1
Final se
Final se
Multipage = <div class = Page Style = & Style> <ul>
'Se Curpage <> 1 então multipage = multipage & <li class = pagel> <a href = & url & page = 1 class = pagelbutton title = primeira página> </a> </li>
Multipage = Multipage <li class = pagenumber>
Se Curpage <> 1 então multipage = multipage <a href = & urlpage = 1 title = Primeira página estilo = decoração de texto: none> <</a> |
Se não for FirstShortcut, Shortcut = AccessKey =, senão atalho =
Se Curpage <> 1 então multipage = multipage <a href = & urlpage = & curpage-1 title = Pagestyle anterior = dececoração de texto: nenhum; & shortcut> </a>
Para PageI = From Page to Topage
Se PageI <> Curpage, então
Multipage = Multipage <a href = & urlpage = & PageI & ANAME> & PAGEI </a> |
Outro
Multipage = Multipage <strong> & PageI </strong>
Se página <>
Final se
Próximo
Se não for FirstShortcut, Shortcut = AccessKey =. caso contrário, atalho =
Se curpá <> páginas, multipage = multipage <a href = & urlpage = & curpage+1 title = próximo pageStyle = text-decoração: none & shortcut> </a>
Se curpá <> páginas então multipage = multipage <a href = & urlpage = & páginas e título de aname = Última página style = text-decoração: none >> </a>
Multipage = Multipage </li>
'Se int (páginas)> int (página) então
'Multipage = Multipage & <li> ... </li> <li> <a href = & url & Page = & Pages & Aname &> & Pages & </a> </li>
'Final se
'Se Curpage <> Páginas então multiprage = multipage & <li class = pager> <a href = & url & page = & Pages & aname & class = PagerButton title = Última página> </a> </li>
Multipage = Multipage </ul> </div>
'Final se
FirstShortcut = true
Função final
Compartilhar: a função geral da ASP para determinar se o valor do banco de dados está vazio Devido a diferentes propriedades de vários campos, os métodos para determinar se um campo está vazio também são diferentes. A seguir, é apresentada uma função geral, que evita a dor do tipo de campo. 'Verifique uma variável não é a função vazia isblank (byref tempvar)' por padrão, suponha que não esteja em branco isblank = false 'agora verifique por variável t