Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.applet.Applet;
  2. import java.applet.AppletContext;
  3. import java.awt.*;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.io.*;
  7. import java.net.MalformedURLException;
  8. import java.net.URL;
  9. import java.util.EventObject;
  10.  
  11. public class PasswdLevel4 extends Applet
  12.     implements ActionListener
  13. {
  14.  
  15.     private URL finalurl;
  16.     String infile;
  17.     String inuser[];
  18.     int totno;
  19.     InputStream countConn;
  20.     BufferedReader countData;
  21.     URL inURL;
  22.     TextField txtlogin;
  23.     Label label1;
  24.     Label label2;
  25.     Label label3;
  26.     TextField txtpass;
  27.     Label lblstatus;
  28.     Button ButOk;
  29.     Button ButReset;
  30.     Label lbltitle;
  31.  
  32.     public PasswdLevel4()
  33.     {
  34.         inuser = new String[22];
  35.         totno = 0;
  36.         countConn = null;
  37.         countData = null;
  38.         inURL = null;
  39.         txtlogin = new TextField();
  40.         label1 = new Label();
  41.         label2 = new Label();
  42.         label3 = new Label();
  43.         txtpass = new TextField();
  44.         lblstatus = new Label();
  45.         ButOk = new Button();
  46.         ButReset = new Button();
  47.         lbltitle = new Label();
  48.     }
  49.  
  50.     void ButOk_ActionPerformed(ActionEvent actionevent)
  51.     {
  52.         boolean flag = false;
  53.         for(int i = 1; i <= totno / 2; i++)
  54.         {
  55.             if(txtlogin.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 2].trim().toUpperCase().intern() && txtpass.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 3].trim().toUpperCase().intern())
  56.             {
  57.                 lblstatus.setText("Login Success, Loading..");
  58.                 flag = true;
  59.                 String s = inuser[1].trim().intern();
  60.                 String s1 = getParameter("targetframe");
  61.                 if(s1 == null)
  62.                 {
  63.                     s1 = "_self";
  64.                 }
  65.                 try
  66.                 {
  67.                     finalurl = new URL(getCodeBase(), s);
  68.                 }
  69.                 catch(MalformedURLException _ex)
  70.                 {
  71.                     lblstatus.setText("Bad URL");
  72.                 }
  73.                 getAppletContext().showDocument(finalurl, s1);
  74.             }
  75.         }
  76.  
  77.         if(!flag)
  78.         {
  79.             lblstatus.setText("Invaild Login or Password");
  80.         }
  81.     }
  82.  
  83.     void ButReset_ActionPerformed(ActionEvent actionevent)
  84.     {
  85.         txtlogin.setText("");
  86.         txtpass.setText("");
  87.     }
  88.  
  89.     public void actionPerformed(ActionEvent actionevent)
  90.     {
  91.         Object obj = actionevent.getSource();
  92.         if(obj == ButOk)
  93.         {
  94.             ButOk_ActionPerformed(actionevent);
  95.             return;
  96.         }
  97.         if(obj == ButReset)
  98.         {
  99.             ButReset_ActionPerformed(actionevent);
  100.         }
  101.     }
  102.  
  103.     public void destroy()
  104.     {
  105.         ButOk.setEnabled(false);
  106.         ButReset.setEnabled(false);
  107.         txtlogin.setVisible(false);
  108.         txtpass.setVisible(false);
  109.     }
  110.  
  111.     public void inFile()
  112.     {
  113.         new StringBuffer();
  114.         try
  115.         {
  116.             countConn = inURL.openStream();
  117.             countData = new BufferedReader(new InputStreamReader(countConn));
  118.             String s;
  119.             while((s = countData.readLine()) != null)
  120.             {
  121.                 if(totno < 21)
  122.                 {
  123.                     totno = totno + 1;
  124.                     inuser[totno] = s;
  125.                     s = "";
  126.                 } else
  127.                 {
  128.                     lblstatus.setText("Cannot Exceed 10 users, Applet fail start!");
  129.                     destroy();
  130.                 }
  131.             }
  132.         }
  133.         catch(IOException ioexception)
  134.         {
  135.             getAppletContext().showStatus("IO Error:" + ioexception.getMessage());
  136.         }
  137.         try
  138.         {
  139.             countConn.close();
  140.             countData.close();
  141.             return;
  142.         }
  143.         catch(IOException ioexception1)
  144.         {
  145.             getAppletContext().showStatus("IO Error:" + ioexception1.getMessage());
  146.         }
  147.     }
  148.  
  149.     public void init()
  150.     {
  151.         setLayout(null);
  152.         setSize(361, 191);
  153.         add(txtlogin);
  154.         txtlogin.setBounds(156, 72, 132, 24);
  155.         label1.setText("Please Enter Login Name & Password");
  156.         label1.setAlignment(1);
  157.         add(label1);
  158.         label1.setFont(new Font("Dialog", 1, 12));
  159.         label1.setBounds(41, 36, 280, 24);
  160.         label2.setText("Login");
  161.         add(label2);
  162.         label2.setFont(new Font("Dialog", 1, 12));
  163.         label2.setBounds(75, 72, 36, 24);
  164.         label3.setText("Password");
  165.         add(label3);
  166.         add(txtpass);
  167.         txtpass.setEchoChar('*');
  168.         txtpass.setBounds(156, 108, 132, 24);
  169.         lblstatus.setAlignment(1);
  170.         label3.setFont(new Font("Dialog", 1, 12));
  171.         label3.setBounds(75, 108, 57, 21);
  172.         add(lblstatus);
  173.         lblstatus.setFont(new Font("Dialog", 1, 12));
  174.         lblstatus.setBounds(14, 132, 344, 24);
  175.         ButOk.setLabel("OK");
  176.         add(ButOk);
  177.         ButOk.setFont(new Font("Dialog", 1, 12));
  178.         ButOk.setBounds(105, 156, 59, 23);
  179.         ButReset.setLabel("Reset");
  180.         add(ButReset);
  181.         ButReset.setFont(new Font("Dialog", 1, 12));
  182.         ButReset.setBounds(204, 156, 59, 23);
  183.         lbltitle.setAlignment(1);
  184.         add(lbltitle);
  185.         lbltitle.setFont(new Font("Dialog", 1, 12));
  186.         lbltitle.setBounds(12, 14, 336, 24);
  187.         String s = getParameter("title");
  188.         lbltitle.setText(s);
  189.         ButOk.addActionListener(this);
  190.         ButReset.addActionListener(this);
  191.         infile = new String("level4");
  192.         try
  193.         {
  194.             inURL = new URL(getCodeBase(), infile);
  195.         }
  196.         catch(MalformedURLException _ex)
  197.         {
  198.             getAppletContext().showStatus("Bad Counter URL:" + inURL);
  199.         }
  200.         inFile();
  201.     }
  202. }