// getJSON으로 크로스도메인 호출하기 - JSONP 콜백 사용하기

// 호출하는 쪽
//아래와 같이 url에 callback=? 를 추가한다
jQuery.getJSON("http://www.yourdomain.com/jsonp/ticker?callback=?",
function(data) {
    alert("Symbol: " + data.symbol + ", Price: " + data.price);
});

callback=?에서 ?는 jQuery가 함수를 생성해서 자동으로 바꿔준다(예: jsonp1232617941775)


// 호출되는 쪽
http://www.yourdomain.com/jsonp/ticker 에서는 아래와 같이 값을 리턴한다

jsonData = "[{""symbol"":""aa"",""price"":""100""}]"
response.write request("callback") & "(" & jsonData & ")"

Posted by ezmind
:
 
textarea 과 button이 나란히 있을경우 버튼이 아래로 약간 내려가는 문제 해결

textarea,
button {vertical-align: middle;}


'WEB > CSS' 카테고리의 다른 글

textarea 사이즈 조절 막기  (0) 2013.03.29
Posted by ezmind
:
 

textarea {resize: none}

Posted by ezmind
:

현재페이지 URL구하기

WEB/ASP 2013. 3. 28. 21:38 |
 

Request.Servervariables("SERVER_NAME") & request.servervariables("url")

request.servervariables("HTTP_URL")

'WEB > ASP' 카테고리의 다른 글

유저정보 구하기  (0) 2013.03.28
아이피 구하기  (0) 2013.03.28
바이너리 파일 읽기 쓰기  (0) 2013.03.28
이미지 사이즈 구하기  (0) 2013.03.28
URLDecode  (0) 2013.03.28
Posted by ezmind
:

유저정보 구하기

WEB/ASP 2013. 3. 28. 21:36 |
 

response.write request.servervariables("HTTP_REFERER") & "<br>"
response.write Request.ServerVariables("REMOTE_ADDR") & "<br>"
'response.write Request.ServerVariables("Http_user_agent")
response.write gOs(Request.ServerVariables("Http_user_agent")) & "<br>"
response.write gBrowser(Request.ServerVariables("Http_user_agent"))


' 사용하는 OS종류를 가져옴
Function gOS(str)

    Dim gTemp
    gTemp = split(Replace(str,")",""),";")
   
    If Str = "" Then gOS = "UnKnown" : Exit Function 
    If UBound(gTemp) < 2 Then gOS = "Unknown" : Exit Function

    gOS = gTemp(2)
End Function


' 브라우져 종류 가져옴
Function gBrowser(str)

    Dim gTemp
    gTemp = split(Replace(str,")",""),";")
       
    If Str = "" Then gBrowser = "UnKnown" : Exit Function
    If UBound(gTemp) < 2 Then  gBrowser = "Unknown" : Exit Function

    gBrowser = gTemp(1)

End Function

'WEB > ASP' 카테고리의 다른 글

현재페이지 URL구하기  (0) 2013.03.28
아이피 구하기  (0) 2013.03.28
바이너리 파일 읽기 쓰기  (0) 2013.03.28
이미지 사이즈 구하기  (0) 2013.03.28
URLDecode  (0) 2013.03.28
Posted by ezmind
:

아이피 구하기

WEB/ASP 2013. 3. 28. 21:35 |
 

Request.ServerVariables("REMOTE_ADDR")

'WEB > ASP' 카테고리의 다른 글

현재페이지 URL구하기  (0) 2013.03.28
유저정보 구하기  (0) 2013.03.28
바이너리 파일 읽기 쓰기  (0) 2013.03.28
이미지 사이즈 구하기  (0) 2013.03.28
URLDecode  (0) 2013.03.28
Posted by ezmind
:
 

Function SaveBinaryData(FileName, ByteArray)
    Const adTypeBinary = 1
    Const adSaveCreateOverWrite = 2
   
    'Create Stream object
    Dim BinaryStream
    Set BinaryStream = CreateObject("ADODB.Stream")
   
    'Specify stream type - we want To save binary data.
    BinaryStream.Type = adTypeBinary
   
    'Open the stream And write binary data To the object
    BinaryStream.Open
    BinaryStream.Write ByteArray
   
    'Save binary data To disk
    BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function


Function SaveTextData(FileName, Text, CharSet)
    Const adTypeText = 2
    Const adSaveCreateOverWrite = 2
   
    'Create Stream object
    Dim BinaryStream
    Set BinaryStream = CreateObject("ADODB.Stream")
   
    'Specify stream type - we want To save text/string data.
    BinaryStream.Type = adTypeText
   
    'Specify charset For the source text (unicode) data.
    If Len(CharSet) > 0 Then
    BinaryStream.CharSet = CharSet
    End If
   
    'Open the stream And write binary data To the object
    BinaryStream.Open
    BinaryStream.WriteText Text
   
    'Save binary data To disk
    BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function



