Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use CGI qw/:all/;
- use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
- print header, start_html('Welcome to Matelook');
- warningsToBrowser(1);
- print page_header();
- $username = param('username') || '';
- $password = param('password') || '';
- sub page_header {
- return <<eof
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Bootstrap Example</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="jumbotron">
- <h1>Matelook</h1>
- </div>
- </body>
- </html>
- eof
- }
- if ($username && $password) {
- $userfiles = "dataset-medium/$username/user.txt";
- if (open F, "<$userfiles") {
- @info = <F>;
- foreach $line (@info) {
- if ($line =~ /password=/) {
- $line =~ s/password=//g;
- $correctPass = $line;
- } elsif ($line =~ /full_name=/) {
- $name = $line;
- $name =~ s/full_name=//g;
- }
- }
- chomp $correctPass;
- if ($password = $correctPass) {
- print <<eof
- <h1>$username authenticated.
- <br></br>
- Welcome to Matelook - $name </h1>
- } else {
- print "Inncorrect Password!\n";
- }
- } else {
- print "Unknown Username!\n";
- }
- } else {
- print start_form, "\n";
- # == Only username ==
- if ($username) {
- print hidden(-name => 'username', -value => $username),"\n";
- print "Password:\n", textfield('password'), "\n";
- }
- if ($password) {
- print hidden(-name => 'password', -value => $password),"\n";
- print "Username:\n", textfield('username'), "\n";
- } else {
- print "Username:\n", textfield('username'), "\n";
- print "Password:\n", textfield('password'), "\n";
- }
- #Syntax to print a button
- print submit(value => Login) ,"\n";
- print end_form, "\n";
- }
- print end_html;
- exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement