레이블이 Classic ASP인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Classic ASP인 게시물을 표시합니다. 모든 게시물 표시

17. 1. 5.

Classic ASP 인스타그램(Instagram) API 로그인

login.asp 파일
<script type="text/javascript">
function instagramlogin(){
 var openUrl = "https://api.instagram.com/oauth/authorize/";
 var client_id = "97e52e1da4064299b2a1ba87db3c4167";
 var return_url = "http://www.mysite.com/login/instagram.asp";
 var DataVal = "";
 DataVal += "client_id="+escape(client_id).replace(/\+/gi, '%2B');;
 DataVal += "&redirect_uri="+escape(return_url).replace(/\+/gi, '%2B');
 DataVal += "&response_type=code";
 var instagramLogin = window.open(openUrl+"?"+DataVal,"instagramLogin","width=450,height=300,scrollbars=no");
 instagramLogin.focus();
}
</script>

<a onclick="instagramlogin();">인스타그램(Instagram) 로그인</a>

instagram.asp 파일
<!-- #include file = "aspJSON1.17.asp"--><%

 return_code = request.QueryString("code")

 returnURL = server.URLEncode("http://www.mysite.com/login/instagram.asp")
 client_id = "97e52e1da4064299b2a1ba87db3c4167"
 client_secret = "db0bcf2b60124ff5a1234298f80a8ca8"

 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 httpObj.open "POST" , "https://api.instagram.com/oauth/access_token", False
 httpObj.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
 httpObj.Send "grant_type=authorization_code&client_id=" & client_id & "&client_secret=" & client_secret & "&redirect_uri=" & returnURL & "&code=" & return_code
 httpObj.WaitForResponse

 If httpObj.Status = "200" Then
  JsonText = httpObj.ResponseText
 Else
  JsonText = null
 End If 

 Set oJSON = New aspJSON
 oJSON.loadJSON(JsonText)

 If oJSON.data("error") = "" then
  UsrId = oJSON.data("user").item("id")
  UserNn = oJSON.data("user").item("username")

  response.write(UsrId & " 님 안녕하세요")
 End If
%>

