고객센터 : 031-548-0481 /호스팅문의:1644-2646 /서버호스팅문의 : 070-7573-5515/ 평일근무 : 09:00~18:00 / 토/일요일, 공휴일 휴무

1:1 고객상담문의 FAQ 자동답변

나노코팅 나노엔

구매안내

  • 아티보드 2.0
  • 아티보드 3.0
  • 아티카페
  • 파일공유사이트
솔루션 > 커뮤니티 > 사용팁

사용팁|

ASP 소스 보기|아티보드3.0

  • 최백호
  • |조회수 : 2881
  • |추천수 : 0
  • |2011-11-25 오후 5:25:08

정해준 경로의 소스를 출력하는 함수를 간단하게 만들어보았습니다.

당연한 말이겠지만 같은 사이트 내의 소스만 출력이 됩니다.


 

<%
function show_source(url)
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")

strFilepath = Server.Mappath(url)
Set oFile = oFSO.OpenTextFile(strFilepath, 1)

strText = oFile.ReadAll

Set oFile = nothing
Set oFSO = nothing

strText = Replace(strText, "&", "&amp;")
strText = Replace(strText, "<", "&lt;")
strText = Replace(strText, " ", "&nbsp;")
strText = Replace(strText, vbTab, "&nbsp;&nbsp;&nbsp;&nbsp;")
strText = Replace(strText, vbCrLf, "<br>")

show_source = strText
end function
%>

<code>
<%=show_source("show_source.asp")%>
</code>


 

Replace 부분에서 매번 strText 변수에 재할당하지 않고 한줄로 한번에 변환하는 것이 실행 효율이 조금 더 낫지만, 저렇게 Replace 항목이 많은 경우에는 여러줄로 나누어 보기 좋게 해주는 것이 수정을 편하게 하여 유지보수 생산성이 높아집니다.


 

<code> 태그는 코드를 화면에 출력할때 사용하는 <xmp> 태그와 유사한 동작을 합니다.

함수내에서 화면 출력에 필요한 작업을 이미 대부분 해놓은 상태이므로 코드 출력용 태그는 사실상 불필요합니다. 위의 경우는 단순히 보기 좋으라고 <code> 태그를 붙여놓은 것이므로 제거하셔도 무방합니다.


 

참고로 <code> 태그 위치에 <xmp> 태그를 대신 사용하면 사소한 문제가 하나 생기니 주의하시길 바랍니다.


 

============================================================================================================================

늦어지만 저도 답변달아 봅니다.

아래와 같이 보여지게 만들어 줍니다.


<%

Sub viewCode(codefile)
response.write "<p style=""background-color=#eeeeee;"">"
set fso = server.createobject("scripting.filesystemobject")
set f = fso.opentextfile(server.mappath(codefile),1)
allViewCode = viewHTML(f.readall)
set f = nothing
response.write codingcolor(allviewcode,"brown")
response.write "</p>"
End Sub

'Coding부분을 찾아서 Coloring함수로...
function CodingColor(strTemp,strFontColor)
Dim firstPos
Dim lastPos
Dim leftString
Dim midString
Dim rightString
Dim xmidString

firstPos =1
lastPos = 1
do until lastPos >= len(strTemp)
firstPos = instr(lastPos, strTemp, "&lt;%")
if firstPos <= 0 then
exit do
end if
lastPos = instr(firstPos, strTemp, "%&gt;")
if lastPos <= 0 then
lastPos = len(strTemp)
end if
lastPos = lastPos + len("%&gt;") - 1
leftString = left(strTemp,firstPos-1)
midString = mid(strTemp,firstPos,lastPos-firstPos+1)
rightString = mid(strTemp,lastPos+1,len(strTemp)-lastPos)
xmidString = coloring(midString)
' strTemp = leftString & xmidString & rightString
' lastPos = firstPos + len(xmidString)-1
strTemp = leftString & "<span style=color:" & strFontColor & ";>" & xmidString & "</span>" & rightString
lastPos = firstPos + len("<span style=color:" & strFontColor & ";>" & xmidString & "</span>")-1
loop

CodingColor = strTemp
end function

