推奨:ASP開発における機能の有用なコレクション(2) ASP開発における有用な機能のコレクションは非常に便利です。それを維持してください! '*************************************************'フィルタリングハイパーリンク '***********************************関数CECKURL(byVal Chkstr)dim str:str = chkstr str = trim(str)isnull(str)isnull(str)じゃあチェックからチェック
ASP開発における有用な機能のコレクションは非常に便利です!みんながそれを維持してくれることを願っています!
<%
'**********************************
'外部提出を防ぎます
'**********************************
関数chkpost()
dim server_v1、server_v2
chkpost = false
server_v1 = cstr(request.servervariables(http_referer))
server_v2 = cstr(request.servervariables(server_name))
if mid(server_v1,8、len(server_v2))<> server_v2 then
chkpost = false
それ以外
chkpost = true
ifを終了します
エンド関数
'**********************************
'IPフィルタリング
'**********************************
function matthip(IP)
エラーの再開時に次に再開します
matchip = false
薄暗いSIP、スプリット
filteripのSIPごとに
sip =置換(sip、*、/d*)
splitip = split(sip、。)
dim re、strmatchs、ストリップ
re = new regexpを設定します
re.ignorecase = true
re.global = true
re.pattern =(&splitip(0)|)。(&splitip(1)|)。(&splitip(2)|)。(&splitip(3)|)
strmatchs = re.execute(ip)を設定します
strip = strmatchs(0).submatches(0)&。 &strmatchs(0).submatches(1)&。 &strmatchs(0).submatches(2)&。 &strmatchs(0).submatches(3)
strip = ipの場合、matthip = true:exit function
StrMatchsを設定=何もない
re =何も設定しません
次
エンド関数
'**********************************
'登録コードを取得します
'**********************************
関数getCode()
getCode = <img src = common/getcode.asp alt = style = marve-right:40px;/>
エンド関数
'**********************************
'ファイルタイプを制限します
'**********************************
関数isvalidfile(file_type)
isvalidfile = false
DIM GNAME
up_filetypeの各gnameについて
file_type = gnameの場合
isvalidfile = true
の出口
ifを終了します
次
エンド関数
'**********************************
'英語と数字のみが含まれているかどうかを検出します
'**********************************
関数isvalidchars(str)
Dim Re、Chkstr
re = new regexpを設定します
re.ignorecase = true
re.global = true
re.pattern = [^_/。a-za-z/d]
isvalidchars = true
chkstr = re.replace(str、)
chkstr <> strの場合、isvalidchars = false
re =何も設定しません
エンド関数
'**********************************
'英語と数字のみが含まれているかどうかを検出します
'**********************************
関数isValidValue(arrayn、str)
isValidValue = false
DIM GNAME
arraynの各gnameについて
str = gnameの場合
isValidValue = true
の出口
ifを終了します
次
エンド関数
'**********************************
'番号が有効かどうかを検出します
'**********************************
関数isinteger(パラ)
isinteger = false
そうでない場合(isnull(para)またはtrim(para)=またはnot not isNumeric(para))
isinteger = true
ifを終了します
エンド関数
'**********************************
'ユーザー名検出
'**********************************
関数isvalidusername(byvalユーザー名)
エラーの再開時に次に再開します
Dim I、c
Dim vusername
isvalidusername = true
i = 1 to len(username)へ
c = lcase(mid(username、i、1))
if strust(!<>?#^%@〜 `&*();:+= '、c)> 0
isvalidusername = false
出口機能
ifを終了します
次
Register_usernameの各vusernameについて
username = vusernameの場合
isvalidusername = false
の出口
ifを終了します
次
エンド関数
'**********************************
'電子メールアドレスが有効かどうかを確認してください
'**********************************
関数isvalidemail(電子メール)
薄暗い名前、名前、i、c
isvalidemail = true
names = split(email、 @)
ubound(names)<> 1の場合
isvalidemail = false
出口機能
ifを終了します
名前の各名前
len(name)<= 0の場合
isvalidemail = false
出口機能
ifを終了します
i = 1からlen(name)へ
c = lcase(mid(name、i、1))
If strust(abcdefghijklmnopqrstuvwxyz_-。、c)<= 0以下ではありません(c)
isvalidemail = false
出口機能
ifを終了します
次
残っている場合(名前、1)=。または右(名前、1)=。それから
isvalidemail = false
出口機能
ifを終了します
次
IF IF IF(名前(1)、。)<= 0
isvalidemail = false
出口機能
ifを終了します
i = len(names(1)) - instrrev(names(1)、。)
i <> 2とi <> 3の場合
isvalidemail = false
出口機能
ifを終了します
If strums(email、..)> 0 then
isvalidemail = false
ifを終了します
エンド関数
'**********************************
'キーワードを強調表示します
'**********************************
関数ハイライト(byval strcontent、byref arraywords)
dim intcounter、strtemp、intpos、inttaglength、intkeywordlength、bupdate
len(arraywords)<1の場合、highlight = strcontent:exit function
intpos = 1からlen(strcontent)へ
bupdate = false
mid(strcontent、intpos、1)= <thenの場合
エラーの再開時に次に再開します
inttaglength =(strus(intpos、strcontent、>、1) - intpos)
エラーの場合
ハイライト= strcontent
err.clear
ifを終了します
strtemp = strtemp&mid(strcontent、intpos、inttaglength)
intpos = intpos + inttaglength
ifを終了します
arraywords <>の場合
intkeywordlength = len(arraywords)
lcase(mid(strcontent、intpos、intkeywordlength))= lcase(arraywords)の場合
strtemp = strtemp&<span class = high1>&mid(strcontent、intpos、intkeywordlength)&</span>
intpos = intpos + intkeywordlength -1
bupdate = true
ifを終了します
ifを終了します
bupdate = falseの場合
strtemp = strtemp&mid(strcontent、intpos、1)
ifを終了します
次
ハイライト= strtemp
エンド関数
共有:ASP開発における機能の有用なコレクション(3) ASP開発における有用な機能のコレクションは非常に便利です。それを維持してください! '*************************************'スライスコンテンツスプリットバイライン '****************************関数スプリットライン(バイバルコンテンツ、バイバルコンテンツナム)ディムTS、I、Lコンテンツナム= int(