Advertisement
Guest User

Untitled

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