Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.54 KB | None | 0 0
  1. <?php
  2. if (!isset($back)) $back = '../';
  3. $users = json_decode(file_get_contents($back . 'users_loginaccesfilesystempools.json'), true);
  4. $error = "";
  5. $logged = false;
  6. if(isset($_POST['username'],$_POST['password'])){ //ha kap posztot
  7.  
  8. $username = $_POST['username'];
  9. $pass = $_POST['password'];
  10. foreach($users as $user){ //kiforgatjuk a felhasználókat
  11. if($username == $user['user'] && $pass == $user['pass']){ //ha mind a 2 egyezik
  12. $logged = true;
  13. $_SESSION['simple_login'] = $username; // elmentjük munkamentbe, ha később kéne valamire
  14. echo '{"error":0}';
  15. break; //ezze kilépünk / megszakítjuk a foreach-t, nincs szükség tovább nézni, ha megvan a keresett
  16. }
  17. }
  18.  
  19. if(!$logged){ //ha nem találtunk usert, akkor kírjuk ezt.. bár egyenlőőre nem tudom ez mire kell
  20. echo '{"error":1}';
  21. }
  22. exit();
  23. }
  24. ?>
  25. <head>
  26. <?php
  27. $page = $_SERVER['PHP_SELF'];
  28. $sec = "1";
  29. ?>
  30. <title><?php echo $config["title"] ?></title>
  31. <meta charset="UTF-8">
  32. <meta name="author" content="<?php echo $config["author"] ?>">
  33. <meta name="application-name" content="<?php echo $config["webname"] ?>">
  34. </head>
  35.  
  36.  
  37.  
  38. <!DOCTYPE html>
  39. <html lang="en">
  40. <head>
  41. <meta charset="utf-8">
  42. <meta name="viewport" content="width=device-width, initial-scale=1">
  43. <!-- Include stylesheets for better appearance of login form -->
  44. <link href="css/bootstrap.min.css" rel="stylesheet">
  45. <link href="css/animate.css" rel="stylesheet">
  46. <style type="text/css">
  47. body{padding-top:20px;background-color:#f9f9f9;}
  48. </style>
  49. <script src="js/jquery-1.11.3.min.js"></script>
  50. <script src="js/bootstrap.min.js"></script>
  51.  
  52. </head>
  53. <body>
  54. <div class="container">
  55. <div class="row">
  56. <center><img src="./webadmin.png"></center>
  57. <div class="col-md-4 col-md-offset-4"><br>
  58. <div class="panel panel-default">
  59. <div class="panel-heading">
  60. <h3 class="panel-title"><strong>Kérlek jelentkezz be</strong> [modi/admin]</h3>
  61. </div>
  62. <div class="panel-body">
  63. <?php echo $error; ?>
  64. <form accept-charset="UTF-8" role="form" method="post" action="index.php">
  65. <fieldset>
  66. <div class="form-group">
  67. <input class="form-control" placeholder="Felhasználónév" name="username" type="text">
  68. </div>
  69. <div class="form-group">
  70. <input class="form-control" placeholder="Jelszó" name="password" type="password" value="">
  71. </div>
  72. <input class="btn btn-lg btn-success btn-block" type="submit" value="Bejelentkezés" />
  73. </fieldset>
  74. </form>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <script>
  81. $('form').submit(function(e){
  82. e.preventDefault();
  83. $('.panel-default').removeClass('animated shake');
  84. $('.alert').remove();
  85. var submit = true;
  86. var btn = $(this).find('input[type="submit"]');
  87. if($(this).find('input[type="text"]').val() == "" || $(this).find('input[type="password"]').val() == ""){
  88. $('.panel-default .panel-body').prepend('<div class="alert alert-danger">Kérlek írj be egy felhasználó nevet és egy jelszót.</div>');
  89. submit = false;
  90. $('.panel-default').addClass('animated shake');
  91. }
  92. if(submit == true){
  93. btn.button('loading');
  94. $.post('index.php',$(this).serialize(),function(data){
  95. if(data.error == 1){
  96. $('.panel-default .panel-body').prepend('<div class="alert alert-danger">A felhasználó vagy nem létezik, vagy a jelszó nem jó,</div>');
  97. $('.panel-default').addClass('animated shake');
  98. }else{
  99. $('.panel-default .panel-body').prepend('<div class="alert alert-success">Sikeres bejelentkezés...</div>');
  100. window.location = 'home.php';
  101. }
  102. },"JSON").error(function(){
  103. alert('Request not complete.');
  104. }).always(function(){
  105. btn.button('reset')
  106. });
  107. }
  108. setTimeout(function(){
  109.  
  110. },100)
  111.  
  112. });
  113. </script>
  114. </body>
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement