%@ page language="java" import='java.util.*'%>
<%
String urlpackage = HttpUtils.getRequestURL(request).toString();
String homepageroot = request.getServerName();
String homepage = "http://" + homepageroot;
String strURLPath = homepage + "/";
String strRealPath = application.getRealPath("/");
String referersent = request.getHeader("Referer");
//The user must be coming from one of the following domains for this tool to work
//This is to try to prevent spammers from hijacking the tool
String allowedreferers[] = {"http://www.kmov.com","http://kmov.com","http://www.wcnc.com","http://wcnc.com","http://www.khou.com","http://khou.com", "http://ice2test.khou.com","http://www.khou.com","http://www.pe.com","http://pe.com","http://ice2test.pe.com","http://ice2.pe.com"};
String allowedrefererfound = "";
String urlaction = request.getParameter("submit");
if (urlaction!=null) {
try {
if (request.getParameter("submit").equals("Cancel"))
response.sendRedirect(request.getParameter("article"));
%>
EMAIL PAGE TO A FRIEND ERRORS
<%
if(request.getHeader("Referer") == null) {
response.sendRedirect(homepage);
} else {
for (int i=0; i < allowedreferers.length; i++) {
if (referersent.startsWith(allowedreferers[i])) {
allowedrefererfound = "yes";
break;
}
}
if (allowedrefererfound.equals("yes")) {
String mailer = request.getParameter("mailer");
boolean results = emailfriend.doEmail(request, mailer);
if (!results) {
out.println(emailfriend.errMsg);
out.println("Return to story.");
} else {
response.sendRedirect(emailfriend.refererURL);
}
} else {
// we must have had a non-allowed referer, so tell the user
// this is to catch anyone who might try to use this for mass e-mails
out.println("It appears you are trying to access this tool from an unapproved site.
");
out.println("You may only use this e-mail a friend tool for sending content on our site.
");
}
}
} catch (Exception e) {
response.sendRedirect(homepage);
}
}
%>