1 / 1
"ASP"으로 검색하여,
8 건의 기사가 검색 되었습니다.
-
2020-01-14ASP에서 UTF-8로 작성하는 경우<%@Language="VBScript" CODEPAGE="65001" %><% Option Explicit %><%Response.CharSet="utf-8"Session.codepage="65001"Response.codepage="65001"Response.ContentType="text/html;charset=utf-8"Response.expires = 0Server.ScriptTimeout = 180%>
-
2014-11-17ASP에서 메일을 보내는 경우 CDO.Message를 이용하여 보내야 한다.사이트내에서 메일보내기는 대게 보내는 메일주소가 일정하므로 보내는 메일주소정보가 함수내 포함하도록 했다.sendmail 함수내의 Const 부분을 환경에 맞게 수정하여 사용하면 된다.사용시 중간부분의 "on error resume next" 부분을 주석으로 막고 테스트후 정상작동하는 경우 사용한다.메일 발송시 보내지는 주소(SEND_USER_NAME)과 실제 메일주소(MAIL_FROM)가 동리하지 않아도 대부분 발송이 되지만daum의 경우에는 이부분이 동일한지 확인하도록 되어있습니다. 사이트 이용자가 메일수신을 다음으로 하는 경우에 대비하여 되도록 일치하도록 하는 것이 좋습니다.<%'===============================' use relay SMTP'===============================function SendMail( cSubject, cMailTo, cBody )Const MAIL_FROM = "메일러(발송전용)<user@mailserver.com>" Const SMTP_SERVER = "mail.mailserver.com"Const SMTP_SERVER_PORT = 25Const SEND_USER_NAME = "user@mailserver.com" Const SEND_PASSWORD = "password" Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing" Const cdoSendUsingPort = 2 '== 1일 경우 로컬(SMTP), 2일 경우 외부(SMTP)로 메일전송Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver" Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport" Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" Const cdoSMTPAccountName = "http://schemas.microsoft.com/cdo/configuration/smtpaccountname" Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" Const cdoBasic = 1 Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername" Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword" on error resume nextdim oConfig ' As CDO.Configuration dim oMessage ' As CDO.Message dim oFields ' As ADODB.oFields '== Get a handle on the config object and it's oFields set oConfig = Server.CreateObject("CDO.Configuration") set oFields = oConfig.Fields '== set config oFields we care about with oFields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = SMTP_SERVER.Item(cdoSMTPServerPort) = SMTP_SERVER_PORT.Item(cdoSMTPAuthenticate) = cdoBasic .Item(cdoSendUserName) = SEND_USER_NAME.Item(cdoSendPassword) = SEND_PASSWORD.Update end with set oMessage = Server.CreateObject("CDO.Message") set oMessage.Configuration = oConfig with oMessage .To = cMailTo.From = MAIL_FROM.Subject = cSubject.HTMLBody = cBody .Send end With set oMessage = nothing set oFields = nothing set oConfig = nothing SendMail = nullend function'=============================' use local SMTP service'=============================function SendMailLocal( cSubject, cMailFrom, cMailTo, cBody )dim oMessage, oConfig, oFieldsset oConfig = Server.CreateObject("CDO.configuration")set oFields = oConfig.FieldsoFields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1oFields.item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25oFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"oFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\Inetpub\mailroot\Pickup"oFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30oFields.updateset oMessage = Server.CreateObject("CDO.Message")set oMessage.Configuration = oConfigoMessage.from = cMailFromoMessage.to = cMailTooMessage.Subject = cSubjectoMessage.HtmlBody = cBodyoMessage.Sendset oMessage = nothing set oFields = nothing set oConfig = nothing SendMailLocal = nullend function%>
-
2014-11-15ASP에서 파일을 다운로드 하는 경우에는 ContentType을 "application/unknown"으로 설정해주어야 MINE 연결이 해제되고 저장하는 방식으로 처리된다.그리고 헤더를 보낸후에 파일 내용을 바이너리형식으로 보내 주어야 하는데 이를 위하여 파일을 Strem형식으로 읽어 보내주면 된다.한가지 주의점은 저장파일의 이름변수의 값이 PC에서 파일이름으로 사용할 수 없는 문자가 포함되지 않도록 되어있어여하는데 함수 RefineFileName는 이값들을 정제해주는 기능의 함수로 잘못된 파일이름으로 인한 에러를 방지해 줄 수 있다, <%function FileDownload( cPathFile, cSaveFileName )Response.ContentType = "application/unknown"Response.AddHeader "Content-Disposition","attachment; filename=" & cSaveFileName&" "Response.BinaryWrite GetFileStream( cPathFile )FileDownload = nullend functionfunction GetFileStream( cPathFile )dim oStream, sFileset oStream = Server.CreateObject("ADODB.Stream")oStream.OpenoStream.Type = 1oStream.LoadFromFile cPathFilesFile = oStream.Readset oStream = nothingGetFileStream = sFileend functionfunction RefineFileName( c )c = Replace( c, "/", "" )c = Replace( c, "?", "" )c = Replace( c, "*", "" )c = Replace( c, ">", "]" )c = Replace( c, "<", "[" )c = Replace( c, "|", "-" )c = Replace( c, ":", "-" )RefineFileName = cend function%>
-
2014-05-08랜덤키를 만들어야 하는 경우에 이용가능하다.랜덤으로 만들어진 값을 숫자(0~9)와 알파벳으로 표현하는 36진수로 변환 하여 랜덤키를 만듭니다.<%response.write KeyGen32()&".txt"function KeyGen32()dim iRnd, Responsedim cRnd, iRandomizecRnd = ""for i = 1 to 8iRnd = Int(( 999999 - 1 + 1) * Rnd + 1) '=== 6 digitscRnd = cRnd & Dec6to36( FillZero(iRnd,6) )nextKeyGen32 = cRndend functionfunction Dec6to36(num)dim d1,d2,d3,d4,r1,r2d1 = Int( num / 46656 )r1 = ( num mod 46656 )d2 = Int( r1 / 1296 )r2 = ( r1 mod 1296 )d3 = Int( r2 / 36 )d4 = ( r2 mod 36 )Dec6to36 = Convert10to36(d1) & Convert10to36(d2) & Convert10to36(d3) & Convert10to36(d4)end function'== 10진수를 36진수로 변환function Convert10to36( i )if ( i < 10 ) thenConvert10to36 = ielseConvert10to36 = chr(55+i)end ifend functionfunction FillZero( cString, iLength )FillZero = FillString( cString, iLength, "0" )end functionfunction FillString( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillString = ( String( iLength -Len( cString ), cFillString ) & cString )elseFillString = cStringend ifend function%>
-
2014-05-03마이크로소프트의 DBMS인 MS-SQL은 현재 2014버전이 나왔지만 8플랫폼에 설치해야하기 때문에 7이나 server 2008이하에서 2008을 설치 해야 한다.Express는 Oracle의 mysql처럼 사용자에게 무료로 제공되는 버전이다. 다만 파일 사이즈가 최대 4G를 넘지 못하는 점이 있어 대형DB나 웨어하우징에는 사용하기 어렵다. 하지만 개발 시 사용하거나 웹서버에서 사용하기에는 부족함이 없다, (개발단계에서 4G가 넘는 파일은 사용하는 경우는 웨어하우징 정도일듯 한데, 이런 경우는 개발 자원 자체가 데스크탑 수준 이상으로 필요하기 떄문에 컨텐트를 DB로 처리하는 경우를 제외하고 거의 처리 된다고 볼 수 있다)소규모 개발 혹은 단일노드 개발에서도 Office의 Access를 사용하기보다는 Express를 사용하는 것을 추천한다.마이크로소프사의 다운로드 사이트http://www.microsoft.com/ko-kr/download/details.aspx?id=22973x86, x64버전 중 OS에 맞는것을 다운로드하여 설치하면 된다. (IA64 시스템에서 지원되지 않는다.)1. 설치 전 OS의 모든 업데이트는 필수 이다.2. .Net Framework을 필요로 하는데 3.5 SP1 이상이 필요하다. (http://www.microsoft.com/ko-kr/download/details.aspx?id=22)3. Windows Installer 4.5 설치 (http://support.microsoft.com/kb/942288)4. Power Shell 설치 (http://technet.microsoft.com/ko-kr/windowsserver/bb512919.aspx)OS 업데이트만 완료하고 설치를 진행하여도 필요한 소프웨어를 추가 자동설치 하거나, 메세지가 나올 떄 처리하여도 무방하다. (OS에 따라 미리설치하여야 하는 경우도 있기 때문에 위의 2,3,4, 소프트웨어를 미리 설치)
-
2014-05-01그 동안 만들어 사용하던 날짜,시간 관련 함수들을 모아 봤다.ASP에선 날짜/시간을 출력하는 경우 시스템의 날짜형식으로 출력이 된다.적합한 모양으로 바꾸어 출력 되도록 하는것들이 대부분 함수들이다.모아보니 함수들이 많은것 같은데 필요할 때마다 추가한것이라 한번씩은 용도가 있었던것이라 참고 하시거나 사용안할듯 한것들은 제거 하여 재구성하여 사용 하길 추천 한다.GetFullDateTimeH(), GetFullDateH(): 구분자를 "-"로 출력 한다. ** in-line query 로 DB에 저장하는 경우 이 형식으로 날짜를 표현해야 한다.GetFullDateTimeON() : 날짜/시간의 숫자 값만 출력한다. ** 임시파일의 파일명 생성시 4~6자리의 랜덤 값과 사용하면 중복을 쉽게 피할 수 있다.GetMonthLastDate(): 해당월의 마지막일자를 구한다. ** 기간 설정 시 유용 하다.CDateWithCheck() : 변수가 유효한 날짜로 변경이 가능한 경우에만 변경된다. ** 날짜 형식은 javascript에서 유효성을 확인 하지만 실제 데이타 처리시에도 반드시 확인 하길 추천 한다.Date연산 함수들: 자주 사용되는 연산 규칙들을 함수로 구성 했다.UNIX Time : 초단위로 출력되는 숫자로 경과시간을 초단위로 나타낼 때 유효하다 ** 경과 시간 구하기 iPastSecond = DateTime2UnixTime( dEnd ) - DateTime2UnixTime( dStart )'============================================' DateTime functions'============================================function GetFullDateTime( dNow )GetFullDateTime = Year(dNow)&"."&FillZero(Month(dNow),2)&"."&FillZero(Day(dNow),2) &" "& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeT( dNow )GetFullDateTimeT = Year(dNow)&"-"&FillZero(Month(dNow),2)&"-"&FillZero(Day(dNow),2) &"T"& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeH( dNow )GetFullDateTimeH = Year(dNow)&"-"&FillZero(Month(dNow),2)&"-"&FillZero(Day(dNow),2) &" "& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeKor( dNow )GetFullDateTimeKor = Year(dNow)&"년 "&Month(dNow)&"월 "&Day(dNow)&"일 ("& WeekDayName(Weekday(dNow), True)&") "& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDate( dNow )GetFullDate = Year(dNow)&"."&FillZero(Month(dNow),2)&"."&FillZero(Day(dNow),2)end Functionfunction GetFullDateH( dNow )GetFullDateH = Year(dNow)&"-"&FillZero(Month(dNow),2)&"-"&FillZero(Day(dNow),2)end Functionfunction GetFullDateKor( dNow )GetFullDateKor = Year(dNow)&"년 "&Month(dNow)&"월 "&Day(dNow)&"일"end Function'===== only numericfunction GetFullDateTimeON( dNow )GetFullDateTimeON = Year(dNow) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2) & FillZero(Hour(dNow),2) & FillZero(Minute(dNow),2) & FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeONHM( dNow )GetFullDateTimeONHM = Year(dNow) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2) & FillZero(Hour(dNow),2) & FillZero(Minute(dNow),2)end Functionfunction GetTime( dNow )GetTime = FillZero(Hour(dNow),2) &":"& FillZero(Minute(dNow),2) &":"& FillZero(Second(dNow),2)end functionfunction GetTimeON( dNow )GetTimeON = FillZero(Hour(dNow),2) & FillZero(Minute(dNow),2) & FillZero(Second(dNow),2)end functionfunction GetFullDateON( dNow )GetFullDateON = Year(dNow) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2)end Functionfunction GetFullDateON6( dNow )GetFullDateON6 = Right(Year(dNow),2) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2)end Functionfunction ONDateTime2DateTime( cDateTime14 )ONDateTime2DateTime = ONDate2DateTime(Mid(cDateTime14,1,8))&" "&ONTime2DateTime(Mid(cDateTime14,9,6))end functionfunction ONDate2DateTime( cDate8 )dim cReturnif (cDate8="") or ISNull(cDate8) thencReturn = ""elsecReturn = Mid(cDate8,1,4) &"-"& Mid(cDate8,5,2) &"-"& Mid(cDate8,7,2)end ifONDate2DateTime = cReturnend functionfunction ONTime2DateTime( cTime6 )dim cReturnif (cTime6="") or ISNull(cTime6) thencReturn = ""elsecReturn = Mid(cTime6,1,2) &":"& Mid(cTime6,3,2) &":"& Mid(cTime6,5,2)end ifONTime2DateTime = cReturnend functionfunction GetYearMonth( dNow )GetYearMonth = FillZero(Year(dNow),4)&"/"& FillZero(Month(dNow),2)end Functionfunction GetMonthDay( dNow )GetMonthDay = FillZero(Month(dNow),2)&"/"& FillZero(Day(dNow),2)end Functionfunction GetHourMinute( dNow )if IsNull(dNow) thenGetHourMinute = ""elseGetHourMinute = FillZero(Hour(dNow),2)&":"& FillZero(Minute(dNow),2)end ifend Functionfunction GetHourMinuteSecond( dNow )if IsNull(dNow) thenGetHourMinuteSecond = ""elseGetHourMinuteSecond = FillZero(Hour(dNow),2)&":"& FillZero(Minute(dNow),2)&":"& FillZero(Second(dNow),2)end ifend functionfunction CDateWithCheck( cDate8 )dim cDate10cDate10 = ONDate2DateTime(cDate8)if IsDate( cDate10 ) thenCDateWithCheck = CDate( cDate10 )elseCDateWithCheck = nullend ifend functionfunction CDateWithCheck10( cDate10 )if IsDate( cDate10 ) thenCDateWithCheck10 = CDate( cDate10 )elseCDateWithCheck10 = nullend ifend functionfunction CheckDateTime( cDate8 )CheckDateTime = IsDate( ONDate2DateTime(cDate8) )end functionfunction CheckDateTimeNull( cDate8 )CheckDateTimeNull = (IsDate( ONDate2DateTime(cDate8) ) or IsNull(cDate8))end functionfunction GetMonthLastDate( iYear, iMonth )dim cNextMonthFistDateif (iMonth=12) thencNextMonthFistDate=FillZero((iYear+1),4)&"0101"elsecNextMonthFistDate=FillZero(iYear,4)&FillZero((iMonth+1),2)&"01"end ifGetMonthLastDate = GetFullDateON(CDateWithCheck(cNextMonthFistDate)-1)&" 23:59:59"end functionfunction GetMonthLastDay( iYear, iMonth )dim cNextMonthFistDateif (iMonth=12) thencNextMonthFistDate=FillZero((iYear+1),4)&"-01-01"elsecNextMonthFistDate=FillZero(iYear,4)&"-"&FillZero((iMonth+1),2)&"-01"end ifGetMonthLastDay = Day(CDate(cNextMonthFistDate)-1)end functionfunction CmpStartEndMonth( iStartYear, iStartMonth, iEndYear, iEndMonth )dim iCmpStartDate, iCmpEndDateiCmpStartDate = CintZero(FillZero(iStartYear,4)&FillZero(iStartMonth,2))iCmpEndDate = CIntZero(FillZero(iEndYear,4)&FillZero(iEndMonth,2))CmpStartEndMonth = CBool(iCmpStartDate > iCmpEndDate)end function'== Date add functionsfunction YearMonthAddMonthGetYear( iYear, iMonth, iAddMonth )YearMonthAddMonthGetYear = Year(YearMonthAddMonth( iYear, iMonth, iAddMonth ))end functionfunction YearMonthAddMonthGetMonth( iYear, iMonth, iAddMonth )YearMonthAddMonthGetMonth = Month(YearMonthAddMonth( iYear, iMonth, iAddMonth ))end functionfunction YearMonthAddMonth( iYear, iMonth, iAddMonth )YearMonthAddMonth = DateAdd( "m", iAddMonth, CDate(FillZero(iYear,4)&"-"&FillZero(iMonth,2)&"-01") )end functionfunction AddMonthGetMonth( dDate, iMonth )AddMonthGetMonth = Month(AddMonth( dDate, iMonth ))end functionfunction AddMonthGetYear( dDate, iMonth )AddMonthGetYear = Year(AddMonth( dDate, iMonth ))end functionfunction AddMonth( dDate, iMonth )AddMonth = DateAdd( "m", iMonth, dDate )end function'== UNIX Timefunction DateTime2UnixTime( dDateTime )DateTime2UnixTime = DateDiff( "s", "01/01/1970 00:00:00", dDateTime )end functionfunction UnixTime2DateTime( iUnixTime )UnixTime2DateTime = DateAdd( "s", iUnixTime, "01/01/1970 00:00:00" )end functionfunction MonthNameEng( iMonth )dim cReturnselect case iMonthcase 1 cReturn = "January"case 2 cReturn = "February"case 3 cReturn = "March"case 4 cReturn = "April"case 5 cReturn = "May"case 6 cReturn = "June"case 7 cReturn = "July"case 8 cReturn = "August"case 9 cReturn = "September"case 10 cReturn = "October"case 11 cReturn = "November"case 12 cReturn = "December"end selectMonthNameEng = cReturnend function
-
2014-04-30ASP는 Microsoft에서 만든 대화형 웹사이트를 만들기 위한 플랫폼입니다. 현재는 ASP.NET을 주로 사용 하다보니 예전의 ASP를 "Classic ASP"로 부르기도 한다.스크립트로는 VBScript와 JScript를 지원합니다. 주로 VBScript를 사용 한다.(예전 Adobe사의 DRM서버는 JScript로 만들어진 경우는 보았지만, 대게는 VB를 주로 사용)본인이 처음 사용한것은 1997년 HTS시스템의 웹부분을 맏으면서 처음 사용했었는데, 이전에 CGI 방식에 비해 여 개발 난이도가 쉬운 편으로 이후 많이 사용 될것이 예상 됬다.1.0(1996년), 2.0버전(1997년)과 3.0버전(2000년)이 있는데 크게 차이는 없고, 3.0에선 주로 성능향상을 위한 최적화가 이루어 졌다현재 IIS7,8에서도 지원이 되고 있다. 다만 ,NET이 기본 설치되고 사용 설정이 필요하다.java/JSP의 인기와 .NET으로 대체등으로 사용하는 곳이 많이 줄었고 계속 줄어 들고 있는 상황이지만 아직 유지하고 있거나 다른 플랫폼과 혼합하여 사용하는 경우도 있다##아직 사용하는 분들을 위해 몇가지 팁 정도를 글로 게시할 계획 입니다.
-
2014-04-30문자 채우기문자(숫자)를 출력하면서 특정문자를 결합하는 경우에 사용한다 - 숫자 "1"을 네자리의 Numneric(빈자리가 "0"로 채워진) 4자리로 변환 하는 경우 1 => "0001" - 좌우측으로 여백문자처리의 경우 • FillString(): 특정문자 채우기 • FillZero(): "0" 문자 채우기 • FillSpace(): 스페이스 채우기문자 자르기mid() 함수를 이용하여 문자를 자르는 경우 2byte 문자도 자릿수에 상관 없이 1문자로 처리되기 떄문에 의도한 것보다 길게 나오는 경우가 많은데 2byte 문자를 감안하여 해당 자릿수에서 문자를 잘라 반환 한다 - 게시판의 제목 등 길어질 수 있는 내용을 좁은 구역에 출력시 유효 - 지정길이보다 긴 경우 +More 사용 • HLeftB(): 2byte 문자 자르기 • HLeftBMore(): 2byte 문자 자른 후 길이가 넘는 경우 "…" 문자 추가<%'===============================================' >> Fill Stuff functions'' FillZero( cString, iLength )' FillSpace( cString, iLength )' FillString( cString, iLength, cFillString )''===============================================function FillZero( cString, iLength )FillZero = FillString( cString, iLength, "0" )end functionfunction FillSpace( cString, iLength )FillSpace = FillString( cString, iLength, " " )end functionfunction FillSpaceRight( cString, iLength )FillSpaceRight = FillStringRight( cString, iLength, " " )end functionfunction FillString( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillString = ( String( iLength -Len( cString ), cFillString ) & cString )elseFillString = cStringend ifend functionfunction FillStringRight( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillStringRight = ( cString & String( iLength -Len( cString ), cFillString ) )elseFillStringRight = cStringend ifend functionfunction HLeftB( cString, iLen ) dim i, c, a, bdim cReturnb = 0cReturn = ""if not IsNull(cString) thenfor i = 1 to Len(cString)c = mid(cString,i,1)a = asc(c)cReturn = cReturn&cif (a>255 or a<0) thenb = b+2elseb = b+1end ifif (iLen=<b) thenexit forend ifnextend ifHLeftB = cReturnend functionfunction HLeftBMore( cString, iLen ) dim cc = HLeftB( cString, iLen ) if (cString>c) thenc = c &"…"end ifHLeftBMore = cend function%>
1