Function ReadBinaryFile(FileName)
    Const adTypeBinary = 1
   
    'Create Stream object
    Dim BinaryStream
    Set BinaryStream = CreateObject("ADODB.Stream")
   
    'Specify stream type - we want To get binary data.
    BinaryStream.Type = adTypeBinary
   
    'Open the stream
    BinaryStream.Open
   
    'Load the file data from disk To stream object
    BinaryStream.LoadFromFile FileName
   
    'Open the stream And get binary data from the object
    ReadBinaryFile = BinaryStream.Read
End Function



Function ReadTextFile(FileName, CharSet)
    Const adTypeText = 2
   
    'Create Stream object
    Dim BinaryStream
    Set BinaryStream = CreateObject("ADODB.Stream")
   
    'Specify stream type - we want To get binary data.
    BinaryStream.Type = adTypeText
   
    'Specify charset For the source text (unicode) data.
    If Len(CharSet) > 0 Then
    BinaryStream.CharSet = CharSet
    End If
   
    'Open the stream
    BinaryStream.Open
   
    'Load the file data from disk To stream object
    BinaryStream.LoadFromFile FileName
   
    'Open the stream And get binary data from the object
    ReadTextFile = BinaryStream.ReadText
End Function


'// Scripting.FileSystemObject object

Function SaveBinaryDataTextStream(FileName, ByteArray)
    'Create FileSystemObject object
    Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")
   
    'Create text stream object
    Dim TextStream
    Set TextStream = FS.CreateTextFile(FileName)
   
    'Convert binary data To text And write them To the file
    TextStream.Write BinaryToString(ByteArray) '// 하단 참조
End Function


'// WinHttpRequest (XMLHTTP, ServerXMLHTTP) and remote files

Function BinaryGetURL(URL)
    'Create an Http object, use any of the four objects
    Dim Http
    '  Set Http = CreateObject("Microsoft.XMLHTTP")
    '  Set Http = CreateObject("MSXML2.ServerXMLHTTP")
    Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
    '  Set Http = CreateObject("WinHttp.WinHttpRequest")
   
    'Send request To URL
    Http.Open "GET", URL, False
    Http.Send
    'Get response data As a string
    BinaryGetURL = Http.ResponseBody
End Function


'// Convert a binary data (BinaryRead) to a string by VBS
'// 1. Use VBS MultiByte functions :
Function SimpleBinaryToString(Binary)
    'SimpleBinaryToString converts binary data (VT_UI1 | VT_ARRAY Or MultiByte string)
    'to a string (BSTR) using MultiByte VBS functions
    Dim I, S
    For I = 1 To LenB(Binary)
    S = S & Chr(AscB(MidB(Binary, I, 1)))
    Next
    SimpleBinaryToString = S
End Function


Function BinaryToString(Binary)
    'Antonin Foller, http://www.pstruh.cz
    'Optimized version of a simple BinaryToString algorithm.
    '// 절대 큰 파일은 읽지마라 -.-
   
    Dim cl1, cl2, cl3, pl1, pl2, pl3
    Dim L
    cl1 = 1
    cl2 = 1
    cl3 = 1
    L = LenB(Binary)
   
    Do While cl1<=L
      pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
      cl1 = cl1 + 1
      cl3 = cl3 + 1
      If cl3>300 Then
       pl2 = pl2 & pl3
       pl3 = ""
       cl3 = 1
       cl2 = cl2 + 1
       If cl2>200 Then
        pl1 = pl1 & pl2
        pl2 = ""
        cl2 = 1
       End If
      End If
    Loop
    BinaryToString = pl1 & pl2 & pl3
End Function



'// 2. Use ADODB.Recordset :
'// ADODB.Recordset lets you work with all supported VARIANT data types - also with binary and String data (VT_UI1 | VT_ARRAY, BSTR). It lets you convert between these two data formats :
Function RSBinaryToString(xBinary)
    'Antonin Foller, http://www.pstruh.cz
    'RSBinaryToString converts binary data (VT_UI1 | VT_ARRAY Or MultiByte string)
    'to a string (BSTR) using ADO recordset
   
    Dim Binary
    'MultiByte data must be converted To VT_UI1 | VT_ARRAY first.
    If vartype(xBinary)=8 Then Binary = MultiByteToBinary(xBinary) Else Binary = xBinary
   
    Dim RS, LBinary
    Const adLongVarChar = 201
    Set RS = CreateObject("ADODB.Recordset")
    LBinary = LenB(Binary)
   
    If LBinary>0 Then
      RS.Fields.Append "mBinary", adLongVarChar, LBinary
      RS.Open
      RS.AddNew
      RS("mBinary").AppendChunk Binary
      RS.Update
      RSBinaryToString = RS("mBinary")
    Else
      RSBinaryToString = ""
    End If
End Function