function coloring(strViewCode)
Dim Reservedwords
Dim aryReservedword
Dim i
Dim strFunction
Dim aryFunction

Reservedwords="AndlCalllCaselConstlDimlDolEachlElselElseIflEmptylEndlEqvlEraselErrorlExitlExplicitlFalselForlFunctionlIflImplInlIslLooplModlNextlNotlNothinglNulllOnlOptionlOrlPrivatelPubliclRandomizelReDimlResumelSelectlSetlSteplSublThenlTolTruelUntillWendlWhilelXor"
aryReservedword=split(Reservedwords,"l")
for i = 0 to ubound(aryReservedword)
strViewCode = wordReplace(strViewCode,aryReservedword(i),"blue")
next

strFunction="AnchorlArraylAsclAtnlCBoollCBytelCCurlCDatelCDbllChrlCIntlCLnglCoslCreateObjectlCSnglCStrlDatelDateAddlDateDifflDatePartlDateSeriallDateValuelDaylDictionarylDocumentlElementlErrlExplFileSystemObjectlFilterlFixlIntlFormlFormatCurrencylFormatDateTimelFormatNumberlFormatPercentlGetObjectlHexlHistorylHourlInputBoxlInStrlInstrRevlIsArraylIsDatelIsEmptylIsNulllIsNumericlIsObjectlJoinlLBoundlLCaselLeftlLenlLinklLoadPicturelLocationlLoglLTrimlRTrimlTrimlMidlMinutelMonthlMonthNamelMsgBoxlNavigatorlNowlOctlReplacelRightlRndlRoundlScriptEnginelScriptEngineBuildVersionlScriptEngineMajorVersionlScriptEngineMinorVersionlSecondlSgnlSinlSpacelSplitlSqrlStrComplStringlStrReverselTanlTimelTextStreamlTimeSeriallTimeValuelTypeNamelUBoundlUCaselVarTypelWeekdaylWeekDayNamelWindowlYear"
aryFunction=split(strFunction,"l")
for i = 0 to

댓글 0

번호 제목 닉네임 조회수 작성일
35 카테고리별 출력하기 [2] file 김광식 3215 2006.02.14
34 클럽 출석부 입니다. 참고 하세요!!!!!! [6] 박인영 2931 2007.10.01
33 패스코리아의 Nwmail 사용사시는분 [5] file 네오지기 2668 2006.08.23
32 페이지와 게시판 하단에 관리담당자를 표시하는 기능 추가 일천 2180 2015.08.25
31 플래시 메뉴 새로고침 안되는 버그 치료방법 [4] 웹사랑 2534 2006.08.11
30 회원 로그인 설치하기 (초보자용) [8] 에버클럽 5118 2006.06.09
29 회원가입 및 방문기록 추출하기 [2] file photo 에버클럽 3355 2006.02.10
28 회원랭킹 소스 입니다.[별루 안좋은딩] [1] 박인영 2462 2007.06.04
27 ABC 업로드 컴포넌트 4.1 ^^ [3] file 김통령 4190 2007.01.31
26 ABC Upload 의 라이센스문제 file 최백호 3262 2011.12.09
25 ABCUpload 컴포넌트 64Bit OS에서 사용 설정법 일천 3187 2015.08.04
24 ASP - FSO 객체 정리한 파일입니다. file photo 최백호 3027 2008.05.19
ASP 소스 보기 최백호 2881 2011.11.25
22 ASP에서의 MD5암호화 모듈입니다. file 최백호 3108 2008.11.14
21 Daum 우편번호 서비스를 이용하려합니다. 이성제 2124 2016.12.12
20 DB설치오류와 대처(동영상)-"sql이 없거나 액세스 할 수 없습니다" [4] file 김경혜 3955 2009.01.28
19 GeoIP 국가별 IP 체크 방법 file 최백호 2787 2011.11.25
18 IE6설계변경패치 예제파일 및 파워포인트자료 [3] file KINvirus 2537 2006.03.02
17 IE패치로 인한 플래쉬/미디어 제대로 나오게하기!!! [2] file 최백호 3077 2008.04.10
16 iframe 크기 안에 들어가는 아티보드에 맞게 폭, 높이 자동으로 .. [2] 최백호 3430 2007.08.01