참고
aspJSON1.17.asp 파일
<%
'Februari 2014 - Version 1.17 by Gerrit van Kuipers
Class aspJSON
 Public data
 Private p_JSONstring
 private aj_in_string, aj_in_escape, aj_i_tmp, aj_char_tmp, aj_s_tmp, aj_line_tmp, aj_line, aj_lines, aj_currentlevel, aj_currentkey, aj_currentvalue, aj_newlabel, aj_XmlHttp, aj_RegExp, aj_colonfound

 Private Sub Class_Initialize()
  Set data = Collection()

     Set aj_RegExp = new regexp
     aj_RegExp.Pattern = "\s{0,}(\S{1}[\s,\S]*\S{1})\s{0,}"
     aj_RegExp.Global = False
     aj_RegExp.IgnoreCase = True
     aj_RegExp.Multiline = True
 End Sub

 Private Sub Class_Terminate()
  Set data = Nothing
     Set aj_RegExp = Nothing
 End Sub

 Public Sub loadJSON(inputsource)
  inputsource = aj_MultilineTrim(inputsource)
  If Len(inputsource) = 0 Then Err.Raise 1, "loadJSON Error", "No data to load."
  
  select case Left(inputsource, 1)
   case "{", "["
   case else
    Set aj_XmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    aj_XmlHttp.open "GET", inputsource, False
    aj_XmlHttp.setRequestHeader "Content-Type", "text/json"
    aj_XmlHttp.setRequestHeader "CharSet", "UTF-8"
    aj_XmlHttp.Send
    inputsource = aj_XmlHttp.responseText
    set aj_XmlHttp = Nothing
  end select

  p_JSONstring = CleanUpJSONstring(inputsource)
  aj_lines = Split(p_JSONstring, Chr(13) & Chr(10))

  Dim level(99)
  aj_currentlevel = 1
  Set level(aj_currentlevel) = data
  For Each aj_line In aj_lines
   aj_currentkey = ""
   aj_currentvalue = ""
   If Instr(aj_line, ":") > 0 Then
    aj_in_string = False
    aj_in_escape = False
    aj_colonfound = False
    For aj_i_tmp = 1 To Len(aj_line)
     If aj_in_escape Then
      aj_in_escape = False
     Else
      Select Case Mid(aj_line, aj_i_tmp, 1)
       Case """"
        aj_in_string = Not aj_in_string
       Case ":"
        If Not aj_in_escape And Not aj_in_string Then
         aj_currentkey = Left(aj_line, aj_i_tmp - 1)
         aj_currentvalue = Mid(aj_line, aj_i_tmp + 1)
         aj_colonfound = True
         Exit For
        End If
       Case "\"
        aj_in_escape = True
      End Select
     End If
    Next
    if aj_colonfound then
     aj_currentkey = aj_Strip(aj_JSONDecode(aj_currentkey), """")
     If Not level(aj_currentlevel).exists(aj_currentkey) Then level(aj_currentlevel).Add aj_currentkey, ""
    end if
   End If
   If right(aj_line,1) = "{" Or right(aj_line,1) = "[" Then
    If Len(aj_currentkey) = 0 Then aj_currentkey = level(aj_currentlevel).Count
    Set level(aj_currentlevel).Item(aj_currentkey) = Collection()
    Set level(aj_currentlevel + 1) = level(aj_currentlevel).Item(aj_currentkey)
    aj_currentlevel = aj_currentlevel + 1
    aj_currentkey = ""
   ElseIf right(aj_line,1) = "}" Or right(aj_line,1) = "]" or right(aj_line,2) = "}," Or right(aj_line,2) = "]," Then
    aj_currentlevel = aj_currentlevel - 1
   ElseIf Len(Trim(aj_line)) > 0 Then
    if Len(aj_currentvalue) = 0 Then aj_currentvalue = aj_line
    aj_currentvalue = getJSONValue(aj_currentvalue)

    If Len(aj_currentkey) = 0 Then aj_currentkey = level(aj_currentlevel).Count
    level(aj_currentlevel).Item(aj_currentkey) = aj_currentvalue
   End If
  Next
 End Sub

 Public Function Collection()
  set Collection = Server.CreateObject("Scripting.Dictionary")
 End Function

 Public Function AddToCollection(dictobj)
  if TypeName(dictobj) <> "Dictionary" then Err.Raise 1, "AddToCollection Error", "Not a collection."
  aj_newlabel = dictobj.Count
  dictobj.Add aj_newlabel, Collection()
  set AddToCollection = dictobj.item(aj_newlabel)
 end function

 Private Function CleanUpJSONstring(aj_originalstring)
  aj_originalstring = Replace(aj_originalstring, Chr(13) & Chr(10), "")
  aj_originalstring = Mid(aj_originalstring, 2, Len(aj_originalstring) - 2)
  aj_in_string = False : aj_in_escape = False : aj_s_tmp = ""
  For aj_i_tmp = 1 To Len(aj_originalstring)
   aj_char_tmp = Mid(aj_originalstring, aj_i_tmp, 1)
   If aj_in_escape Then
    aj_in_escape = False
    aj_s_tmp = aj_s_tmp & aj_char_tmp
   Else
    Select Case aj_char_tmp
     Case "\" : aj_s_tmp = aj_s_tmp & aj_char_tmp : aj_in_escape = True
     Case """" : aj_s_tmp = aj_s_tmp & aj_char_tmp : aj_in_string = Not aj_in_string
     Case "{", "["
      aj_s_tmp = aj_s_tmp & aj_char_tmp & aj_InlineIf(aj_in_string, "", Chr(13) & Chr(10))
     Case "}", "]"
      aj_s_tmp = aj_s_tmp & aj_InlineIf(aj_in_string, "", Chr(13) & Chr(10)) & aj_char_tmp
     Case "," : aj_s_tmp = aj_s_tmp & aj_char_tmp & aj_InlineIf(aj_in_string, "", Chr(13) & Chr(10))
     Case Else : aj_s_tmp = aj_s_tmp & aj_char_tmp
    End Select
   End If
  Next

  CleanUpJSONstring = ""
  aj_s_tmp = split(aj_s_tmp, Chr(13) & Chr(10))
  For Each aj_line_tmp In aj_s_tmp
   aj_line_tmp = replace(replace(aj_line_tmp, chr(10), ""), chr(13), "")
   CleanUpJSONstring = CleanUpJSONstring & aj_Trim(aj_line_tmp) & Chr(13) & Chr(10)
  Next
 End Function

 Private Function getJSONValue(ByVal val)
  val = Trim(val)
  If Left(val,1) = ":"  Then val = Mid(val, 2)
  If Right(val,1) = "," Then val = Left(val, Len(val) - 1)
  val = Trim(val)

  Select Case val
   Case "true"  : getJSONValue = True
   Case "false" : getJSONValue = False
   Case "null" : getJSONValue = Null
   Case Else
    If (Instr(val, """") = 0) Then
     If IsNumeric(val) Then
      getJSONValue = CDbl(val)
     Else
      getJSONValue = val
     End If
    Else
     If Left(val,1) = """" Then val = Mid(val, 2)
     If Right(val,1) = """" Then val = Left(val, Len(val) - 1)
     getJSONValue = aj_JSONDecode(Trim(val))
    End If
  End Select
 End Function

 Private JSONoutput_level
 Public Function JSONoutput()
  dim wrap_dicttype, aj_label
  JSONoutput_level = 1
  wrap_dicttype = "[]"
  For Each aj_label In data
    If Not aj_IsInt(aj_label) Then wrap_dicttype = "{}"
  Next
  JSONoutput = Left(wrap_dicttype, 1) & Chr(13) & Chr(10) & GetDict(data) & Right(wrap_dicttype, 1)
 End Function

 Private Function GetDict(objDict)
  dim aj_item, aj_keyvals, aj_label, aj_dicttype
  For Each aj_item In objDict
   Select Case TypeName(objDict.Item(aj_item))
    Case "Dictionary"
     GetDict = GetDict & Space(JSONoutput_level * 4)
     
     aj_dicttype = "[]"
     For Each aj_label In objDict.Item(aj_item).Keys
       If Not aj_IsInt(aj_label) Then aj_dicttype = "{}"
     Next
     If aj_IsInt(aj_item) Then
      GetDict = GetDict & (Left(aj_dicttype,1) & Chr(13) & Chr(10))
     Else
      GetDict = GetDict & ("""" & aj_JSONEncode(aj_item) & """" & ": " & Left(aj_dicttype,1) & Chr(13) & Chr(10))
     End If
     JSONoutput_level = JSONoutput_level + 1
     
     aj_keyvals = objDict.Keys
     GetDict = GetDict & (GetSubDict(objDict.Item(aj_item)) & Space(JSONoutput_level * 4) & Right(aj_dicttype,1) & aj_InlineIf(aj_item = aj_keyvals(objDict.Count - 1),"" , ",") & Chr(13) & Chr(10))
    Case Else
     aj_keyvals =  objDict.Keys
     GetDict = GetDict & (Space(JSONoutput_level * 4) & aj_InlineIf(aj_IsInt(aj_item), "", """" & aj_JSONEncode(aj_item) & """: ") & WriteValue(objDict.Item(aj_item)) & aj_InlineIf(aj_item = aj_keyvals(objDict.Count - 1),"" , ",") & Chr(13) & Chr(10))
   End Select
  Next
 End Function

 Private Function aj_IsInt(val)
  aj_IsInt = (TypeName(val) = "Integer" Or TypeName(val) = "Long")
 End Function

 Private Function GetSubDict(objSubDict)
  GetSubDict = GetDict(objSubDict)
  JSONoutput_level= JSONoutput_level -1
 End Function

 Private Function WriteValue(ByVal val)
  Select Case TypeName(val)
   Case "Double", "Integer", "Long": WriteValue = val
   Case "Null"      : WriteValue = "null"
   Case "Boolean"     : WriteValue = aj_InlineIf(val, "true", "false")
   Case Else      : WriteValue = """" & aj_JSONEncode(val) & """"
  End Select
 End Function

 Private Function aj_JSONEncode(ByVal val)
  val = Replace(val, "\", "\\")
  val = Replace(val, """", "\""")
  'val = Replace(val, "/", "\/")
  val = Replace(val, Chr(8), "\b")
  val = Replace(val, Chr(12), "\f")
  val = Replace(val, Chr(10), "\n")
  val = Replace(val, Chr(13), "\r")
  val = Replace(val, Chr(9), "\t")
  aj_JSONEncode = Trim(val)
 End Function

 Private Function aj_JSONDecode(ByVal val)
  val = Replace(val, "\""", """")
  val = Replace(val, "\\", "\")
  val = Replace(val, "\/", "/")
  val = Replace(val, "\b", Chr(8))
  val = Replace(val, "\f", Chr(12))
  val = Replace(val, "\n", Chr(10))
  val = Replace(val, "\r", Chr(13))
  val = Replace(val, "\t", Chr(9))
  aj_JSONDecode = Trim(val)
 End Function

 Private Function aj_InlineIf(condition, returntrue, returnfalse)
  If condition Then aj_InlineIf = returntrue Else aj_InlineIf = returnfalse
 End Function

 Private Function aj_Strip(ByVal val, stripper)
  If Left(val, 1) = stripper Then val = Mid(val, 2)
  If Right(val, 1) = stripper Then val = Left(val, Len(val) - 1)
  aj_Strip = val
 End Function

 Private Function aj_MultilineTrim(TextData)
  aj_MultilineTrim = aj_RegExp.Replace(TextData, "$1")
 End Function

 private function aj_Trim(val)
  aj_Trim = Trim(val)
  Do While Left(aj_Trim, 1) = Chr(9) : aj_Trim = Mid(aj_Trim, 2) : Loop
  Do While Right(aj_Trim, 1) = Chr(9) : aj_Trim = Left(aj_Trim, Len(aj_Trim) - 1) : Loop
  aj_Trim = Trim(aj_Trim)
 end function
End Class
%>

14. 1. 10.

안드로이드 Classic ASP PUSH 서버

push.asp 파일
<%
 ' 안드로이드 ASP 푸시 요청
 PushServerURL = "https://android.googleapis.com/gcm/send"

'  브라우저APIkey
 ApplicationAPIKey = "AIzaSyBi0pn1ckaJhRL9kK3mbwsHzk7x0fdE_Z8"

 ' regId(받을사람이 지급받은 registration_ids - 여러명일 경우 배열로 받아처리하면 될 듯 최대 1000)
 RegId = "APA91bFNkzpbgBJnWkDgyGmU0XsF8ZLMAEhVaAtcbf9po8_i1GoA4JNt4HiUc6xScBMEOoJMIHHybZECIns9e2EF4AGalfOgZqwmQIEUG1UpVk08nTapx0iY17vOELD_9wIQTUdRwUsR"

 ' 알림명
 tickerText = "알림테스트"
 ' 알림 제목
 contentTitle = "테스트 제목"
 ' 알림 내용
 message = "헬로~~~ 테스트입니다.~~~"

 postJSONData = "" & _
    "{" & _
    "  ""registration_ids"" : [ """ & RegId & """ ]" & _
    ", ""data"": {" & _
    "                 ""tickerText"" : """ & tickerText & """" & _
    "               , ""contentTitle"" : """ & contentTitle & """" & _
    "               , ""message"" : """ & message & """" & _
    "            }" & _
    "}"

 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 httpObj.open "POST" , PushServerURL, False
 httpObj.SetRequestHeader "Content-Type", "application/json"
 httpObj.SetRequestHeader "Authorization", "key=" & ApplicationAPIKey
 httpObj.Send postJSONData
 httpObj.WaitForResponse

 If httpObj.Status = "200" Then
  response.Write("전송성공 : " & httpObj.ResponseText)
 Else
  response.Write("전송실패 : " & httpObj.ResponseText)
 End If

%>


참고:
html
<form method="post" action="push.asp">
    tickerText :
    <input type="text" name="tickerText" value="알림테스트" /><br>
    contentTitle :
    <input type="text" name="contentTitle" value="테스트 제목" /><br>
    message :
    <textarea name="message">헬로~~~ 테스트입니다.~~~</textarea><br>
    RegId :
    <input type="text" name="RegId" value="APA91bFNkzpbgBJnWkDgyGmU0XsF8ZLMAEhVaAtcbf9po8_i1GoA4JNt4HiUc6xScBMEOoJMIHHybZECIns9e2EF4AGalfOgZqwmQIEUG1UpVk08nTapx0iY17vOELD_9wIQTUdRwUsR" /><br>
    <input type="text" name="RegId" value="APA91bFNkzpbgBJnWkDgyGmU0XsF8ZLMAEhVaAtcbf9pp8_i1GoA4JNt4HiUc6xScBMEOoJMIHHybZECIns9e2EF4AGalfOgZqwmQIEUG1UpVk08nTapx0iY17vOELD_9wIQTUdRwUsR" /><br>
    <input type="text" name="RegId" value="APA91bFNkzpbgBJnWkDgyGmU0XsF8ZLMAEhVaAtcbf9pd8_i1GoA4JNt4HiUc6xScBMEOoJMIHHybZECIns9e2EF4AGalfOgZqwmQIEUG1UpVk08nTapx0iY17vOELD_9wIQTUdRwUsR" /><br>
    <input type="submit" value="전송요청" />
</form>
asp
<%
 tickerText = request.Form("tickerText")
 contentTitle = request.Form("contentTitle")
 message = request.Form("message")
 RegId_Count = request.Form("RegId").Count
 RegId = ""
 For i = 1 To RegId_Count
  if i<>1 then RegId = RegId & ","
  RegId = RegId & """" & request.Form("RegId")(i) & """"
 Next


 postJSONData = "" & _
    "{" & _
    "  ""registration_ids"" : [ " & RegId & " ]" & _
    ", ""data"": {" & _
    "                 ""tickerText"" : """ & tickerText & """" & _
    "               , ""contentTitle"" : """ & contentTitle & """" & _
    "               , ""message"" : """ & message & """" & _
    "            }" & _
    "}"

%>

13. 5. 21.

Classic ASP Email 전송

<%
    
' Mail 발송
Function eMailCDOSend(MailTitle, MailTag, Sender, Receiver) 
 ' MailTitle : 제목
 ' MailTag : html내용
 ' Sender : 보내는 사람
 ' Receiver : 받는사람
 ' 2008서버 이상 에서 발송하는 환경정보 설정
 Dim eMailObject, eMailConfig
 Set eMailObject = Server.CreateObject("CDO.Message")
 Set eMailConfig = Server.CreateObject("CDO.Configuration")
 Dim SchemaPath : SchemaPath = "http://schemas.microsoft.com/cdo/configuration/"
 With eMailConfig.Fields
  .Item (SchemaPath & "sendusing") = 2  'CDOSendUsingPort
  .Item (SchemaPath & "smtpserver") = "127.0.0.1"  'CDOSendUsingPort [ServerIP]
  .Item (SchemaPath & "smtpserver") = "localhost"    'CDOSendUsingPort
  .Item (SchemaPath & "smtpserverport") = "25"  'Port
  .Update
 End With
 eMailObject.Configuration = eMailConfig
 Set eMailConfig = Nothing
 With eMailObject
  .From = Sender
  .To = Receiver
  .Subject = MailTitle
  .HTMLBody = MailTag
'  .HTMLBodyPart.Charset = "Utf-8"
  .Send
 End With
 Set eMailObject = Nothing
End Function


%>

Class ASP 에서 사이트 소스 긁어오기

<%
'페이지로드Post방식
Function getSiteSourcePost( siteURL, params )
 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 httpObj.open "POST" , siteURL, False
 httpObj.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
 '포스트 방식시 위의 라인을 추가해 주어야 한다.
 
 httpObj.Send params
 '포스트의 파라미터는 Send 호출시 같이 값을 넘겨 주어야 한다.
 httpObj.WaitForResponse
 If httpObj.Status = "200" Then
  getSiteSourcePost = httpObj.ResponseText
 Else
  getSiteSourcePost = null
 End If 
End Function

'페이지로드 get방식
Function getSiteSourceGet( siteURL, params )
 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 httpObj.open "GET", siteURL & "?" & params, False
 
 httpObj.Send()
 httpObj.WaitForResponse
 If httpObj.Status = "200" Then
  getSiteSourceGet = httpObj.ResponseText
 Else
  getSiteSourceGet = null
 End If 
End Function

'네이버
response.write(getSiteSourcePost("http://www.naver.com",""))

'다음
response.write(getSiteSourcePost("http://www.daum.net",""))
%>

Classic ASP HTML 태그 제거

'태그제거
function StripTags( htmlDoc )
  dim rex
  set rex = new Regexp
  rex.Pattern= "<[^>]+>"
  rex.Global=true
  StripTags =rex.Replace(htmlDoc,"")
end function

html = "<a href=""http://2nusa.blogspot.kr/""><b>Hello My World</b></a>"

response.write(StripTags(html ))

13. 5. 12.

Classic ASP 영상파일 이미지추출

Set Executor = Server.CreateObject("ASPExec.Execute")

fileUrl = "d:\file\abc.avi"

if fs.FileExists(fileUrl) then
 VideoimgName = fs.getfilename(fileUrl)
 VideoimgNameArr = split(VideoimgName,".")
 if isArray(VideoimgNameArr) then
  vFileName = "v" & mid(VideoimgNameArr(0),2)
  Executor.Application = "ffmpeg -y -i " & fileUrl & " -vframes 1 -ss 00:00:02 -an -vcodec png -f rawvideo -s 400*300 d:\file\videoimg\" & vFileName & ".png"
  Executor.Parameters = ""
  strResult = Executor.ExecuteDosApp
  vImg = "'/file/videoimg/"& vFileName & ".png'"
 end if
end if

13. 5. 11.

Classic ASP 모바일 체크

    dim u,b,v

    set u=Request.ServerVariables("HTTP_USER_AGENT")
    set b=new RegExp
    set v=new RegExp

    b.Pattern="android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino"
    v.Pattern="1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-"

    b.IgnoreCase=true
    v.IgnoreCase=true

    b.Global=true
    v.Global=true

    if b.test(u) or v.test(Left(u,4)) then
        Response.Write("모바일페이지입니다.")
    end if

13. 5. 10.

Classic ASP 와 MS-SQL 연동

<OBJECT RUNAT="server" PROGID=ADODB.Connection id="ObjConn"> </OBJECT>
<%
   dim fs,objFile
   dim ObjSql ,WhereSql ,Rs,i,ListArr
   dim Field0,Field1,,Field2,Field3,Field4
   dim Val1, Val12,Url 
   dim intNowPage ,intPageSize ,intBlockPage 

   Set fs = Server.CreateObject("Scripting.FileSystemObject")
   Set objFile = fs.OpenTextFile("c:\DB_file.dat",1)
   ' c:\DB_file.dat 내용
   ' Provider=SQLOLEDB.1;User ID=sa;Password=1111;Initial Catalog=master;Data Source=123.123.123.123,1433
   ObjConn.open objFile.readline
 
   Val1 = Request.QueryString("Val1")
   Val2 = Request.QueryString("Val2")
 
   If Val1<>"" and Val12<>"" Then
      WhereSql = " WHERE " & Val1 & "='" & Val2 & & "'"
      Url = "&Val1=" & Val1 & "&Val2 =" & Val2
   End If
 
   ObjSql = "SELECT * FROM DB_TABLE" & WhereSql 
 
   Set Rs=ObjConn.Execute(ObjSql)
   If Not Rs.Eof Then ListArr = Rs.Getrows ' DB를 ListArr 에 저장
   Rs.Close
   Set Rs=Nothing
 
   intNowPage = Request.QueryString("page")  ' 현제페이지
   intPageSize = 10    ' 페이지크기
   intBlockPage = 10   ' 페이지묶음크기
 
    If Len(intNowPage) = 0 Then      ' 현제페이지값이없을경우
        intNowPage = 1
    End If

    If isArray(ListArr) then               ' 목록이 있을경우 페이지 수
       intTotalCount = Ubound(ListArr,2)+1
       If (intTotalCount Mod intPageSize)=0 Then
          intTotalPage = int(intTotalCount/intPageSize)
       Else
          intTotalPage = int(intTotalCount/intPageSize)+1
       End if
    End if

   If isArray(ListArr) Then   '자료 있다면 변수에 저장
     ' 페이지 나눌경우(없을경우 0 To Ubound(ListArr,2))
      For i=0+(intNowPage*intPageSize-intPageSize) to (intNowPage*intPageSize)-1   
        If i<=Ubound(ListArr,2) then
           Field0 = ListArr(0,i)
           Field1 = ListArr(1,i)
           Field2 = ListArr(2,i)
           Field3 = ListArr(3,i)
           Field4 = ListArr(4,i)
        End If
     Next
 
   ' 페이지 나누기
If isArray(ListArr) Then 
    intTemp = Int((intNowPage - 1) / intBlockPage) * intBlockPage + 1
 
    If intTemp = 1 Then
     Response.Write("◀")
    Else 
     Response.Write("<a href=""?page=" & intTemp - intBlockPage & Url & """>◀</a>")
    End If
 
    intLoop = 1
 
    Do Until intLoop > intBlockPage Or intTemp > intTotalPage
     If intTemp = CInt(intNowPage) Then
      Response.Write("<font size= 3><b>" & intTemp &"</b></font> " )
     Else
      Response.Write("<a href=""?page=" & intTemp &url &""">" & intTemp& "</a> ")
     End If
     intTemp = intTemp + 1
     intLoop = intLoop + 1
    Loop
 
     If intTemp > intTotalPage Then
       Response.Write("▶")
     Else
       Response.Write("<a href=""?page=" & intTemp & Url &  """>▶</a>")
     End If
   End if
%>