'// RSBinaryToString is not limitted by time - only by physical memory. The function is up to 100 times faster than MultiByte conversions - you can use it to convert up to 100MB data.
Function MultiByteToBinary(MultiByte)
    '? 2000 Antonin Foller, http://www.pstruh.cz
    ' MultiByteToBinary converts multibyte string To real binary data (VT_UI1 | VT_ARRAY)
    ' Using recordset
    Dim RS, LMultiByte, Binary
    Const adLongVarBinary = 205
    Set RS = CreateObject("ADODB.Recordset")
    LMultiByte = LenB(MultiByte)
    If LMultiByte>0 Then
      RS.Fields.Append "mBinary", adLongVarBinary, LMultiByte
      RS.Open
      RS.AddNew
      RS("mBinary").AppendChunk MultiByte & ChrB(0)
      RS.Update
      Binary = RS("mBinary").GetChunk(LMultiByte)
    End If
    MultiByteToBinary = Binary
End Function



'// 3. Use ADODB.Stream :
'// ADODB.Stream lets you work with String and binary data type. It lets you also convert between these two data formats :
Function Stream_BinaryToString(Binary, CharSet)
    Const adTypeText = 2
    Const adTypeBinary = 1
   
    'Create Stream object
    Dim BinaryStream 'As New Stream
    Set BinaryStream = CreateObject("ADODB.Stream")
   
    'Specify stream type - we want To save text/string data.
    BinaryStream.Type = adTypeBinary
   
    'Open the stream And write text/string data To the object
    BinaryStream.Open
    BinaryStream.Write Binary
   
   
    'Change stream type To binary
    BinaryStream.Position = 0
    BinaryStream.Type = adTypeText
   
    'Specify charset For the source text (unicode) data.
    If Len(CharSet) > 0 Then
      BinaryStream.CharSet = CharSet
    Else
      BinaryStream.CharSet = "us-ascii"
    End If
   
    'Open the stream And get binary data from the object
    Stream_BinaryToString = BinaryStream.ReadText
End Function

'WEB > ASP' 카테고리의 다른 글

유저정보 구하기  (0) 2013.03.28
아이피 구하기  (0) 2013.03.28
이미지 사이즈 구하기  (0) 2013.03.28
URLDecode  (0) 2013.03.28
Server Variables 다 보기  (0) 2013.03.28
Posted by ezmind
:

이미지 사이즈 구하기

WEB/ASP 2013. 3. 28. 21:33 |
 

Sub GetImageSize(ByVal f, ByRef x, ByRef y)        
        Dim p
        Set p = LoadPicture(f)
        x = CLng(CDbl(p.Width) * 24 / 635) 
        y = CLng(CDbl(p.Height) * 24 / 635)
       
        Set p = Nothing
    End Sub
   
    dim x,y
    GetImageSize "c:\inetpub\wwwroot\test\warning.gif", x, y
    response.write "x=" & x
    response.write "<br>"
    response.write "y=" & y

'WEB > ASP' 카테고리의 다른 글

아이피 구하기  (0) 2013.03.28
바이너리 파일 읽기 쓰기  (0) 2013.03.28
URLDecode  (0) 2013.03.28
Server Variables 다 보기  (0) 2013.03.28
MD5 소스  (0) 2013.03.28
Posted by ezmind
:

URLDecode

WEB/ASP 2013. 3. 28. 21:32 |
 

Function URLDecode(Expression)

    Dim strSource, strTemp, strResult, strchr
    Dim lngPos, AddNum, IFKor
    strSource = Replace(Expression, "+", " ")
    For lngPos = 1 To Len(strSource)
        AddNum = 2
        strTemp = Mid(strSource, lngPos, 1)
        If strTemp = "%" Then
            If lngPos + AddNum < Len(strSource) + 1 Then
                strchr = CInt("&H" & Mid(strSource, lngPos + 1, AddNum))
                If strchr > 130 Then
                    AddNum = 5
                    IFKor = Mid(strSource, lngPos + 1, AddNum)
                    IFKor = Replace(IFKor, "%", "")
                    strchr = CInt("&H" & IFKor )
                End If
                strResult = strResult & Chr(strchr)
                lngPos = lngPos + AddNum
            End If
        Else
            strResult = strResult & strTemp
        End If
    Next
    URLDecode = strResult
   
End Function

'WEB > ASP' 카테고리의 다른 글

바이너리 파일 읽기 쓰기  (0) 2013.03.28
이미지 사이즈 구하기  (0) 2013.03.28
Server Variables 다 보기  (0) 2013.03.28
MD5 소스  (0) 2013.03.28
MapPath  (0) 2013.03.28
Posted by ezmind
:

Server Variables 다 보기

WEB/ASP 2013. 3. 28. 21:32 |
 

<%
    for each key in request.servervariables
        response.write key & " = " & Request.ServerVariables(key) & "<br>"
    next
%>

'WEB > ASP' 카테고리의 다른 글

이미지 사이즈 구하기  (0) 2013.03.28
URLDecode  (0) 2013.03.28
MD5 소스  (0) 2013.03.28
MapPath  (0) 2013.03.28
페이지에 넘어온 모든 Form값 보기  (0) 2013.03.28
Posted by ezmind
: