<% @language=VBScript %> <% option explicit %> <% Response.Buffer = true %> <% const HITS_PER_PAGE = 5 const IDS_ANONYMOUS = "Brak imienia" const IDS_FIELDSMISSING = "Nie wszystkie wymagane pola zostały wypełnione. Spróbuj jeszcze raz." const IDS_ERRORDELETE = "Problem z kasowaniem wpisu" const IDS_MAIL = "Wyślij email do" const IDS_ERROR = "Wystąpił błąd" const MODE_NORMAL = 1 const MODE_ERROR = 2 const MODE_INSERT = 4 const MODE_DELETE = 8 const MODE_ADMIN = 16 dim mode mode = Request("mode") if mode="" then mode = MODE_NORMAL mode = CLng(mode) function min( a, b ) if ab then max=a else max=b end function function fmtDate( in_str ) fmtDate = FormatDateTime( in_str, 2 ) end function function fmtMl( in_str ) if IsNull(in_str) then fmtMl = "" exit function end if dim str if in_str<>"" then str = Replace( in_str, vbCrLf, vbCr ) str = Replace( str , vbLf , vbCr ) str = Replace( str , vbCr , "
" ) fmtMl = str else fmtMl = in_str end if end function function fmtText( byval txt ) txt = Server.HtmlEncode(txt) txt = Replace( txt, Server.HtmlEncode(""), "" ) txt = Replace( txt, Server.HtmlEncode(""), "" ) txt = Replace( txt, Server.HtmlEncode(""), "" ) txt = Replace( txt, Server.HtmlEncode(""), "" ) txt = Replace( txt, Server.HtmlEncode(""), "" ) txt = Replace( txt, Server.HtmlEncode(""), "" ) txt = Replace( txt, Server.HtmlEncode(""), "" ) txt = Replace( txt, Server.HtmlEncode(""), "" ) fmtText = fmtMl(txt) end function function myselfUrl( mode_ ) if (CLng(mode) and CLng(MODE_ADMIN))<>CLng(0) then mode_ = CLng(mode_) or CLng(MODE_ADMIN) end if myselfUrl = Request.ServerVariables("SCRIPT_NAME") & "?mode=" & mode_ end function function normalUrl normalUrl = myselfUrl(MODE_NORMAL) end function function errorUrl( error_text ) errorUrl = myselfUrl(MODE_ERROR) & "&error=" & Server.UrlEncode(error_text) end function function insertUrl insertUrl = myselfUrl(MODE_INSERT) end function function deleteUrl( id ) deleteUrl = myselfUrl(MODE_DELETE) & "&id=" & Server.UrlEncode(id) end function function naviUrl( page ) naviUrl = myselfUrl(MODE_NORMAL) & "&pg=" & page end function function openDb() set openDb = Server.CreateObject("ADODB.Connection") openDb.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Persist Security Info=False;" & _ "Data Source=" &Server.MapPath("guestbook.mdb") end function function insertEntry( byref conn ) dim name dim email dim text name = Request("gb_name") email = Request("gb_email") text = Request("gb_text") if name="" then name = IDS_ANONYMOUS if text="" then insertEntry = false exit function end if dim rs set rs = Server.CreateObject("ADODB.Recordset") rs.Open "Guestbook", conn, 2, 3 rs.AddNew rs("Date") = Now rs("Name") = name if email<>"" then rs("EMail") = email else rs("EMail") = null end if rs("Text") = text rs.Update insertEntry = true end function function deleteEntry( byref conn ) dim id id = Request("id") if id="" then deleteEntry = false exit function end if on error resume next conn.Execute "delete FROM Guestbook WHERE Guestbook.No=" &id if err<>0 then deleteEntry = false else deleteEntry = true end if end function function hasMode( mode_chk ) if (CLng(mode) and CLng(mode_chk))<>0 then hasMode = true else hasMode = false end if end function dim conn set conn = openDb if hasMode(MODE_INSERT) then if not insertEntry(conn) then Response.Redirect errorUrl(IDS_FIELDSMISSING) else Response.Redirect normalUrl end if end if if hasMode(MODE_DELETE) then if not deleteEntry(conn) then Response.Redirect errorUrl(IDS_ERRORDELETE& ": " &err.Description) else Response.Redirect normalUrl end if end if dim rs set rs = conn.Execute("SELECT COUNT(*) FROM Guestbook") dim sum_cnt sum_cnt = rs(0) dim cur_page if Request("pg")="" then cur_page = 0 else cur_page = Request("pg") end if dim total_pages total_pages = CLng(CLng(sum_cnt)/CLng(HITS_PER_PAGE)) if (CLng(CLng(sum_cnt) mod CLng(HITS_PER_PAGE))>0) and _ (CLng(sum_cnt)>CLng(HITS_PER_PAGE)) then total_pages = total_pages+1 end if if total_pages<=0 then total_pages=1 dim hit_display_start, hit_display_end hit_display_start = 1+cur_page*HITS_PER_PAGE hit_display_end = hit_display_start+min(CLng(sum_cnt),CLng(HITS_PER_PAGE))-1 if hit_display_end>sum_cnt then hit_display_end=sum_cnt dim cntdwn_start dim cntdwn_end cntdwn_start = sum_cnt-hit_display_start+1 cntdwn_end = sum_cnt-hit_display_end+1 dim can_prev_page, can_next_page, can_prevornext_page if CLng(cur_page)>0 then can_prev_page=true else can_prev_page=false end if if CLng(cur_page)0) can_last_page = (can_prevornext_page) and (CLng(cur_page)<(CLng(total_pages)-1)) set rs = conn.Execute("SELECT * FROM Guestbook ORDER BY Date DESC") if not (rs.Bof and rs.Eof) then rs.Move hit_display_start-1 end if %> Księga gości - Tattoo And Piercing Studio


Czekamy na Wasze opinie, uwagi i komentarze dotyczące naszej pracy...
Na Wasze pytania czekamy tutaj
<%if hasMode(MODE_ADMIN) then%>  Witamy w trybie administracyjnym Księgi Gości <%end if%>


<% if hasMode(MODE_ERROR) then %>

<%=IDS_ERROR &" : "& Request("error")%>

<% end if %>

- <%=sum_cnt%> istniejących komentarzy. Strona <%=cur_page+1%> z <%=total_pages%>, wpisy <%=cntdwn_start%> do <%=cntdwn_end%>. <%if hasMode(MODE_ADMIN) then%>   wyjdź z panelu administracyjnego <%end if%>
<% if can_first_page then %> Pierwsza strona <%end if%> <% if can_prev_page then %> Następna strona <%end if%> <% if can_next_page then %> Poprzednia strona <%end if%> <% if can_last_page then %> Ostatnia strona <%end if%>
Strony: <% ' display discrete pages to jump directly to. dim i for i=1 to total_pages %> <%=i%>  <% next %>
<% ' *************************************************************************** ' output all entries. dim cntdwn cntdwn = cntdwn_start dim cnt cnt = 0 while not rs.Eof and CLng(cnt) <%=cntdwn%>.  <%if e then%> " href="mailto:<%=rs("EMail")%>"> <%end if%> <%=rs("Name")%> <%if e then%> <%end if%> , <%=fmtDate(rs("Date"))%> <%if hasMode(MODE_ADMIN) then%>  ">Usuń wpis <%end if%>

<%=fmtText(rs("Text"))%>

<% cntdwn = cntdwn-1 rs.MoveNext wend %> <% ' /////////////////////////////////////////////////////////////////////////// %>

Zamknij okno