Guest User

Untitled

a guest
Feb 28th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.33 KB | None | 0 0
  1. import java.applet.Applet;
  2. import java.applet.AppletContext;
  3. import java.awt.Button;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Font;
  7. import java.awt.Label;
  8. import java.awt.TextComponent;
  9. import java.awt.TextField;
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12. import java.io.BufferedReader;
  13. import java.io.IOException;
  14. import java.io.InputStream;
  15. import java.io.InputStreamReader;
  16. import java.net.MalformedURLException;
  17. import java.net.URL;
  18. import java.util.EventObject;
  19.  
  20. public class pass1 extends Applet
  21. {
  22.   private URL finalurl;
  23.   String infile;
  24.   String[] inuser = new String[20];
  25.   int totno;
  26.   InputStream countConn;
  27.   BufferedReader countData;
  28.   URL inURL;
  29.   TextField txtlogin = new TextField();
  30.   Label label1 = new Label();
  31.   Label label2 = new Label();
  32.   Label label3 = new Label();
  33.   TextField txtpass = new TextField();
  34.   Label lblstatus = new Label();
  35.   Button ButOk = new Button();
  36.   Button ButReset = new Button();
  37.   Label lbltitle = new Label();
  38.  
  39.   public void init()
  40.   {
  41.     setLayout(null);
  42.     setSize(361, 191);
  43.     add(this.txtlogin);
  44.     this.txtlogin.setBounds(156, 72, 132, 24);
  45.     this.label1.setText("Please Enter Login Name & Password");
  46.     this.label1.setAlignment(1);
  47.     add(this.label1);
  48.     this.label1.setFont(new Font("Dialog", 1, 12));
  49.     this.label1.setBounds(68, 36, 228, 24);
  50.     this.label2.setText("Login");
  51.     add(this.label2);
  52.     this.label2.setFont(new Font("Dialog", 1, 12));
  53.     this.label2.setBounds(75, 72, 36, 24);
  54.     this.label3.setText("Password");
  55.     add(this.label3);
  56.     add(this.txtpass);
  57.     this.txtpass.setEchoChar('*');
  58.     this.txtpass.setBounds(156, 108, 132, 24);
  59.     this.lblstatus.setAlignment(1);
  60.     this.label3.setFont(new Font("Dialog", 1, 12));
  61.     this.label3.setBounds(75, 108, 57, 21);
  62.     add(this.lblstatus);
  63.     this.lblstatus.setFont(new Font("Dialog", 1, 12));
  64.     this.lblstatus.setBounds(84, 132, 204, 24);
  65.     this.ButOk.setLabel("OK");
  66.     add(this.ButOk);
  67.     this.ButOk.setFont(new Font("Dialog", 1, 12));
  68.     this.ButOk.setBounds(105, 156, 59, 23);
  69.     this.ButReset.setLabel("Reset");
  70.     add(this.ButReset);
  71.     this.ButReset.setFont(new Font("Dialog", 1, 12));
  72.     this.ButReset.setBounds(204, 156, 59, 23);
  73.     this.lbltitle.setAlignment(1);
  74.     add(this.lbltitle);
  75.     this.lbltitle.setFont(new Font("Dialog", 1, 12));
  76.     this.lbltitle.setBounds(12, 14, 336, 24);
  77.     String str1 = getParameter("title");
  78.     this.lbltitle.setText(str1);
  79.     pass1.SymAction localSymAction = new pass1.SymAction();
  80.     this.ButOk.addActionListener(localSymAction);
  81.     this.ButReset.addActionListener(localSymAction);
  82.     this.infile = new String("in.txt");
  83.     try
  84.     {
  85.       this.inURL = new URL(getCodeBase(), this.infile);
  86.     }
  87.     catch (MalformedURLException localMalformedURLException)
  88.     {
  89.       getAppletContext().showStatus("Bad Counter URL:" + this.inURL);
  90.     }
  91.     String str2 = getParameter("author");
  92.     if (str2.trim().toUpperCase().intern() == "JACKY LEUNG")
  93.       inFile();
  94.   }
  95.  
  96.   public void inFile()
  97.   {
  98.     new StringBuffer();
  99.     String str = "";
  100.     int i = 0;
  101.     try
  102.     {
  103.       this.countConn = this.inURL.openStream();
  104.       this.countData = new BufferedReader(new InputStreamReader(this.countConn));
  105.       while ((str = this.countData.readLine()) != null)
  106.       {
  107.         this.totno += 1;
  108.         this.inuser[this.totno] = str;
  109.         str = "";
  110.         i = 0;
  111.       }
  112.     }
  113.     catch (IOException localIOException1)
  114.     {
  115.       getAppletContext().showStatus("IO Error:" + localIOException1.getMessage());
  116.     }
  117.     try
  118.     {
  119.       this.countConn.close();
  120.       this.countData.close();
  121.       return;
  122.     }
  123.     catch (IOException localIOException2)
  124.     {
  125.       getAppletContext().showStatus("IO Error:" + localIOException2.getMessage());
  126.     }
  127.   }
  128.  
  129.   void ButOk_ActionPerformed(ActionEvent paramActionEvent)
  130.   {
  131.     int i = 0;
  132.     for (int j = 1; j <= this.totno / 2; j++)
  133.     {
  134.       if ((this.txtlogin.getText().trim().toUpperCase().intern() != this.inuser[(2 * (j - 1) + 2)].trim().toUpperCase().intern()) || (this.txtpass.getText().trim().toUpperCase().intern() != this.inuser[(2 * (j - 1) + 3)].trim().toUpperCase().intern()))
  135.         continue;
  136.       this.lblstatus.setText("Login Success, Loading..");
  137.       i = 1;
  138.       String str = this.inuser[1].trim().intern();
  139.       try
  140.       {
  141.         this.finalurl = new URL(getCodeBase(), str);
  142.       }
  143.       catch (MalformedURLException localMalformedURLException)
  144.       {
  145.         this.lblstatus.setText("Bad URL");
  146.       }
  147.       getAppletContext().showDocument(this.finalurl, "_self");
  148.     }
  149.     if (i == 0)
  150.       this.lblstatus.setText("Invaild Login or Password");
  151.   }
  152.  
  153.   void ButReset_ActionPerformed(ActionEvent paramActionEvent)
  154.   {
  155.     this.txtlogin.setText("");
  156.     this.txtpass.setText("");
  157.   }
  158.  
  159.   class SymAction
  160.     implements ActionListener
  161.   {
  162.     public void actionPerformed(ActionEvent paramActionEvent)
  163.     {
  164.       Object localObject = paramActionEvent.getSource();
  165.       if (localObject == pass1.this.ButOk)
  166.       {
  167.         pass1.this.ButOk_ActionPerformed(paramActionEvent);
  168.         return;
  169.       }
  170.       if (localObject == pass1.this.ButReset)
  171.         pass1.this.ButReset_ActionPerformed(paramActionEvent);
  172.     }
  173.  
  174.     SymAction()
  175.     {
  176.     }
  177.   }
  178. }
Add Comment
Please, Sign In to add comment