/*
 * Generated by the Jasper component of Apache Tomcat
 * Version: Apache Tomcat/7.0.19
 * Generated at: 2012-12-26 21:24:33 UTC
 * Note: The last modified time of this file was set to
 *       the last modified time of the source file after
 *       generation to assist with modification tracking.
 */
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import com.goldhuman.util.*;

public final class loginform_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final javax.servlet.jsp.JspFactory _jspxFactory =
          javax.servlet.jsp.JspFactory.getDefaultFactory();

  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

  static {
    _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(2);
    _jspx_dependants.put("/../include/head.jsp", Long.valueOf(1330833146000L));
    _jspx_dependants.put("/../include/footer.jsp", Long.valueOf(1332996548000L));
  }

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
  }

  public void _jspDestroy() {
  }

  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\n');
      out.write('\n');
      out.write('\n');
	boolean showTag = false;
	if (request.getSession().getAttribute("username")!=null) showTag = true;

	boolean Proc = false;
	if (request.getParameter("password")!=null) Proc = true;
	if (showTag) Proc = false;

if(Proc)
{
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	String loginrecord = null;
	int separatorIndex = 0;
	String recordUsername = null;
	String recordPassword = null;
	int recordLength = 0;
	boolean matchTag = false;
	
	try{
		FileReader fr = new FileReader("/opt/useriash.txt");
		BufferedReader br = new BufferedReader(fr);
		loginrecord = new String();
		while((loginrecord=br.readLine())!=null && !matchTag){
			recordLength = loginrecord.length();
			separatorIndex = loginrecord.indexOf(":");
			recordUsername = loginrecord.substring(0, separatorIndex);
			recordPassword = loginrecord.substring(separatorIndex+1,recordLength);
			if(recordUsername.compareTo(username)==0){
				if((recordPassword.compareTo(password)==0)) matchTag = true;
			} 
		}
		if(matchTag){
			FileWriter fw = new FileWriter("/opt/useriash.log",true);
			BufferedWriter bw = new BufferedWriter(fw);
			Date dateToday = new Date();
			String logStr = recordUsername+":login:"+dateToday;
			bw.write(logStr);
			bw.newLine();
			bw.close();
			bw = null;
			fw = null;
		}
		fr = null;
		br = null;
		
	}catch(Exception e){
		out.println("Error!"+e.getMessage());
	}
		
	if(matchTag){
		request.getSession().setAttribute("username", username);
		response.sendRedirect("index.jsp");
	} else {
		response.sendRedirect("loginform.jsp?err=1");
	}

}
else
{

      out.write("\n");
      out.write("<html>\n");
      out.write("<head>\n");
      out.write('\r');
      out.write('\n');
      out.write("\n");
      out.write("</head>\n");
      out.write("<body>\n");
      out.write("<table width=\"96%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
      out.write("\t<tr align=\"center\"><td><img src=\"http://1.bp.blogspot.com/-4IDvG58kMzY/Tgc7-L4wb8I/AAAAAAAACUw/5V7s9qBKIVQ/s1600/header102610genesisclas.jpg\"></img></td></tr>\n");
      out.write("</table>\n");
      out.write("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");

if(showTag)
{
      out.write("\n");
      out.write("\t<tr>\n");
      out.write("\t  <td colspan=\"2\" class=\"ver_12_black_b\">&nbsp;&nbsp;<strong>Bem vindo a Administracao do Legendary</strong> - Administrador efetue login</td></tr> \n");
      out.write("\t");


} else { 

	String strErr = "";
	if(request.getParameter("err")!=null && request.getParameter("err").equals("1")) strErr = "Dados incorretos!";
      out.write("\n");
      out.write("\t<tr>\n");
      out.write("\t  <tr align=\"center\"><td colspan=\"2\" class=\"ver_12_black_b\"><strong>Bem vindo a Administracao do Legendary</strong> - Administrador efetue login</td></tr> \n");
      out.write("\t<tr><td colspan=\"2\">&nbsp;</td></tr>\n");
      out.write("\t<tr>\n");
      out.write("\t\t<td width=\"5%\"></td>\n");
      out.write("\t\t<td width=\"95%\">\n");
      out.write("\t\t<form name=\"login\" action=\"loginform.jsp\">\n");
      out.write("\t\t\t<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n");
      out.write("\t\t\t\t");
	if(!strErr.equals("")){ 
      out.write("\n");
      out.write("\t\t\t\t\t<tr bgcolor=\"#FFFFFF\"><td colspan=\"2\" class=\"ver_10_red\">");
      out.print(strErr);
      out.write("</td></tr>");
}
      out.write("     \n");
      out.write("\t\t\t\t<tr>\n");
      out.write("\t\t\t\t\t<tr align=\"center\"><td width=\"10%\" class=\"ver_10_black\">Login:</td>\n");
      out.write("\t\t\t\t\t<tr align=\"center\"><td width=\"90%\"><input type=\"text\" name=\"username\" value=\"\"></td>\n");
      out.write("\t\t\t\t</tr>\n");
      out.write("\t\t\t\t<tr>\n");
      out.write("\t\t\t\t\t<tr align=\"center\"><td class=\"ver_10_black\">Senha:</td>\n");
      out.write("\t\t\t\t\t<tr align=\"center\"><td><input type=\"password\" name=\"password\" value=\"\"></td>\n");
      out.write("\t\t\t\t</tr>\n");
      out.write("\t\t\t\t<tr>\n");
      out.write("\t\t\t\t\t<tr align=\"center\"><td></td>\n");
      out.write("\t\t\t\t\t<tr align=\"center\"><td><input type=\"reset\" value=\"Limpar\" class=\"button\">\n");
      out.write("\t\t\t\t    <input type=\"submit\" value=\"Logar\" class=\"button\"></td>\n");
      out.write("\t\t\t\t</tr>\n");
      out.write("\t\t\t</table>\n");
      out.write("\t\t</form>\n");
      out.write("\t\t</td>\n");
      out.write("\t</tr>   \n");
      out.write("\t<tr><td colspan=\"2\">&nbsp;</td></tr>   \n");
      out.write("\t<tr><td colspan=\"2\">&nbsp;</td></tr>");

}
      out.write(" \n");
      out.write("</table>\n");
      out.write("<table width=\"96%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
      out.write("<tr>\n");
      out.write("\t<td align=\"center\"><img align=\"center\" src=\"\"></td>\n");
      out.write("</tr>\n");
      out.write("</table>\n");
      out.write("   \n");
      out.write("</body>\n");
      out.write("</html>");

}
      out.write('\n');
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
