%@ include file="globalPaths.jsp" %>
<%@ include file="globalDefinitions.jsp" %>
<%
String artist = request.getParameter("artist");
if (artist == null)
{
session.setAttribute("404.errorDescription", "Incorrect parameter value");
response.sendError(response.SC_NOT_FOUND);
return;
}
if (!isInteger(artist))
{
sendRedirect(globalErrorPage + "?errorDescription="
+ URLEncoder.encode("Incorrect parameter value: artist=" + artist));
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();
}
%>
<%
boolean err = false;
String errorMessage = "";
String getname = request.getParameter("realname");
String getemail = request.getParameter("email");
String getcomments = request.getParameter("comments");
String getsubject = request.getParameter("subject");
String company = "";
String oName = "";
String temp = null;
String pack = "";
String snapshot = "";
String firstlastName = "";
String artistFirstName = "";
String showPhone = "";
String phone = "";
String website = "";
String email = "";
%>
<%
String wtype = null;
String wcategory = null;
Vector wtypes = new Vector();
Vector fineartCategories = new Vector();
Vector craftCategories = new Vector();
Vector commercialartCategories = new Vector();
boolean enableCaptcha=true;
String captchaResponseToken = request.getParameter("resptoken");
%>
<%
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
String query = "";
boolean scam = false;
%>
<%
try
{
connection = openConnection();
statement = connection.createStatement();
query = "SELECT ipLastLoggedFrom,activeflag,package,firstName,lastName,"
+ " phone, showPhone, website, email, showPhone, snapshot, company, "
+ " portfolio"
+ " FROM galleryArtist A WHERE A.activeflag!='F' AND A.id="
+ quoteString(artist);
resultSet = statement.executeQuery(query);
if (resultSet.next())
{
if (!"admin".equals((String)session.getValue("admin.logged"))
&& !remoteIP.equals(resultSet.getString("ipLastLoggedFrom"))
&& !artist.equals(cookieArtist))
{
if ("N".equals(resultSet.getString("activeflag")))
{
throw new UserInputException("The pages you are trying to view belong"
+ " to an account that is not currently activated."
+ " If this is a new account, the artist needs to "
+ "complete the setup process before the artwork will be"
+ " available on the Internet");
}
if ("P".equals(resultSet.getString("activeflag")))
{
throw new UserInputException("The pages you are trying to view belong"
+ " to an account that has been closed. Please update "
+ "your bookmark");
}
}
pack = resultSet.getString("package");
if (!"0".equals(pack) && !"1".equals(pack) && !"5".equals(pack))
{
//throw new Exception("Incorrect package");
}
if ("2".equals(pack))
{
String personalLink = resultSet.getString("portfolio");
sendRedirect(personalLink);
return;
}
if (resultSet.getString("firstName").equals(""))
{
firstlastName = resultSet.getString("lastName");
artistFirstName = "Artist";
}
else
{
firstlastName = resultSet.getString("firstName") + " "
+ resultSet.getString("lastName");
artistFirstName = resultSet.getString("firstName");
}
phone = resultSet.getString("phone");
website = resultSet.getString("website");
snapshot = resultSet.getString("snapshot");
company = resultSet.getString("company");
pack = resultSet.getString("package");
showPhone = resultSet.getString("showPhone");
email = resultSet.getString("email");
}
else
{
throw new UserInputException("Artist not found");
}
resultSet.close();
query = "SELECT DISTINCT type, category FROM galleryArtwork "
+ " WHERE (activeflag='Y' OR activeflag='L') AND artist="
+ quoteString(artist);
resultSet = statement.executeQuery(query);
while (resultSet.next())
{
wtype=resultSet.getString("type");
wcategory=resultSet.getString("category");
wtypes.addElement(wtype);
if (wtype.equals("fineart"))
{
fineartCategories.addElement(wcategory);
}
if (wtype.equals("craft"))
{
craftCategories.addElement(wcategory);
}
if (wtype.equals("commercialart"))
{
commercialartCategories.addElement(wcategory);
}
}
resultSet.close();
%>
<%
if (request.getParameter("submit") != null)
{
String comments = request.getParameter("comments");
query = "SELECT * FROM galleryVisitor "
+ " WHERE type='SCAMMER'";
resultSet = statement.executeQuery(query);
while (resultSet.next())
{
if (request.getRemoteAddr() != null
&& resultSet.getString("IPaddress") != null
&& request.getRemoteAddr().equals(resultSet.getString("IPaddress")))
scam = true;
if (request.getParameter("email") != null
&& resultSet.getString("email") != null
&& request.getParameter("email").equals(resultSet.getString("email")))
scam = true;
}
resultSet.close();
if (!"true".equals(request.getParameter("jscheck")))
{
scam = true;
}
// Long sessionCheck = (Long)session.getAttribute("contact.sessioncheck");
// session.removeAttribute("contact.sessioncheck"); // Reset
// if (sessionCheck == null || (sessionCheck.longValue() % 1998 != 0))
// {
// scam = true;
// }
if (scam)
{
throw new UserInputException("There was a problem submitting your message. Unknown Error.");
}
if (enableCaptcha)
{
if (captchaResponseToken == null)
{
throw new UserInputException("Missing required captcha parameter");
}
boolean flag = verifyCaptchaResponse(captchaResponseToken, remoteIP, null);
if (!flag)
{
throw new UserInputException("\"I'm not a robot\" challenge failed");
}
}
if ("".equals(request.getParameter("realname")))
{
throw new UserInputException("There was a problem submitting your message. Please specify name.");
}
if ("".equals(request.getParameter("email"))
|| !checkEmail(request.getParameter("email")))
{
throw new UserInputException("There was a problem submitting your message. Please check your email address.");
}
if ("".equals(request.getParameter("subject")))
{
throw new UserInputException("There was a problem submitting your message. Please check your email subject.");
}
if ("".equals(comments))
{
throw new UserInputException("There was a problem submitting your message. Please specify comments.");
}
else
{
if (comments.indexOf("www.") != -1 || comments.indexOf("http:/") != -1 )
{
scam = true;
throw new UserInputException("It\'s not OK to contact this artist with services or other commercial interests.");
}
if (isSpam(comments, true, false))
{
scam = true;
throw new UserInputException("A problem has occured while recording you message.");
}
}
boolean wasspace=false;
int spcnt=0;
for (int i=0;i<(request.getParameter("comments")).length();i++)
{
if ((request.getParameter("comments")).charAt(i)==' ')
{
if (!wasspace)
{
wasspace=true;
spcnt+=1;
}
}
else
{
wasspace=false;
}
}
if (spcnt>177)
{
throw new UserInputException("Message must not exceed 178 words.");
}
Cookie[] allCookies;
allCookies = request.getCookies();
String existingCookie = "";
Vector contactedEmails = new Vector();
//boolean found = false;
for (int i = 0; allCookies != null && i < allCookies.length; i++)
{
Cookie cookie = cookies[i];
if ((cookie.getName()).equals("visitorIP"))
{
existingCookie = cookie.getValue();
}
if ((cookie.getName()).startsWith("contactedEmail"))
{
contactedEmails.addElement(cookie.getValue());
//if (email.equals(cookie.getValue()))
//{
// found = true;
//}
}
}
if (comments.length() > 1000)
{
throw new UserInputException("Message can not contain more than 1000 symbols.");
}
try
{
//if (!found)
//{
if (contactedEmails.size() < 3)
{
Cookie cookieToAdd = new Cookie("contactedEmail" + (Math.random()), email);
cookieToAdd.setMaxAge(24 * 60 * 60);
response.addCookie(cookieToAdd);
}
else
{
throw new Exception("Attempt to contact too many artists in 24 hours");
}
//}
plainContent = request.getParameter("artistName")
+ ","
+ "\n\n"
+ "Message has been sent by "
+ request.getParameter("realname")
+ " ["
+ request.getParameter("email")
+ "]"
+ "\n\n"
+ request.getParameter("comments")
+ "\n\n";
if (!send(htmlContent, plainContent,request.getParameter("artistName"), email,
request.getParameter("subject") + "." ,
request.getParameter("realname"),
request.getParameter("email"),
contactUsEmail, request.getRemoteAddr()))
{
throw new IllegalStateException("Error sending e-mail");
// Error will be logged inside send function
}
String name = request.getParameter("realname");
if (name == null)
name = "";
name = name.trim();
String firstname = "";
String lastname = name;
String senderemail = request.getParameter("email");
if (senderemail == null)
senderemail = "";
if (name.indexOf(" ") > 0)
{
firstname = name.substring(0, name.lastIndexOf(" ")).trim();
lastname = name.substring(name.lastIndexOf(" ") + 1);
}
query = "INSERT galleryArtistMailingList (id, artist, firstname, lastname,email,category,source,createdDate, activatedDate,flag)"
+ " VALUES (NULL, " + quoteString(artist) + "," + quoteString(firstname) + "," + quoteString(lastname) + "," + quoteString(senderemail) + ", 'Contact Artist Page visitors', 'CONTACT ARTIST PAGE', NOW(), NULL, '0')";
statement.executeUpdate(query);
sendRedirect("sent3.jsp?artist=" + URLEncoder.encode(artist));
return;
}
catch(IllegalStateException e)
{
throw new UserInputException("There was a problem submitting your message.");
}
//catch(Exception e)
//{
// throw new UserInputException("There was a problem submitting your message. Unknown Error.");
//}
}
// else
// {
// session.setAttribute("contact.sessioncheck",
// new Long(Math.round(Math.random() * 1000.0) * 1998));
// }
}
catch (UserInputException uie)
{
err = true;
errorMessage = uie.getMessage();
boolean notFound = (errorMessage != null && errorMessage.indexOf("not found") != -1);
if (!scam && !notFound)
errorLog(uie);
if (notFound)
{
session.setAttribute("404.errorDescription", uie.getMessage());
response.sendError(response.SC_NOT_FOUND);
return;
}
}
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();
}
%>
Contact <%= firstlastName %>
<%@ include file="inc/head.txt" %>
<%@ include file="inc/top.txt" %>
 |
 |
