Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use CGI qw/:all/;
  4. use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
  5.  
  6. print header, start_html('Welcome to Matelook');
  7. warningsToBrowser(1);
  8.  
  9. print page_header();
  10. $username = param('username') || '';
  11. $password = param('password') || '';
  12.  
  13.  
  14. sub page_header {
  15. return <<eof
  16.  
  17. <!DOCTYPE html>
  18. <html lang="en">
  19. <head>
  20. <title>Bootstrap Example</title>
  21. <meta charset="utf-8">
  22. <meta name="viewport" content="width=device-width, initial-scale=1">
  23. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  24. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  25. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  26. </head>
  27. <body>
  28.  
  29. <div class="container">
  30. <div class="jumbotron">
  31. <h1>Matelook</h1>
  32.  
  33. </div>
  34.  
  35. </body>
  36. </html>
  37. eof
  38. }
  39.  
  40. if ($username && $password) {
  41. $userfiles = "dataset-medium/$username/user.txt";
  42. if (open F, "<$userfiles") {
  43.  
  44. @info = <F>;
  45. foreach $line (@info) {
  46. if ($line =~ /password=/) {
  47. $line =~ s/password=//g;
  48. $correctPass = $line;
  49. } elsif ($line =~ /full_name=/) {
  50. $name = $line;
  51. $name =~ s/full_name=//g;
  52. }
  53. }
  54. chomp $correctPass;
  55. if ($password = $correctPass) {
  56. print <<eof
  57. <h1>$username authenticated.
  58. <br></br>
  59. Welcome to Matelook - $name </h1>
  60. } else {
  61. print "Inncorrect Password!\n";
  62. }
  63. } else {
  64. print "Unknown Username!\n";
  65. }
  66. } else {
  67. print start_form, "\n";
  68. # == Only username ==
  69. if ($username) {
  70. print hidden(-name => 'username', -value => $username),"\n";
  71. print "Password:\n", textfield('password'), "\n";
  72. }
  73.  
  74. if ($password) {
  75. print hidden(-name => 'password', -value => $password),"\n";
  76. print "Username:\n", textfield('username'), "\n";
  77. } else {
  78. print "Username:\n", textfield('username'), "\n";
  79. print "Password:\n", textfield('password'), "\n";
  80. }
  81.  
  82. #Syntax to print a button
  83. print submit(value => Login) ,"\n";
  84. print end_form, "\n";
  85. }
  86. print end_html;
  87. exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement