<%@ page isThreadSafe="false" %> <%@ include file="globalPaths.jsp" %> <%@ include file="globalDefinitions.jsp" %> <%@ include file="cacheBegin.jsp" %> <% // This code prevents caching for malicious cnt parameter specified by user int artworksPerPage = 60; int count = -1; try { if (request.getParameter("cnt") != null) { count=Integer.parseInt(request.getParameter("cnt")); } } catch (Exception e) { count = -1; } int cnt = count - count % artworksPerPage; if (cnt < 0) cnt = 0; String newurl = "lobby.jsp"; String queryString = "?"; if (request.getParameter("type") != null) { queryString = queryString + "type=" + request.getParameter("type") + "&"; } if (request.getParameter("cat") != null) { queryString = queryString + "cat=" + request.getParameter("cat") + "&"; } newurl=newurl + queryString; if (cnt != count) { sendRedirect(newurl + "cnt=" + cnt); return; } %> <% Cookie[] cookies; cookies = request.getCookies(); String cookieArtist = ""; for (int icook = 0; cookies!=null && icook < cookies.length; icook++) { Cookie cookie = cookies[icook]; if ((cookie.getName()).equals("galleryArtistID")) { cookieArtist = cookie.getValue(); } } String remoteIP = "UndefinedIP"; if (request.getRemoteAddr() != null) { remoteIP = request.getRemoteAddr(); } %> <% Connection connection = null; Statement statement = null; ResultSet resultSet = null; String query = ""; %> <% Vector artworkIDs = new Vector(); Vector names = new Vector(); Vector artistNames = new Vector(); Vector artists = new Vector(); Vector portfolios = new Vector(); Vector smallshots = new Vector(); Vector imageHeights = new Vector(); Vector imageWidths = new Vector(); boolean needCaching = true; %> <% try { connection = openConnection(); statement = connection.createStatement(); query = "SELECT A.id, A.firstName, A.lastName, A.activeflag, A.portfolio, W.*" + " FROM galleryArtist A, galleryArtwork W WHERE" + " W.artist = A.id " + " AND A.package IN (0,1,2,3,5) AND A.unwelcome=0" + " AND (W.activeflag='Y' OR W.activeflag='L')" + " AND (A.activeflag='Y' OR A.id=" + quoteString(cookieArtist) + " OR A.ipLastLoggedFrom=" + quoteString(remoteIP) + " OR 'admin'=" + quoteString((String)session.getValue("logged")) + ")" + " ORDER BY A.lastName, A.firstName, W.activeflag, W.id"; resultSet = statement.executeQuery(query); String lastId = null; while (resultSet.next()) { String id = resultSet.getString("A.id"); // Many records for 1 artist may present in this resultSet; // We need the first of them. if (!id.equals(lastId)) { if (!"Y".equals(resultSet.getString("A.activeflag"))) { needCaching = false; } artworkIDs.addElement(resultSet.getString("W.id")); names.addElement(resultSet.getString("W.name")); String fln; String fn = resultSet.getString("A.firstName"); String ln = resultSet.getString("A.lastName"); if (fn.equals("")) fln = ln; else fln = fn + " " + ln; artistNames.addElement(fln); String portfolio = resultSet.getString("A.portfolio"); if (portfolio != null && portfolio.length() > 0) { portfolios.addElement(portfolio); } else { portfolios.addElement("./artworks.jsp?artist=" + id); } artists.addElement(resultSet.getString("A.id")); if (resultSet.getString("smallshot") == null || "".equals(resultSet.getString("smallshot"))) { smallshots.addElement("ima/e1.gif"); } else { smallshots.addElement(resultSet.getString("smallshot")); } if (resultSet.getString("W.heightImage") == null || "".equals(resultSet.getString("W.heightImage"))) { imageHeights.addElement("1"); } else { imageHeights.addElement(resultSet.getString("W.heightImage")); } if (resultSet.getString("W.widthImage") == null || "".equals(resultSet.getString("W.widthImage"))) { imageWidths.addElement("1"); } else { imageWidths.addElement(resultSet.getString("W.widthImage")); } lastId = id; } } resultSet.close(); connection.close(); } catch (Exception e) { errorLog(e, query); sendRedirect(globalErrorPage + "?errorDescription=" + URLEncoder.encode(e.getMessage() + ".")); return; } finally { if (resultSet != null) resultSet.close(); if (connection != null && !connection.isClosed()) connection.close(); } %> <% int numpages = (int)Math.ceil((double)artworkIDs.size() / (double)artworksPerPage); int[] pageindex = new int[numpages]; for (int i = 0; i < numpages; i ++) { pageindex[i] = i * artworksPerPage; } if (cnt > artworkIDs.size() - 1) { if (numpages > 0) { cnt = pageindex[numpages-1]; } else { cnt = 0; } } if (cnt != count) { sendRedirect(newurl + "cnt=" + cnt); return; } int fromindex = cnt; int toindex = cnt + artworksPerPage - 1; if (toindex > artworkIDs.size() - 1) toindex = artworkIDs.size() - 1; int previndex = fromindex - artworksPerPage; if (previndex < 0) previndex = 0; %> <% if (needCaching) { %> <%@ include file="cacheLaunch.jsp" %> <% } %> Lobby <%@ include file="inc/head.txt" %> <%@ include file="inc/top.txt" %>

Portfolios | Artist Studios | Artist Galleries | Open Studios | Lobby

<% if (artworkIDs.size() < 1) { %>
There are no artworks found matching the specified criteria.
<% } else { %> <% String width, height; for (int j = fromindex; j < toindex + 1 && numpages > 0; j += 5) { %> <% for (int i = j; i < j + 5; i ++) { if (i < artworkIDs.size()) { %> <% } else { %> <% } } %> <% } %> <% } %>

<%=(String)artistNames.elementAt(i) + " border=0 <% width = (String)imageWidths.elementAt(i); height = (String)imageHeights.elementAt(i); if (Integer.parseInt((String)artworkIDs.elementAt(i)) > 262) { if ((float)Integer.valueOf(height).intValue() / Integer.valueOf(width).intValue() > 1.15) { %> height=108 <% } else { if ((float)(Integer.valueOf(height).intValue())/(Integer.valueOf(width).intValue()) < 1/1.15) { %> width=108 <% } else { %> width=92 <% } } } %>>

<%= (String)artistNames.elementAt(i) %>

<% if (numpages > 1) { %> <% } else { %> <% } %>

 Results <%= fromindex + 1 %>-<%= toindex + 1 %> of <%=artworkIDs.size() %>    <% if (fromindex > 0) { %>  Previous    <% }; for (int j = 0; j < numpages; j++) { %>  <%= (pageindex[j] == fromindex) ? "" : ""%><%=j + 1%><%=(pageindex[j] == fromindex) ? "" : "" %>  <% } if (toindex < artworkIDs.size() - 1) { %>  Next  <% } %>

 
<%@ include file="inc/bottom.txt" %> <% artworkIDs.removeAllElements(); names.removeAllElements(); artistNames.removeAllElements(); artists.removeAllElements(); portfolios.removeAllElements(); smallshots.removeAllElements(); imageHeights.removeAllElements(); imageWidths.removeAllElements(); %> <% if (needCaching) { %> <%@ include file="cacheEnd.jsp" %> <% } %> <%@ include file="globalFinally.jsp" %>