<%
if ("1".equals(pack))
{
%>

<%= artistFirstName %>'s Calendar
<%
}
%> |
 |
<%
boolean artistInfo = false;
if (wtypes.contains("fineart"))
{
artistInfo = true;
%>
 |
|
| FINE ART: |

<%
String FAtext = "";
if (fineartCategories.contains("painting"))
FAtext += ", Painting";
if (fineartCategories.contains("graphics"))
FAtext += ", Graphics";
if (fineartCategories.contains("printmaking"))
FAtext += ", Printmaking";
if (fineartCategories.contains("photography"))
FAtext += ", Photography";
if (fineartCategories.contains("sculpture"))
FAtext += ", Sculpture";
if (fineartCategories.contains("mixedmedia"))
FAtext += ", Mixed Media";
if (fineartCategories.contains("newmedia"))
FAtext += ", New Media";
if (fineartCategories.contains("installationart"))
FAtext += ", Installation Art";
if (fineartCategories.contains("artbooks"))
FAtext += ", Art Books";
if (FAtext.length() > 7)
FAtext = FAtext.substring(7);
out.print(FAtext);
%>
|
|
<%
}
if (wtypes.contains("craft"))
{
%>
<%
if (artistInfo)
{
%>
<%
}
else
{
artistInfo = true;
%>

<%
}
%> |
|
| CRAFT: |

<%
String CRtext = "";
if (craftCategories.contains("ceramics"))
CRtext += ", Ceramics";
if (craftCategories.contains("glass"))
CRtext += ", Glass";
if (craftCategories.contains("jewelry"))
CRtext += ", Jewelry";
if (craftCategories.contains("furniture"))
CRtext += ", Furniture";
if (craftCategories.contains("metalart"))
CRtext += ", Fiber Art";
if (craftCategories.contains("wood"))
CRtext += ", Wood";
if (craftCategories.contains("textile"))
CRtext += ", Fiber Art";
if (CRtext.length() > 7)
CRtext = CRtext.substring(7);
out.print(CRtext);
%>
|
|
<%
}
if (wtypes.contains("commercialart"))
{
%>
<%
if (artistInfo)
{
%>
<%
}
else
{
artistInfo = true;
%>

<%
}
%> |
|
| GRAPHIC DESIGN: |

<%
String CAtext = "";
if (commercialartCategories.contains("booksart"))
CAtext += ", Book Art";
if (commercialartCategories.contains("illustration"))
CAtext += ", Illustration";
if (commercialartCategories.contains("calligraphy"))
CAtext += ", Calligraphy";
if (commercialartCategories.contains("printdesign"))
CAtext += ", Print Design";
if (commercialartCategories.contains("typography"))
CAtext += ", Typography";
if (commercialartCategories.contains("webdesign"))
CAtext += ", Web Design";
if (CAtext.length() > 7)
CAtext = CAtext.substring(7);
out.print(CAtext);
%>
|
|
<%
}
%>
 |
 |
 |
 |
 |
 |
<%
if (err)
{
%>
| |
| Error: |
<%= errorMessage %> |
| |
<%
}
%>
<%
if ("1".equals(pack) || "5".equals(pack) || "2".equals(pack))
{
%>
border=0 alt="Inquire" width="139">
<%
}
%>
 |
<%
out.print(firstlastName);
%>
<%
%>
<%
if (!"".equals(company.trim()))
{
%>

<%=company%>
<%
}
%> |
| |
| <%
if ("1".equals(pack) || "5".equals(pack) || "2".equals(pack))
{
%>
<%
}
%> |
|
 |
| |
|
|
<%@ include file="inc/bottom.txt" %>
<%
if ("1".equals(pack) || "5".equals(pack) || "2".equals(pack))
{
%>
<%
if (temp != null)
{
out.print(temp);
}
%>
<%
}
%>
<%@ include file="globalFinally.jsp" %>