ClassicASP 갤러리#1 ( gallery.asp ) 리스트
페이지 정보
본문
db_conn.asp 내용
<%
Dim Sql, Con
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open ("Provider=SQLOLEDB;Data Source=디비주소;Initial Catalog=디비명;user ID=아이디;password=비밀번호;")
%>
<%@ Language=VBScript %>
<% Option Explicit %>
<%
' 작성자: 해피정닷컴 ( https://www.happyjung.com )
' 2008-06-23 : 1차 작성
' 2008-08-02 : 디비 테이블 이름 변경 tbl_gallery → hp_gallery
' 2009-01-20 : 오타 및 img 폴더명 변경 "../..imgs/noimage.jpg -> "../../img/noimage.jpg
' 2009-11-11 : 검색기능 개선
'
'
'
%>
<!--#include virtual="/inc/db_conn.asp" -->
<%
dim str,val ' 해피정닷컴 추가 2008-05-27
' 인젝션 방지관련 https://www.happyjung.com/bbs/board.php?bo_table=lecture&wr_id=480
'function sqlCheck(str)
'...
'end function
dim page, pagesize, block, j, nanuki, num, name, title, email, url, write_diff, writeday, visit, filename1, i_width1, i_height1, nowday, first_page, end_page, i, recordCount, pagecount, id_num, SearchStr, SearchPart, wc
Page = sqlCheck(request("page"))
SearchStr = sqlCheck(request("SearchStr"))
SearchPart = sqlCheck(request("SearchPart"))
if page="" then
page=1
end if
'#################################
pagesize = 8 '## 한페이지에 나타낼 이미지 수
block = 10 '## 페이지 네비게이션의 수
nanuki = 4 '## 한줄에 표시할 이미지 수
'#################################
if SearchPart = "" then SearchPart = "name"
if SearchStr <> "" then
wc = " where " & SearchPart & " like '%"& SearchStr & "%'"
end if
SQL = "select count(num) as recCount from hp_gallery" & wc '### 저장된 글 수를 가져온다.
Set rs = Con.Execute(SQL)
recordCount = Rs(0) '### 저장된 전체 글 수
pagecount = int((recordCount-1)/pagesize) +1 '### 페이지가 나눠진 수
id_num = recordCount - (Page -1) * PageSize '### 글 번호 순차적으로 처리하는 부분. 갤러리에서는 쓰이지 않음.
'### 글을 가져오는 부분
if SearchStr = "" then
SQL = "SELECT TOP " & pagesize & " * FROM hp_gallery"
if int(page) > 1 then
SQL = SQL & " WHERE num not in "
SQL = SQL & "(SELECT TOP " & ((page - 1) * pagesize) & " num FROM hp_gallery"
SQL = SQL & " ORDER BY num DESC)"
end if
else
SQL = "SELECT TOP " & pagesize & " * FROM hp_gallery " & wc
if int(page) > 1 then
SQL = SQL & " and num not in "
SQL = SQL & "(SELECT TOP " & ((page - 1) * pagesize) & " num FROM hp_gallery"
SQL = SQL & " ORDER BY num DESC)"
end if
end if
SQL = SQL & " order by num desc"
set rs = Con.execute(sql)
%>
<!--#include file="../inc/_happyjung_.asp"-->
<title>갤러리</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>
<body>
<!-- 갤러리 -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>총 <%=recordcount%>개의 이미지가 있습니다. (<%=page%> page / <%=pagecount%> page)<br></td>
</tr>
<tr>
<td height="2" bgcolor="#333333"></td>
</tr>
<%
Do until Rs.EOF
%>
<tr>
<td height="120"><table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<%
for j=1 to nanuki
num = rs("num")
name = rs("name")
title = rs("title")
email = rs("email")
url = rs("url")
write_diff=rs("writeday")
writeday = left(write_diff,10)
visit = rs("visit")
filename1 = rs("filename1")
i_width1 = rs("i_width1")
i_height1 = rs("i_height1")
if filename1 = "" then
filename1 = "../../img/noimage.jpg"
i_height1 = 100
i_width1 = 145
else
filename1 = "../../upload/" & filename1
i_height1 = 100
i_width1 = 145
end if
if writeday = left(nowday,10) then
writeday=right(write_diff,11)
writeday=left(writeday,8)
end if
%>
<td valign="top" style="padding:5;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><a href="gallery_view.asp?num=<%=num%>&page=<%=page%>"><img src="<%=filename1%>" width="<%=i_width1%>" height="<%=i_height1%>" border="0"></a></td>
</tr>
<tr>
<td align="center"><%=title%></td>
</tr>
</table></td>
<%
Rs.Movenext
id_num = id_num - 1
if rs.EOF then
exit for
end if
next
%>
</tr>
</table></td>
</tr>
<tr>
<td height="2" bgcolor="#333333"></td>
</tr>
<%
Loop
%>
<tr>
<td align="center" style="padding-left:5;">
<% '페이지 네비게이션 시작
If Rs.BOF Then
Else
If Int(Page) <> 1 Then
%>
<a href="gallery.asp?page=<%=Page-1%>" onFocus="this.blur()"><font color="#000000" style="font-size:8pt;">[prv]</font></a>
<%
end if
First_Page = Int((Page-1)/Block)*Block+1
If First_Page <> 1 Then
%>
[<a href="gallery.asp?page=1" onFocus="this.blur()"><font color="#000000" style="font-size:8pt;">1</font></a>] ..
<%
end if
If PageCount - First_Page < Block Then
End_Page = PageCount
Else
End_Page = First_Page + Block - 1
End If
For i = First_Page To End_Page
If Int(Page) = i Then
%>
[<font color="#FF0000" style="font-size:8pt;"><b><%=i%></b></font>]
<%
Else
%>
[<a href="gallery.asp?page=<%=i%>" onFocus="this.blur()"><font color="#000000" style="font-size:8pt;"><%=i%></font></a>]
<%
End If
Next
If End_Page <> PageCount Then
%>
.. [<a href="gallery.asp?page=<%=PageCount%>" onFocus="this.blur()"><font color="000000" style="font-size:8pt;"><%=PageCount%></font></a>]
<%
end if
If Int(Page) <> PageCount Then
%>
<a href="gallery.asp?page=<%=page+1%>" onFocus="this.blur()"><font color="#000000" style="font-size:8pt;">[next]</font></a>
<%
End If
End If
'페이지 네비게이션 끝
%></td>
</tr>
<tr>
<td align="center" style="padding-top:10px;"><table width="100%" border="0" cellspacing="0" bordercolor="0">
<tr>
<form action="gallery.asp" method="post" name="search" id="search">
<td><select name="SearchPart" class="input_box">
<option value="title" <% if SearchPart = "title" then Response.Write("selected") end if %>>제목 </option>
<option value="content" <% if SearchPart = "content" then Response.Write("selected") end if %>>내용 </option>
<option value="name" <% if SearchPart = "name" then Response.Write("selected") end if %>>작성자 </option>
</select>
<input name="SearchStr" type="text" class="input_box" value="<%=SearchStr %>" size="30" />
<input name="submit" type="image" onClick="submit();" value="찾 기" src="img/searchs.gif" width="34" height="20" align="absmiddle" /></td>
</form>
<td align="right"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="padding:0 5 0 0;">
<% if session("admin") = "administrator" then %>
<a href="gallery_write.asp?page=<%=Page %>&SearchPart=<%=SearchPart %>&SearchStr=<%=SearchStr %>"><img src="img/bbs_write.gif" border="0"></a>
<% end if%></td>
<td valign="top"><a href="gallery.asp"><img src="img/bbs_list.gif" border="0"></a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
댓글목록
등록된 댓글이 없습니다.